@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --primary: #6366f1;
    --primary-light: #818cf8;
    --primary-dark: #4f46e5;
    --secondary: #10b981;
    --accent: #f59e0b;
    --danger: #ef4444;
    --bg-color: #f3f4f6;
    --glass-bg: rgba(255, 255, 255, 0.7);
    --glass-border: rgba(255, 255, 255, 0.5);
    --text-main: #1f2937;
    --text-muted: #6b7280;
    --sidebar-bg: #1e1b4b;
    --sidebar-width: 260px;
    --header-height: 70px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    --border-color: #e5e7eb;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body.dark-mode {
    --bg-color: #0f172a;
    --glass-bg: rgba(30, 41, 59, 0.7);
    --glass-border: rgba(255, 255, 255, 0.1);
    --text-main: #f1f5f9;
    --text-muted: #94a3b8;
    --border-color: rgba(51, 65, 85, 0.5);
}

.theme-transition {
    transition: background-color 0.3s ease, color 0.3s ease, border-color 0.3s ease;
}

body {
    background-color: var(--bg-color);
    background-image: radial-gradient(at 0% 0%, hsla(253,16%,7%,1) 0, transparent 50%), 
                      radial-gradient(at 50% 0%, hsla(225,39%,30%,1) 0, transparent 50%), 
                      radial-gradient(at 100% 0%, hsla(339,49%,30%,1) 0, transparent 50%);
    background-attachment: fixed;
    color: var(--text-main);
    min-height: 100vh;
    overflow-x: hidden;
}

/* Animations */
@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(20px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { transform: translateX(-100%); }
    to { transform: translateX(0); }
}

.animate-fade-in { animation: fadeInUp 0.6s ease-out forwards; }

/* Glassmorphism Utility */
.glass {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: #fff;
    padding: 2rem 1.5rem;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 200; /* Ditingkatkan agar di atas header mobile */
    transition: transform 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto; /* Memungkinkan scroll jika menu terlalu banyak */
    scrollbar-width: none; /* Sembunyikan scrollbar di Firefox */
    -ms-overflow-style: none; /* Sembunyikan scrollbar di IE/Edge */
}

.sidebar::-webkit-scrollbar {
    display: none; /* Sembunyikan scrollbar di Chrome/Safari */
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,0.5); }
}

.sidebar .brand {
    font-size: 1.25rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    margin-bottom: 2.5rem;
    color: #fff;
    line-height: 1.2;
}

.sidebar .brand span {
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.sidebar .brand img {
    height: 48px;
    width: auto;
    max-width: 180px;
    object-fit: contain;
    border-radius: 8px;
}

.sidebar .brand i {
    font-size: 2rem;
    background: linear-gradient(135deg, var(--primary-light), var(--primary));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar nav {
    flex: none; /* Berubah dari flex: 1 agar tidak memaksa ruang */
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar nav a {
    color: rgba(255,255,255,0.7);
    text-decoration: none;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-md);
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.3s;
}

.sidebar nav a:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
    transform: translateX(5px);
}

.sidebar nav a.active {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
}

.sidebar-footer {
    margin-top: 2rem;
    flex-shrink: 0;
}
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
}

@media (max-width: 1024px) {
    .main-content { margin-left: 0; }
}

/* Header */
.header-top {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.8);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid var(--glass-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 2rem;
    position: sticky;
    top: 0;
    z-index: 90;
}

.container-proportional {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 2rem;
    flex: 1;
}

/* Proportional alignment for small screens */
@media (max-width: 640px) {
    .container-proportional { padding: 1rem; }
}

/* Topbar in content */
.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2.5rem;
    gap: 1.5rem;
    animation: fadeInUp 0.6s ease-out;
}

.page-title {
    font-size: 2rem;
    font-weight: 800;
    color: #fff;
    text-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

/* Cards */
.card-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1.5rem;
    margin-bottom: 2rem;
}

.stat-card {
    padding: 1.75rem;
    transition: transform 0.3s, box-shadow 0.3s;
    animation: fadeInUp 0.7s ease-out;
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--glass-border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.2);
}

