/* =========================================================
   DOCUVAULT - Core Stylesheet
   Palet: dominan biru (gradient biru tua), kartu putih, rounded corners
   ========================================================= */

:root {
    --blue-900: #0f2557;
    --blue-800: #142d6e;
    --blue-700: #1a3a85;
    --blue-600: #1e3a8a;
    --blue-500: #2851b8;
    --blue-400: #3b6fe0;
    --blue-100: #e8effc;
    --blue-50:  #f2f6fd;
    --white: #ffffff;
    --gray-50: #f7f9fc;
    --gray-100: #eef1f7;
    --gray-200: #dde3ee;
    --gray-400: #97a3ba;
    --gray-600: #5c6b85;
    --gray-800: #263248;
    --danger: #e0435c;
    --success: #22b07d;
    --warning: #f0a93b;
    --radius-sm: 10px;
    --radius-md: 16px;
    --radius-lg: 22px;
    --shadow-sm: 0 2px 8px rgba(15, 37, 87, 0.06);
    --shadow-md: 0 8px 24px rgba(15, 37, 87, 0.10);
    --shadow-lg: 0 16px 40px rgba(15, 37, 87, 0.18);
    --font: 'Segoe UI', Roboto, -apple-system, BlinkMacSystemFont, 'Helvetica Neue', Arial, sans-serif;
}

* { box-sizing: border-box; }

html, body {
    margin: 0; padding: 0;
    font-family: var(--font);
    background: var(--gray-50);
    color: var(--gray-800);
    -webkit-tap-highlight-color: transparent;
}

