/* ==========================================================
   Consignment Dashboard — Core Stylesheet
   Colors are injected as CSS variables from PHP (see header includes)
   ========================================================== */

:root {
    --primary: #1E3A8A;
    --primary-dark: #16296b;
    --primary-light: #eef1fb;
    --secondary: #F59E0B;
    --secondary-dark: #b9790a;
    --text: #1f2430;
    --text-muted: #6b7280;
    --border: #e5e7eb;
    --bg: #f4f6fb;
    --surface: #ffffff;
    --success: #16a34a;
    --danger: #dc2626;
    --radius: 10px;
    --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 1px 3px rgba(16, 24, 40, .1);
    --shadow-lg: 0 8px 24px rgba(16, 24, 40, .12);
}

* { box-sizing: border-box; }

html, body {
    margin: 0;
    padding: 0;
    background: var(--bg);
    color: var(--text);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 15px;
    line-height: 1.5;
}

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

h1, h2, h3, h4 { margin: 0 0 .5em; font-weight: 700; letter-spacing: -0.01em; }

img { max-width: 100%; }

/* ---------------- Layout shells ---------------- */

.app-shell { display: flex; min-height: 100vh; }

.sidebar {
    width: 250px;
    flex-shrink: 0;
    background: var(--primary-dark);
    color: #fff;
    display: flex;
    flex-direction: column;
    position: sticky;
    top: 0;
    height: 100vh;
}

.sidebar .brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 20px 18px;
    border-bottom: 1px solid rgba(255,255,255,.12);
}
.sidebar .brand img { height: 34px; width: auto; border-radius: 6px; }
.sidebar .brand span { font-weight: 700; font-size: 16px; }

.sidebar nav { flex: 1; padding: 14px 10px; overflow-y: auto; }
.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: rgba(255,255,255,.78);
    padding: 10px 12px;
    border-radius: 8px;
    margin-bottom: 3px;
    font-size: 14px;
    font-weight: 500;
}
.sidebar nav a:hover { background: rgba(255,255,255,.08); text-decoration: none; color: #fff; }
.sidebar nav a.active { background: var(--secondary); color: #1f2430; }
.sidebar nav .nav-section-title {
    text-transform: uppercase;
    font-size: 11px;
    letter-spacing: .06em;
    color: rgba(255,255,255,.45);
    margin: 16px 12px 6px;
}
.sidebar .sidebar-footer {
    padding: 14px 18px;
    border-top: 1px solid rgba(255,255,255,.12);
    font-size: 13px;
}
.sidebar .sidebar-footer a { color: rgba(255,255,255,.75); }

.main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}

.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 14px 26px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 10;
}
.topbar h1 { font-size: 19px; margin: 0; }
.topbar .user-chip {
    display: flex; align-items: center; gap: 10px; font-size: 14px; color: var(--text-muted);
}
.topbar .user-chip .avatar {
    width: 32px; height: 32px; border-radius: 50%;
    background: var(--primary); color: #fff;
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 13px;
}

.content { padding: 24px 26px 60px; }

/* Mobile sidebar toggle */
.menu-toggle { display: none; background: none; border: none; font-size: 22px; cursor: pointer; color: var(--text); }
@media (max-width: 900px) {
    .sidebar { position: fixed; left: -260px; z-index: 100; transition: left .2s ease; box-shadow: var(--shadow-lg); }
    .sidebar.open { left: 0; }
    .menu-toggle { display: block; }
    .content { padding: 18px; }
    .topbar { padding: 12px 16px; }
}

/* ---------------- Cards / surfaces ---------------- */

.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px;
    margin-bottom: 20px;
}
.card-header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 16px; gap: 12px; flex-wrap: wrap;
}
.card-header h2 { font-size: 16px; margin: 0; }
.card-header p { margin: 2px 0 0; color: var(--text-muted); font-size: 13px; }

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 22px;
}
.stat-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 18px 20px;
    box-shadow: var(--shadow);
}
.stat-card .stat-label { font-size: 12.5px; color: var(--text-muted); text-transform: uppercase; letter-spacing: .04em; }
.stat-card .stat-value { font-size: 26px; font-weight: 800; margin-top: 6px; }
.stat-card .stat-icon {
    width: 38px; height: 38px; border-radius: 9px;
    display: flex; align-items: center; justify-content: center;
    background: var(--primary-light); color: var(--primary);
    font-size: 18px; margin-bottom: 10px;
}

/* ---------------- Forms ---------------- */

label { display: block; font-size: 13px; font-weight: 600; margin-bottom: 6px; color: var(--text); }
.form-row { margin-bottom: 16px; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(230px, 1fr)); gap: 16px; }
.form-hint { font-size: 12px; color: var(--text-muted); margin-top: 4px; }

input[type=text], input[type=email], input[type=password], input[type=number],
input[type=date], input[type=tel], input[type=search], input[type=file],
select, textarea {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    font-size: 14px;
    font-family: inherit;
    background: #fff;
    color: var(--text);
    transition: border-color .15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}
