:root {
    --bg-main: #f8fafb;
    --bg-white: #ffffff;
    --text-dark: #1e293b;
    --text-grey: #64748b;
    --text-light-grey: #94a3b8;
    --border-color: #e2e8f0;
    
    --primary-red: #ea4335;
    --light-red: #fde8e8;
    --primary-blue: #3b82f6;
    --light-blue: #eff6ff;
    --primary-green: #22c55e;
    --light-green: #dcfce7;
    --primary-orange: #f59e0b;
    --light-orange: #fef3c7;
    --primary-purple: #8b5cf6;
    --light-purple: #f3e8ff;
    
    --font-main: 'Inter', 'Noto Sans Lao', sans-serif;
    --sidebar-width: 250px;
    --header-height: 70px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    background-color: var(--bg-main);
    color: var(--text-dark);
    font-family: var(--font-main);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* SIDEBAR */
.sidebar {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    transition: left 0.3s ease;
    box-shadow: 4px 0 20px rgba(0,0,0,0.1);
    width: var(--sidebar-width);
    background-color: var(--bg-white);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    z-index: 1000;
}

.sidebar.show-sidebar {
    left: 0;
}

.sidebar-logo {
    height: var(--header-height);
    display: flex;
    align-items: center;
    padding: 0 1.5rem;
    border-bottom: 1px solid var(--border-color);
}

.logo-icon {
    width: 35px;
    height: 35px;
    background-color: var(--primary-red);
    color: white;
    font-size: 1.2rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    margin-right: 0.8rem;
}

.logo-text {
    font-weight: 700;
    font-size: 1.2rem;
    color: var(--primary-red);
}

.sidebar-nav {
    padding: 1.5rem 0;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.nav-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 1.5rem;
    text-decoration: none;
    color: var(--text-grey);
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.2s;
    position: relative;
    margin: 0 1rem;
    border-radius: 8px;
}

.nav-item i {
    width: 24px;
    font-size: 1.1rem;
    margin-right: 0.8rem;
    text-align: center;
}

.nav-item:hover {
    background-color: #f1f5f9;
}

.nav-item.active {
    background-color: var(--light-red);
    color: var(--primary-red);
}

.nav-item.active::after {
    content: '';
    position: absolute;
    right: -1rem; /* align correctly with padding */
    top: 50%;
    transform: translateY(-50%);
    height: 70%;
    width: 4px;
    background-color: var(--primary-red);
    border-radius: 4px 0 0 4px;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-main);
    overflow: hidden; 
}

/* TOP HEADER */
.top-header {
    height: var(--header-height);
    background-color: var(--bg-white);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.header-left h2 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
    letter-spacing: 0.5px;
}

.icon-btn {
    width: 35px;
    height: 35px;
    border-radius: 50%;
    border: none;
    background: transparent;
    color: var(--text-grey);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: 0.2s;
}

.icon-btn:hover { background-color: #f1f5f9; }
.borderless { border: none !important; }
.outline { border: 1px solid var(--border-color); }

.header-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.search-box {
    display: flex;
    align-items: center;
    background-color: #f1f5f9;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    width: 250px;
}

.search-box i { color: var(--text-light-grey); margin-right: 0.5rem; }
.search-box input {
    border: none;
    background: transparent;
    outline: none;
    font-family: inherit;
    font-size: 0.9rem;
    width: 100%;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: right;
}

.user-name { font-weight: 700; font-size: 0.9rem; color: var(--text-dark); }
.user-role { font-size: 0.75rem; color: var(--primary-red); font-weight: 600; }
.avatar { width: 38px; height: 38px; border-radius: 50%; object-fit: cover; }

/* SCROLL AREA */
.dashboard-scroll-area {
    padding: 2rem;
    overflow-y: auto;
    flex: 1;
}

/* PAGE TITLE */
.page-title-section {
    margin-bottom: 2rem;
}

.page-title-section h1 {
    font-size: 1.8rem;
    font-weight: 800;
    color: #111827;
    margin-bottom: 0.3rem;
}

.page-title-section p {
    color: var(--text-grey);
    font-size: 0.95rem;
}

/* GRID LAYOUTS */
.top-dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stats-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1.5rem;
}

/* STAT CARDS */
.stat-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.04);
}

.stat-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 1.5rem;
}

.icon-box {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.red-bg { background-color: var(--light-red); color: var(--primary-red); }
.purple-bg { background-color: var(--light-purple); color: var(--primary-purple); }
.green-bg { background-color: var(--light-green); color: var(--primary-green); }
.orange-bg { background-color: var(--light-orange); color: var(--primary-orange); }

.badge {
    padding: 0.2rem 0.6rem;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
}
.grey-badge { background-color: #f1f5f9; color: var(--text-grey); }

.stat-card-body p {
    color: var(--text-grey);
    font-weight: 600;
    font-size: 0.9rem;
    margin-bottom: 0.2rem;
}

.stat-card-body h3 {
    font-size: 2.2rem;
    font-weight: 800;
    color: #111827;
}

/* CHART CARD */
.chart-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.04);
    display: flex;
    flex-direction: column;
}

.chart-header {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    margin-bottom: 1.5rem;
}

.chart-header .blue-text {
    color: var(--primary-blue);
    font-size: 1.2rem;
}

