/* Global Styles: assets/css/style.css */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');

:root {
    /* Color Palette from Figma */
    --color-primary: #3BAF7D;
    --color-primary-dark: #2D865F;
    --color-primary-light: rgba(59, 175, 125, 0.1);
    --color-white: #FFFFFF;
    --color-black: #333333;
    --color-gray: #808080;
    --color-light-gray: #EFEFEF;
    --color-bg: #F7F9FA;

    /* Warning/States Colors */
    --color-red: #E50000;
    --color-red-light: #FFC5C5;
    --color-yellow: #FFBE33;
    --color-yellow-light: #FFF2CC;

    /* Fonts & Typography */
    --font-primary: 'Poppins', sans-serif;

    /* Shadow & Transition effects */
    --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.08);
    --shadow-lg: 0 10px 30px rgba(0, 0, 0, 0.12);
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Reset CSS */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: var(--font-primary);
    -webkit-tap-highlight-color: transparent;
}

body {
    background-color: #f1f3f5;
    color: var(--color-black);
    display: flex;
    justify-content: center;
    align-items: flex-start;
    min-height: 100vh;
    overflow-x: hidden;
}

/* Mobile Wrapper Container (Desain Sama Persis Figma) */
.app-container {
    width: 100%;
    max-width: 450px;
    /* Standar Viewport Mobile */
    min-height: 100vh;
    background-color: var(--color-bg);
    display: flex;
    flex-direction: column;
    position: relative;
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.1);
}

/* Wrapper Khusus Desktop (Untuk visualisasi agar tetap baik & relevan) */
@media (min-width: 768px) {
    body {
        background: linear-gradient(135deg, #e0f2fe 0%, #f1f5f9 50%, #dcfce7 100%);
        background-attachment: fixed;
        align-items: flex-start;
        padding: 40px 0;
    }

    .app-container {
        max-width: 960px;
        /* Tablet view container */
        min-height: calc(100vh - 80px);
        margin: 0 auto;
        box-shadow: 0 20px 80px rgba(0, 0, 0, 0.06);
        background-color: rgba(255, 255, 255, 0.95);
        backdrop-filter: blur(20px);
        border: 1px solid rgba(255, 255, 255, 0.5);
        border-radius: 24px;
        overflow: hidden;
    }
}

@media (min-width: 1024px) {
    .app-container {
        max-width: 1140px;
        /* Desktop view container */
    }
}

/* Header Styles */
.header-green {
    background-color: var(--color-primary);
    color: var(--color-white);
    padding: 30px 24px 70px 24px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    position: relative;
}

.header-nav {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.header-nav .icon-btn {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--color-white);
    width: 40px;
    height: 40px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 20px;
    transition: var(--transition);
}

.header-nav .icon-btn:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: scale(1.05);
}

.header-nav .btn-exit {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: var(--color-white);
    padding: 8px 16px;
    border-radius: 20px;
    font-size: 13px;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 6px;
    cursor: pointer;
    text-decoration: none;
    transition: var(--transition);
}

.header-nav .btn-exit:hover {
    background: rgba(255, 255, 255, 0.3);
}

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

.user-welcome h2 {
    font-size: 20px;
    font-weight: 600;
    margin-top: 4px;
    line-height: 1.3;
}

.user-welcome p {
    font-size: 13px;
    opacity: 0.9;
}

.user-role-badge {
    display: inline-block;
    background: rgba(255, 255, 255, 0.2);
    padding: 4px 16px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 600;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.user-avatar-header {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    border: 2px solid var(--color-white);
    overflow: hidden;
    background-color: var(--color-white);
    box-shadow: var(--shadow-sm);
}

.user-avatar-header.default-avatar {
    background: transparent;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2.5px solid var(--color-white);
    box-shadow: none;
}

.user-avatar-header.default-avatar i {
    color: var(--color-white);
    font-size: 38px;
}

.user-avatar-header img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* Floating Card Layout */
.card-floating {
    background-color: var(--color-white);
    border-radius: 20px;
    margin: -50px 24px 0 24px;
    padding: 20px;
    box-shadow: var(--shadow-md);
    z-index: 10;
    position: relative;
}

/* Content Area */
.content-body {
    flex: 1;
    padding: 24px;
}

/* Bottom Navigation Bar (Matches Figma BERANDA.png) */
.bottom-nav {
    background-color: var(--color-white);
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 100;
    height: calc(68px + env(safe-area-inset-bottom, 0px));
    border-top: 1.5px solid #EFEFEF;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.03);
    padding-bottom: env(safe-area-inset-bottom, 0px);
}

/* For mobile: clear bottom-nav height */
.app-container.has-bottom-nav {
    padding-bottom: calc(78px + env(safe-area-inset-bottom, 0px));
}

.nav-item,
.nav-item-center {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: flex-end;
    padding-bottom: 10px;
    text-decoration: none;
    color: var(--color-gray);
    font-size: 11px;
    font-weight: 500;
    transition: var(--transition);
    flex: 1;
    height: 100%;
    position: relative;
    -webkit-tap-highlight-color: transparent;
}

.nav-item.active {
    color: var(--color-primary);
    font-weight: 600;
}

.nav-item i,
.nav-item svg {
    font-size: 24px;
    width: 24px;
    height: 24px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 4px;
    transition: var(--transition);
}

.nav-item.active i,
.nav-item.active svg {
    font-size: 24px;
    color: var(--color-primary);
}

.nav-item span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 70px;
    text-align: center;
    font-size: 11px;
}

