/* =========================
   GOOGLE FONTS
========================= */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', Arial, sans-serif;
}

body {
    background: #f4f4f9;
    color: #22223b;
    min-height: 100vh;
    overflow-x: hidden;
}


/* =========================
   LAYOUT
========================= */

.admin-layout {
    display: flex;
    min-height: 100vh;
    overflow-x: hidden;
    width: 100%;
}


/* =========================
   SIDEBAR
========================= */

.sidebar {
    width: 240px;
    background: #17152b;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 30px 0 20px;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 25px 30px;
    color: white;
    font-size: 18px;
    font-weight: 800;
    letter-spacing: 1.5px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
    margin-bottom: 20px;
}

.brand-dot {
    width: 10px;
    height: 10px;
    background: linear-gradient(135deg, #a78bfa, #60a5fa);
    border-radius: 50%;
    flex-shrink: 0;
}

.sidebar-nav {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 12px;
    flex: 1;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 11px 15px;
    border-radius: 10px;
    color: rgba(255,255,255,0.65);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.2s;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.08);
    color: white;
}

.sidebar-link.active {
    background: linear-gradient(135deg, rgba(124,58,237,0.55), rgba(37,99,235,0.55));
    color: white;
    font-weight: 600;
}

.sidebar-logout {
    margin-top: auto;
    color: rgba(252, 165, 165, 0.8);
}

.sidebar-logout:hover {
    background: rgba(239, 68, 68, 0.15);
    color: #fca5a5;
}

.icon {
    font-size: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.icon-svg {
    width: 18px;
    height: 18px;
    stroke: currentColor;
    stroke-width: 2;
    fill: none;
    transition: transform 0.2s ease;
}

.sidebar-link:hover .icon-svg {
    transform: scale(1.15);
}


/* =========================
   MAIN CONTENT
========================= */

.admin-main {
    margin-left: 240px;
    flex: 1;
    padding: 35px 40px;
    min-height: 100vh;
}

.admin-topbar {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 30px;
}

.admin-title {
    font-size: 26px;
    font-weight: 800;
    color: #17152b;
}

.admin-sub {
    font-size: 14px;
    color: #888;
    margin-top: 4px;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 12px;
}

.badge-time {
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 20px;
    padding: 7px 16px;
    font-size: 13px;
    color: #555;
    font-weight: 500;
}


/* =========================
   STAT CARDS
========================= */

.stat-cards {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}

.stat-card {
    background: white;
    border-radius: 16px;
    padding: 22px 25px;
    display: flex;
    align-items: center;
    gap: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f8;
    transition: all 0.25s;
}

.stat-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 25px rgba(124,58,237,0.12);
}

.stat-card.stat-today { border-color: #e0e7ff; }

.stat-icon {
    font-size: 28px;
    width: 52px;
    height: 52px;
    background: #f5f3ff;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-label {
    font-size: 13px;
    color: #888;
    font-weight: 500;
    margin-bottom: 4px;
}

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: #17152b;
    line-height: 1;
}


/* =========================
   ADMIN CARD (TABLE CONTAINER)
========================= */

.admin-card {
    background: white;
    border-radius: 18px;
    box-shadow: 0 2px 12px rgba(0,0,0,0.05);
    border: 1px solid #f0f0f8;
    overflow: hidden;
}

.admin-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 28px;
    border-bottom: 1px solid #f0f0f8;
}

.admin-card-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: #17152b;
}

.badge-total {
    background: #f5f3ff;
    color: #7c3aed;
    font-size: 13px;
    font-weight: 600;
    padding: 5px 14px;
    border-radius: 20px;
}


/* =========================
   ADMIN TABLE
========================= */

.table-wrapper {
    overflow-x: auto;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
}

.admin-table th {
    background: #faf9ff;
    padding: 13px 20px;
    text-align: left;
    font-size: 12px;
    font-weight: 700;
    color: #7c3aed;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid #f0f0f8;
    white-space: nowrap;
}

.admin-table td {
    padding: 14px 20px;
    border-bottom: 1px solid #f8f8ff;
    color: #333;
    vertical-align: top;
}

.admin-table tbody tr:last-child td {
    border-bottom: none;
}

.admin-table tbody tr:hover {
    background: #faf9ff;
}

.admin-table th:first-child,
.admin-table td:first-child {
    width: 50px;
    text-align: center;
    color: #aaa;
}

.td-nama {
    font-weight: 600;
    color: #22223b !important;
    white-space: nowrap;
    width: 150px;
}

.td-pesan {
    max-width: 400px;
    line-height: 1.6;
    color: #555 !important;
}

.btn-hapus {
    display: inline-block;
    padding: 6px 16px;
    background: #fee2e2;
    color: #dc2626;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-hapus:hover {
    background: #dc2626;
    color: white;
}


/* EMPTY STATE */

