/* ============================================================
   MERONA PICTURES - style.css (Collapsible Sidebar + Accordion)
   ============================================================ */

:root {
    --primary: #7C3AED;
    --primary-dark: #6D28D9;
    --primary-light: #EDE9FE;
    --secondary: #EC4899;
    --accent: #F59E0B;
    --success: #10B981;
    --danger: #EF4444;
    --warning: #F59E0B;
    --info: #3B82F6;
    --dark: #1E1B4B;
    --gray-100: #F3F4F6;
    --gray-200: #E5E7EB;
    --gray-300: #D1D5DB;
    --gray-400: #9CA3AF;
    --gray-500: #6B7280;
    --gray-700: #374151;
    --gray-900: #111827;
    --sidebar-width: 260px;
    --sidebar-collapsed: 0px;
    --topbar-height: 60px;
    --radius: 12px;
    --shadow: 0 2px 8px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.12);
    --bottom-nav-height: 64px;
    --transition: 0.3s cubic-bezier(0.4,0,0.2,1);
}

*, *::before, *::after { margin:0; padding:0; box-sizing:border-box; }
html { -webkit-text-size-adjust:100%; }
body {
    font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',system-ui,sans-serif;
    font-size:15px; color:var(--gray-700);
    background:var(--gray-100); line-height:1.6;
    -webkit-font-smoothing:antialiased;
}
a { text-decoration:none; color:inherit; }
img { max-width:100%; height:auto; }

/* ============ LAYOUT ============ */
.wrapper { display:flex; min-height:100vh; }

/* ============ SIDEBAR ============ */
.sidebar {
    width:var(--sidebar-width);
    background:var(--dark); color:#fff;
    position:fixed; top:0; left:0;
    height:100vh;
    display:flex; flex-direction:column;
    overflow:hidden;
    z-index:200;
    transition:width var(--transition), transform var(--transition);
    will-change:width,transform;
}

/* Sidebar collapsed state (desktop) */
.sidebar.collapsed {
    width:0;
}

