/* =====================================================
   Dashboard Specific Styles
   ===================================================== */

/* =====================================================
   Layout: Sidebar + Main Content
   ===================================================== */
body {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
}

/* =====================================================
   Sidebar
   ===================================================== */
.sidebar {
    width: 260px;
    min-height: 100vh;
    background: linear-gradient(180deg, #FFFFFF 0%, #F8FAFC 100%);
    display: flex;
    flex-direction: column;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: transform 0.3s ease;
    border-right: 1px solid #E2E8F0;
    box-shadow: 2px 0 8px rgba(0, 0, 0, 0.04);
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #E2E8F0;
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: #1E293B;
}

.logo svg {
    width: 32px;
    height: 32px;
    color: #0080FF;
}

.logo span {
    font-family: var(--font-heading);
    font-weight: 600;
    font-size: 1.125rem;
    color: #1E293B;
}

.sidebar-toggle {
    display: none;
    background: none;
    border: none;
    color: #64748B;
    cursor: pointer;
    padding: 0.5rem;
}

.sidebar-toggle svg {
    width: 24px;
    height: 24px;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.875rem 1.5rem;
    color: #64748B;
    text-decoration: none;
    font-size: 0.9375rem;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
    margin: 0.25rem 0.75rem;
    border-radius: var(--radius-lg);
}

.nav-item:hover {
    color: #1E293B;
    background: #F1F5F9;
}

.nav-item.active {
    color: white;
    background: #0080FF;
    border-left-color: transparent;
}

.nav-item svg {
    width: 22px;
    height: 22px;
}

.sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #E2E8F0;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-avatar {
    width: 40px;
    height: 40px;
    background: linear-gradient(135deg, #0080FF 0%, #8B5CF6 100%);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
}

.user-avatar svg {
    width: 24px;
    height: 24px;
}

.user-details {
    display: flex;
    flex-direction: column;
}

.user-name {
    color: #1E293B;
    font-weight: 600;
    font-size: 0.875rem;
}

.user-role {
    color: #64748B;
    font-size: 0.75rem;
}

/* =====================================================
   Main Content
   ===================================================== */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 1.5rem 2rem;
    background: var(--color-bg);
    min-height: 100vh;
    transition: margin-left 0.3s ease;
}

.main-content.expanded {
    margin-left: 0;
}

/* =====================================================
   Page Header
   ===================================================== */
.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 2rem;
}

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

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.5rem;
    color: var(--color-text);
}

.mobile-menu-btn svg {
    width: 24px;
    height: 24px;
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    color: var(--color-text);
}

.current-date {
    color: var(--color-text-muted);
    font-size: 0.9375rem;
}

/* =====================================================
   KPI Cards
   ===================================================== */
.kpi-section {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.kpi-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    transition: all 0.2s ease;
}

