/* style.css - AIPLN Dark Glassmorphism Design System */
:root {
    --bg-dark: #0b0f19;
    --card-bg: rgba(22, 27, 46, 0.75);
    --card-border: rgba(255, 255, 255, 0.08);
    --primary-gradient: linear-gradient(135deg, #6372FF 0%, #BA46FF 100%);
    --secondary-gradient: linear-gradient(135deg, #22d3ee 0%, #0ea5e9 100%);
    --success-gradient: linear-gradient(135deg, #10b981 0%, #059669 100%);
    --warning-gradient: linear-gradient(135deg, #f59e0b 0%, #d97706 100%);
    --danger-gradient: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    --gold-gradient: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    --silver-gradient: linear-gradient(135deg, #cbd5e1 0%, #94a3b8 100%);
    --bronze-gradient: linear-gradient(135deg, #fb923c 0%, #d97706 100%);
    --gold-glow: 0 0 20px rgba(245, 158, 11, 0.35);
    --primary-glow: 0 0 20px rgba(99, 114, 255, 0.3);
}

body {
    background-color: var(--bg-dark);
    font-family: 'Plus Jakarta Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    color: #e2e8f0;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow-x: hidden;
}

/* Glassmorphism card */
.glass-card {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.37);
}

/* App Header & Navigation (Mobile First) */
.app-header {
    background: rgba(11, 15, 25, 0.92);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--card-border);
    position: sticky;
    top: 0;
    z-index: 1020;
    padding: 0.5rem 0;
}

/* Mobile-First Layout: Row 1 = Logo (left) + Logout (right), Row 2 = Nav Segmented Pills */
.header-container {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    row-gap: 0.45rem;
}

.brand-badge {
    order: 1;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    text-decoration: none;
}

.brand-logo-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: var(--primary-gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.1rem;
    box-shadow: var(--primary-glow);
}

.brand-title {
    font-weight: 800;
    font-size: 1.15rem;
    letter-spacing: -0.02em;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.brand-sub {
    font-size: 0.65rem;
    color: #94a3b8;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    display: block;
    line-height: 1;
}

.header-actions {
    order: 2;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.header-nav-pills {
    order: 3;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.25rem;
    padding: 0.25rem;
    border-radius: 999px;
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.08);
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.header-nav-pills .nav-pill-btn {
    flex: 1 1 auto;
    justify-content: center;
    text-align: center;
    padding: 0.35rem 0.45rem;
    font-size: 0.78rem;
    white-space: nowrap;
}

.nav-pill-btn {
    color: #94a3b8;
    font-weight: 600;
    font-size: 0.8rem;
    padding: 0.32rem 0.75rem;
    border-radius: 999px;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    transition: all 0.2s ease;
}

.nav-pill-btn:hover {
    color: #ffffff;
    background: rgba(255, 255, 255, 0.05);
}

.nav-pill-btn.active {
    color: #ffffff;
    background: var(--primary-gradient);
    box-shadow: var(--primary-glow);
}

/* Desktop View (min-width: 992px): Single Row Layout */
@media (min-width: 992px) {
    .app-header {
        padding: 0.55rem 0;
    }

    .header-container {
        flex-wrap: nowrap;
        row-gap: 0;
    }

    .brand-badge {
        order: 1;
        flex: 0 0 auto;
    }

    .header-nav-pills {
        order: 2;
        width: auto;
        justify-content: center;
        margin: 0 auto;
        padding: 0.25rem 0.4rem;
        gap: 0.35rem;
    }

    .header-nav-pills .nav-pill-btn {
        flex: 0 0 auto;
        padding: 0.32rem 0.85rem;
        font-size: 0.8rem;
    }

    .header-actions {
        order: 3;
        flex: 0 0 auto;
    }
}

/* Metric Cards */
.metric-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    border-radius: 14px;
    transition: transform 0.2s ease, border-color 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.metric-card:hover {
    transform: translateY(-2px);
    border-color: rgba(99, 114, 255, 0.3);
}

.metric-icon-box {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

.metric-icon-indigo { background: rgba(99, 114, 255, 0.15); color: #818cf8; }
.metric-icon-emerald { background: rgba(16, 185, 129, 0.15); color: #34d399; }
.metric-icon-cyan { background: rgba(34, 211, 238, 0.15); color: #22d3ee; }
.metric-icon-purple { background: rgba(186, 70, 255, 0.15); color: #c084fc; }
.metric-icon-amber { background: rgba(245, 158, 11, 0.15); color: #fbbf24; }

/* Badges */
.badge-pln {
    background: rgba(99, 114, 255, 0.18);
    color: #a5b4fc;
    border: 1px solid rgba(99, 114, 255, 0.35);
}

.badge-success-glow {
    background: rgba(16, 185, 129, 0.18);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}

.badge-warning-glow {
    background: rgba(245, 158, 11, 0.18);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}

.badge-danger-glow {
    background: rgba(239, 68, 68, 0.18);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

/* Custom Buttons */
.btn-gradient {
    background: var(--primary-gradient);
    color: #ffffff;
    border: none;
    font-weight: 600;
    box-shadow: var(--primary-glow);
    transition: opacity 0.2s ease, transform 0.2s ease;
}

.btn-gradient:hover {
    opacity: 0.92;
    transform: translateY(-1px);
    color: #ffffff;
}

.btn-secondary-custom {
    background: rgba(255, 255, 255, 0.06);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #cbd5e1;
    font-weight: 500;
}

.btn-secondary-custom:hover {
    background: rgba(255, 255, 255, 0.12);
    border-color: rgba(255, 255, 255, 0.2);
    color: #ffffff;
}

/* Horizontal Scroll for Filter Tabs on Mobile */
.filter-scroll-wrapper {
    display: flex;
    gap: 0.5rem;
    overflow-x: auto;
    white-space: nowrap;
    padding-bottom: 0.35rem;
    -webkit-overflow-scrolling: touch;
}

.filter-scroll-wrapper::-webkit-scrollbar {
    height: 4px;
}

.filter-scroll-wrapper::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 999px;
}

/* Podium Top 3 Cards */
.podium-card {
    border-radius: 16px;
    padding: 1.25rem 1rem;
    position: relative;
    overflow: hidden;
    backdrop-filter: blur(16px);
}

.podium-card-gold {
    background: linear-gradient(180deg, rgba(245, 158, 11, 0.15) 0%, rgba(26, 31, 46, 0.9) 100%);
    border: 1px solid rgba(245, 158, 11, 0.4);
    box-shadow: var(--gold-glow);
}

.podium-card-silver {
    background: linear-gradient(180deg, rgba(148, 163, 184, 0.15) 0%, rgba(26, 31, 46, 0.9) 100%);
    border: 1px solid rgba(148, 163, 184, 0.35);
}

.podium-card-bronze {
    background: linear-gradient(180deg, rgba(217, 119, 6, 0.15) 0%, rgba(26, 31, 46, 0.9) 100%);
    border: 1px solid rgba(217, 119, 6, 0.35);
}

.rank-badge-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 800;
    font-size: 1.05rem;
}

.rank-badge-gold {
    background: var(--gold-gradient);
    color: #1a1a1a;
    box-shadow: var(--gold-glow);
}

.rank-badge-silver {
    background: var(--silver-gradient);
    color: #1a1a1a;
}

.rank-badge-bronze {
    background: var(--bronze-gradient);
    color: #ffffff;
}

.rank-badge-default {
    background: rgba(255, 255, 255, 0.08);
    color: #94a3b8;
}

/* Leaderboard item list */
.lb-item-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: 12px;
    padding: 0.75rem 1rem;
    margin-bottom: 0.5rem;
    transition: transform 0.15s ease, background 0.15s ease, border-color 0.15s ease;
}

.lb-item-card:hover {
    transform: translateX(4px);
    background: rgba(30, 38, 64, 0.85);
    border-color: rgba(99, 114, 255, 0.3);
}

.lb-item-card.is-top-3 {
    border-color: rgba(255, 255, 255, 0.12);
}

/* Table Monitoring Styles */
.table-custom-wrapper {
    background: var(--card-bg);
    backdrop-filter: blur(16px);
    border: 1px solid var(--card-border);
    border-radius: 16px;
    overflow: hidden;
    width: 100%;
}

.table-monitoring {
    margin-bottom: 0;
    color: #cbd5e1;
    font-size: 0.75rem;
    border-color: rgba(255, 255, 255, 0.06);
    width: 100%;
}

.table-monitoring thead th {
    background: #101524;
    color: #94a3b8;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
    padding: 0.45rem 0.15rem;
    border-bottom: 2px solid rgba(255, 255, 255, 0.1);
    white-space: nowrap;
    text-align: center;
}

.table-monitoring tbody td {
    padding: 0.35rem 0.15rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* Daily Cell Matrix Status Coloring */
.day-cell {
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.72rem;
    padding: 0.25rem 0.05rem !important;
    transition: all 0.15s ease;
    border-radius: 3px;
    overflow: hidden;
    text-overflow: clip;
}

/* 0 - Merah */
.day-cell.cell-red {
    background: rgba(239, 68, 68, 0.22) !important;
    color: #f87171 !important;
    font-weight: 700;
    border: 1px solid rgba(239, 68, 68, 0.45) !important;
}

/* Di bawah target - Orange */
.day-cell.cell-orange {
    background: rgba(245, 158, 11, 0.22) !important;
    color: #fbbf24 !important;
    font-weight: 700;
    border: 1px solid rgba(245, 158, 11, 0.45) !important;
}

/* Sesuai Target / Lebih dari target - Hijau */
.day-cell.cell-green {
    background: rgba(16, 185, 129, 0.24) !important;
    color: #34d399 !important;
    font-weight: 700;
    border: 1px solid rgba(16, 185, 129, 0.5) !important;
    box-shadow: inset 0 0 6px rgba(16, 185, 129, 0.15);
}

.day-cell.cell-empty {
    color: rgba(255, 255, 255, 0.15);
    background: transparent;
}

/* Th Day Headers */
.th-day {
    padding: 0.35rem 0.05rem !important;
    font-family: 'JetBrains Mono', monospace;
    vertical-align: middle;
}

.th-day .day-num {
    font-size: 0.72rem;
    font-weight: 700;
    line-height: 1;
}

.th-day .day-target-sub {
    font-size: 0.55rem;
    font-weight: 500;
    line-height: 1;
    margin-top: 2px;
}

.th-day.th-weekend {
    background: rgba(245, 158, 11, 0.12) !important;
    color: #fbbf24 !important;
    border-bottom: 2px solid #f59e0b !important;
}

.th-day.th-weekday {
    border-bottom: 2px solid rgba(99, 114, 255, 0.4);
}

/* Legend items */
.legend-pill {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    padding: 0.2rem 0.55rem;
    border-radius: 999px;
    font-family: 'JetBrains Mono', monospace;
    font-weight: 600;
}
.legend-pill-green {
    background: rgba(16, 185, 129, 0.15);
    color: #34d399;
    border: 1px solid rgba(16, 185, 129, 0.35);
}
.legend-pill-orange {
    background: rgba(245, 158, 11, 0.15);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.35);
}
.legend-pill-red {
    background: rgba(239, 68, 68, 0.15);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.35);
}

.group-header-row td {
    background: rgba(99, 114, 255, 0.15) !important;
    color: #ffffff;
    font-size: 0.8rem;
}

.subtotal-row td {
    background: rgba(255, 255, 255, 0.03) !important;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
}

.grandtotal-row td {
    background: rgba(99, 114, 255, 0.25) !important;
    color: #ffffff;
    font-weight: 800;
    border-top: 2px solid rgba(99, 114, 255, 0.5);
    font-size: 0.82rem;
}

/* =========================================================
   DESKTOP AUTO-FIT & RESPONSIVE RULES (NO HORIZONTAL SCROLL)
   ========================================================= */
@media (min-width: 992px) {
    /* Auto-fit container */
    .table-monitoring-desktop-fit {
        table-layout: fixed !important;
        width: 100% !important;
    }

    .table-monitoring-desktop-fit th,
    .table-monitoring-desktop-fit td {
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
    }

    .table-monitoring-desktop-fit .col-no { width: 2.2% !important; }
    .table-monitoring-desktop-fit .col-unit { width: 11.8% !important; text-align: left; }
    .table-monitoring-desktop-fit .col-tgthr { width: 2.8% !important; }
    .table-monitoring-desktop-fit .col-day { width: 2.05% !important; }
    .table-monitoring-desktop-fit .col-target { width: 4.2% !important; }
    .table-monitoring-desktop-fit .col-realisasi { width: 4.5% !important; }
    .table-monitoring-desktop-fit .col-deviasi { width: 4.2% !important; }
    .table-monitoring-desktop-fit .col-progress { width: 4.8% !important; }
    .table-monitoring-desktop-fit .col-tgtakhir { width: 2.8% !important; }

    /* Remove sticky constraints on desktop auto-fit */
    .table-monitoring th:nth-child(1), .table-monitoring td:nth-child(1),
    .table-monitoring th:nth-child(2), .table-monitoring td:nth-child(2) {
        position: static !important;
        box-shadow: none !important;
    }
}

/* MOBILE RESPONSIVE SCROLL & STICKY COLUMNS */
@media (max-width: 991px) {
    .table-monitoring {
        min-width: 1100px;
    }

    .table-monitoring th:nth-child(1), .table-monitoring td:nth-child(1) {
        position: sticky;
        left: 0;
        z-index: 3;
        background: #0f1524 !important;
    }
    .table-monitoring th:nth-child(2), .table-monitoring td:nth-child(2) {
        position: sticky;
        left: 36px;
        z-index: 3;
        background: #0f1524 !important;
        box-shadow: 3px 0 8px rgba(0, 0, 0, 0.5);
    }
    .group-header-row td {
        position: sticky;
        left: 0;
        z-index: 2;
    }
}

/* Form Dark Controls */
.form-control-dark, .form-select.form-control-dark {
    background-color: rgba(15, 23, 42, 0.8) !important;
    border: 1px solid rgba(255, 255, 255, 0.12) !important;
    color: #f1f5f9 !important;
}

.form-control-dark:focus, .form-select.form-control-dark:focus {
    background-color: rgba(15, 23, 42, 0.95) !important;
    border-color: #6372FF !important;
    color: #ffffff !important;
    box-shadow: 0 0 0 0.25rem rgba(99, 114, 255, 0.25) !important;
}

.form-control-custom {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #ffffff;
    padding: 0.55rem 0.85rem;
}

.form-control-custom:focus {
    background: rgba(255, 255, 255, 0.08);
    border-color: #6372FF;
    color: #ffffff;
    box-shadow: 0 0 0 0.2rem rgba(99, 114, 255, 0.25);
}

.text-xs {
    font-size: 0.72rem !important;
}

/* Footer */
.app-footer {
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(16px);
    border-top: 1px solid var(--card-border);
    padding: 0.85rem 0;
    margin-top: auto;
}

.spin-animation {
    animation: spin 1s linear infinite;
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