/* Sidebar header */
.sidebar-header {
    padding:1.25rem 1rem;
    border-bottom:1px solid rgba(255,255,255,0.08);
    flex-shrink:0;
    min-width:var(--sidebar-width);
}
.brand { display:flex; align-items:center; gap:10px; }
.brand-icon {
    width:40px; height:40px; background:var(--primary);
    border-radius:10px; display:flex; align-items:center; justify-content:center;
    font-size:17px; flex-shrink:0;
}
.brand-name { font-size:15px; font-weight:700; color:#fff; white-space:nowrap; }
.brand-sub  { font-size:11px; color:rgba(255,255,255,0.4); white-space:nowrap; }

/* User info */
.user-info {
    display:flex; align-items:center; gap:10px;
    padding:0.875rem 1rem;
    background:rgba(255,255,255,0.05);
    margin:0.75rem;
    border-radius:10px;
    flex-shrink:0;
    min-width:calc(var(--sidebar-width) - 1.5rem);
}
.user-avatar {
    width:38px; height:38px; background:var(--primary); border-radius:50%;
    display:flex; align-items:center; justify-content:center;
    font-weight:700; font-size:16px; flex-shrink:0;
}
.user-name { font-size:13px; font-weight:600; color:#fff; white-space:nowrap; }
.user-role { font-size:11px; color:rgba(255,255,255,0.5); text-transform:capitalize; }

/* Nav menu */
.nav-menu { list-style:none; padding:0.5rem 0; flex:1; overflow-y:auto; overflow-x:hidden; -webkit-overflow-scrolling:touch; min-width:var(--sidebar-width); }

/* ---- ACCORDION KATEGORI ---- */
.nav-section-btn {
    display:flex; align-items:center; justify-content:space-between;
    padding:0.65rem 1rem 0.3rem;
    cursor:pointer;
    user-select:none;
    border:none !important;
    outline:none !important;
    background:transparent !important;
    box-shadow:none !important;
    -webkit-appearance:none;
    appearance:none;
    width:100%; text-align:left;
    white-space:nowrap;
    color:inherit;
    font-family:inherit;
    font-size:inherit;
    line-height:inherit;
    margin:0; padding-left:1rem;
}
.nav-section-btn .section-label {
    font-size:10px; text-transform:uppercase; letter-spacing:0.08em;
    color:rgba(255,255,255,0.45); font-weight:700;
}
.nav-section-btn .section-arrow {
    font-size:10px; color:rgba(255,255,255,0.3);
    transition:transform 0.25s ease;
    flex-shrink:0;
}
.nav-section-btn.open .section-arrow { transform:rotate(180deg); }
.nav-section-btn:hover .section-label { color:rgba(255,255,255,0.8); }
.nav-section-btn:hover { background:rgba(255,255,255,0.04) !important; border-radius:8px; }

/* Accordion content */
.nav-group-items {
    overflow:hidden;
    max-height:0;
    transition:max-height 0.35s ease;
}
.nav-group-items.open { max-height:500px; }

/* Nav item & link */
.nav-item { display:block; }
.nav-link {
    display:flex; align-items:center; gap:10px;
    padding:0.7rem 1rem;
    color:rgba(255,255,255,0.65);
    border-radius:8px;
    margin:2px 0.5rem;
    font-size:13.5px;
    min-height:44px;
    cursor:pointer;
    white-space:nowrap;
}
.nav-link i { width:18px; text-align:center; font-size:15px; flex-shrink:0; }
.nav-link:hover  { background:rgba(124,58,237,0.35); color:#fff; }
.nav-link.active { background:var(--primary); color:#fff; }

/* Sidebar footer */
.sidebar-footer {
    padding:1rem;
    border-top:1px solid rgba(255,255,255,0.08);
    flex-shrink:0;
    min-width:var(--sidebar-width);
}
.logout-btn {
    display:flex; align-items:center; gap:8px;
    color:rgba(255,255,255,0.5); font-size:13px;
    padding:0.7rem 0.75rem;
    border-radius:8px; min-height:44px; cursor:pointer;
    white-space:nowrap;
}
.logout-btn:hover { background:rgba(239,68,68,0.15); color:#FCA5A5; }

/* ============ SIDEBAR OVERLAY ============ */
.sidebar-overlay {
    display:none; position:fixed; inset:0;
    background:rgba(0,0,0,0.5); z-index:199;
    pointer-events:none;
}
.sidebar-overlay.show { display:block; pointer-events:auto; }

/* ============ MAIN CONTENT ============ */
.main-content {
    margin-left:var(--sidebar-width);
    flex:1; display:flex; flex-direction:column;
    min-height:100vh; min-width:0;
    transition:margin-left var(--transition);
}
.main-content.expanded { margin-left:0; }

/* ============ TOPBAR ============ */
.topbar {
    height:var(--topbar-height); background:#fff;
    border-bottom:1px solid var(--gray-200);
    display:flex; align-items:center; justify-content:space-between;
    padding:0 1.25rem;
    position:sticky; top:0; z-index:100;
    box-shadow:var(--shadow);
}
.toggle-sidebar {
    background:none; border:none; color:var(--gray-500); font-size:20px;
    cursor:pointer; padding:10px; border-radius:8px;
    min-width:44px; min-height:44px;
    display:flex; align-items:center; justify-content:center;
}
.toggle-sidebar:hover { background:var(--gray-100); }

.topbar-right { display:flex; align-items:center; gap:0.75rem; }
.notif-btn {
    position:relative; color:var(--gray-500); font-size:19px;
    padding:10px; border-radius:8px;
    min-width:44px; min-height:44px;
    display:flex; align-items:center; justify-content:center; cursor:pointer;
}
.notif-btn:hover { background:var(--gray-100); }
.notif-badge {
    position:absolute; top:6px; right:6px;
    background:var(--danger); color:#fff;
    font-size:10px; font-weight:700;
    width:16px; height:16px; border-radius:50%;
    display:flex; align-items:center; justify-content:center;
    border:2px solid #fff;
}
.topbar-user { font-size:13px; font-weight:600; color:var(--gray-700); }

/* ============ CONTENT AREA ============ */
.content-area {
    padding:1.25rem; flex:1;
    padding-bottom:calc(1.25rem + env(safe-area-inset-bottom,0px));
}
.page-header {
    display:flex; align-items:flex-start; justify-content:space-between;
    gap:1rem; margin-bottom:1.25rem; flex-wrap:wrap;
}
.page-title    { font-size:18px; font-weight:700; color:var(--gray-900); }
.page-subtitle { font-size:13px; color:var(--gray-400); margin-top:2px; }

/* ============ CARDS ============ */
.card { background:#fff; border-radius:var(--radius); box-shadow:var(--shadow); margin-bottom:1rem; overflow:hidden; }
.card-header {
    padding:0.875rem 1.25rem; border-bottom:1px solid var(--gray-200);
    display:flex; align-items:center; justify-content:space-between;
    gap:0.5rem; flex-wrap:wrap;
}
.card-title { font-size:14px; font-weight:600; color:var(--gray-900); }
.card-body  { padding:1.25rem; }
.card-footer { padding:0.75rem 1.25rem; border-top:1px solid var(--gray-200); background:var(--gray-100); }

/* ============ STAT CARDS ============ */
.stats-grid { display:grid; grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); gap:1rem; margin-bottom:1rem; }
.stat-card {
    background:#fff; border-radius:var(--radius); padding:1rem;
    box-shadow:var(--shadow); display:flex; align-items:center; gap:0.75rem;
    border-left:4px solid transparent;
}
.stat-card.purple { border-color:var(--primary); }
.stat-card.pink   { border-color:var(--secondary); }
.stat-card.green  { border-color:var(--success); }
.stat-card.amber  { border-color:var(--accent); }
.stat-card.blue   { border-color:var(--info); }
.stat-card.red    { border-color:var(--danger); }
.stat-icon { width:44px; height:44px; border-radius:10px; display:flex; align-items:center; justify-content:center; font-size:18px; flex-shrink:0; }
.stat-card.purple .stat-icon { background:var(--primary-light); color:var(--primary); }
.stat-card.pink .stat-icon   { background:#FCE7F3; color:var(--secondary); }
.stat-card.green .stat-icon  { background:#D1FAE5; color:var(--success); }
.stat-card.amber .stat-icon  { background:#FEF3C7; color:var(--accent); }
.stat-card.blue .stat-icon   { background:#DBEAFE; color:var(--info); }
.stat-card.red .stat-icon    { background:#FEE2E2; color:var(--danger); }
.stat-label { font-size:11px; color:var(--gray-400); }
.stat-value { font-size:20px; font-weight:700; color:var(--gray-900); line-height:1.2; }
.stat-sub   { font-size:11px; color:var(--gray-400); margin-top:2px; }

/* ============ TABLE ============ */
.table-container { overflow-x:auto; -webkit-overflow-scrolling:touch; }
table { width:100%; border-collapse:collapse; min-width:480px; }
thead th {
    background:var(--gray-100); font-weight:600; font-size:11px;
    text-transform:uppercase; letter-spacing:0.05em; color:var(--gray-500);
    padding:0.75rem 1rem; text-align:left;
    border-bottom:1px solid var(--gray-200); white-space:nowrap;
}
tbody td { padding:0.75rem 1rem; border-bottom:1px solid var(--gray-100); font-size:13px; color:var(--gray-700); }
tbody tr:last-child td { border-bottom:none; }
tbody tr:hover { background:#FAFAFA; }

/* ============ BADGES ============ */
.badge { display:inline-flex; align-items:center; padding:3px 10px; border-radius:20px; font-size:11px; font-weight:600; white-space:nowrap; }
.badge-success   { background:#D1FAE5; color:#065F46; }
.badge-danger    { background:#FEE2E2; color:#991B1B; }
.badge-warning   { background:#FEF3C7; color:#92400E; }
.badge-info      { background:#DBEAFE; color:#1E40AF; }
.badge-primary   { background:var(--primary-light); color:var(--primary-dark); }
.badge-secondary { background:var(--gray-200); color:var(--gray-500); }
.badge-pink      { background:#FCE7F3; color:#9D174D; }

/* ============ BUTTONS ============ */
.btn {
    display:inline-flex; align-items:center; justify-content:center; gap:6px;
    padding:0.6rem 1.1rem; border-radius:9px; border:none; cursor:pointer;
    font-size:13px; font-weight:600; text-decoration:none;
    min-height:44px; white-space:nowrap;
    -webkit-appearance:none; appearance:none;
    touch-action:manipulation;
}
.btn:active { opacity:0.85; }
.btn-primary   { background:var(--primary); color:#fff; }
.btn-primary:hover { background:var(--primary-dark); }
.btn-secondary { background:var(--gray-200); color:var(--gray-700); }
.btn-secondary:hover { background:var(--gray-300); }
.btn-success   { background:var(--success); color:#fff; }
.btn-danger    { background:var(--danger); color:#fff; }
.btn-warning   { background:var(--warning); color:#fff; }
.btn-info      { background:var(--info); color:#fff; }
.btn-outline   { background:transparent; border:1.5px solid var(--primary); color:var(--primary); }
.btn-outline:hover { background:var(--primary-light); }
.btn-sm        { padding:0.35rem 0.75rem; font-size:12px; min-height:38px; }

/* ============ FORMS ============ */
.form-group { margin-bottom:1rem; }
.form-label { display:block; font-size:13px; font-weight:600; color:var(--gray-700); margin-bottom:6px; }
.form-control {
    width:100%; padding:0.65rem 0.875rem;
    border:1.5px solid var(--gray-300); border-radius:9px;
    font-size:16px; color:var(--gray-700); background:#fff;
    font-family:inherit; min-height:48px;
    touch-action:manipulation;
    -webkit-appearance:none; appearance:none;
}
.form-control:focus { outline:none; border-color:var(--primary); box-shadow:0 0 0 3px rgba(124,58,237,0.12); }
select.form-control {
    cursor:pointer;
    background-image:url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%236B7280' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat:no-repeat; background-position:right 12px center; padding-right:32px;
}
textarea.form-control { min-height:100px; resize:vertical; font-size:15px; }
.form-text { font-size:12px; color:var(--gray-400); margin-top:4px; }
.form-row  { display:grid; grid-template-columns:repeat(auto-fit,minmax(180px,1fr)); gap:0.875rem; }

/* ============ ALERTS ============ */
.alert { padding:0.875rem 1rem; border-radius:10px; margin-bottom:1rem; font-size:13.5px; display:flex; align-items:center; gap:8px; }
.alert-success { background:#D1FAE5; color:#065F46; border:1px solid #A7F3D0; }
.alert-danger  { background:#FEE2E2; color:#991B1B; border:1px solid #FCA5A5; }
.alert-warning { background:#FEF3C7; color:#92400E; border:1px solid #FDE68A; }
.alert-info    { background:#DBEAFE; color:#1E40AF; border:1px solid #BFDBFE; }

/* ============ PROGRESS ============ */
.progress { background:var(--gray-200); border-radius:10px; height:8px; overflow:hidden; }
.progress-bar { height:100%; border-radius:10px; background:var(--primary); }
.progress-bar.success { background:var(--success); }

/* ============ MODAL ============ */
.modal-overlay {
    display:none; position:fixed; inset:0;
    background:rgba(0,0,0,0.5); z-index:1000;
    align-items:flex-end; justify-content:center;
    pointer-events:none;
}
.modal-overlay.show { display:flex; pointer-events:auto; }
.modal {
    background:#fff; border-radius:20px 20px 0 0;
    width:100%; max-height:92vh;
    overflow-y:auto; -webkit-overflow-scrolling:touch;
    box-shadow:var(--shadow-md); animation:slideUp 0.3s ease;
    padding-bottom:env(safe-area-inset-bottom,0px);
}
@keyframes slideUp { from { transform:translateY(100%); } to { transform:translateY(0); } }
.modal-header {
    padding:1.25rem 1.25rem 1rem; border-bottom:1px solid var(--gray-200);
    display:flex; align-items:center; justify-content:space-between;
    position:sticky; top:0; background:#fff; z-index:10;
}
.modal-header::before {
    content:''; position:absolute; top:8px; left:50%;
    transform:translateX(-50%); width:40px; height:4px;
    background:var(--gray-300); border-radius:2px;
}
.modal-title { font-size:16px; font-weight:700; margin-top:8px; }
.modal-body  { padding:1.25rem; }
.modal-footer {
    padding:0.875rem 1.25rem; border-top:1px solid var(--gray-200);
    display:flex; gap:8px; justify-content:flex-end;
    position:sticky; bottom:0; background:#fff;
}
.modal-footer .btn { flex:1; }
.btn-close {
    background:none; border:none; font-size:20px; cursor:pointer;
    color:var(--gray-400); min-width:44px; min-height:44px;
    display:flex; align-items:center; justify-content:center;
    border-radius:8px; margin-top:6px;
    touch-action:manipulation;
}

/* ============ BOTTOM NAV ============ */
.bottom-nav {
    display:none;
    position:fixed; bottom:0; left:0; right:0;
    background:#fff; border-top:1px solid var(--gray-200);
    padding:6px 0;
    padding-bottom:calc(6px + env(safe-area-inset-bottom,0px));
    z-index:300; box-shadow:0 -2px 12px rgba(0,0,0,0.08);
}
.bottom-nav-inner { display:flex; justify-content:space-around; align-items:center; }
.bottom-nav-item {
    display:flex; flex-direction:column; align-items:center; gap:3px;
    color:var(--gray-400); font-size:10px; font-weight:500;
    padding:6px 10px; border-radius:10px;
    min-width:52px; min-height:48px; justify-content:center;
    cursor:pointer; text-decoration:none;
    touch-action:manipulation;
}
.bottom-nav-item i { font-size:21px; display:block; }
.bottom-nav-item.active { color:var(--primary); }
.bottom-nav-item:active { background:var(--primary-light); }

/* ============ LOGIN ============ */
.login-page {
    min-height:100vh;
    background:linear-gradient(135deg,var(--dark) 0%,#312E81 60%,var(--primary) 100%);
    display:flex; align-items:center; justify-content:center;
    padding:1.5rem;
    padding-top:calc(1.5rem + env(safe-area-inset-top,0px));
    padding-bottom:calc(1.5rem + env(safe-area-inset-bottom,0px));
}
.login-card { background:#fff; border-radius:20px; padding:2rem; width:100%; max-width:420px; box-shadow:0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align:center; margin-bottom:2rem; }
.login-logo-icon { width:68px; height:68px; background:var(--primary); border-radius:16px; display:flex; align-items:center; justify-content:center; font-size:30px; color:#fff; margin:0 auto 1rem; }
.login-title { font-size:22px; font-weight:800; color:var(--gray-900); }
.login-sub   { font-size:13px; color:var(--gray-400); margin-top:4px; }

/* ============ EMPTY STATE ============ */
.empty-state { text-align:center; padding:3rem 1.5rem; color:var(--gray-400); }
.empty-state i { font-size:44px; margin-bottom:1rem; opacity:0.4; display:block; }
.empty-state p { font-size:14px; }

/* ============ DESKTOP — Collapsible Sidebar ============ */
@media (min-width:769px) {
    .sidebar { transform:translateX(0) !important; }
    .sidebar-overlay { display:none !important; }
    .bottom-nav { display:none !important; }
    .topbar-user { display:block; }
    .stats-grid { grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); }
    .form-row { grid-template-columns:repeat(auto-fit,minmax(200px,1fr)); }

    /* Modal centered di desktop */
    .modal-overlay { align-items:center; padding:1.5rem; }
    .modal { border-radius:16px; width:90%; max-width:640px; max-height:90vh; animation:modalIn 0.25s ease; }
    @keyframes modalIn { from { transform:scale(0.95); opacity:0; } to { transform:scale(1); opacity:1; } }
    .modal-header::before { display:none; }
    .modal-title { margin-top:0; }
    .modal-footer .btn { flex:none; }
}

/* ============ MOBILE ============ */
@media (max-width:768px) {
    .sidebar {
        transform:translateX(-100%);
        width:var(--sidebar-width) !important;
        z-index:400; /* Lebih tinggi dari bottom nav */
        height:100vh;
        height:-webkit-fill-available;
    }
    .sidebar.open { transform:translateX(0); box-shadow:4px 0 24px rgba(0,0,0,0.25); }
    .sidebar-overlay { z-index:399; } /* Di bawah sidebar tapi di atas konten */
    .main-content { margin-left:0 !important; }
    .content-area {
        padding:1rem;
        padding-bottom:calc(var(--bottom-nav-height) + 1rem + env(safe-area-inset-bottom,0px));
    }
    .bottom-nav {
        display:block;
        z-index:300; /* Di bawah sidebar overlay */
    }
    .stats-grid { grid-template-columns:repeat(2,1fr); gap:0.625rem; }
    .stat-card { padding:0.875rem 0.75rem; gap:0.625rem; }
    .stat-icon { width:38px; height:38px; font-size:15px; }
    .stat-value { font-size:18px; }
    .stat-label { font-size:10px; }
    .form-row { grid-template-columns:1fr; gap:0; }
    .page-title { font-size:16px; }
    div[style*="grid-template-columns: 1fr 1fr"] { display:block !important; }
    div[style*="grid-template-columns: 1fr 1fr"] > .card { margin-bottom:1rem; }
    .modal { max-height:90vh; }
    .modal-footer .btn { flex:1; }
    tbody td { font-size:12px; padding:0.6rem 0.75rem; }
    thead th { font-size:10px; padding:0.6rem 0.75rem; }
    .card-body { padding:1rem; }
    .topbar-user { display:block; font-size:12px; max-width:110px; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
}

@media (max-width:480px) {
    .stats-grid { gap:0.5rem; }
    .stat-card { flex-direction:column; align-items:flex-start; padding:0.75rem; gap:0.5rem; }
    .stat-icon { width:34px; height:34px; font-size:14px; border-radius:8px; }
    .stat-value { font-size:17px; }
    .topbar { padding:0 0.75rem; }
    .login-card { padding:1.5rem 1.25rem; }
    .content-area { padding:0.75rem; padding-bottom:calc(var(--bottom-nav-height) + 0.75rem + env(safe-area-inset-bottom,0px)); }
}