/* Center Floating Absensi Button */
.btn-scan-floating {
    position: absolute;
    top: -24px;
    left: 50%;
    transform: translateX(-50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: var(--color-primary);
    border: 4px solid var(--color-white);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 16px rgba(59, 175, 125, 0.3);
    transition: var(--transition);
    cursor: pointer;
    z-index: 2;
    -webkit-tap-highlight-color: transparent;
}

.btn-scan-floating:hover {
    transform: translateX(-50%) scale(1.06);
    background-color: var(--color-primary-dark);
    box-shadow: 0 6px 20px rgba(59, 175, 125, 0.4);
}

.btn-scan-floating:active {
    transform: translateX(-50%) scale(0.96);
}

.icon-absensi-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
    display: block;
    pointer-events: none;
}

.nav-center-label {
    font-size: 11px;
    font-weight: 600;
    color: var(--color-gray);
    text-align: center;
}

/* Helper Classes for viewport visibility toggling */
.desktop-only {
    display: none !important;
}

.mobile-only {
    display: block !important;
}

/* Base Mobile Profile Styles */
.profile-layout-container {
    display: flex;
    flex-direction: column;
}

.profile-left-panel {
    /* Handled by header-green on mobile */
}

.profile-right-panel {
    /* Plain wrapper on mobile to prevent margin doubling */
}

.profile-right-panel .card-floating {
    margin-top: -30px;
    margin-bottom: 24px;
}

.profile-logout-container {
    margin-top: 10px;
    padding: 0 24px 24px 24px;
}

.profile-info-item.last-mobile {
    border-bottom: none !important;
    padding-bottom: 0 !important;
}

/* ==========================================================================
   TATA LETAK RESPONSIF: TABLET & DESKTOP (DOSEN & STAFF USER VIEWS)
   ========================================================================== */