a { text-decoration: none; color: inherit; }
button { font-family: inherit; cursor: pointer; }
input, select { font-family: inherit; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 6px;
    padding: 11px 20px; border-radius: var(--radius-sm); border: none;
    font-size: 14.5px; font-weight: 600; transition: all .15s ease;
}
.btn-primary { background: linear-gradient(135deg, var(--blue-600), var(--blue-900)); color: #fff; }
.btn-primary:hover { filter: brightness(1.08); }
.btn-secondary { background: var(--blue-100); color: var(--blue-700); }
.btn-outline { background: #fff; color: var(--blue-700); border: 1.5px solid var(--blue-200, var(--gray-200)); }
.btn-block { width: 100%; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-icon {
    background: transparent; border: none; font-size: 18px; color: var(--gray-800);
    width: 36px; height: 36px; border-radius: 50%; display: inline-flex; align-items: center; justify-content: center;
}
.btn-icon:hover { background: var(--gray-100); }

/* ---------- Auth Page ---------- */
.auth-body { background: linear-gradient(160deg, var(--blue-900), var(--blue-600) 60%, var(--blue-400)); min-height: 100vh; display: flex; align-items: center; justify-content: center; padding: 20px; }
.auth-wrapper { width: 100%; max-width: 420px; }
.auth-card { background: #fff; border-radius: var(--radius-lg); padding: 36px 30px; box-shadow: var(--shadow-lg); }
.auth-logo { text-align: center; margin-bottom: 26px; }
.auth-logo .logo-icon { font-size: 40px; }
.auth-logo h1 { margin: 8px 0 2px; color: var(--blue-800); letter-spacing: 1px; font-size: 24px; }
.auth-logo p { margin: 0; color: var(--gray-600); font-size: 13.5px; }
.auth-form .form-group { margin-bottom: 16px; }
.auth-form label { display: block; margin-bottom: 6px; font-size: 13.5px; font-weight: 600; color: var(--gray-800); }
.auth-form input { width: 100%; padding: 12px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--gray-200); font-size: 14.5px; }
.auth-form input:focus { outline: none; border-color: var(--blue-500); }
.form-error { background: #fdecef; color: var(--danger); padding: 10px 14px; border-radius: var(--radius-sm); font-size: 13.5px; margin-bottom: 14px; }
.auth-demo { margin-top: 22px; padding-top: 16px; border-top: 1px dashed var(--gray-200); font-size: 12.5px; color: var(--gray-600); text-align: center; }
.auth-demo p { margin: 2px 0; }

/* ---------- App Shell ---------- */
.app-shell { display: flex; min-height: 100vh; }
.main-wrap { flex: 1; display: flex; flex-direction: column; min-width: 0; }
.content { flex: 1; padding: 16px; overflow-y: auto; }
.loading-state, .empty-state { text-align: center; padding: 60px 20px; color: var(--gray-400); }
.empty-state .emoji { font-size: 42px; display: block; margin-bottom: 10px; }

/* ---------- Global Search Bar ---------- */
.global-search-bar {
    display: flex; align-items: center; gap: 8px;
    background: #fff; margin: 12px 16px 4px; padding: 10px 14px;
    border-radius: var(--radius-md); box-shadow: var(--shadow-sm);
}
.global-search-bar input { flex: 1; border: none; outline: none; font-size: 14.5px; background: transparent; }
.search-icon { color: var(--gray-400); }
.btn-filter { background: var(--blue-50); border: none; border-radius: 8px; padding: 6px 10px; font-size: 15px; }

/* ---------- Cards / Stats ---------- */
.stats-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 12px; margin-bottom: 16px; }
.stat-card {
    background: linear-gradient(135deg, var(--blue-700), var(--blue-900));
    color: #fff; border-radius: var(--radius-md); padding: 16px; box-shadow: var(--shadow-md);
}
.stat-card.alt { background: #fff; color: var(--gray-800); border: 1px solid var(--gray-200); box-shadow: var(--shadow-sm); }
.stat-card .stat-value { font-size: 24px; font-weight: 700; }
.stat-card .stat-label { font-size: 12.5px; opacity: .85; margin-top: 2px; }

.section-title { font-size: 15.5px; font-weight: 700; color: var(--gray-800); margin: 18px 0 10px; display: flex; align-items: center; justify-content: space-between; }
.section-title .see-all { font-size: 12.5px; color: var(--blue-500); font-weight: 600; }

.quick-access-grid { display: grid; grid-template-columns: repeat(2, 1fr); gap: 10px; }
.quick-access-item {
    background: #fff; border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-sm);
    display: flex; align-items: center; gap: 10px; font-size: 13.5px; font-weight: 600; color: var(--gray-800);
}
.quick-access-item .qa-icon { font-size: 20px; }

/* ---------- Document Card (mobile list) ---------- */
.doc-card {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border-radius: var(--radius-md); padding: 12px 14px; margin-bottom: 10px;
    box-shadow: var(--shadow-sm);
}
.doc-icon { width: 42px; height: 42px; border-radius: 10px; background: var(--blue-50); display: flex; align-items: center; justify-content: center; font-size: 20px; flex-shrink: 0; }
.doc-info { flex: 1; min-width: 0; }
.doc-name { font-weight: 600; font-size: 14px; color: var(--gray-800); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.doc-meta { font-size: 12px; color: var(--gray-400); margin-top: 2px; }
.doc-actions { display: flex; align-items: center; gap: 2px; flex-shrink: 0; }
.doc-fav.active { color: var(--warning); }

/* ---------- Folder Grid ---------- */
.folder-grid { display: grid; grid-template-columns: 1fr; gap: 10px; }
.folder-card {
    display: flex; align-items: center; gap: 12px;
    background: #fff; border-radius: var(--radius-md); padding: 14px; box-shadow: var(--shadow-sm);
}
.folder-card .folder-icon { font-size: 24px; }
.folder-card .folder-name { font-weight: 700; font-size: 14.5px; }
.folder-card .folder-meta { font-size: 12px; color: var(--gray-400); }
.breadcrumb { font-size: 12.5px; color: var(--gray-600); margin-bottom: 12px; }
.breadcrumb a { color: var(--blue-500); font-weight: 600; }

/* ---------- Modals ---------- */
.modal-overlay {
    display: none; position: fixed; inset: 0; background: rgba(15, 37, 87, 0.55);
    z-index: 1000; align-items: center; justify-content: center; padding: 16px;
}
.modal-overlay.open { display: flex; }
.modal-card { background: #fff; border-radius: var(--radius-lg); width: 100%; max-width: 460px; max-height: 88vh; overflow-y: auto; box-shadow: var(--shadow-lg); }
.modal-header { display: flex; align-items: center; justify-content: space-between; padding: 18px 20px; border-bottom: 1px solid var(--gray-100); }
.modal-header h3 { margin: 0; font-size: 16.5px; }
.modal-close { background: none; border: none; font-size: 18px; color: var(--gray-400); }
.modal-body { padding: 18px 20px; }
.form-group { margin-bottom: 14px; }
.form-group label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 5px; color: var(--gray-800); }
.form-group input, .form-group select { width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--gray-200); font-size: 14px; }
.checkbox-label { display: flex; align-items: center; gap: 8px; font-weight: 500; }

/* ---------- Upload ---------- */
.upload-drop { border: 2px dashed var(--blue-200, var(--gray-200)); border-radius: var(--radius-md); padding: 26px 14px; text-align: center; background: var(--blue-50); }
.upload-drop .btn { margin: 6px 4px; }
.upload-drop .hint { font-size: 11.5px; color: var(--gray-400); margin-top: 8px; }
.upload-queue { margin-top: 14px; }
.upload-item { background: var(--gray-50); border-radius: 10px; padding: 10px 12px; margin-bottom: 8px; }
.upload-item .u-name { font-size: 13px; font-weight: 600; margin-bottom: 6px; display: flex; justify-content: space-between; }
.upload-progress-bar { background: var(--gray-200); border-radius: 8px; height: 7px; overflow: hidden; }
.upload-progress-fill { background: linear-gradient(90deg, var(--blue-500), var(--blue-700)); height: 100%; width: 0%; transition: width .2s; }
.upload-item.done .u-name { color: var(--success); }
.upload-item.error .u-name { color: var(--danger); }

/* ---------- PDF Viewer ---------- */
.viewer-container { position: fixed; inset: 0; background: #12224e; display: flex; flex-direction: column; z-index: 1100; }
#viewerModal.open .viewer-container { display: flex; }
.viewer-toolbar { display: flex; align-items: center; gap: 8px; padding: 10px 14px; background: var(--blue-900); color: #fff; flex-wrap: wrap; }
.viewer-title { flex: 1; font-size: 13.5px; font-weight: 600; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.viewer-actions { display: flex; align-items: center; gap: 4px; }
.viewer-actions .btn-icon { color: #fff; }
.viewer-actions .btn-icon:disabled { opacity: 0.3; cursor: default; }
.viewer-page-info { font-size: 12.5px; padding: 0 6px; }
.viewer-body { flex: 1; overflow: auto; display: flex; justify-content: center; padding: 16px; background: #1a2c5c; }
#pdfCanvas { background: #fff; box-shadow: var(--shadow-lg); border-radius: 4px; max-width: 100%; }

/* ---------- Tables (desktop docs) ---------- */
.doc-table { width: 100%; border-collapse: collapse; background: #fff; border-radius: var(--radius-md); overflow: hidden; box-shadow: var(--shadow-sm); }
.doc-table th { text-align: left; font-size: 12.5px; color: var(--gray-600); background: var(--gray-50); padding: 12px 16px; }
.doc-table td { padding: 12px 16px; font-size: 13.5px; border-top: 1px solid var(--gray-100); vertical-align: middle; }
.doc-table tr:hover td { background: var(--blue-50); }

/* ---------- Misc ---------- */
.tag-badge { display: inline-block; padding: 3px 10px; border-radius: 20px; font-size: 11px; font-weight: 700; }
.tag-admin { background: #fdf0d5; color: #b06f00; }
.tag-user { background: var(--blue-100); color: var(--blue-700); }
.tag-active { background: #e3f8ee; color: var(--success); }
.tag-inactive { background: #fdecef; color: var(--danger); }

.toast-container { position: fixed; top: 16px; right: 16px; z-index: 2000; display: flex; flex-direction: column; gap: 8px; }
.toast { background: var(--gray-800); color: #fff; padding: 11px 18px; border-radius: 10px; font-size: 13.5px; box-shadow: var(--shadow-md); animation: fadein .2s; }
.toast.success { background: var(--success); }
.toast.error { background: var(--danger); }
@keyframes fadein { from { opacity: 0; transform: translateY(-8px);} to { opacity: 1; transform: translateY(0);} }

.storage-mini { padding: 0 6px 10px; font-size: 11.5px; color: var(--gray-400); }
.storage-mini-bar { background: var(--gray-200); border-radius: 6px; height: 6px; overflow: hidden; margin-bottom: 4px; }
.storage-mini-fill { background: linear-gradient(90deg, var(--blue-500), var(--blue-700)); height: 100%; width: 10%; }

/* Sales & QC tidak memiliki fitur Upload/Import (lihat form perubahan bagian 3) */
.app-shell[data-role="sales"] .fab-upload,
.app-shell[data-role="qc"] .fab-upload {
    display: none;
}

/* Perbaikan tombol "Kembali" di PDF Viewer: sebelumnya dipaksa jadi lingkaran 36px
   padahal isinya teks "← Kembali", sehingga teks terlihat tumpang tindih/terpotong. */
#viewerBack {
    width: auto;
    height: auto;
    padding: 8px 14px;
    border-radius: 20px;
    gap: 6px;
    font-size: 13.5px;
    background: rgba(255,255,255,0.08);
    color: #fff;
    white-space: nowrap;
}
#viewerBack:hover { background: rgba(255,255,255,0.18); }

/* Batasi lebar toast supaya pesan error yang lebih panjang tidak melebar ke luar layar */
.toast { max-width: 320px; }

/* Modal Profil Akun (mobile "Akun" button) */
.account-avatar {
    width: 64px; height: 64px; border-radius: 50%; margin: 0 auto 12px;
    background: var(--blue-100); color: var(--blue-700);
    display: flex; align-items: center; justify-content: center;
    font-size: 26px; font-weight: 700;
}
.account-name { font-size: 17px; font-weight: 700; color: var(--gray-800); }
.account-role { font-size: 13px; color: var(--blue-500); font-weight: 600; margin-top: 2px; }
.account-email { font-size: 13px; color: var(--gray-400); margin-top: 6px; }

.form-error-inline { color: var(--danger); font-size: 12.5px; margin-top: 6px; }

/* =========================================================
   v2 - DATA CATALOG / REQUEST / QC APPROVAL WORKFLOW
   ========================================================= */

/* Tambahan badge status akses/request */
.tag-request { background: #fdf3d9; color: #a3720c; }
.tag-pending { background: #fdf3d9; color: #a3720c; }

/* Tombol kecil untuk aksi di dalam kartu (Request Document, View, Download, dsb.) */
.btn-sm { padding: 7px 12px; font-size: 12.5px; border-radius: 8px; }

/* Textarea (form alasan penolakan) mengikuti style input existing */
.form-group textarea {
    width: 100%; padding: 10px 12px; border-radius: 10px; border: 1.5px solid var(--gray-200);
    font-size: 14px; font-family: inherit; resize: vertical;
}

/* Kartu Data Catalog: status badge + area aksi kontekstual */
.doc-status-row { margin-top: 6px; }
.catalog-actions { display: flex; flex-direction: column; align-items: flex-end; gap: 6px; }
.catalog-actions .btn { white-space: nowrap; }
.catalog-actions .hint { font-size: 11px; color: var(--gray-400); text-align: right; max-width: 120px; }
.catalog-card .doc-info { cursor: default; }
.catalog-search-row { margin-bottom: 10px; }
.catalog-search-row input {
    width: 100%; padding: 10px 14px; border-radius: var(--radius-sm); border: 1.5px solid var(--gray-200);
    font-size: 14px; background: #fff;
}

/* Kartu Request (My Requests / Request Masuk / Approval History) */
.request-card .doc-icon { background: var(--blue-50); }

/* List container untuk view v2 (Data Catalog, Request, Approval) - SELALU tampil
   di semua breakpoint (berbeda dari .doc-list-mobile lama yang disembunyikan di desktop.css) */
.workflow-list { display: block; }

/* Modal actions row (Approve/Reject buttons di dalam modal) */
.modal-actions { display: flex; gap: 10px; margin-top: 16px; }
.modal-actions .btn { flex: 1; }

/* ---------- Notifikasi ---------- */
.notif-btn { position: relative; }
.notif-badge {
    position: absolute; top: 2px; right: 2px; background: var(--danger); color: #fff;
    font-size: 10px; font-weight: 700; min-width: 16px; height: 16px; border-radius: 8px;
    display: inline-flex; align-items: center; justify-content: center; padding: 0 3px;
}
.notif-dropdown {
    display: none; position: absolute; top: 64px; right: 16px; width: 320px; max-width: calc(100vw - 32px);
    background: #fff; border-radius: var(--radius-md); box-shadow: var(--shadow-lg); z-index: 1200;
    max-height: 70vh; overflow: hidden; flex-direction: column;
}
.notif-dropdown.open { display: flex; }
.notif-dropdown-header {
    display: flex; align-items: center; justify-content: space-between;
    padding: 14px 16px; border-bottom: 1px solid var(--gray-100); font-size: 14px;
}
.notif-dropdown-list { overflow-y: auto; }
.notif-item { padding: 12px 16px; border-bottom: 1px solid var(--gray-100); cursor: pointer; }
.notif-item:hover { background: var(--blue-50); }
.notif-item.unread { background: var(--blue-50); }
.notif-item .notif-title { font-weight: 700; font-size: 13px; color: var(--gray-800); }
.notif-item .notif-message { font-size: 12.5px; color: var(--gray-600); margin-top: 2px; }
.notif-item .notif-time { font-size: 11px; color: var(--gray-400); margin-top: 4px; }