textarea { resize: vertical; min-height: 90px; }
input[type=color] { width: 60px; height: 40px; padding: 4px; cursor: pointer; }

.input-inline-color { display: flex; align-items: center; gap: 10px; }
.input-inline-color code { font-size: 13px; color: var(--text-muted); }

/* ---------------- Buttons ---------------- */

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 10px 18px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    border: 1px solid transparent;
    cursor: pointer;
    text-decoration: none;
    line-height: 1.2;
}
.btn:hover { text-decoration: none; }
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:hover { background: var(--primary-dark); }
.btn-secondary { background: var(--secondary); color: #1f2430; }
.btn-secondary:hover { background: var(--secondary-dark); }
.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }
.btn-outline:hover { background: #f9fafb; }
.btn-danger { background: #fef2f2; color: var(--danger); border-color: #fecaca; }
.btn-danger:hover { background: #fee2e2; }
.btn-sm { padding: 6px 12px; font-size: 13px; }
.btn-block { width: 100%; }
.btn[disabled] { opacity: .55; cursor: not-allowed; }

/* ---------------- Tables ---------------- */

.table-wrap { overflow-x: auto; }
table.data-table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
table.data-table th {
    text-align: left; padding: 11px 14px; background: #fafbfd;
    border-bottom: 1px solid var(--border); color: var(--text-muted);
    font-size: 12px; text-transform: uppercase; letter-spacing: .04em; white-space: nowrap;
}
table.data-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); vertical-align: middle; }
table.data-table tr:last-child td { border-bottom: none; }
table.data-table tr:hover td { background: #fafbfd; }
.table-actions { display: flex; gap: 8px; }

/* ---------------- Badges ---------------- */

.badge {
    display: inline-block; padding: 4px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 700; white-space: nowrap;
}
.badge-gray   { background: #f1f2f4; color: #52525b; }
.badge-blue   { background: #dbeafe; color: #1d4ed8; }
.badge-purple { background: #ede9fe; color: #6d28d9; }
.badge-amber  { background: #fef3c7; color: #b45309; }
.badge-green  { background: #dcfce7; color: #15803d; }
.badge-red    { background: #fee2e2; color: #b91c1c; }

/* ---------------- Alerts / flash ---------------- */

.alert { padding: 13px 16px; border-radius: 8px; margin-bottom: 18px; font-size: 14px; border: 1px solid transparent; }
.alert-success { background: #f0fdf4; color: #166534; border-color: #bbf7d0; }
.alert-error   { background: #fef2f2; color: #991b1b; border-color: #fecaca; }
.alert-info    { background: var(--primary-light); color: var(--primary-dark); border-color: #dbe2fb; }

/* ---------------- Login page ---------------- */

.auth-wrap {
    min-height: 100vh; display: flex; align-items: center; justify-content: center;
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    padding: 20px;
}
.auth-card {
    background: #fff; border-radius: 14px; padding: 38px 34px; width: 100%; max-width: 400px;
    box-shadow: var(--shadow-lg);
}
.auth-card .brand-row { text-align: center; margin-bottom: 22px; }
.auth-card .brand-row img { height: 46px; margin-bottom: 10px; }
.auth-card h1 { font-size: 20px; text-align: center; }
.auth-card p.sub { text-align: center; color: var(--text-muted); font-size: 13.5px; margin-bottom: 24px; }

/* ---------------- Public tracking page ---------------- */

.public-header {
    background: var(--surface); border-bottom: 1px solid var(--border);
    padding: 16px 5%;
    display: flex; align-items: center; justify-content: space-between;
}
.public-header .brand { display: flex; align-items: center; gap: 10px; }
.public-header .brand img { height: 36px; }
.public-header .brand span { font-weight: 800; font-size: 18px; color: var(--text); }

.hero {
    background: linear-gradient(135deg, var(--primary) 0%, var(--primary-dark) 100%);
    color: #fff;
    padding: 70px 5% 90px;
    text-align: center;
}
.hero h1 { font-size: 32px; margin-bottom: 10px; }
.hero p { font-size: 15.5px; opacity: .9; max-width: 520px; margin: 0 auto 28px; }

.track-form {
    max-width: 560px; margin: 0 auto; display: flex; gap: 10px;
    background: #fff; padding: 8px; border-radius: 12px; box-shadow: var(--shadow-lg);
}
.track-form input {
    border: none; flex: 1; padding: 12px 14px; font-size: 15px; border-radius: 8px;
}
.track-form input:focus { box-shadow: none; }
.track-form button {
    white-space: nowrap;
}

.public-wrap { max-width: 900px; margin: -50px auto 60px; padding: 0 5%; }

.timeline { position: relative; margin-left: 10px; padding-left: 30px; }
.timeline::before {
    content: ''; position: absolute; left: 6px; top: 6px; bottom: 6px; width: 2px; background: var(--border);
}
.timeline-item { position: relative; padding-bottom: 26px; }
.timeline-item:last-child { padding-bottom: 0; }
.timeline-item .dot {
    position: absolute; left: -30px; top: 2px; width: 14px; height: 14px; border-radius: 50%;
    background: var(--primary); border: 3px solid var(--primary-light);
}
.timeline-item.is-latest .dot { background: var(--secondary); border-color: #fef3c7; }
.timeline-item .ti-top { display: flex; align-items: center; gap: 10px; margin-bottom: 4px; flex-wrap: wrap; }
.timeline-item .ti-loc { font-weight: 700; }
.timeline-item .ti-date { font-size: 12.5px; color: var(--text-muted); }
.timeline-item .ti-msg { color: var(--text-muted); font-size: 13.5px; }

.progress-track { display: flex; align-items: center; margin: 26px 0 10px; }
.progress-step { flex: 1; text-align: center; position: relative; font-size: 11.5px; color: var(--text-muted); }
.progress-step .circle {
    width: 26px; height: 26px; border-radius: 50%; background: #e5e7eb; color: #fff;
    display: flex; align-items: center; justify-content: center; margin: 0 auto 6px; font-size: 13px; font-weight: 700;
    position: relative; z-index: 2;
}
.progress-step.done .circle { background: var(--success); }
.progress-step.current .circle { background: var(--secondary); }
.progress-step::before {
    content: ''; position: absolute; top: 13px; left: -50%; width: 100%; height: 2px; background: #e5e7eb; z-index: 1;
}
.progress-step:first-child::before { display: none; }
.progress-step.done::before { background: var(--success); }

.detail-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 18px; margin-bottom: 6px; }
.detail-grid .dg-label { font-size: 12px; text-transform: uppercase; letter-spacing: .04em; color: var(--text-muted); }
.detail-grid .dg-value { font-weight: 600; margin-top: 3px; }

.public-footer { text-align: center; padding: 30px; color: var(--text-muted); font-size: 13px; }

/* ---------------- Invoice ---------------- */

.invoice-sheet {
    max-width: 800px; margin: 30px auto; background: #fff; padding: 46px;
    border-radius: var(--radius); box-shadow: var(--shadow-lg);
}
.invoice-top { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 34px; flex-wrap: wrap; gap: 20px; }
.invoice-top .company img { height: 48px; margin-bottom: 10px; }
.invoice-top .company h2 { font-size: 18px; margin-bottom: 2px; }
.invoice-top .company p { margin: 0; color: var(--text-muted); font-size: 12.5px; }
.invoice-top .meta { text-align: right; }
.invoice-top .meta h1 { font-size: 26px; letter-spacing: .05em; color: var(--primary); margin-bottom: 6px; }
.invoice-top .meta p { margin: 2px 0; font-size: 13px; color: var(--text-muted); }
.invoice-top .meta .badge { margin-top: 6px; }

.invoice-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-bottom: 28px; }
.invoice-parties .party-label { font-size: 11.5px; text-transform: uppercase; color: var(--text-muted); letter-spacing: .05em; margin-bottom: 6px; }
.invoice-parties .party-name { font-weight: 700; margin-bottom: 2px; }
.invoice-parties p { margin: 1px 0; font-size: 13.5px; color: var(--text-muted); }

table.invoice-table { width: 100%; border-collapse: collapse; margin-bottom: 22px; }
table.invoice-table th {
    background: var(--primary); color: #fff; text-align: left; padding: 10px 14px; font-size: 12.5px; text-transform: uppercase;
}
table.invoice-table th:last-child, table.invoice-table td:last-child { text-align: right; }
table.invoice-table td { padding: 12px 14px; border-bottom: 1px solid var(--border); font-size: 14px; }

.invoice-totals { margin-left: auto; width: 280px; }
.invoice-totals .row { display: flex; justify-content: space-between; padding: 7px 0; font-size: 14px; color: var(--text-muted); }
.invoice-totals .row.grand { border-top: 2px solid var(--text); margin-top: 6px; padding-top: 12px; font-size: 17px; font-weight: 800; color: var(--text); }

.invoice-notes { margin-top: 30px; padding-top: 18px; border-top: 1px dashed var(--border); font-size: 13px; color: var(--text-muted); }
.invoice-actions { max-width: 800px; margin: 0 auto 20px; display: flex; justify-content: flex-end; gap: 10px; padding: 0 46px; }

@media print {
    .no-print { display: none !important; }
    body { background: #fff; }
    .invoice-sheet { box-shadow: none; margin: 0; max-width: 100%; }
}

/* ---------------- Misc ---------------- */

.empty-state { text-align: center; padding: 50px 20px; color: var(--text-muted); }
.empty-state .icon { font-size: 36px; margin-bottom: 10px; }

.tag-swatch { display: inline-block; width: 20px; height: 20px; border-radius: 5px; vertical-align: middle; border: 1px solid var(--border); }

.two-col { display: grid; grid-template-columns: 1.3fr 1fr; gap: 20px; align-items: start; }
@media (max-width: 900px) { .two-col { grid-template-columns: 1fr; } }

.color-swatch-preview { display: flex; align-items: center; gap: 12px; margin-top: 10px; }
.color-swatch-preview .swatch { width: 42px; height: 42px; border-radius: 8px; border: 1px solid var(--border); }