.chart-header h3 {
    font-size: 1rem;
    font-weight: 700;
    color: var(--text-dark);
}

.chart-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
}

.donut-wrapper {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 1.5rem auto;
}

.donut-center-text {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
}

.donut-center-text h2 {
    font-size: 1.8rem;
    font-weight: 800;
    line-height: 1;
}

.donut-center-text p {
    font-size: 0.65rem;
    color: var(--text-grey);
    font-weight: 600;
    margin-top: 0.2rem;
    letter-spacing: 0.5px;
}

.chart-legend {
    display: flex;
    flex-direction: column;
    gap: 0.8rem;
    padding: 0 1rem;
}

.legend-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-dark);
}

.legend-left {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.legend-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
}

.legend-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.legend-pct {
    color: var(--text-light-grey);
    font-size: 0.75rem;
}

/* PROJECT DETAILS CARD */
.project-details-card {
    background: var(--bg-white);
    border-radius: 16px;
    padding: 1.5rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.02);
    border: 1px solid rgba(0,0,0,0.04);
}

.card-header-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

.header-title-group {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.big-icon-box {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}
.red-gradient {
    background: linear-gradient(135deg, #ff4d4d, #cc0000);
}

.header-title-group h2 {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
}

.header-title-group p {
    font-size: 0.85rem;
    color: var(--text-grey);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}

.btn-dark {
    padding: 0.6rem 1.2rem;
    background-color: #111827;
    color: white;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.9rem;
    font-family: inherit;
    cursor: pointer;
    transition: 0.2s;
}

.btn-dark:hover { background-color: #1f2937; }

/* TABLE */
table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 1rem;
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-light-grey);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f1f5f9;
}

td {
    padding: 1.2rem 1rem;
    border-bottom: 1px solid #f1f5f9;
    vertical-align: middle;
}

/* Project Name Cell */
.project-name-cell p.title {
    font-weight: 700;
    color: var(--text-dark);
    font-size: 0.95rem;
    margin-bottom: 0.2rem;
}
.project-name-cell p.subtitle {
    font-size: 0.7rem;
    color: var(--text-light-grey);
    text-transform: uppercase;
    font-weight: 600;
}

/* Owner Cell */
.owner-cell {
    display: flex;
    align-items: center;
    gap: 0.8rem;
}
.owner-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
}
.owner-name {
    font-weight: 600;
    font-size: 0.9rem;
}

/* Purpose Dropdown */
.purpose-dropdown {
    position: relative;
    display: inline-block;
}

.purpose-dropdown summary {
    list-style: none;
}

.purpose-dropdown summary::-webkit-details-marker {
    display: none;
}

.purpose-dropdown[open] .fa-chevron-down {
    transform: rotate(180deg);
}

.purpose-dropdown .fa-chevron-down {
    transition: transform 0.2s ease;
}

.purpose-badge {
    background-color: #f1f5f9;
    color: var(--text-grey);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 600;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: background-color 0.2s;
    user-select: none;
}

.purpose-badge:hover {
    background-color: #e2e8f0;
}

.purpose-content {
    position: absolute;
    top: calc(100% + 8px);
    left: 0;
    width: max-content;
    max-width: 300px;
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    padding: 1rem;
    box-shadow: 0 4px 15px rgba(0,0,0,0.1);
    font-size: 0.85rem;
    color: var(--text-dark);
    z-index: 100;
    white-space: normal;
    line-height: 1.4;
}

/* Progress Bar */
.progress-cell {
    width: 150px;
}
.progress-text {
    font-size: 0.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    color: var(--text-grey);
}
.progress-track {
    width: 100%;
    height: 6px;
    background-color: #f1f5f9;
    border-radius: 3px;
    overflow: hidden;
}
.progress-fill {
    height: 100%;
    border-radius: 3px;
}

/* Status Badges */
.status-pill {
    padding: 0.4rem 0.8rem;
    border-radius: 6px;
    font-size: 0.75rem;
    font-weight: 700;
    display: inline-flex;
    align-items: center;
    gap: 0.4rem;
    text-transform: uppercase;
}

.status-pill .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
}

.status-in-progress {
    background-color: var(--light-red);
    color: var(--primary-red);
}
.status-in-progress .dot { background-color: var(--primary-red); }

.status-completed {
    background-color: var(--light-green);
    color: var(--primary-green);
}
.status-completed .dot { background-color: var(--primary-green); }

.status-pending {
    background-color: var(--light-orange);
    color: var(--primary-orange);
}
.status-pending .dot { background-color: var(--primary-orange); }

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
}

@media (max-width: 1024px) {
    .top-dashboard-grid {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 768px) {
    /* Make table content not squish */
    table {
        white-space: nowrap;
    }

    /* Stack the stats cards */
    .stats-grid {
        grid-template-columns: 1fr;
    }

    /* Adjust main content layout */
    .search-box {
        display: none; /* simple hide for extremely small screens */
    }
    
    .top-header {
        padding: 0 1rem;
    }
    
    .dashboard-scroll-area {
        padding: 1rem;
    }
    
    /* Card structural adjustments */
    .card-header-row {
        flex-direction: column;
        align-items: flex-start;
        gap: 1rem;
    }
    
    .header-actions {
        width: 100%;
        justify-content: flex-end;
    }
    
    .page-title-section h1 {
        font-size: 1.5rem;
    }
}
