/* ==========================================
   E-PERPUSTAKAAN - STYLESHEET
   SD Muhammadiyah Serut
   ========================================== */

:root {
    --accent: #7c3aed;
    --accent-light: #ede9fe;
    --accent-dark: #5b21b6;
    --primary: #1e293b;
    --success: #16a34a;
    --success-bg: #dcfce7;
    --warning: #ca8a04;
    --warning-bg: #fef9c3;
    --danger: #dc2626;
    --danger-bg: #fee2e2;
    --bg-app: #f8fafc;
    --bg-card: #ffffff;
    --text-primary: #0f172a;
    --text-secondary: #64748b;
    --border: #e2e8f0;
    --sidebar-bg: #1e1b4b;
    --sidebar-text: rgba(255,255,255,0.75);
    --sidebar-active: rgba(124,58,237,0.25);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
    --shadow-md: 0 4px 12px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 30px rgba(0,0,0,0.12);
    --th-bg: #f1f5f9;
    --th-color: #475569;
    --sidebar-width: 260px;
    --header-height: 64px;
}

[data-theme="dark"] {
    --bg-app: #0f172a;
    --bg-card: #1e293b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --border: #334155;
    --th-bg: #1e293b;
    --th-color: #94a3b8;
}

* { margin:0; padding:0; box-sizing:border-box; }

body {
    font-family: 'Inter', sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 13px;
}

/* SIDEBAR */
.sidebar {
    position: fixed; top:0; left:0; bottom:0;
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    overflow-y: auto; overflow-x: hidden;
    z-index: 200;
    transition: transform 0.3s ease;
    scrollbar-width: thin;
    scrollbar-color: rgba(255,255,255,0.1) transparent;
}
.sidebar-header {
    display: flex; align-items: center; gap:12px;
    padding: 20px 16px; border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-icon {
    width:40px; height:40px; border-radius:12px;
    background: var(--accent); display:flex; align-items:center; justify-content:center;
    color:white; flex-shrink:0;
}
.brand-text h1 { color:white; font-size:13px; font-weight:700; }
.brand-text p  { color:var(--sidebar-text); font-size:10px; margin-top:2px; }
.sidebar-menu { padding:12px 8px; }
.menu-category {
    font-size:9px; font-weight:700; letter-spacing:1.5px; color:rgba(255,255,255,0.35);
    padding:12px 10px 4px; text-transform:uppercase;
}
.nav-item {
    display:flex; align-items:center; gap:10px;
    padding:10px 12px; border-radius:10px; margin-bottom:2px;
    color:var(--sidebar-text); cursor:pointer;
    transition: background 0.15s, color 0.15s;
    font-size:12px; font-weight:500;
}
.nav-item:hover { background:rgba(255,255,255,0.08); color:white; }
.nav-item.active { background:var(--sidebar-active); color:white; font-weight:600; }
.nav-item .material-icons-round { font-size:18px; flex-shrink:0; }
.back-btn { color:#a78bfa; margin-bottom:10px; border-bottom:1px solid rgba(255,255,255,0.08); border-radius:0; padding-bottom:12px; text-decoration:none; }

/* MAIN WRAPPER */
.main-wrapper {
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex; flex-direction: column;
}

/* HEADER */
header {
    position: sticky; top:0; z-index:100;
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    padding: 0 24px;
    display: flex; align-items:center; justify-content:space-between;
    box-shadow: var(--shadow-sm);
}
.header-title { font-weight:600; color:var(--text-secondary); font-size:13px; }
.header-actions { display:flex; align-items:center; gap:12px; }
.datetime-container { text-align:right; }
.datetime-container div:first-child { font-size:11px; color:var(--text-secondary); }
.live-time { font-size:16px; font-weight:700; color:var(--text-primary); font-variant-numeric:tabular-nums; }
.theme-switch {
    width:36px; height:36px; border-radius:50%; background:var(--accent-light);
    cursor:pointer; display:flex; align-items:center; justify-content:center;
    border: 2px solid var(--accent);
}
.theme-switch::after { content:'🌙'; font-size:16px; }
[data-theme="dark"] .theme-switch::after { content:'☀️'; }

/* CONTENT AREA */
.content-area { flex:1; padding:24px; }
.tab-content { display:none; }
.tab-content.active { display:block; }

/* CARDS */
.card {
    background: var(--bg-card); border-radius:16px;
    border: 1px solid var(--border); box-shadow: var(--shadow-sm);
    overflow: hidden;
}
.card-header {
    display:flex; align-items:center; justify-content:space-between;
    flex-wrap:wrap; gap:10px;
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
}
.card-title {
    font-size:14px; font-weight:700; color:var(--text-primary);
    display:flex; align-items:center; gap:8px;
}
.card-header-actions { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }

/* STAT GRID */
.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(170px, 1fr));
    gap: 16px; margin-bottom: 20px;
}
.stat-card {
    background: var(--bg-card); border-radius:14px;
    border: 1px solid var(--border); padding:16px;
    display:flex; align-items:center; gap:12px;
    box-shadow: var(--shadow-sm);
}
.stat-icon {
    width:44px; height:44px; border-radius:12px;
    display:flex; align-items:center; justify-content:center;
    flex-shrink:0;
}
.stat-icon .material-icons-round { font-size:22px; }
.stat-info h3 { font-size:22px; font-weight:800; color:var(--text-primary); }
.stat-info p  { font-size:10px; color:var(--text-secondary); margin-top:2px; }