@media (min-width: 768px) {

    /* 1. Splash Screen & Login Card Center-floating on Desktop */
    .splash-screen {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        min-height: calc(100vh - 80px) !important;
        background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%) !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: space-between !important;
        align-items: center !important;
    }

    .login-screen {
        width: 100% !important;
        max-width: none !important;
        margin: 0 !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        min-height: calc(100vh - 80px) !important;
        display: grid !important;
        grid-template-columns: 1.2fr 1fr !important;
        padding: 0 !important;
        background-color: var(--color-white) !important;
        overflow: hidden;
    }

    .login-screen .login-header {
        background: linear-gradient(135deg, var(--color-primary-dark) 0%, var(--color-primary) 100%);
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 40px 24px !important;
        margin: 0 !important;
        max-width: none !important;
        position: relative;
        color: var(--color-white);
    }

    /* Abstract glowing background circles for desktop/tablet login hero panel */
    .login-screen .login-header::before {
        content: '';
        position: absolute;
        width: 320px;
        height: 320px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.08) 0%, rgba(255, 255, 255, 0) 70%);
        top: -60px;
        left: -60px;
        pointer-events: none;
    }

    .login-screen .login-header::after {
        content: '';
        position: absolute;
        width: 240px;
        height: 240px;
        border-radius: 50%;
        background: radial-gradient(circle, rgba(255, 255, 255, 0.06) 0%, rgba(255, 255, 255, 0) 70%);
        bottom: -40px;
        right: -40px;
        pointer-events: none;
    }

    .login-screen .login-title {
        font-size: 28px !important;
        font-weight: 700 !important;
        margin-top: 16px !important;
        text-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .login-screen .login-body {
        height: 100% !important;
        display: flex !important;
        flex-direction: column !important;
        justify-content: center !important;
        align-items: center !important;
        padding: 40px 24px !important;
        background-color: #f8fafc !important;
        max-width: none !important;
    }

    .login-screen .login-card {
        width: 100%;
        max-width: 360px;
        box-shadow: 0 10px 30px rgba(0, 0, 0, 0.04) !important;
        border: 1px solid rgba(0, 0, 0, 0.02);
    }

    /* Desktop Specific Scaling (1024px+) */
    @media (min-width: 1024px) {
        .login-screen .login-header {
            padding: 60px 40px !important;
        }

        .login-screen .login-title {
            font-size: 32px !important;
            margin-top: 20px !important;
        }

        .login-screen .login-body {
            padding: 60px 40px !important;
        }

        .login-screen .login-card {
            max-width: 380px;
        }
    }

    .splash-screen .splash-content,
    .splash-screen .splash-footer {
        width: 100%;
        max-width: 450px;
        margin-left: auto;
        margin-right: auto;
    }

    /* 2. Full-width Fixed Bottom Navigation for Tablet */
    .bottom-nav {
        position: fixed;
        bottom: 0;
        left: 50%;
        transform: translateX(-50%);
        width: 100%;
        max-width: 960px;
        /* Constrained to tablet container width */
        height: 68px;
        background-color: var(--color-white);
        border-top: 1.5px solid #EFEFEF;
        border-radius: 0;
        /* Flat bottom touching the screen edge */
        box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.03);
        display: flex;
        justify-content: center;
        /* Center navigation elements */
        align-items: stretch;
        padding-bottom: 0;
        z-index: 1000;
    }

    .bottom-nav .nav-item,
    .bottom-nav .nav-item-center {
        flex: 0 0 120px;
        max-width: 120px;
        height: 100%;
    }

    .app-container.has-bottom-nav {
        padding-bottom: 78px;
        /* Fixed space to clear the fixed footer */
    }

    /* 2b. Premium Rounded Floating Footer for Desktop (1024px+) */
    @media (min-width: 1024px) {
        .bottom-nav {
            position: fixed !important;
            bottom: 24px !important;
            left: 50% !important;
            transform: translateX(-50%) !important;
            width: 90% !important;
            max-width: 480px !important;
            /* Centered sleek floating dock */
            height: 68px !important;
            background-color: rgba(255, 255, 255, 0.95) !important;
            backdrop-filter: blur(16px) !important;
            -webkit-backdrop-filter: blur(16px) !important;
            border-radius: 40px !important;
            /* Beautiful long capsule/pill shape */
            border: 1px solid rgba(0, 0, 0, 0.05) !important;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.08) !important;
            display: flex !important;
            justify-content: space-around !important;
            align-items: stretch !important;
            padding: 0 24px !important;
            /* Space buffer for pill ends */
            padding-bottom: 0 !important;
        }

        .bottom-nav .nav-item,
        .bottom-nav .nav-item-center {
            flex: 1 !important;
            /* Stretch items to occupy equal space in the dock */
            max-width: none !important;
        }

        .app-container.has-bottom-nav {
            padding-bottom: 110px !important;
            /* Clear space for the floating dock */
        }
    }

    /* 3. Dashboard Grid Layout (2-Column) */
    .dashboard-content-grid {
        display: grid;
        grid-template-columns: 1fr 1.3fr;
        gap: 24px;
        padding: 0 24px 24px 24px;
        margin-top: 0 !important;
        position: relative;
        z-index: 20;
        align-items: start;
    }

    .dashboard-content-grid .card-today-status {
        margin-top: -50px !important;
        position: sticky;
        top: 24px;
    }

    .dashboard-content-grid .content-body {
        padding: 0 !important;
    }

    /* 4. Riwayat / History Grid Layout (2-Column) */
    .riwayat-content-grid {
        display: grid;
        grid-template-columns: 1fr 1.5fr;
        gap: 30px;
        align-items: start;
        margin-top: 10px;
    }

    .riwayat-sidebar-col {
        position: sticky;
        top: 24px;
        display: flex;
        flex-direction: column;
        gap: 20px;
    }

    .riwayat-sidebar-col .stats-grid-container {
        grid-template-columns: repeat(2, 1fr) !important;
        /* Make 2x2 grid on sidebar desktop */
        gap: 12px !important;
        margin-bottom: 0 !important;
    }

    .riwayat-sidebar-col .filter-unduh-row {
        flex-direction: column;
        align-items: stretch;
        background-color: var(--color-white);
        padding: 20px;
        border-radius: 16px;
        box-shadow: var(--shadow-sm);
        gap: 16px;
        margin-bottom: 0 !important;
    }

    .riwayat-sidebar-col .filter-dropdown-form {
        display: flex;
        gap: 10px;
    }

    .riwayat-sidebar-col .filter-dropdown-form .select-wrapper {
        flex: 1;
        margin-left: 0 !important;
    }

    .riwayat-sidebar-col .filter-dropdown-form .select-wrapper select {
        width: 100%;
    }

    .riwayat-sidebar-col .btn-unduh-laporan {
        justify-content: center;
        background-color: var(--color-primary-light);
        color: var(--color-primary-dark);
        padding: 12px;
        border-radius: 10px;
        transition: var(--transition);
        width: 100%;
    }

    .riwayat-sidebar-col .btn-unduh-laporan:hover {
        background-color: var(--color-primary);
        color: var(--color-white);
    }

    .riwayat-main-col .tab-selector-bar {
        margin-bottom: 20px;
    }

    /* 5. Center Forms & Detail Screens on Desktop (Izin, Dinas, Absensi, Register Face) */
    .form-pengajuan-screen,
    .absensi-screen,
    .reg-face-screen {
        max-width: 680px;
        margin: 0 auto !important;
        width: 100%;
    }

    .form-card {
        background-color: var(--color-white);
        border-radius: 20px;
        padding: 30px !important;
        box-shadow: var(--shadow-md) !important;
        margin-bottom: 24px;
    }

    .form-toggle-link-container {
        max-width: 680px;
        margin: 10px auto 30px auto !important;
    }

    /* Helper Visibility Overrides inside Tablet/Desktop query */
    .desktop-only {
        display: block !important;
    }

    .mobile-only {
        display: none !important;
    }

    /* 6. Profile View Responsive Centered Layout for Tablet & Desktop */
    .profile-layout-container {
        max-width: 680px;
        margin: 20px auto !important;
        padding: 0 24px 24px 24px;
        display: flex;
        flex-direction: column;
        width: 100%;
        box-sizing: border-box;
    }

    .profile-left-panel {
        border-radius: 24px 24px 0 0 !important;
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
        padding: 40px 24px 75px 24px !important;
        text-align: center;
        width: 100%;
        box-sizing: border-box;
        display: block !important;
        box-shadow: var(--shadow-md);
    }

    .profile-left-panel:hover {
        transform: none !important;
        box-shadow: var(--shadow-md) !important;
    }

    .profile-right-panel {
        display: flex;
        flex-direction: column;
        width: 100%;
        padding: 0 !important;
        box-sizing: border-box;
    }

    .profile-right-panel .card-floating {
        margin: -40px 0 24px 0 !important;
        /* Overlaps banner, zero side margins */
        width: 100%;
        box-shadow: var(--shadow-md) !important;
        border-radius: 24px !important;
        padding: 30px !important;
        box-sizing: border-box;
        background-color: var(--color-white);
    }

    .profile-info-item.last-mobile {
        border-bottom: 1.5px solid var(--color-light-gray) !important;
        padding-bottom: 14px !important;
    }

    .profile-logout-container {
        width: 100%;
        margin-top: 10px;
        padding: 0 !important;
    }

    .profile-logout-container .btn-logout {
        width: 100%;
        background-color: var(--color-primary) !important;
        color: var(--color-white) !important;
        box-shadow: 0 4px 12px rgba(59, 175, 125, 0.2) !important;
        height: 46px;
        border-radius: 10px;
        font-weight: 600;
        cursor: pointer;
        display: flex;
        align-items: center;
        justify-content: center;
        gap: 8px;
        transition: var(--transition);
        border: none;
    }

    .profile-logout-container .btn-logout:hover {
        background-color: var(--color-primary-dark) !important;
        transform: translateY(-2px) !important;
        box-shadow: 0 6px 16px rgba(59, 175, 125, 0.3) !important;
    }

    /* 7. Webcam & Circular Viewfinder on Desktop */
    .viewfinder-wrapper {
        width: 320px;
        height: 320px;
    }

    .viewfinder-circle {
        width: 300px;
        height: 300px;
    }

    .viewfinder-ring {
        width: 316px;
        height: 316px;
    }

    /* 8. Refined Header & Card Visual Effects (Premium Touch) */
    .header-green {
        border-radius: 24px 24px 0 0 !important;
        background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%) !important;
    }

    .card-item,
    .card-floating,
    .stats-box,
    .empty-state-container {
        transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        border: 1px solid rgba(0, 0, 0, 0.03) !important;
    }

    .card-item:hover,
    .card-floating:hover {
        transform: translateY(-3px) !important;
        box-shadow: 0 16px 36px rgba(0, 0, 0, 0.08) !important;
        border-color: rgba(59, 175, 125, 0.15) !important;
    }

    .stats-box:hover {
        transform: translateY(-4px) !important;
        box-shadow: 0 12px 28px rgba(0, 0, 0, 0.08) !important;
    }

    .empty-state-container:hover {
        box-shadow: 0 8px 24px rgba(0, 0, 0, 0.04) !important;
    }
}