/* ============================================================
   E-INVENTARIS - DESKTOP & CORE STYLESHEET
   SD Muhammadiyah Serut
   Tema: Amber Gold & Slate Navy
   ============================================================ */

:root {
    --primary:          #0f172a; /* Slate 900 */
    --primary-light:    #1e293b; /* Slate 800 */
    --accent:           #f59e0b; /* Amber 500 */
    --accent-dark:      #d97706; /* Amber 600 */
    --accent-light:     #fef3c7; /* Amber 100 */
    --accent-subtle:    #fffbeb;

    --success:          #10b981;
    --success-bg:       #d1fae5;
    --warning:          #f59e0b;
    --warning-bg:       #fef3c7;
    --danger:           #ef4444;
    --danger-bg:        #fee2e2;
    --info:             #0284c7;
    --info-bg:          #e0f2fe;

    --bg-app:           #f8fafc;
    --bg-card:          #ffffff;
    --text-primary:     #0f172a;
    --text-secondary:   #64748b;
    --text-muted:       #94a3b8;
    --border:           #e2e8f0;
    --border-light:     #f1f5f9;

    --sidebar-bg:       #0f172a;
    --sidebar-width:    260px;
    --header-height:    64px;

    --shadow-xs:        0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm:        0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md:        0 4px 12px rgba(15,23,42,0.08);
    --shadow-lg:        0 12px 30px rgba(15,23,42,0.12);
    --radius-sm:        8px;
    --radius-md:        12px;
    --radius-lg:        16px;
    --radius-full:      9999px;
}

/* RESET */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--bg-app);
    color: var(--text-primary);
    font-size: 13.5px;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    max-width: 100vw;
    position: relative;
}


/* ANIMASI */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}
@keyframes spin {
    from { transform: rotate(0deg); }
    to   { transform: rotate(360deg); }
}
@keyframes slideInRight {
    from { opacity: 0; transform: translateX(40px); }
    to   { opacity: 1; transform: translateX(0); }
}
@keyframes slideOutRight {
    from { opacity: 1; transform: translateX(0); }
    to   { opacity: 0; transform: translateX(40px); }
}

/* SIDEBAR */
.sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1000;
    box-shadow: 2px 0 16px rgba(0,0,0,0.15);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}
.brand-icon {
    width: 42px;
    height: 42px;
    background: linear-gradient(135deg, #f59e0b, #d97706);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(245, 158, 11, 0.35);
    flex-shrink: 0;
}
.brand-icon i { font-size: 24px; }
.brand-text h1 {
    font-size: 15px;
    font-weight: 700;
    color: #ffffff;
    letter-spacing: -0.2px;
}
.brand-text p {
    font-size: 11px;
    color: #94a3b8;
    margin-top: 1px;
}

.sidebar-menu {
    flex: 1;
    overflow-y: auto;
    padding: 16px 12px;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.menu-category {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: #64748b;
    padding: 12px 12px 6px;
    margin-top: 4px;
}
.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: #94a3b8;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.18s ease;
}
.nav-item i { font-size: 20px; flex-shrink: 0; }
.nav-item:hover {
    background: rgba(255,255,255,0.06);
    color: #f8fafc;
}
.nav-item.active {
    background: linear-gradient(135deg, rgba(245, 158, 11, 0.22), rgba(217, 119, 6, 0.15));
    color: #fbbf24;
    font-weight: 600;
    border: 1px solid rgba(245, 158, 11, 0.3);
}
.nav-item.back-portal {
    background: rgba(255,255,255,0.04);
    border: 1px solid rgba(255,255,255,0.08);
    color: #cbd5e1;
    margin-bottom: 8px;
}
.nav-item.back-portal:hover {
    background: rgba(255,255,255,0.1);
    color: #ffffff;
}

/* MAIN CONTENT */
.main-wrapper {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
    min-height: 100vh;
    overflow-x: hidden; /* Cegah overflow horizontal */
    max-width: calc(100vw - var(--sidebar-width));
}

/* TOP HEADER */
.top-header {
    height: var(--header-height);
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 900;
}
.header-left {
    display: flex;
    align-items: center;
    gap: 14px;
}
.btn-menu-mobile {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-primary);
    padding: 6px;
    border-radius: var(--radius-sm);
}
.header-title h2 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
}
.header-title p {
    font-size: 11.5px;
    color: var(--text-secondary);
}
.header-right {
    display: flex;
    align-items: center;
    gap: 14px;
}
.user-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 6px 12px;
    background: var(--bg-app);
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}
.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: var(--primary);
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    font-weight: 700;
}
.user-meta {
    display: flex;
    flex-direction: column;
}
.user-meta span:first-child { font-size: 12px; font-weight: 600; }
.user-meta span:last-child { font-size: 10.5px; color: var(--text-muted); }

/* CONTENT WRAPPER */
.content-area {
    padding: 28px;
    flex: 1;
    overflow-x: hidden;
    max-width: 100%;
    min-width: 0;
}
.tab-content {
    display: none;
    overflow-x: hidden;
    max-width: 100%;
    animation: fadeIn 0.25s ease forwards;
}
.tab-content.active {
    display: block;
}

