/**
 * PT WIJAYAKUSUMA INTI NUSA (WIN)
 * Sistem Penilaian KPI Karyawan - Area Cilacap
 * Responsive Stylesheet (Handphone, Tablet, Laptop)
 */

:root {
    --win-primary: #1e3a8a;       /* Deep Corporate Navy */
    --win-primary-light: #2563eb;
    --win-secondary: #f97316;     /* Safety / Construction Orange */
    --win-accent: #0284c7;        /* Industrial Cyan */
    --win-dark: #0f172a;
    --win-light: #f8fafc;
    --win-border: #e2e8f0;
    --sidebar-width: 260px;
    --header-height: 64px;
}

body {
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
    background-color: #f1f5f9;
    color: #334155;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Scrollbar halus */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* NAVBAR & TOPBAR */
.app-navbar {
    height: var(--header-height);
    background: #ffffff;
    border-bottom: 1px solid var(--win-border);
    position: sticky;
    top: 0;
    z-index: 1020;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.brand-badge {
    background: linear-gradient(135deg, #1e3a8a 0%, #0f172a 100%);
    color: #ffffff;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* SIDEBAR LAYOUT */
.app-wrapper {
    display: flex;
    align-items: flex-start; /* sidebar tidak ikut melar setinggi konten, supaya bisa menempel (sticky) */
    flex: 1;
    min-height: calc(100vh - var(--header-height));
}

.app-sidebar {
    width: var(--sidebar-width);
    background: #ffffff;
    border-right: 1px solid var(--win-border);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;

    /* Sidebar menetap di layar saat konten di-scroll.
       Jika menunya lebih panjang dari layar, sidebar punya scroll sendiri. */
    position: sticky;
    top: var(--header-height);
    height: calc(100vh - var(--header-height));
    overflow-y: auto;
    overscroll-behavior: contain; /* scroll di sidebar tidak "bocor" menggerakkan konten */
    scrollbar-width: thin;
}

.sidebar-heading {
    font-size: 0.72rem;
    text-transform: uppercase;
    font-weight: 700;
    color: #94a3b8;
    letter-spacing: 1px;
    padding: 1rem 1.25rem 0.5rem;
}

.sidebar-menu {
    list-style: none;
    padding: 0.5rem 0.75rem;
    margin: 0;
}

.sidebar-menu .nav-item {
    margin-bottom: 0.25rem;
}

.sidebar-menu .nav-link {
    display: flex;
    align-items: center;
    padding: 0.65rem 1rem;
    color: #475569;
    font-size: 0.92rem;
    font-weight: 500;
    border-radius: 0.5rem;
    transition: all 0.2s ease;
    text-decoration: none;
}

.sidebar-menu .nav-link i {
    font-size: 1.15rem;
    margin-right: 0.75rem;
    width: 24px;
    text-align: center;
    color: #64748b;
    transition: color 0.2s;
}

.sidebar-menu .nav-link:hover {
    background-color: #f8fafc;
    color: var(--win-primary);
}

.sidebar-menu .nav-link:hover i {
    color: var(--win-secondary);
}

.sidebar-menu .nav-link.active {
    background: linear-gradient(135deg, #1e3a8a 0%, #2563eb 100%);
    color: #ffffff;
    font-weight: 600;
    box-shadow: 0 4px 10px rgba(37, 99, 235, 0.25);
}

.sidebar-menu .nav-link.active i {
    color: #ffffff;
}

/* MAIN CONTENT AREA */
.app-main {
    flex: 1;
    min-width: 0; /* Mencegah overflow flexbox */
    padding: 1.5rem 1.75rem;
}

/* CARDS & PANELS */
.card-kpi {
    background: #ffffff;
    border: 1px solid var(--win-border);
    border-radius: 0.85rem;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.03);
    margin-bottom: 1.5rem;
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.card-kpi:hover {
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.06);
}

.card-kpi .card-header {
    background: #ffffff;
    border-bottom: 1px solid var(--win-border);
    padding: 1rem 1.25rem;
    border-top-left-radius: 0.85rem;
    border-top-right-radius: 0.85rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

/* STATS WIDGET */
.stat-widget {
    padding: 1.25rem;
    border-radius: 0.85rem;
    background: #ffffff;
    border: 1px solid var(--win-border);
    display: flex;
    align-items: center;
    position: relative;
    overflow: hidden;
}

.stat-widget::before {
    content: "";
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 4px;
}

.stat-widget.stat-primary::before { background-color: #2563eb; }
.stat-widget.stat-success::before { background-color: #16a34a; }
.stat-widget.stat-warning::before { background-color: #eab308; }
.stat-widget.stat-danger::before { background-color: #dc2626; }
.stat-widget.stat-orange::before { background-color: #f97316; }

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-right: 1rem;
    flex-shrink: 0;
}

/* STEPPER ALUR KPI (6 TAHAP) */
.kpi-stepper {
    display: flex;
    justify-content: space-between;
    position: relative;
    margin: 1.5rem 0 2rem;
    padding: 0;
    list-style: none;
    overflow-x: auto;
    padding-bottom: 0.5rem;
}

.kpi-stepper::before {
    content: '';
    position: absolute;
    top: 20px;
    left: 30px;
    right: 30px;
    height: 3px;
    background: #e2e8f0;
    z-index: 1;
}

.stepper-item {
    position: relative;
    z-index: 2;
    text-align: center;
    flex: 1;
    min-width: 100px;
}

.stepper-circle {
    width: 42px;
    height: 42px;
    border-radius: 50%;
    background: #ffffff;
    border: 3px solid #cbd5e1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.95rem;
    color: #64748b;
    transition: all 0.3s ease;
}

.stepper-item.completed .stepper-circle {
    background: #16a34a;
    border-color: #16a34a;
    color: #ffffff;
}

.stepper-item.active .stepper-circle {
    background: #2563eb;
    border-color: #93c5fd;
    color: #ffffff;
    box-shadow: 0 0 0 4px rgba(37, 99, 235, 0.2);
}

.stepper-label {
    margin-top: 0.5rem;
    font-size: 0.78rem;
    font-weight: 600;
    color: #64748b;
    display: block;
    line-height: 1.2;
}

.stepper-item.active .stepper-label {
    color: #1e3a8a;
    font-weight: 700;
}

/* TOUCH TARGETS UNTUK SKOR (1-5) */
.score-radios {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
}

.score-radios input[type="radio"] {
    display: none;
}

.score-radios label {
    flex: 1;
    min-width: 48px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f8fafc;
    border: 2px solid #cbd5e1;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 700;
    font-size: 1.05rem;
    color: #475569;
    transition: all 0.15s ease;
    user-select: none;
}

.score-radios label:hover {
    background: #e2e8f0;
    border-color: #94a3b8;
}

.score-radios input[type="radio"]:checked + label {
    background: #1e3a8a;
    border-color: #1e3a8a;
    color: #ffffff;
    box-shadow: 0 2px 8px rgba(30, 58, 138, 0.35);
}

/* RESPONSIVE DESIGN (HANDPHONE, TABLET, LAPTOP) */

/* Smartphone / Handphone (< 768px) */
@media (max-width: 767.98px) {
    .app-sidebar {
        display: none; /* Menggunakan offcanvas drawer di handphone */
    }
    .app-main {
        padding: 1rem 0.85rem;
    }
    .kpi-stepper {
        justify-content: flex-start;
    }
    .kpi-stepper::before {
        display: none; /* Hide line on small screens */
    }
    .stepper-item {
        flex: 0 0 110px;
    }
    .table-responsive {
        font-size: 0.85rem;
    }
    .btn-mobile-full {
        width: 100%;
        margin-bottom: 0.5rem;
    }
    .score-radios label {
        height: 40px;
        font-size: 0.95rem;
    }
}

/* Tablet (768px - 1024px) */
@media (min-width: 768px) and (max-width: 1024px) {
    .app-sidebar {
        width: 220px;
    }
    .app-main {
        padding: 1.25rem;
    }
    .sidebar-menu .nav-link {
        font-size: 0.88rem;
        padding: 0.55rem 0.85rem;
    }
}

/* Laptop & Desktop (> 1024px) */
@media (min-width: 1025px) {
    .app-main {
        padding: 2rem;
    }
}

/* Utilities */
.bg-subtle-primary { background-color: #eff6ff; }
.bg-subtle-success { background-color: #f0fdf4; }
.bg-subtle-warning { background-color: #fefce8; }
.bg-subtle-danger  { background-color: #fef2f2; }
.bg-subtle-orange  { background-color: #fff7ed; }

.badge-predicate {
    font-size: 1.1rem;
    padding: 0.5rem 1rem;
    font-weight: 700;
    border-radius: 0.5rem;
}

/* ==========================================
   ANIMASI: Auto-fill dari Data Absensi
   ========================================== */
@keyframes flashHighlight {
    0%   { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0.7); }
    50%  { box-shadow: 0 0 0 8px rgba(59, 130, 246, 0.2); background: #dbeafe; }
    100% { box-shadow: 0 0 0 0 rgba(59, 130, 246, 0); }
}

.flash-highlight {
    animation: flashHighlight 1.2s ease-in-out;
    border-radius: 8px;
}

.card-kpi.border-primary {
    border-left: 3px solid #0d6efd !important;
}