/* ── Variables ── */
:root {
    --bg:         #f1f5f9;
    --surface:    #ffffff;
    --sidebar-bg: #0f172a;
    --primary:    #6366f1;
    --primary-dk: #4f46e5;
    --success:    #10b981;
    --danger:     #ef4444;
    --warning:    #f59e0b;
    --muted:      #64748b;
    --text:       #0f172a;
    --border:     #e2e8f0;
    --radius:     12px;
    --radius-sm:  8px;
    --shadow:     0 2px 16px rgba(0,0,0,0.07);
    --sidebar-w:  220px;
    --header-h:   60px;
    --touch-min:  52px;
}

/* ── Reset ── */
*,*::before,*::after { box-sizing: border-box; }
body { margin:0; font-family:'Outfit',sans-serif; background:var(--bg); color:var(--text); font-size:15px; }
a { text-decoration:none; color:inherit; }
button,input,select,textarea { font-family:inherit; }

/* ── Sidebar ── */
#sidebar {
    position:fixed; top:0; left:0; bottom:0; width:var(--sidebar-w);
    background:var(--sidebar-bg); color:#e2e8f0; display:flex; flex-direction:column;
    z-index:100; transition:transform .25s;
}
#sidebar .brand {
    height:var(--header-h); display:flex; align-items:center; gap:10px;
    padding:0 20px; font-size:20px; font-weight:800; color:white;
    border-bottom:1px solid rgba(255,255,255,0.08);
}
#sidebar .brand .logo-icon { font-size:22px; color:var(--primary); }
#sidebar nav { flex:1; overflow-y:auto; padding:12px 0; }
#sidebar nav a {
    display:flex; align-items:center; gap:10px; padding:10px 20px;
    font-size:14px; font-weight:500; color:#94a3b8; border-radius:0;
    transition:background .15s, color .15s; cursor:pointer; white-space:nowrap;
    min-height:var(--touch-min);
}
#sidebar nav a:hover { background:rgba(255,255,255,0.06); color:#e2e8f0; }
#sidebar nav a.active { background:rgba(99,102,241,0.18); color:white; border-left:3px solid var(--primary); }
#sidebar nav a i { width:18px; text-align:center; font-size:15px; }
#sidebar nav .nav-section {
    font-size:10px; font-weight:700; letter-spacing:0.8px; text-transform:uppercase;
    color:#475569; padding:14px 20px 4px; margin-top:4px;
}
#sidebar .sidebar-user {
    padding:14px 20px; border-top:1px solid rgba(255,255,255,0.08);
    font-size:13px; color:#64748b;
}
#sidebar .sidebar-user strong { display:block; color:#e2e8f0; font-size:14px; }
#sidebar .sidebar-logout {
    display:flex; align-items:center; gap:8px; padding:10px 20px;
    font-size:13px; color:#ef4444; cursor:pointer;
    min-height:var(--touch-min); transition:background .15s;
}
#sidebar .sidebar-logout:hover { background:rgba(239,68,68,0.08); }

/* ── Main content ── */
#main {
    margin-left:var(--sidebar-w);
    min-height:100vh;
    display:flex; flex-direction:column;
}
#topbar {
    height:var(--header-h); background:var(--surface); border-bottom:1px solid var(--border);
    display:flex; align-items:center; justify-content:space-between;
    padding:0 24px; position:sticky; top:0; z-index:50;
    box-shadow:0 1px 4px rgba(0,0,0,0.04);
}
#topbar h1 { font-size:18px; font-weight:700; margin:0; }
#topbar .topbar-right { display:flex; align-items:center; gap:12px; font-size:14px; color:var(--muted); }
#content { padding:24px; flex:1; }

/* Mobile hamburger */
#hamburger {
    display:none; background:none; border:none; cursor:pointer;
    font-size:22px; color:var(--text); padding:4px 8px;
}
#sidebar-overlay {
    display:none; position:fixed; inset:0; background:rgba(0,0,0,0.35); z-index:99;
}

/* ── Cards & Layout ── */
.card {
    background:var(--surface); border-radius:var(--radius);
    box-shadow:var(--shadow); padding:20px;
}
.card-sm { padding:14px 16px; }
.grid-2 { display:grid; grid-template-columns:repeat(2,1fr); gap:16px; }
.grid-3 { display:grid; grid-template-columns:repeat(3,1fr); gap:16px; }
.grid-4 { display:grid; grid-template-columns:repeat(4,1fr); gap:16px; }
.flex    { display:flex; }
.flex-1  { flex:1; }
.gap-8   { gap:8px; }
.gap-12  { gap:12px; }
.gap-16  { gap:16px; }
.align-center { align-items:center; }
.justify-between { justify-content:space-between; }
.mt-8  { margin-top:8px; }
.mt-12 { margin-top:12px; }
.mt-16 { margin-top:16px; }
.mt-24 { margin-top:24px; }
.mb-8  { margin-bottom:8px; }
.mb-12 { margin-bottom:12px; }
.mb-16 { margin-bottom:16px; }