/* MINI STAT */
.mini-stat {
    background:var(--bg-app); border-radius:10px; padding:10px 14px;
    display:flex; flex-direction:column; gap:2px; border:1px solid var(--border);
}
.mini-stat span { font-size:10px; color:var(--text-secondary); }
.mini-stat strong { font-size:16px; font-weight:700; color:var(--text-primary); }

/* TABLE */
.table-wrapper { overflow-x:auto; }
table { width:100%; border-collapse:collapse; font-size:12px; }
thead tr { background:var(--th-bg); }
th { padding:10px 12px; font-size:10px; font-weight:700; color:var(--th-color); text-transform:uppercase; letter-spacing:0.5px; white-space:nowrap; border-bottom:2px solid var(--border); }
td { padding:10px 12px; border-bottom:1px solid var(--border); color:var(--text-primary); vertical-align:middle; }
tbody tr:hover { background:rgba(124,58,237,0.04); }
.text-left { text-align:left !important; }

/* BUTTONS */
.btn {
    display:inline-flex; align-items:center; gap:6px;
    padding: 8px 14px; border-radius:8px;
    font-size:12px; font-weight:600; cursor:pointer;
    border:1px solid transparent; transition:all 0.15s;
    white-space:nowrap;
}
.btn-primary { background:var(--accent); color:white; border-color:var(--accent); }
.btn-primary:hover { background:var(--accent-dark); }
.btn-outline { background:transparent; color:var(--text-primary); border-color:var(--border); }
.btn-outline:hover { background:var(--bg-app); }
.btn-success { background:var(--success); color:white; }
.btn-danger  { background:var(--danger); color:white; }
.btn-sm { padding:5px 10px; font-size:11px; }
.btn .material-icons-round { font-size:16px; }