.admin-empty {
    padding: 50px 20px;
    text-align: center;
    color: #aaa;
    font-size: 15px;
}


/* =========================
   ALERT ADMIN
========================= */

.admin-alert {
    padding: 14px 20px;
    border-radius: 10px;
    margin-bottom: 22px;
    font-size: 14px;
    font-weight: 500;
}

.admin-alert-sukses {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #6ee7b7;
}


/* =========================
   LOGIN BOX
========================= */

.login-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #17152b 0%, #30205c 100%);
    padding: 20px;
}

.login-box {
    width: 420px;
    max-width: 100%;
    padding: 45px 40px;
    background: white;
    border-radius: 20px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
}

.login-box h1 {
    text-align: center;
    color: #17152b;
    font-size: 26px;
    font-weight: 800;
    letter-spacing: 1px;
    margin-bottom: 8px;
}

.login-box > p {
    text-align: center;
    color: #888;
    margin-bottom: 30px;
    font-size: 14px;
}

.login-box label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    font-size: 14px;
    color: #22223b;
}

.login-box input {
    width: 100%;
    padding: 13px 16px;
    margin-bottom: 20px;
    border: 1.5px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fafafa;
}

.login-box input:focus {
    outline: none;
    border-color: #7c3aed;
    background: white;
    box-shadow: 0 0 0 3px rgba(124,58,237,0.1);
}

.login-box button {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: white;
    font-size: 15px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    letter-spacing: 0.3px;
}

.login-box button:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(124,58,237,0.35);
}

.error {
    background: #fee2e2;
    color: #dc2626;
    border: 1px solid #fca5a5;
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 22px;
    text-align: center;
    font-size: 14px;
    font-weight: 500;
}


/* =========================
   FORM EDITOR & CMS GRID
========================= */

.admin-grid {
    display: grid;
    grid-template-columns: 1.6fr 1fr;
    gap: 30px;
    align-items: start;
}

.grid-left {
    min-width: 0;
}

.grid-right {
    position: sticky;
    top: 35px;
}

.admin-form {
    padding: 28px;
}

.form-group {
    margin-bottom: 20px;
}

.form-row {
    display: flex;
    gap: 20px;
    margin-bottom: 20px;
}

.form-row .form-group-half {
    flex: 1;
}

.admin-form label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: #4b5563;
    margin-bottom: 8px;
}

.admin-form input[type="text"],
.admin-form input[type="number"],
.admin-form input[type="email"],
.admin-form select,
.admin-form textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    font-size: 14px;
    background: #f9fafb;
    color: #1f2937;
    transition: all 0.2s;
}

