@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');
@import url('open-iconic/font/css/open-iconic-bootstrap.min.css');

/* ─── CSS Variables ─────────────────────────────── */
:root {
    --color-primary: #1e40af;
    --color-primary-dark: #1e3a8a;
    --color-secondary: #64748b;
    --color-success: #16a34a;
    --color-warning: #d97706;
    --color-danger: #dc2626;
    --color-info: #0891b2;
    --color-bg: #f1f5f9;
    --color-surface: #ffffff;
    --color-border: #e2e8f0;
    --color-text: #1e293b;
    --color-text-muted: #64748b;
    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 1px 3px rgba(0,0,0,.1), 0 1px 2px rgba(0,0,0,.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,.07), 0 2px 4px rgba(0,0,0,.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,.1), 0 4px 6px rgba(0,0,0,.05);
    --transition: all 0.2s ease;
    --sidebar-width: 260px;
    --topbar-height: 56px;
}

/* ─── Base ───────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    font-family: 'Inter', 'Helvetica Neue', Arial, sans-serif;
    font-size: 14px;
    background-color: var(--color-bg);
    color: var(--color-text);
    -webkit-text-size-adjust: 100%;
    overscroll-behavior: none;
}

h1, h2, h3, h4, h5, h6 { font-weight: 600; }
h3 { font-size: 1.1rem; }
h5 { font-size: 0.95rem; }

a { color: var(--color-primary); text-decoration: none; }

/* ─── Bootstrap overrides ────────────────────────── */
.btn {
    border-radius: var(--radius-sm) !important;
    font-weight: 500;
    font-size: 0.85rem;
    padding: 0.45rem 1rem;
    transition: var(--transition);
}