/* BADGES */
.badge {
    display:inline-flex; align-items:center; padding:3px 10px;
    border-radius:20px; font-size:10px; font-weight:700; white-space:nowrap;
}
.badge-success { background:var(--success-bg); color:var(--success); }
.badge-warning { background:var(--warning-bg); color:var(--warning); }
.badge-danger  { background:var(--danger-bg); color:var(--danger); }
.badge-info    { background:#dbeafe; color:#1d4ed8; }
.badge-gray    { background:#f1f5f9; color:#475569; }

/* FORMS */
.form-group { display:flex; flex-direction:column; gap:5px; }
.form-group label { font-size:11px; font-weight:600; color:var(--text-secondary); }
.form-row { display:grid; grid-template-columns:1fr 1fr; gap:12px; }
.input-control {
    padding:9px 12px; border:1.5px solid var(--border); border-radius:8px;
    font-size:12px; font-family:inherit; background:var(--bg-card); color:var(--text-primary);
    transition:border-color 0.15s; outline:none; width:100%;
}
.input-control:focus { border-color:var(--accent); }
.input-select {
    padding:7px 10px; border:1px solid var(--border); border-radius:8px;
    font-size:12px; font-family:inherit; background:var(--bg-card); color:var(--text-primary);
    cursor:pointer; outline:none;
}
.required { color:var(--danger); }

/* SEARCH */
.search-wrapper { position:relative; }
.search-icon-mini { position:absolute; left:8px; top:50%; transform:translateY(-50%); font-size:16px; color:var(--text-secondary); }
.search-input-mini { padding:7px 10px 7px 30px; border:1px solid var(--border); border-radius:8px; font-size:12px; font-family:inherit; background:var(--bg-card); color:var(--text-primary); outline:none; min-width:200px; }
.search-input-mini:focus { border-color:var(--accent); }

/* SUGGESTIONS DROPDOWN */
.suggestions-box {
    position:absolute; z-index:500; background:var(--bg-card);
    border:1px solid var(--border); border-radius:8px;
    box-shadow:var(--shadow-md); max-height:200px; overflow-y:auto;
    width:100%; margin-top:2px; display:none;
}
.suggestion-item {
    padding:8px 12px; cursor:pointer; font-size:12px;
    border-bottom:1px solid var(--border); transition:background 0.1s;
}
.suggestion-item:hover { background:var(--accent-light); }
.suggestion-item:last-child { border-bottom:none; }
.selected-info {
    margin-top:6px; padding:8px 12px; border-radius:8px;
    background:var(--accent-light); border:1px solid var(--accent);
    font-size:11px; font-weight:600; color:var(--accent-dark);
}

/* MODALS */
.modal-overlay {
    display:none; position:fixed; inset:0; z-index:1000;
    background:rgba(0,0,0,0.5); backdrop-filter:blur(4px);
    align-items:center; justify-content:center; padding:20px;
}
.modal-overlay.open { display:flex; }
.modal-card {
    background:var(--bg-card); border-radius:16px;
    width:100%; max-width:560px; max-height:90vh; overflow-y:auto;
    box-shadow:var(--shadow-lg); animation:modalIn 0.2s ease;
}
.modal-sm { max-width:380px; }
.modal-header {
    display:flex; align-items:center; justify-content:space-between;
    padding:16px 20px; border-bottom:1px solid var(--border);
}
.modal-header h3 { font-size:15px; font-weight:700; }
.modal-close { background:none; border:none; cursor:pointer; color:var(--text-secondary); display:flex; }
.modal-body { padding:20px; display:flex; flex-direction:column; gap:14px; }
.modal-footer { padding:16px 20px; border-top:1px solid var(--border); display:flex; justify-content:flex-end; gap:8px; }

@keyframes modalIn { from { transform:scale(0.95); opacity:0; } to { transform:scale(1); opacity:1; } }

/* TOAST */
.toast-notif {
    position:fixed; bottom:24px; right:24px; z-index:9999;
    background:#1e293b; color:white; padding:12px 20px; border-radius:12px;
    font-size:13px; font-weight:500; box-shadow:var(--shadow-lg);
    transform:translateY(100px); opacity:0; transition:all 0.3s ease;
    max-width:320px;
}
.toast-notif.show { transform:translateY(0); opacity:1; }

/* MOBILE */
#sidebarOverlay { display:none; position:fixed; inset:0; background:rgba(0,0,0,0.5); z-index:150; }
.mobile-toggle { display:none; background:none; border:none; cursor:pointer; color:var(--text-primary); }

@media (max-width: 1024px) {
    .sidebar { transform:translateX(-100%); }
    .sidebar.open { transform:translateX(0); }
    .main-wrapper { margin-left:0; }
    .mobile-toggle { display:flex; }
    #sidebarOverlay.open { display:block; }
    .stat-grid { grid-template-columns:repeat(2,1fr); }
    .form-row { grid-template-columns:1fr; }
}

@media (max-width: 600px) {
    .stat-grid { grid-template-columns:1fr 1fr; }
    .content-area { padding:16px; }
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}

/* ==========================================
   TOOLTIP PETUNJUK ISIAN
   ========================================== */
.field-hint {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 15px; height: 15px;
    border-radius: 50%;
    background: #e0f2fe;
    color: #0284c7;
    font-size: 9px;
    font-weight: 800;
    cursor: help;
    margin-left: 4px;
    vertical-align: middle;
    position: relative;
    flex-shrink: 0;
}
.field-hint::after {
    content: attr(data-tip);
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #1e293b;
    color: white;
    font-size: 10px;
    font-weight: 400;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: pre-line;
    min-width: 180px;
    max-width: 260px;
    line-height: 1.5;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    text-align: left;
}
.field-hint::before {
    content: '';
    position: absolute;
    bottom: calc(100% + 1px);
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1e293b;
    z-index: 9999;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.15s;
}
.field-hint:hover::after,
.field-hint:hover::before { opacity: 1; }

.form-group label {
    display: flex;
    align-items: center;
    gap: 2px;
}

/* Teks hint di bawah input */
.input-hint {
    font-size: 10px;
    color: var(--text-secondary);
    margin-top: 3px;
    font-style: italic;
}