.stat-card h3 { 
    color: var(--text-muted); 
    font-size: 0.85rem; 
    text-transform: uppercase; 
    letter-spacing: 0.1em; 
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.stat-card .value { 
    font-size: 2.5rem; 
    font-weight: 800; 
    color: var(--primary); 
}

/* Table Area */
.table-container {
    padding: 0;
    margin-top: 1rem;
    animation: fadeInUp 0.8s ease-out;
    background: #fff;
    border-radius: var(--radius-lg);
    overflow: hidden;
    box-shadow: 0 4px 24px rgba(99,102,241,0.07), 0 1px 4px rgba(0,0,0,0.06);
    border: 1px solid var(--border-color);
}

table {
    width: 100%;
    border-collapse: collapse;
    border-spacing: 0;
}

thead {
    background: linear-gradient(90deg, #f8f8ff 0%, #f3f4f6 100%);
    border-bottom: 2px solid var(--border-color);
}

th {
    padding: 0.85rem 1.25rem;
    color: var(--text-muted);
    font-weight: 700;
    text-transform: uppercase;
    font-size: 0.7rem;
    letter-spacing: 0.08em;
    text-align: left;
    white-space: nowrap;
}

tbody tr {
    transition: background 0.18s, box-shadow 0.18s;
    background: #fff;
    border-bottom: 1px solid var(--border-color);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody tr td {
    padding: 1rem 1.25rem;
    background: transparent;
    color: var(--text-main);
    font-size: 0.9rem;
    vertical-align: middle;
}

tbody tr td:first-child {
    border-left: none;
    border-radius: 0;
}

tbody tr td:last-child {
    border-right: none;
    border-radius: 0;
}

tbody tr:hover {
    background: #f5f3ff;
    box-shadow: none;
}

/* Buttons */
.btn {
    padding: 0.8rem 1.6rem;
    border-radius: var(--radius-md);
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
    cursor: pointer;
    border: none;
    font-size: 0.95rem;
    min-height: 48px; /* High touch target */
}

@media (max-width: 640px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start !important;
        gap: 1rem;
        padding: 1rem;
    }
    .topbar > div:last-child {
        width: 100%;
        display: flex;
        flex-direction: column;
        gap: 0.5rem;
    }
    .topbar .btn {
        width: 100%;
        justify-content: center;
    }
    .page-title {
        font-size: 1.25rem;
        line-height: 1.2;
    }
    
    /* Form & Filter Adjustments */
    .glass[style*="display: flex"] {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    .glass form {
        width: 100%;
    }
    .form-control {
        width: 100% !important;
    }

    .modal-content {
        padding: 1.5rem;
        margin: 1rem;
    }

    /* Additional Mobile Optimizations */
    .card-grid {
        grid-template-columns: 1fr !important;
    }
    .glass {
        padding: 1.25rem !important;
    }
    .attendance-select-form {
        flex-direction: column !important;
        gap: 1rem !important;
    }
    .btn-pilih {
        width: 100% !important;
    }
    .mobile-brand {
        font-size: 0.85rem; /* Perkecil sedikit agar muat di layar sempit */
    }
    .mobile-brand img {
        height: 30px;
    }
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: #fff;
    box-shadow: 0 4px 14px rgba(99, 102, 241, 0.39);
}

/* Forms */
.form-group { margin-bottom: 1.5rem; }
.form-label { display: block; font-weight: 600; margin-bottom: 0.6rem; color: var(--text-main); font-size: 0.95rem; }
.form-control {
    width: 100%;
    padding: 0.9rem 1.1rem;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-md);
    transition: all 0.3s;
    outline: none;
    font-size: 1rem; /* Prevent zoom on mobile */
    min-height: 50px;
}

/* Mobile Optimizations */
.header-top {
    display: none;
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 150;
    padding: 0 1.5rem; /* Menambah padding agar logo tidak terpotong */
    align-items: center;
    justify-content: space-between;
}

body.dark-mode .header-top {
    background: rgba(30, 41, 59, 0.8);
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.mobile-brand {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-weight: 700;
    font-size: 1rem;
    color: var(--primary);
    flex: 1;
    justify-content: center;
    min-width: 0; /* Mencegah overflow flex item */
}

.mobile-brand img {
    height: 40px; /* Diperbesar sedikit */
    width: auto;
    max-width: 100px;
    object-fit: contain;
    flex-shrink: 0;
}

.brand-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px;
    flex-shrink: 1;
}

.user-profile-mobile {
    display: flex;
    align-items: center;
}

.user-profile-mobile .avatar {
    width: 32px;
    height: 32px;
    background: var(--primary);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.mobile-brand img {
    height: 32px;
    width: auto;
    max-width: 120px;
    object-fit: contain;
}

.menu-toggle {
    width: 44px;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    color: var(--primary);
    font-size: 1.75rem;
    cursor: pointer;
}

.sidebar-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(4px);
    z-index: 190; /* Ditingkatkan agar di bawah sidebar tapi di atas header */
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    display: block;
    opacity: 1;
}

@media (max-width: 1024px) {
    .header-top { display: flex; }
    .main-content { padding-top: var(--header-height); }
    .container-proportional { padding: 1.5rem 1rem; }
}

@media (max-width: 1024px) {
    .sidebar { transform: translateX(-100%); }
    .sidebar.open { transform: translateX(0); box-shadow: 20px 0 50px rgba(0,0,0,0.5); }
}

@media (max-width: 1024px) {
    .card-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }

    .stat-card {
        padding: 1.25rem;
    }

    .stat-card .value {
        font-size: 2rem;
    }

    /* Better Table for Mobile (Card View) */
    .table-container {
        padding: 0;
        background: transparent;
        box-shadow: none;
    }

    table, thead, tbody, th, td, tr {
        display: block;
    }

    thead tr {
        position: absolute;
        top: -9999px;
        left: -9999px;
    }

    tr {
        background: var(--glass-bg);
        backdrop-filter: blur(10px);
        margin-bottom: 1rem;
        border-radius: var(--radius-lg);
        border: 1px solid var(--glass-border);
        padding: 1rem;
        box-shadow: var(--shadow);
    }

    tbody tr td {
        border: none;
        padding: 0.5rem 0;
        padding-left: 40%;
        position: relative;
        white-space: normal;
        text-align: right;
        font-size: 0.9rem;
    }

    tbody tr td:before {
        content: attr(data-label);
        position: absolute;
        left: 0;
        width: 35%;
        padding-right: 10px;
        white-space: nowrap;
        text-align: left;
        font-weight: 700;
        color: var(--text-muted);
        font-size: 0.8rem;
        text-transform: uppercase;
    }

    tbody tr td:last-child {
        border-top: 1px solid var(--border-color);
        margin-top: 0.5rem;
        padding-top: 1rem;
        text-align: center;
        padding-left: 0;
    }

    tbody tr td:last-child:before {
        display: none;
    }

    /* Exceptions for tables that should stay horizontal */
    .table-horizontal, .table-horizontal tr, .table-horizontal td {
        display: table-cell;
    }
    .table-horizontal { display: table; }
    .table-horizontal thead tr { position: static; }
}

/* Badge Tweaks */
.badge {
    padding: 0.4rem 0.8rem;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.7rem;
    letter-spacing: 0.02em;
}

/* Modal */
.modal {
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: none;
    position: fixed;
    inset: 0;
    z-index: 200;
    align-items: flex-start; /* Menggunakan flex-start agar scroll berfungsi baik di mobile */
    justify-content: center;
    padding: 2rem 1rem;
    overflow-y: auto; /* Memungkinkan modal itu sendiri untuk scroll */
    -webkit-overflow-scrolling: touch;
}

body.modal-open {
    overflow: hidden;
}

.modal.active { display: flex; }

.modal-content {
    background: #fff;
    width: 100%;
    max-width: 550px;
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    position: relative;
    margin: auto; /* Membantu centering saat align-items: flex-start */
    animation: fadeInUp 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.attendance-select-form {
    display: flex;
    gap: 1.5rem;
    align-items: flex-end;
}

.btn-pilih {
    padding: 0 2rem;
    white-space: nowrap;
}

@media (max-width: 768px) {
    .attendance-select-form {
        flex-direction: column;
        align-items: stretch;
        gap: 1rem;
    }
    
    .btn-pilih {
        width: 100%;
        margin-top: 0.5rem;
    }
}
.login-body {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-card {
    width: 100%;
    max-width: 450px;
    padding: 3rem;
    text-align: center;
}

.login-card .brand {
    font-size: 2.2rem; /* Ukuran sedikit lebih proporsional */
    margin-bottom: 1rem;
    justify-content: center;
    display: flex;
    align-items: center;
    gap: 1.2rem;
    font-weight: 800;
    line-height: 1.1; /* Merapatkan jarak antar baris jika teks wrap */
    color: var(--text-main);
}

.login-card .brand span {
    text-align: left;
    letter-spacing: -0.02em;
    background: linear-gradient(135deg, var(--text-main) 0%, var(--primary) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.login-card .brand img {
    height: 70px; /* Ukuran logo lebih pas */
    width: auto;
    max-width: 200px;
    object-fit: contain;
    filter: drop-shadow(0 4px 6px rgba(0,0,0,0.1));
}

/* Custom Scrollbar */
::-webkit-scrollbar { width: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.1); border-radius: 10px; }
::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.2); }

/* ============================================
   JURNAL TABLE ENHANCEMENTS
   ============================================ */

/* Tabel header baris berganti-ganti (zebra) */
tbody tr:nth-child(even) {
    background: #fafafa;
}
tbody tr:nth-child(even):hover {
    background: #f5f3ff;
}

/* Kolom tanggal - lebih rapi */
tbody tr td:first-child {
    font-weight: 600;
    color: var(--text-main);
    min-width: 120px;
}
tbody tr td:first-child small {
    font-weight: 400;
    font-size: 0.78rem;
    color: var(--text-muted);
    display: block;
    margin-top: 2px;
}

/* Kolom Kelas - badge lebih konsisten */
.badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 0.3rem 0.75rem;
    border-radius: 20px;
    font-weight: 700;
    font-size: 0.72rem;
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.badge-warning  { background: #fef3c7; color: #92400e; }
.badge-success  { background: #d1fae5; color: #065f46; }
.badge-danger   { background: #fee2e2; color: #991b1b; }
.badge-primary  { background: #ede9fe; color: #4c1d95; }

/* Tombol aksi di tabel - lebih compact dan rapi */
tbody .btn {
    padding: 0.4rem 0.9rem !important;
    font-size: 0.8rem !important;
    min-height: unset !important;
    border-radius: 8px !important;
    font-weight: 600;
    letter-spacing: 0.01em;
}

/* Kolom Aksi - spasi tombol */
tbody tr td:last-child {
    white-space: nowrap;
}
tbody tr td:last-child > div {
    gap: 0.4rem !important;
    align-items: center;
}

/* Topbar judul halaman - padding dalam container */
.table-container .topbar,
.container-proportional > .topbar {
    padding: 1.5rem 0 0 0;
}

/* Heading kolom - border bawah halus */
thead th:not(:last-child) {
    border-right: 1px solid #f0f0f4;
}

/* Dark mode table support */
body.dark-mode .table-container {
    background: rgba(30, 41, 59, 0.85);
    border-color: rgba(255,255,255,0.08);
}
body.dark-mode thead {
    background: rgba(15, 23, 42, 0.6);
    border-bottom-color: rgba(255,255,255,0.08);
}
body.dark-mode tbody tr {
    background: transparent;
    border-bottom-color: rgba(255,255,255,0.06);
}
body.dark-mode tbody tr:nth-child(even) {
    background: rgba(255,255,255,0.02);
}
body.dark-mode tbody tr td {
    color: var(--text-main);
}
body.dark-mode tbody tr:hover {
    background: rgba(99,102,241,0.10);
}
body.dark-mode thead th {
    border-right-color: rgba(255,255,255,0.06);
}