.btn-primary { background-color: var(--color-primary) !important; border-color: var(--color-primary) !important; }
.btn-primary:hover { background-color: var(--color-primary-dark) !important; }
.btn-secondary { background-color: var(--color-secondary) !important; border-color: var(--color-secondary) !important; color: #fff !important; }

.btn-sm { padding: 0.3rem 0.75rem; font-size: 0.8rem; }
.btn-lg { padding: 0.65rem 1.5rem; font-size: 0.95rem; }

.btn-block { width: 100%; }

.card {
    border: 1px solid var(--color-border) !important;
    border-radius: var(--radius) !important;
    box-shadow: var(--shadow) !important;
}

.card-header {
    border-radius: var(--radius) var(--radius) 0 0 !important;
    padding: 0.75rem 1rem;
    font-size: 0.88rem;
}

.card-body { padding: 1rem; }

.form-control, .form-control-lg {
    border-radius: var(--radius-sm) !important;
    border: 1.5px solid var(--color-border) !important;
    font-size: 0.9rem !important;
    padding: 0.5rem 0.75rem !important;
    transition: var(--transition) !important;
}

.form-control:focus {
    border-color: var(--color-primary) !important;
    box-shadow: 0 0 0 3px rgba(30,64,175,.15) !important;
}

.form-group { margin-bottom: 0.9rem; }
.form-group label { font-weight: 500; margin-bottom: 0.3rem; display: block; color: var(--color-text); font-size: 0.83rem; }

.table { border-collapse: collapse; width: 100%; }
.table th { background: #f8fafc; color: var(--color-text-muted); font-weight: 600; font-size: 0.75rem; text-transform: uppercase; letter-spacing: 0.04em; border-bottom: 2px solid var(--color-border); padding: 0.65rem 0.75rem; }
.table td { padding: 0.65rem 0.75rem; vertical-align: middle; border-bottom: 1px solid var(--color-border); font-size: 0.85rem; }
.table-hover tbody tr:hover { background-color: #f8fafc; }

.badge { border-radius: 6px !important; font-weight: 500; font-size: 0.75rem; }
.badge-info { background-color: var(--color-info) !important; color: #fff !important; }
.badge-success { background-color: var(--color-success) !important; color: #fff !important; }
.badge-warning { background-color: var(--color-warning) !important; color: #fff !important; }
.badge-secondary { background-color: var(--color-secondary) !important; color: #fff !important; }

.alert { border-radius: var(--radius) !important; border: none !important; font-weight: 500; }
.alert-success { background: #dcfce7 !important; color: #15803d !important; }
.alert-danger { background: #fee2e2 !important; color: #dc2626 !important; }

.list-group-item { border-color: var(--color-border) !important; padding: 0.75rem 1rem; }

/* ─── Page Layout ────────────────────────────────── */
.page {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

main {
    flex: 1;
    padding: 1rem;
    padding-bottom: 6rem; /* space for bottom nav on mobile */
    max-width: 100%;
    overflow-x: hidden;
}

/* ─── Top Bar (mobile) ───────────────────────────── */
.admin-topbar {
    position: sticky;
    top: 0;
    z-index: 100;
    height: var(--topbar-height);
    background: linear-gradient(135deg, #1e40af 0%, #3b0764 100%);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1rem;
    box-shadow: var(--shadow-md);
}

.admin-topbar .brand {
    font-weight: 700;
    font-size: 1rem;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.admin-topbar .brand .brand-icon {
    width: 32px; height: 32px;
    background: rgba(255,255,255,0.2);
    border-radius: 8px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1rem;
}

.hamburger-btn {
    background: rgba(255,255,255,0.15);
    border: none;
    border-radius: 8px;
    padding: 0.4rem 0.6rem;
    cursor: pointer;
    color: #fff;
    font-size: 1.2rem;
    transition: var(--transition);
    display: none; /* shown on mobile only */
}

.hamburger-btn:hover { background: rgba(255,255,255,0.25); }

/* ─── Bottom Navigation (mobile) ────────────────── */
.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 200;
    background: var(--color-surface);
    border-top: 1px solid var(--color-border);
    display: none;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.08);
}

.bottom-nav nav {
    display: flex;
    align-items: stretch;
}

.bottom-nav .nav-item {
    flex: 1;
    padding: 0 !important;
}

.bottom-nav .nav-link {
    display: flex !important;
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    padding: 0.5rem 0.25rem !important;
    height: 60px;
    font-size: 0.65rem !important;
    font-weight: 500 !important;
    color: var(--color-text-muted) !important;
    border-radius: 0 !important;
    gap: 3px;
    text-decoration: none;
    transition: var(--transition);
    line-height: 1.2 !important;
}

.bottom-nav .nav-link .oi {
    font-size: 1.1rem !important;
    width: auto !important;
    display: block;
}

.bottom-nav .nav-link.active {
    color: var(--color-primary) !important;
    background-color: rgba(30,64,175,.06) !important;
}

.bottom-nav .nav-link:hover { color: var(--color-primary) !important; background: #f8fafc !important; }

/* ─── Sidebar (desktop) ──────────────────────────── */
.sidebar {
    width: var(--sidebar-width);
    background: linear-gradient(160deg, #1e40af 0%, #3b0764 100%);
    height: 100vh;
    position: sticky;
    top: 0;
    flex-shrink: 0;
    overflow-y: auto;
    display: none; /* hidden by default, shown on desktop */
}

.sidebar-header {
    padding: 1.25rem 1.25rem 0.75rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
}

.sidebar-brand {
    font-size: 1rem;
    font-weight: 700;
    color: #fff;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.sidebar-brand .brand-icon {
    width: 36px; height: 36px;
    background: rgba(255,255,255,0.2);
    border-radius: 10px;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.1rem;
}

.sidebar nav { padding: 0.75rem 0.75rem; }

.sidebar .nav-item { padding-bottom: 0.25rem !important; }
.sidebar .nav-item:first-of-type { padding-top: 0 !important; }

.sidebar .nav-link {
    color: rgba(255,255,255,0.75) !important;
    border-radius: var(--radius-sm) !important;
    padding: 0.65rem 0.9rem !important;
    height: auto !important;
    line-height: 1.4 !important;
    display: flex !important;
    align-items: center !important;
    gap: 0.6rem;
    font-size: 0.88rem !important;
    font-weight: 500 !important;
    transition: var(--transition) !important;
}

.sidebar .nav-link .oi {
    width: 1.2rem !important;
    font-size: 0.9rem !important;
    top: 0 !important;
    flex-shrink: 0;
}

.sidebar .nav-link:hover { color: #fff !important; background: rgba(255,255,255,0.12) !important; }
.sidebar .nav-link.active { color: #fff !important; background: rgba(255,255,255,0.22) !important; font-weight: 600 !important; }

/* ─── Overlay for mobile sidebar ─────────────────── */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 150;
}

.sidebar.sidebar-mobile-open {
    display: block;
    position: fixed;
    z-index: 160;
    height: 100vh;
    top: 0;
    left: 0;
}

/* ─── Content Cards & Page header ────────────────── */
.page-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 1.25rem;
}

.page-header h3 { margin: 0; font-size: 1.05rem; }
.page-header .page-actions { display: flex; gap: 0.5rem; flex-wrap: wrap; }

/* ─── Mobile card list (replacing table on mobile) ── */
.order-card {
    background: var(--color-surface);
    border-radius: var(--radius);
    border: 1px solid var(--color-border);
    box-shadow: var(--shadow);
    padding: 0.9rem 1rem;
    margin-bottom: 0.75rem;
    transition: var(--transition);
}

.order-card:hover { box-shadow: var(--shadow-md); transform: translateY(-1px); }

.order-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 0.5rem;
}

.order-card-code { font-weight: 700; font-size: 0.9rem; color: var(--color-primary); }

.order-card-body {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.4rem 1rem;
    font-size: 0.8rem;
}

.order-card-body .label { color: var(--color-text-muted); font-size: 0.72rem; font-weight: 500; display: block; }
.order-card-body .value { font-weight: 600; }

.order-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: 0.75rem;
    padding-top: 0.6rem;
    border-top: 1px solid var(--color-border);
}

/* ─── Detail page ──────────────────────────── */
.detail-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1rem;
}

/* ─── Info rows ──────────────────────────────────── */
.info-row {
    display: flex;
    justify-content: space-between;
    padding: 0.45rem 0;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.85rem;
    gap: 1rem;
}

.info-row:last-child { border-bottom: none; }
.info-row .info-label { color: var(--color-text-muted); font-weight: 500; flex-shrink: 0; }
.info-row .info-value { font-weight: 600; text-align: right; word-break: break-word; }

/* ─── Timeline ───────────────────────────────────── */
.timeline { list-style: none; padding: 0; margin: 0; position: relative; }
.timeline::before { content: ''; position: absolute; left: 16px; top: 0; bottom: 0; width: 2px; background: var(--color-border); }

.timeline-item { display: flex; gap: 1rem; padding-bottom: 1.25rem; position: relative; }
.timeline-item:last-child { padding-bottom: 0; }

.timeline-dot {
    width: 32px; height: 32px;
    background: var(--color-primary);
    border-radius: 50%;
    flex-shrink: 0;
    display: flex; align-items: center; justify-content: center;
    color: #fff;
    font-size: 0.75rem;
    z-index: 1;
    box-shadow: 0 0 0 3px rgba(30,64,175,0.15);
}

.timeline-content { flex: 1; padding-top: 0.15rem; }
.timeline-status { font-weight: 600; font-size: 0.88rem; color: var(--color-text); }
.timeline-time { font-size: 0.73rem; color: var(--color-text-muted); margin-top: 1px; }
.timeline-note { font-size: 0.8rem; color: var(--color-text-muted); margin-top: 3px; }
.timeline-location { font-size: 0.78rem; color: var(--color-info); margin-top: 3px; }

/* ─── Quick Update ───────────────────────────────── */
.scan-area {
    background: linear-gradient(135deg, #eff6ff, #f5f3ff);
    border: 2px dashed var(--color-primary);
    border-radius: var(--radius);
    padding: 1.5rem;
    text-align: center;
}

.scan-input {
    font-size: 1.4rem !important;
    text-align: center !important;
    font-weight: 600 !important;
    letter-spacing: 0.1em !important;
}

/* ─── Filters bar ────────────────────────────────── */
.filters-bar {
    display: flex;
    gap: 0.5rem;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.filters-bar .form-control { flex: 1; min-width: 0; }

/* ─── Error UI ──────────────────────────────────── */
#blazor-error-ui {
    background: #fef3c7;
    border-top: 2px solid #f59e0b;
    bottom: 0;
    display: none;
    left: 0;
    padding: 0.75rem 1.25rem;
    position: fixed;
    width: 100%;
    z-index: 1000;
    font-size: 0.85rem;
}

#blazor-error-ui .dismiss { cursor: pointer; position: absolute; right: 0.75rem; top: 0.5rem; }

.blazor-error-boundary {
    background: #b32121;
    padding: 1rem;
    color: white;
    border-radius: var(--radius);
}

/* ─── Utilities ──────────────────────────────────── */
.text-primary { color: var(--color-primary) !important; }
.text-success { color: var(--color-success) !important; }
.text-danger { color: var(--color-danger) !important; }
.text-muted { color: var(--color-text-muted) !important; }
.fw-600 { font-weight: 600; }
.fs-sm { font-size: 0.78rem; }
.gap-2 { gap: 0.5rem; }

/* ─── Scrollbar ──────────────────────────────────── */
::-webkit-scrollbar { width: 5px; height: 5px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

/* ─── Responsive: Mobile ─────────────────────────── */
@media (max-width: 767.98px) {
    .admin-topbar { display: flex; }
    .hamburger-btn { display: block; }
    .bottom-nav { display: block; }
    .sidebar { display: none; }
    main { padding: 0.75rem; }
    
    /* hide desktop table, show card list */
    .desktop-table { display: none; }
    .mobile-cards { display: block; }
    
    .page-header h3 { font-size: 0.95rem; }
    .page-header .page-actions .btn { font-size: 0.78rem; padding: 0.35rem 0.7rem; }
    
    .col-6 { padding-left: 0.5rem; padding-right: 0.5rem; }
}

/* ─── Responsive: Desktop ────────────────────────── */
@media (min-width: 768px) {
    .page { flex-direction: row; }
    .admin-topbar { display: none; }
    .hamburger-btn { display: none; }
    .bottom-nav { display: none; }
    .sidebar { display: block; }

    main {
        padding: 1.5rem;
        padding-bottom: 1.5rem;
    }

    .detail-grid { grid-template-columns: 1fr 1fr; }

    .desktop-table { display: table; }
    .mobile-cards { display: none; }
}

/* ─── Responsive: Tablet ─────────────────────────── */
@media (min-width: 768px) and (max-width: 1023px) {
    :root { --sidebar-width: 220px; }
    main { padding: 1rem; }
}

/* ─── Print ──────────────────────────────────────── */
@media print {
    .admin-topbar, .bottom-nav, .sidebar, .no-print { display: none !important; }
    main { padding: 0; }
}