/* ── Buttons ── */
.btn {
    display:inline-flex; align-items:center; justify-content:center; gap:6px;
    padding:10px 20px; border:none; border-radius:var(--radius-sm);
    font-size:14px; font-weight:600; cursor:pointer; transition:filter .15s, transform .1s;
    min-height:var(--touch-min); white-space:nowrap; font-family:inherit;
}
.btn:active { transform:scale(.97); }
.btn-primary  { background:var(--primary); color:white; }
.btn-primary:hover { filter:brightness(1.1); }
.btn-success  { background:var(--success); color:white; }
.btn-danger   { background:var(--danger);  color:white; }
.btn-warning  { background:var(--warning); color:white; }
.btn-ghost    { background:transparent; color:var(--muted); border:1px solid var(--border); }
.btn-ghost:hover { background:var(--bg); }
.btn-lg { padding:14px 28px; font-size:16px; min-height:60px; }
.btn-xl { padding:18px 36px; font-size:18px; min-height:68px; border-radius:12px; }
.btn-icon { padding:10px; border-radius:50%; min-height:auto; width:40px; height:40px; }

/* ── Forms ── */
.form-group { margin-bottom:16px; }
.form-group label { display:block; font-size:13px; font-weight:600; color:var(--muted); margin-bottom:6px; }
.form-control {
    width:100%; padding:11px 14px; border:1.5px solid var(--border); border-radius:var(--radius-sm);
    font-size:15px; background:var(--surface); color:var(--text); transition:border-color .15s;
    min-height:var(--touch-min);
}
.form-control:focus { outline:none; border-color:var(--primary); }
.form-control::placeholder { color:#94a3b8; }
select.form-control { cursor:pointer; }

/* ── Tables ── */
.table-wrap { overflow-x:auto; border-radius:var(--radius); }
table { width:100%; border-collapse:collapse; font-size:14px; }
table thead th {
    padding:10px 14px; background:#0f172a; color:white;
    font-size:11px; font-weight:700; text-align:left; white-space:nowrap;
}
table tbody td { padding:12px 14px; border-bottom:1px solid var(--border); vertical-align:middle; }
table tbody tr:last-child td { border-bottom:none; }
table tbody tr:hover { background:#f8fafc; }

/* ── Badges ── */
.badge {
    display:inline-flex; align-items:center; padding:3px 9px; border-radius:20px;
    font-size:11px; font-weight:700; text-transform:uppercase; letter-spacing:.3px;
}
.badge-success { background:#d1fae5; color:#065f46; }
.badge-danger  { background:#fee2e2; color:#991b1b; }
.badge-warning { background:#fef3c7; color:#92400e; }
.badge-info    { background:#e0f2fe; color:#0c4a6e; }
.badge-muted   { background:#f1f5f9; color:#64748b; }
.badge-primary { background:#ede9fe; color:#4338ca; }

/* ── Toast ── */
#toast-container {
    position:fixed; bottom:24px; right:24px; z-index:9999;
    display:flex; flex-direction:column; gap:8px;
}
.toast {
    padding:12px 20px; border-radius:var(--radius-sm); font-size:14px; font-weight:600;
    color:white; box-shadow:0 4px 16px rgba(0,0,0,0.15); animation:slideIn .25s ease;
    max-width:320px;
}
.toast-success { background:#10b981; }
.toast-error   { background:#ef4444; }
.toast-warning { background:#f59e0b; }
.toast-info    { background:#6366f1; }
@keyframes slideIn { from { transform:translateX(110%); } to { transform:translateX(0); } }

/* ── Stat cards ── */
.stat-card {
    background:var(--surface); border-radius:var(--radius); padding:20px;
    display:flex; flex-direction:column; gap:4px; box-shadow:var(--shadow);
}
.stat-card .stat-label { font-size:12px; font-weight:700; color:var(--muted); text-transform:uppercase; letter-spacing:.5px; }
.stat-card .stat-value { font-size:32px; font-weight:900; color:var(--text); line-height:1; }
.stat-card .stat-sub   { font-size:13px; color:var(--muted); }

/* ── Home launchpad ── */
.launchpad { display:grid; grid-template-columns:repeat(auto-fill,minmax(160px,1fr)); gap:16px; }
.launch-card {
    background:var(--surface); border-radius:var(--radius); padding:28px 20px;
    display:flex; flex-direction:column; align-items:center; gap:12px;
    cursor:pointer; box-shadow:var(--shadow); transition:transform .15s, box-shadow .15s;
    border:2px solid transparent; text-align:center; min-height:140px;
}
.launch-card:hover { transform:translateY(-3px); box-shadow:0 8px 24px rgba(0,0,0,0.1); }
.launch-card:active { transform:scale(.97); }
.launch-card i { font-size:32px; }
.launch-card span { font-size:14px; font-weight:700; }

/* ── Order processing ── */
.process-header {
    background:var(--surface); border-radius:var(--radius); padding:16px 20px;
    display:flex; align-items:center; justify-content:space-between; gap:16px;
    box-shadow:var(--shadow); margin-bottom:16px;
}
.process-ticket { font-size:28px; font-weight:900; color:var(--primary); }
.process-info   { font-size:14px; color:var(--muted); }
.process-progress { display:flex; align-items:center; gap:10px; }
.progress-bar {
    width:160px; height:10px; background:var(--border); border-radius:10px; overflow:hidden;
}
.progress-fill { height:100%; background:var(--primary); border-radius:10px; transition:width .3s; }
.progress-text { font-size:14px; font-weight:700; color:var(--text); white-space:nowrap; }

.scan-bar {
    background:var(--surface); border-radius:var(--radius); padding:14px 16px;
    box-shadow:var(--shadow); margin-bottom:16px;
}
.scan-input {
    width:100%; padding:14px 16px; border:2px solid var(--primary);
    border-radius:var(--radius-sm); font-size:16px; background:var(--bg);
    color:var(--text); min-height:56px;
}
.scan-input:focus { outline:none; background:white; }

.book-row {
    background:var(--surface); border-radius:var(--radius-sm); margin-bottom:8px;
    display:flex; align-items:center; gap:12px; padding:10px 14px;
    box-shadow:0 1px 4px rgba(0,0,0,0.04); transition:background .15s;
    min-height:var(--touch-min);
}
.book-row.done-available { opacity:0.55; background:#f0fdf4; }
.book-row.done-unavailable { opacity:0.55; background:#fff1f2; }
.book-cover {
    width:40px; height:52px; object-fit:cover; border-radius:4px;
    background:#f1f5f9; flex-shrink:0; display:flex; align-items:center; justify-content:center;
    color:var(--muted); font-size:18px; overflow:hidden;
}
.book-cover img { width:100%; height:100%; object-fit:cover; }
.book-title { flex:1; font-weight:600; font-size:14px; line-height:1.3; }
.book-actions { display:flex; gap:8px; flex-shrink:0; }
.btn-avail, .btn-unavail {
    min-width:64px; min-height:44px; border:none; border-radius:var(--radius-sm);
    font-size:13px; font-weight:700; cursor:pointer; transition:filter .15s;
    font-family:inherit;
}
.btn-avail   { background:#d1fae5; color:#065f46; }
.btn-avail:hover   { filter:brightness(.95); }
.btn-unavail { background:#fee2e2; color:#991b1b; }
.btn-unavail:hover { filter:brightness(.95); }

.section-header {
    font-size:11px; font-weight:800; text-transform:uppercase; letter-spacing:.8px;
    color:var(--muted); margin:16px 0 8px; display:flex; align-items:center; gap:8px;
}
.section-header::after { content:''; flex:1; height:1px; background:var(--border); }

/* ── Queue card ── */
.queue-card {
    background:var(--surface); border-radius:var(--radius); padding:16px;
    box-shadow:var(--shadow); display:flex; justify-content:space-between; align-items:center;
    gap:12px; margin-bottom:10px; min-height:72px;
}
.queue-ticket { font-size:22px; font-weight:900; color:var(--primary); min-width:60px; }
.queue-info   { flex:1; }
.queue-client { font-weight:700; font-size:15px; }
.queue-meta   { font-size:12px; color:var(--muted); margin-top:2px; }

/* ── Modal ── */
.modal-overlay {
    position:fixed; inset:0; background:rgba(0,0,0,0.4); z-index:200;
    display:flex; align-items:center; justify-content:center; padding:16px;
}
.modal {
    background:var(--surface); border-radius:var(--radius); padding:28px;
    max-width:560px; width:100%; max-height:90vh; overflow-y:auto;
    box-shadow:0 20px 60px rgba(0,0,0,0.2);
}
.modal h3 { margin:0 0 20px; font-size:18px; font-weight:800; }

/* ── Upload drop zone ── */
.drop-zone {
    border:2px dashed var(--border); border-radius:var(--radius);
    padding:40px 20px; text-align:center; cursor:pointer;
    transition:border-color .15s, background .15s; color:var(--muted);
}
.drop-zone.drag-over { border-color:var(--primary); background:#ede9fe22; }
.drop-zone i { font-size:36px; margin-bottom:12px; display:block; }

/* ── Review screen split ── */
.review-split { display:grid; grid-template-columns:1fr 1fr; gap:20px; }
.review-panel { background:var(--surface); border-radius:var(--radius); padding:16px; box-shadow:var(--shadow); }
.review-panel h4 { margin:0 0 12px; font-size:14px; font-weight:700; color:var(--muted); text-transform:uppercase; }
.raw-text-area { font-family:monospace; font-size:12px; white-space:pre-wrap; overflow-y:auto; max-height:400px; line-height:1.7; color:var(--muted); }

/* ── Book search autocomplete ── */
.book-search-wrap { position:relative; }
.book-search-display { display:flex; align-items:center; gap:6px; min-height:36px; }
.book-match-label { font-size:13px; font-weight:600; color:var(--text-main); flex:1; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.book-match-none { font-size:13px; color:var(--muted); flex:1; font-style:italic; }
.book-search-input-wrap { display:flex; flex-direction:column; gap:4px; }
.book-search-dropdown { position:absolute; z-index:200; background:var(--surface); border:1px solid var(--border); border-radius:8px; box-shadow:0 8px 24px rgba(0,0,0,0.12); max-height:240px; overflow-y:auto; width:100%; }
.book-search-opt { padding:8px 12px; font-size:13px; cursor:pointer; border-bottom:1px solid var(--border); }
.book-search-opt:last-child { border-bottom:none; }
.book-search-opt:hover { background:var(--hover); }
.book-search-empty { padding:10px 12px; font-size:13px; color:var(--muted); font-style:italic; }
.book-search-create { background:rgba(6,182,212,.05); color:var(--primary,#06b6d4); font-style:italic; border-top:1px dashed rgba(6,182,212,.3) !important; }
.book-search-create:hover { background:rgba(6,182,212,.12) !important; }

/* ── Login ── */
.login-wrap {
    min-height:100vh; display:flex; align-items:center; justify-content:center;
    background:var(--sidebar-bg);
}
.login-card { background:var(--surface); border-radius:var(--radius); padding:36px; width:360px; box-shadow:0 20px 60px rgba(0,0,0,0.3); }
.login-logo { text-align:center; margin-bottom:28px; }
.login-logo i { font-size:42px; color:var(--primary); }
.login-logo h1 { margin:8px 0 0; font-size:28px; font-weight:900; }
.login-logo p  { margin:4px 0 0; color:var(--muted); font-size:14px; }

/* ── Print ── */
@media print {
    #sidebar, #topbar, #hamburger, #sidebar-overlay, .no-print { display:none !important; }
    #main { margin-left:0 !important; }
    #content { padding:0 !important; }
    body { background:white; font-size:13px; }
    .print-slip { max-width:360px; margin:0 auto; font-family:monospace; }
    .print-slip hr { border:1px dashed #999; }
}

/* ── Responsive ── */
@media (max-width:820px) {
    #sidebar { transform:translateX(-100%); }
    #sidebar.open { transform:translateX(0); }
    #sidebar-overlay.open { display:block; }
    #main { margin-left:0; }
    #hamburger { display:block; }
    .grid-3 { grid-template-columns:repeat(2,1fr); }
    .grid-4 { grid-template-columns:repeat(2,1fr); }
    .review-split { grid-template-columns:1fr; }
    #topbar { padding:0 12px; }
    #content { padding:12px; }
    .process-ticket { font-size:22px; }
    .progress-bar { width:100px; }
}
@media (max-width:480px) {
    .grid-2,.grid-3,.grid-4 { grid-template-columns:1fr; }
    .launchpad { grid-template-columns:repeat(2,1fr); }
}

/* ── Spinner ── */
.spinner { display:inline-block; width:20px; height:20px; border:3px solid var(--border); border-top-color:var(--primary); border-radius:50%; animation:spin .7s linear infinite; }
@keyframes spin { to { transform:rotate(360deg); } }

/* ── Misc ── */
.text-muted  { color:var(--muted); }
.text-small  { font-size:12px; }
.text-right  { text-align:right; }
.text-center { text-align:center; }
.font-mono   { font-family:monospace; }
.fw-bold     { font-weight:700; }
.fw-900      { font-weight:900; }
.d-none      { display:none !important; }
.w-full      { width:100%; }
hr { border:none; border-top:1px solid var(--border); margin:20px 0; }