/* STATS CARDS */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}
.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 16px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    flex-shrink: 0;
}
.stat-icon i { font-size: 26px; }
.stat-icon.blue   { background: linear-gradient(135deg, #3b82f6, #2563eb); }
.stat-icon.amber  { background: linear-gradient(135deg, #f59e0b, #d97706); }
.stat-icon.green  { background: linear-gradient(135deg, #10b981, #059669); }
.stat-icon.purple { background: linear-gradient(135deg, #8b5cf6, #7c3aed); }
.stat-icon.red    { background: linear-gradient(135deg, #ef4444, #dc2626); }

.stat-info { flex: 1; }
.stat-label { font-size: 12px; color: var(--text-secondary); font-weight: 500; }
.stat-value { font-size: 22px; font-weight: 800; color: var(--text-primary); margin: 2px 0; }
.stat-sub   { font-size: 11px; color: var(--text-muted); }

/* CARDS & PANELS */
.panel {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
}
.panel-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-wrap: wrap;
}
.panel-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.panel-body {
    padding: 24px;
}

/* BUTTONS */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 8px 16px;
    border-radius: var(--radius-md);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.18s ease;
    text-decoration: none;
    white-space: nowrap;
}
.btn i { font-size: 18px; }
.btn-primary {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: #ffffff;
    box-shadow: 0 2px 6px rgba(245, 158, 11, 0.3);
}
.btn-primary:hover {
    background: linear-gradient(135deg, #d97706, #b45309);
    transform: translateY(-1px);
    box-shadow: 0 4px 10px rgba(245, 158, 11, 0.4);
}
.btn-secondary {
    background: #ffffff;
    border-color: var(--border);
    color: var(--text-primary);
}
.btn-secondary:hover {
    background: var(--bg-app);
    border-color: #cbd5e1;
}
.btn-success {
    background: #10b981;
    color: #ffffff;
}
.btn-success:hover { background: #059669; }
.btn-danger {
    background: #ef4444;
    color: #ffffff;
}
.btn-danger:hover { background: #dc2626; }
.btn-sm {
    padding: 5px 10px;
    font-size: 12px;
    border-radius: var(--radius-sm);
}
.btn-sm i { font-size: 16px; }

/* TOOLBAR & FILTERS */
.toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
    margin-bottom: 18px;
    flex-wrap: wrap;
}
.search-box {
    position: relative;
    min-width: 260px;
    flex: 1;
    max-width: 380px;
}
.search-box i {
    position: absolute;
    left: 12px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 19px;
}
.search-box input {
    width: 100%;
    padding: 9px 12px 9px 38px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: #ffffff;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.search-box input:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
.filter-group {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}
.filter-select {
    padding: 8px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #ffffff;
    color: var(--text-primary);
    font-size: 12.5px;
    outline: none;
    cursor: pointer;
}
.filter-select:focus {
    border-color: var(--accent);
}

/* DATA TABLE */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    background: #ffffff;
}
.data-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    white-space: nowrap;
}
.data-table th {
    background: #f8fafc;
    padding: 12px 16px;
    font-size: 11.5px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: #475569;
    border-bottom: 1px solid var(--border);
}
.data-table td {
    padding: 13px 16px;
    font-size: 13px;
    border-bottom: 1px solid var(--border-light);
    color: var(--text-primary);
    vertical-align: middle;
}
.data-table tbody tr:hover {
    background: #fbfcfe;
}
.data-table tbody tr:last-child td {
    border-bottom: none;
}

/* BADGES */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 3px 10px;
    border-radius: var(--radius-full);
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}
.badge-icon { font-size: 14px; }
.badge-success { background: var(--success-bg); color: #047857; }
.badge-warning { background: var(--warning-bg); color: #b45309; }
.badge-danger  { background: var(--danger-bg);  color: #b91c1c; }
.badge-info    { background: var(--info-bg);    color: #0369a1; }
.badge-muted   { background: #f1f5f9;           color: #64748b; }

/* MODALS */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}
.modal-overlay.active {
    display: flex;
}
.modal-card {
    background: #ffffff;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-lg);
    width: 100%;
    max-width: 640px;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.2s cubic-bezier(0.16, 1, 0.3, 1);
    margin: auto;
}
.modal-card.modal-lg { max-width: 860px; }
.modal-card.modal-xl { max-width: 1050px; }

/* Form di dalam modal wajib flex agar modal-body bisa scroll sempurna */
.modal-card > form,
.modal-card form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.modal-header h3 {
    font-size: 16px;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}
.modal-close {
    background: none;
    border: none;
    font-size: 20px;
    color: var(--text-muted);
    cursor: pointer;
    border-radius: var(--radius-sm);
    padding: 4px;
    line-height: 1;
}
.modal-close:hover { color: var(--danger); }

.modal-body {
    padding: 24px;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    flex: 1;
    min-height: 0; /* PENTING: agar modal-body bisa mengecil dan mengaktifkan scrollbar */
    overscroll-behavior-y: contain;
}
.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 12px;
    background: #f8fafc;
    flex-shrink: 0;
}

/* FORM ELEMENTS */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 16px;
}
.form-group {
    margin-bottom: 16px;
}
.form-group.full {
    grid-column: 1 / -1;
}
.form-label {
    display: block;
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.form-label.required::after {
    content: ' *';
    color: var(--danger);
}
.form-control {
    width: 100%;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    font-size: 13px;
    background: #ffffff;
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-control:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.15);
}
textarea.form-control {
    resize: vertical;
    min-height: 80px;
}
.form-hint {
    font-size: 11.5px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* PAGINATION */
.pagination {
    display: flex;
    align-items: center;
    gap: 6px;
    justify-content: center;
    margin-top: 18px;
}
.page-btn {
    min-width: 34px;
    height: 34px;
    padding: 0 8px;
    border: 1px solid var(--border);
    background: #ffffff;
    border-radius: var(--radius-sm);
    font-size: 12.5px;
    font-weight: 600;
    color: var(--text-secondary);
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    transition: all 0.15s ease;
}
.page-btn:hover:not(:disabled) {
    border-color: var(--accent);
    color: var(--accent-dark);
}
.page-btn.active {
    background: var(--accent);
    border-color: var(--accent);
    color: #ffffff;
}
.page-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}
.page-dots { color: var(--text-muted); font-size: 14px; }

/* PRINT STYLES */
@media print {
    .sidebar, .top-header, .toolbar, .btn, .pagination, .no-print {
        display: none !important;
    }
    .main-wrapper {
        margin-left: 0 !important;
    }
    .content-area {
        padding: 0 !important;
    }
    .panel {
        border: none !important;
        box-shadow: none !important;
    }
}

/* ============================================================
   SCANNER BARCODE & QR CODE STYLES
   ============================================================ */
.scanner-grid {
    display: grid;
    grid-template-columns: minmax(320px, 460px) 1fr;
    gap: 24px;
    align-items: start;
}

@media (max-width: 900px) {
    .scanner-grid {
        grid-template-columns: 1fr;
    }
}

.scanner-viewport-wrapper {
    position: relative;
    background: #0f172a;
    border-radius: var(--radius-md);
    overflow: hidden;
    box-shadow: var(--shadow-md);
    border: 2px solid #1e293b;
    min-height: 280px;
}

#pageScannerView, #modalScannerView {
    width: 100% !important;
    background: #0f172a;
    border-radius: var(--radius-md);
    overflow: hidden;
}

#pageScannerView video, #modalScannerView video {
    width: 100% !important;
    height: auto !important;
    border-radius: var(--radius-md);
    display: block;
    object-fit: cover;
}

/* Scanner Overlay UI (Loading, Error, Active states) */
#scannerOverlay {
    transition: opacity 0.2s ease;
}

#scannerRetryBtn {
    cursor: pointer !important;
    pointer-events: auto !important;
    position: relative;
    z-index: 20;
    -webkit-tap-highlight-color: transparent;
    user-select: none;
}

#scannerRetryBtn:active {
    transform: scale(0.96);
    opacity: 0.9;
}

#scannerActiveBar {
    pointer-events: auto;
}

/* Utility: hide text on very small screens */
@media (max-width: 400px) {
    .hide-xs {
        display: none;
    }
}


.scanner-card-matched {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid #10b98144;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.08);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.scanner-card-unregistered {
    background: #ffffff;
    border-radius: var(--radius-md);
    border: 1px solid #f59e0b55;
    box-shadow: 0 4px 20px rgba(245, 158, 11, 0.08);
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

.scanner-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #ecfdf5;
    border-bottom: 1px solid #a7f3d0;
}

.scanner-card-header.unregistered {
    background: #fffbeb;
    border-bottom: 1px solid #fde68a;
}

.scanner-status-tag {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    font-weight: 700;
}

.scanner-status-tag.registered {
    color: #065f46;
}

.scanner-status-tag.unregistered {
    color: #92400e;
}

.scanner-code-display {
    font-family: monospace;
    font-size: 13px;
    font-weight: 700;
    padding: 4px 10px;
    border-radius: 6px;
    background: #ffffff;
    border: 1px solid #cbd5e1;
    color: #0f172a;
}

.scanner-card-body {
    padding: 20px;
}

.scanner-product-title {
    font-size: 18px;
    font-weight: 800;
    color: #0f172a;
    margin-bottom: 10px;
    line-height: 1.3;
}

.scanner-meta-pills {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 12px;
}

.pill-meta {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 12px;
    font-weight: 500;
    background: #f1f5f9;
    color: #334155;
    padding: 4px 10px;
    border-radius: 6px;
}

.pill-meta i {
    font-size: 14px;
    color: #64748b;
}

.scanner-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 18px;
    padding-top: 16px;
    border-top: 1px solid #e2e8f0;
}