.admin-form input:focus,
.admin-form select:focus,
.admin-form textarea:focus {
    outline: none;
    border-color: #7c3aed;
    background: white;
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.admin-form textarea {
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.form-actions {
    margin-top: 25px;
    display: flex;
    justify-content: flex-end;
}

.btn-primary {
    padding: 12px 24px;
    background: linear-gradient(135deg, #7c3aed, #2563eb);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 15px rgba(124, 58, 237, 0.3);
}

.btn-edit {
    display: inline-block;
    padding: 6px 14px;
    background: #fef3c7;
    color: #d97706;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    margin-right: 6px;
    transition: all 0.2s;
}

.btn-edit:hover {
    background: #d97706;
    color: white;
}

.btn-cancel {
    display: inline-block;
    padding: 6px 14px;
    background: #f3f4f6;
    color: #4b5563;
    border-radius: 8px;
    text-decoration: none;
    font-size: 13px;
    font-weight: 600;
    transition: all 0.2s;
}

.btn-cancel:hover {
    background: #e5e7eb;
    color: #1f2937;
}

/* BADGES FOR VISI MISI */

.badge-jenis {
    display: inline-block;
    padding: 4px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
}

.badge-visi {
    background: #dbeafe;
    color: #1e40af;
}

.badge-misi {
    background: #e0f2fe;
    color: #0369a1;
}

/* TABLE WIDTH HELPER FOR CMS */

.td-tahun {
    width: 90px;
    font-weight: 700;
    color: #7c3aed;
}

.td-jenis {
    width: 120px;
}

.td-jabatan {
    width: 200px;
    font-weight: 600;
}

.td-nama-program {
    width: 200px;
    font-weight: 600;
}

.td-aksi {
    width: 160px;
    white-space: nowrap;
}

.td-isi-visi,
.td-desc-sejarah,
.td-desc-program {
    line-height: 1.6;
    color: #4b5563 !important;
}


/* =========================
   RESPONSIVE & MOBILE DRAWER
========================= */

/* Default hidden mobile elements on desktop */
.mobile-header,
.sidebar-close-btn,
.sidebar-overlay {
    display: none;
}

@media (max-width: 1100px) {
    .admin-grid {
        grid-template-columns: 1fr;
        gap: 30px;
    }
    
    .grid-right {
        position: static;
    }
}

@media (max-width: 900px) {
    .sidebar {
        width: 200px;
    }

    .admin-main {
        margin-left: 200px;
        padding: 25px 20px;
    }
}

@media (max-width: 768px) {
    /* Mobile Header Navigation */
    .mobile-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        height: 60px;
        background: #17152b;
        color: white;
        padding: 0 20px;
        position: fixed;
        top: 0;
        left: 0;
        right: 0;
        z-index: 1000;
        box-shadow: 0 2px 10px rgba(0,0,0,0.15);
    }

    .mobile-header-brand {
        display: flex;
        align-items: center;
        gap: 8px;
        font-size: 16px;
        font-weight: 800;
        letter-spacing: 1px;
    }

    /* Hamburger Menu Trigger Button */
    .mobile-toggle-btn {
        display: flex;
        flex-direction: column;
        justify-content: space-between;
        width: 24px;
        height: 18px;
        background: transparent;
        border: none;
        cursor: pointer;
        padding: 0;
        z-index: 1001;
    }

    .mobile-toggle-btn .bar {
        width: 100%;
        height: 2px;
        background-color: white;
        border-radius: 2px;
        transition: all 0.3s ease;
    }

    /* Hamburger Animation States */
    .mobile-toggle-btn.active .bar:nth-child(1) {
        transform: translateY(8px) rotate(45deg);
    }

    .mobile-toggle-btn.active .bar:nth-child(2) {
        opacity: 0;
    }

    .mobile-toggle-btn.active .bar:nth-child(3) {
        transform: translateY(-8px) rotate(-45deg);
    }

    /* Overlay Backdrop on Mobile */
    .sidebar-overlay {
        display: block;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(15, 12, 30, 0.6);
        backdrop-filter: blur(4px);
        z-index: 998;
        opacity: 0;
        pointer-events: none;
        transition: opacity 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    }

    .sidebar-overlay.active {
        opacity: 1;
        pointer-events: auto;
    }

    /* Off-canvas Sidebar Drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        width: 260px;
        height: 100vh;
        min-height: 100vh;
        z-index: 999;
        transform: translateX(-100%);
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
        display: flex;
        flex-direction: column;
        padding: 20px 0;
        box-shadow: 5px 0 25px rgba(0,0,0,0.15);
    }

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

    /* Close Button inside Sidebar Drawer */
    .sidebar-close-btn {
        display: block;
        background: transparent;
        border: none;
        color: rgba(255,255,255,0.6);
        font-size: 26px;
        cursor: pointer;
        padding: 0;
        line-height: 1;
        transition: color 0.2s;
    }

    .sidebar-close-btn:hover {
        color: white;
    }

    /* Brand Section in Mobile Sidebar */
    .sidebar-brand {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 0 20px 20px;
        margin-bottom: 15px;
        border-bottom: 1px solid rgba(255,255,255,0.08);
        width: 100%;
    }

    /* Sidebar Navigation inside Mobile Drawer */
    .sidebar-nav {
        display: flex;
        flex-direction: column;
        gap: 4px;
        padding: 0 12px;
        flex: 1;
        overflow-y: auto;
    }

    .sidebar-link {
        padding: 11px 15px;
        font-size: 14px;
    }

    /* Adjust Main Panel Content to fit Sticky Top Header */
    .admin-main {
        margin-left: 0;
        padding: 85px 16px 24px; /* 85px top margin to leave space for 60px header */
        width: 100%;
        max-width: 100%;
        min-width: 0; /* Prevents flexbox item from stretching to fit table content */
    }

    /* Ensure table wrapper scrolls horizontally when content overflows on mobile */
    .table-wrapper {
        overflow-x: auto;
        width: 100%;
        -webkit-overflow-scrolling: touch; /* Smooth momentum scrolling on iOS */
    }

    .admin-topbar {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
        margin-bottom: 24px;
    }

    .admin-title {
        font-size: 22px;
    }

    /* Stat Cards */
    .stat-cards {
        grid-template-columns: 1fr;
        gap: 14px;
        margin-bottom: 24px;
    }

    /* Stack form fields vertically on mobile */
    .form-row {
        flex-direction: column;
        gap: 15px;
    }

    /* Prevent iOS auto-zoom on input focus by forcing font size to 16px */
    .admin-form input[type="text"],
    .admin-form input[type="number"],
    .admin-form input[type="email"],
    .admin-form select,
    .admin-form textarea,
    .login-box input {
        font-size: 16px !important;
    }

    /* Prevent page scroll when Mobile Sidebar is active */
    body.sidebar-open {
        overflow: hidden;
    }
}

@media (min-width: 480px) and (max-width: 768px) {
    .stat-cards {
        grid-template-columns: 1fr 1fr;
    }
}