.kpi-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.kpi-icon {
    width: 56px;
    height: 56px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.kpi-icon svg {
    width: 28px;
    height: 28px;
}

.kpi-icon.total {
    background: linear-gradient(135deg, #DBEAFE 0%, #BFDBFE 100%);
    color: #2563EB;
}

.kpi-icon.completed {
    background: linear-gradient(135deg, #D1FAE5 0%, #A7F3D0 100%);
    color: #059669;
}

.kpi-icon.in-progress {
    background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
    color: #D97706;
}

.kpi-icon.delayed {
    background: linear-gradient(135deg, #FEE2E2 0%, #FECACA 100%);
    color: #DC2626;
}

.kpi-content {
    display: flex;
    flex-direction: column;
}

.kpi-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: var(--font-heading);
}

.kpi-label {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

/* =====================================================
   Charts Section
   ===================================================== */
.charts-section {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.chart-card {
    background: white;
    border-radius: var(--radius-xl);
    padding: 1.5rem;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    min-height: 320px;
    display: flex;
    flex-direction: column;
}

.chart-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--color-text);
    margin-bottom: 1.25rem;
}

/* Progress Ring Chart */
.progress-chart {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.progress-ring {
    position: relative;
    width: 140px;
    height: 140px;
}

.progress-ring svg {
    width: 100%;
    height: 100%;
    transform: rotate(-90deg);
}

.ring-bg {
    fill: none;
    stroke: #E2E8F0;
    stroke-width: 10;
}

.ring-progress {
    fill: none;
    stroke: url(#progressGradient);
    stroke: #3B82F6;
    stroke-width: 10;
    stroke-linecap: round;
    transition: stroke-dashoffset 0.5s ease;
}

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

.ring-value {
    display: block;
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: var(--font-heading);
}

.ring-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.progress-legend {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: var(--color-text-muted);
}

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

.legend-dot.completed {
    background: #10B981;
}

.legend-dot.delayed {
    background: #EF4444;
}

.legend-dot.pending {
    background: #94A3B8;
}

/* Status Bars Chart */
.status-bars {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.status-bar-item {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.status-bar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.status-name {
    font-size: 0.8125rem;
    color: var(--color-text);
}

.status-count {
    font-size: 0.8125rem;
    font-weight: 600;
    color: var(--color-text-muted);
}

.status-bar-track {
    height: 8px;
    background: #E2E8F0;
    border-radius: 4px;
    overflow: hidden;
}

.status-bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

/* Unit List */
.unit-list {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.unit-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.625rem 0;
    border-bottom: 1px solid var(--color-border);
}

.unit-item:last-child {
    border-bottom: none;
}

.unit-name {
    font-size: 0.875rem;
    color: var(--color-text);
}

.unit-count {
    font-size: 0.875rem;
    font-weight: 600;
    color: var(--color-primary);
    background: var(--color-primary-light);
    padding: 0.25rem 0.625rem;
    border-radius: var(--radius-full);
}

/* =====================================================
   Table Section
   ===================================================== */
.table-section {
    background: white;
    border-radius: var(--radius-xl);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--color-border);
    overflow: hidden;
}

.table-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--color-border);
}

.table-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--color-text);
}

/* Filters */
.table-filters {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.5rem;
    background: var(--color-bg);
    border-bottom: 1px solid var(--color-border);
}

.search-box {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background: white;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    padding: 0.625rem 1rem;
    flex: 1;
    max-width: 400px;
}

.search-box svg {
    width: 20px;
    height: 20px;
    color: var(--color-text-muted);
}

.search-input {
    flex: 1;
    border: none;
    background: none;
    font-size: 0.9375rem;
    color: var(--color-text);
    outline: none;
}

.search-input::placeholder {
    color: var(--color-text-light);
}

.filter-group {
    display: flex;
    gap: 0.75rem;
}

.filter-select {
    padding: 0.625rem 2rem 0.625rem 1rem;
    border: 1px solid var(--color-border);
    border-radius: var(--radius-md);
    background: white;
    font-size: 0.875rem;
    color: var(--color-text);
    cursor: pointer;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='20' height='20' viewBox='0 0 24 24' fill='none' stroke='%2364748B' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='m6 9 6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.5rem center;
    background-size: 16px;
}

.filter-select:focus {
    outline: none;
    border-color: var(--color-primary);
}

/* Table */
.table-container {
    overflow-x: auto;
}

.data-table {
    width: 100%;
    border-collapse: collapse;
}

.data-table th,
.data-table td {
    padding: 1rem 1.25rem;
    text-align: left;
    font-size: 0.875rem;
    border-bottom: 1px solid var(--color-border);
}

.data-table th {
    background: var(--color-bg);
    font-weight: 600;
    color: var(--color-text-muted);
    text-transform: uppercase;
    font-size: 0.75rem;
    letter-spacing: 0.05em;
    white-space: nowrap;
}

.data-table tbody tr {
    transition: background 0.15s ease;
}

.data-table tbody tr:hover {
    background: #F8FAFC;
}

.data-table td {
    color: var(--color-text);
}

.doc-name {
    font-weight: 500;
    color: var(--color-text);
    max-width: 250px;
}

.doc-type {
    display: inline-block;
    padding: 0.25rem 0.625rem;
    background: var(--color-bg);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 500;
    color: var(--color-text-muted);
}

.progress-cell {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.progress-mini {
    width: 60px;
    height: 6px;
    background: #E2E8F0;
    border-radius: 3px;
    overflow: hidden;
}

.progress-mini-fill {
    height: 100%;
    border-radius: 3px;
}

.progress-mini-fill.high {
    background: #10B981;
}

.progress-mini-fill.medium {
    background: #F59E0B;
}

.progress-mini-fill.low {
    background: #EF4444;
}

.progress-text {
    font-size: 0.8125rem;
    font-weight: 500;
    min-width: 35px;
}

.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
    padding: 0.375rem 0.75rem;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 500;
    white-space: nowrap;
}

.status-badge.drafting {
    background: #DBEAFE;
    color: #1D4ED8;
}

.status-badge.reviewing {
    background: #EDE9FE;
    color: #7C3AED;
}

.status-badge.evaluating {
    background: #FEF3C7;
    color: #B45309;
}

.status-badge.submitted {
    background: #CFFAFE;
    color: #0891B2;
}

.status-badge.issued {
    background: #D1FAE5;
    color: #047857;
}

.status-badge.paused {
    background: #F1F5F9;
    color: #64748B;
}

.action-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--color-bg);
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.action-btn:hover {
    background: var(--color-primary-light);
    color: var(--color-primary);
}

.action-btn svg {
    width: 18px;
    height: 18px;
}

/* Pagination */
.table-pagination {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--color-border);
}

.pagination-info {
    font-size: 0.875rem;
    color: var(--color-text-muted);
}

.pagination-controls {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pagination-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 1px solid var(--color-border);
    background: white;
    border-radius: var(--radius-md);
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.pagination-btn:hover:not(:disabled) {
    border-color: var(--color-primary);
    color: var(--color-primary);
}

.pagination-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.pagination-btn svg {
    width: 18px;
    height: 18px;
}

.pagination-page {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    cursor: pointer;
    transition: all 0.15s ease;
}

.pagination-page:hover {
    background: var(--color-bg);
}

.pagination-page.active {
    background: var(--color-primary);
    color: white;
}

/* =====================================================
   Responsive
   ===================================================== */
@media (max-width: 1280px) {
    .charts-section {
        grid-template-columns: 1fr 1fr;
    }

    .charts-section .chart-card:last-child {
        grid-column: span 2;
    }
}

@media (max-width: 1024px) {
    .kpi-section {
        grid-template-columns: repeat(2, 1fr);
    }

    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .sidebar-toggle {
        display: flex;
    }
}

@media (max-width: 768px) {
    .main-content {
        padding: 1rem;
    }

    .kpi-section {
        grid-template-columns: 1fr;
    }

    .charts-section {
        grid-template-columns: 1fr;
    }

    .charts-section .chart-card:last-child {
        grid-column: span 1;
    }

    .table-filters {
        flex-direction: column;
        align-items: stretch;
    }

    .search-box {
        max-width: 100%;
    }

    .filter-group {
        flex-wrap: wrap;
    }

    .filter-select {
        flex: 1;
        min-width: 140px;
    }

    .table-pagination {
        flex-direction: column;
        gap: 1rem;
    }

    .page-title {
        font-size: 1.25rem;
    }
}

/* Mobile overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 99;
}

.sidebar-overlay.active {
    display: block;
}

/* =====================================================
   4-Column Charts Section (Minister Page Style)
   ===================================================== */
.charts-section.charts-4col {
    grid-template-columns: repeat(4, 1fr);
}

/* Pie Chart */
.pie-chart-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.5rem;
    height: 100%;
    justify-content: center;
}

.pie-chart {
    position: relative;
    width: 160px;
    height: 160px;
    border-radius: 50%;
    background: conic-gradient(#0080FF 0deg 244.8deg,
            #8B5CF6 244.8deg 345.6deg,
            #94A3B8 345.6deg 360deg);
    display: flex;
    align-items: center;
    justify-content: center;
}

.pie-svg {
    display: none;
}

.pie-center {
    width: 90px;
    height: 90px;
    background: white;
    border-radius: 50%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.pie-total {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-text);
    font-family: var(--font-heading);
}

.pie-label {
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

.pie-legend {
    width: 100%;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.legend-row {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8rem;
}

.legend-row .legend-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    flex-shrink: 0;
}

.legend-text {
    flex: 1;
    color: var(--color-text-muted);
}

.legend-value {
    font-weight: 600;
    color: var(--color-text);
}

/* Progress Bars Chart (4 categories) */
.progress-bars-chart {
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
    height: 100%;
    justify-content: center;
}

.progress-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.bar-label {
    width: 110px;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
}

.bar-track {
    flex: 1;
    height: 28px;
    background: #E2E8F0;
    border-radius: 6px;
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    border-radius: 4px;
    transition: width 0.5s ease;
}

.bar-value {
    width: 30px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-text);
    text-align: right;
}

/* Unit Bars Chart (Stacked) */
.unit-bars-chart {
    display: flex;
    flex-direction: column;
    gap: 1rem;
    height: 100%;
    justify-content: flex-start;
    padding-top: 0.5rem;
}

.unit-bar-row {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.unit-label {
    width: 120px;
    font-size: 0.7rem;
    color: var(--color-text-muted);
    flex-shrink: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.unit-bar-track {
    flex: 1;
    height: 22px;
    background: #E2E8F0;
    border-radius: 6px;
    overflow: hidden;
    display: flex;
}

.unit-bar-fill {
    height: 100%;
    transition: width 0.5s ease;
}

.unit-bar-fill.completed {
    background: #0080FF;
}

.unit-bar-fill.pending {
    background: #8B5CF6;
}

.unit-legend {
    display: flex;
    gap: 1rem;
    margin-top: 0.75rem;
    font-size: 0.75rem;
}

.unit-legend-item {
    display: flex;
    align-items: center;
    gap: 0.375rem;
    color: var(--color-text-muted);
}

.unit-legend-item .dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
}

.unit-legend-item .dot.completed {
    background: #0080FF;
}

.unit-legend-item .dot.pending {
    background: #8B5CF6;
}

/* Responsive for 4-column charts */
@media (max-width: 1400px) {
    .charts-section.charts-4col {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .charts-section.charts-4col {
        grid-template-columns: 1fr;
    }

    .bar-label {
        width: 90px;
    }

    .unit-label {
        width: 100px;
    }
}