/* ============================================================
   Velocity Helpdesk — Design Tokens
   Palette: warm signal-orange on clean neutral surface, with
   status colors doubling as the pipeline's visual vocabulary.
   Display face: Poppins (matches Velocity Computers branding)
   Body/data face: Inter (tighter, better for tables & numbers)
   Signature: the horizontal "Repair Journey" rail on ticket detail
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@500;600;700&family=Inter:wght@400;500;600&display=swap');

:root {
    --ink: #201a15;
    --ink-soft: #6b5f54;
    --paper: #faf7f3;
    --card: #ffffff;
    --line: #ece4db;
    --orange: #ff6a1a;
    --orange-dark: #e4550a;
    --orange-wash: #fff1e8;

    --open: #e67e22;
    --progress: #2d9cdb;
    --wait-cust: #9b59b6;
    --wait-parts: #f2994a;
    --resolved: #219653;
    --closed: #8a7f74;
    --urgent: #eb5757;

    --radius: 12px;
    --shadow: 0 2px 10px rgba(32, 26, 21, 0.06);
    --shadow-lift: 0 8px 24px rgba(32, 26, 21, 0.10);
}

* { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Inter', -apple-system, sans-serif;
    background: var(--paper);
    color: var(--ink);
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

h1, h2, h3, .brand {
    font-family: 'Poppins', sans-serif;
    font-weight: 600;
    letter-spacing: -0.01em;
    margin: 0;
}
.brand { text-decoration: none; display: inline-block; }
.brand:hover { text-decoration: none; }

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

/* ---------- Layout shell ---------- */
.app-shell { display: block; min-height: 100vh; }

.sidebar {
    width: 220px;
    background: var(--ink);
    color: #f2ece5;
    display: flex;
    flex-direction: column;
    padding: 24px 0;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    overflow-y: auto;
    z-index: 100;
}

.sidebar-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px 24px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    margin-bottom: 12px;
}
.sidebar .brand {
    color: #fff;
    font-size: 1.15rem;
    padding: 0;
    border-bottom: none;
    margin-bottom: 0;
}
.sidebar .brand span { color: var(--orange); }
.mobile-nav-toggle {
    display: none;
    background: none;
    border: none;
    color: #fff;
    font-size: 1.4rem;
    line-height: 1;
    cursor: pointer;
    padding: 6px 8px;
}
.sidebar-drawer { display: flex; flex-direction: column; flex: 1; }
.nav-backdrop { display: none; }
body.nav-locked { overflow: hidden; }

.sidebar nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #cfc4b8;
    padding: 11px 24px;
    font-size: 0.92rem;
    font-weight: 500;
    text-decoration: none;
    border-left: 3px solid transparent;
}
.sidebar nav a:hover { color: #fff; background: rgba(255,255,255,0.04); }
.sidebar nav a.active {
    color: #fff;
    background: rgba(255,106,26,0.12);
    border-left-color: var(--orange);
}
.sidebar .staff-box {
    margin-top: auto;
    padding: 16px 24px 0;
    border-top: 1px solid rgba(255,255,255,0.1);
    font-size: 0.82rem;
    color: #a89c8f;
}
.sidebar .staff-box a { color: #cfc4b8; }

.main {
    margin-left: 220px;
    padding: 28px 36px 60px;
    max-width: 1200px;
    box-sizing: border-box;
}

.topbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}
.topbar h1 { font-size: 1.4rem; }
.topbar .sub { color: var(--ink-soft); font-size: 0.88rem; margin-top: 2px; }

/* ---------- Buttons ---------- */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.88rem;
    border: none;
    cursor: pointer;
    text-decoration: none;
    font-family: inherit;
}
.btn-primary { background: var(--orange); color: #fff; }
.btn-primary:hover { background: var(--orange-dark); text-decoration: none; }
.btn-outline { background: transparent; border: 1.5px solid var(--line); color: var(--ink); }
.btn-outline:hover { border-color: var(--orange); text-decoration: none; }
.btn-sm { padding: 6px 12px; font-size: 0.8rem; }
.btn-danger { background: #fdecec; color: #c0392b; }

/* ---------- Cards & stats ---------- */
.card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.stat-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 14px;
    margin-bottom: 26px;
}
.stat-card {
    background: var(--card);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 16px 18px;
    box-shadow: var(--shadow);
}
.stat-card .num { font-family: 'Poppins'; font-size: 1.7rem; font-weight: 700; }
.stat-card .label { color: var(--ink-soft); font-size: 0.8rem; margin-top: 2px; }
.stat-card.accent .num { color: var(--orange-dark); }

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th {
    text-align: left;
    font-size: 0.74rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    color: var(--ink-soft);
    padding: 10px 14px;
    border-bottom: 1px solid var(--line);
}
td {
    padding: 13px 14px;
    border-bottom: 1px solid var(--line);
    font-size: 0.9rem;
    vertical-align: middle;
}
tr:hover td { background: var(--orange-wash); }
.ticket-row { cursor: pointer; }
.edit-staff-row { display: none; }
.edit-staff-row.open-edit { display: table-row; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 0.76rem;
    font-weight: 600;
    color: #fff;
}
.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: rgba(255,255,255,0.85);
}

/* ---------- Forms ---------- */
label { display: block; font-size: 0.82rem; font-weight: 600; margin: 14px 0 5px; color: var(--ink); }
input, select, textarea {
    width: 100%;
    min-width: 0;
    padding: 10px 12px;
    border: 1.5px solid var(--line);
    border-radius: 8px;
    font-family: inherit;
    font-size: 0.92rem;
    background: #fff;
    color: var(--ink);
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--orange);
    box-shadow: 0 0 0 3px var(--orange-wash);
}
.field-row { display: grid; grid-template-columns: minmax(0, 1fr) minmax(0, 1fr); gap: 16px; }
.help-text { font-size: 0.78rem; color: var(--ink-soft); margin-top: 4px; }

/* ---------- Password show/hide toggle ---------- */
.password-wrap { position: relative; }
.password-wrap input { padding-right: 42px; }
.password-toggle {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    cursor: pointer;
    padding: 6px;
    color: var(--ink-soft);
    display: flex;
    align-items: center;
    border-radius: 6px;
}
.password-toggle:hover { color: var(--ink); background: var(--orange-wash); }

/* ---------- Login page ---------- */
.login-wrap {
    min-height: 100vh;
    display: flex; align-items: center; justify-content: center;
    background: linear-gradient(160deg, #201a15 0%, #3a2c1f 100%);
    padding: 20px;
}
.login-card {
    background: #fff;
    border-radius: 16px;
    padding: 40px 36px;
    width: 100%;
    max-width: 360px;
    box-shadow: var(--shadow-lift);
}
.login-card .brand { font-size: 1.4rem; margin-bottom: 4px; color: var(--ink); }
.login-card .brand span { color: var(--orange); }
.login-card p.tagline { color: var(--ink-soft); font-size: 0.85rem; margin-bottom: 20px; }
.login-card .btn { width: 100%; justify-content: center; margin-top: 18px; }
.error-msg { background: #fdecec; color: #c0392b; padding: 10px 14px; border-radius: 8px; font-size: 0.85rem; margin-bottom: 14px; }

/* ============================================================
   SIGNATURE ELEMENT: The Repair Journey rail
   A horizontal progress line on the ticket detail page that
   visualizes where a device is in its repair/replace lifecycle —
   the one thing this product is fundamentally about.
   ============================================================ */
.journey-rail {
    display: flex;
    align-items: flex-start;
    margin: 8px 0 30px;
    overflow-x: auto;
    padding-bottom: 4px;
}
.journey-step {
    flex: 1;
    min-width: 110px;
    text-align: center;
    position: relative;
}
.journey-step .dot {
    width: 16px; height: 16px;
    border-radius: 50%;
    background: var(--line);
    border: 3px solid var(--paper);
    box-shadow: 0 0 0 1.5px var(--line);
    margin: 0 auto 8px;
    position: relative;
    z-index: 2;
}
.journey-step.done .dot { background: var(--orange); box-shadow: 0 0 0 1.5px var(--orange); }
.journey-step.current .dot { background: var(--orange); box-shadow: 0 0 0 4px var(--orange-wash), 0 0 0 1.5px var(--orange); }
.journey-step::after {
    content: '';
    position: absolute;
    top: 7px; left: 50%; width: 100%;
    height: 2px;
    background: var(--line);
    z-index: 1;
}
.journey-step:last-child::after { display: none; }
.journey-step.done::after { background: var(--orange); }
.journey-step .step-label { font-size: 0.76rem; font-weight: 600; color: var(--ink-soft); }
.journey-step.done .step-label, .journey-step.current .step-label { color: var(--ink); }

/* ---------- Ticket detail ---------- */
.ticket-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 6px; }
.detail-grid { display: grid; grid-template-columns: minmax(0, 2fr) minmax(0, 1fr); gap: 20px; align-items: start; }
.panel-title { font-size: 0.78rem; text-transform: uppercase; letter-spacing: 0.05em; color: var(--ink-soft); margin-bottom: 12px; font-weight: 700; }
.info-row { display: flex; justify-content: space-between; padding: 8px 0; border-bottom: 1px dashed var(--line); font-size: 0.87rem; }
.info-row span:first-child { color: var(--ink-soft); }
.info-row span:last-child { font-weight: 600; text-align: right; }

.history-item { display: flex; gap: 12px; padding: 12px 0; border-bottom: 1px solid var(--line); }
.history-item .avatar {
    width: 30px; height: 30px; border-radius: 50%;
    background: var(--orange-wash); color: var(--orange-dark);
    display: flex; align-items: center; justify-content: center;
    font-weight: 700; font-size: 0.78rem; flex-shrink: 0;
}
.history-item .meta { font-size: 0.76rem; color: var(--ink-soft); margin-bottom: 2px; }

/* ---------- Chat attachments (photos/videos inline in replies) ---------- */
.chat-attach-label {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    margin-top: 10px;
    padding: 6px 12px;
    border: 1.5px dashed var(--line);
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--ink-soft);
    cursor: pointer;
}
.chat-attach-label:hover { border-color: var(--orange); color: var(--ink); }
.chat-media { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 10px; }
.chat-media-thumb {
    width: 140px; height: 140px;
    object-fit: cover;
    border-radius: 8px;
    border: 1px solid var(--line);
    cursor: pointer;
}
.chat-media-video {
    max-width: 260px;
    max-height: 200px;
    border-radius: 8px;
    border: 1px solid var(--line);
    background: #000;
}

/* ---------- Public tracking page ---------- */
.track-wrap {
    min-height: 100vh;
    background: var(--paper);
    padding: 60px 20px;
}
.track-card {
    max-width: 480px;
    width: 100%;
    margin: 0 auto;
    background: var(--card);
    border-radius: 16px;
    box-shadow: var(--shadow-lift);
    padding: 32px;
}
.track-card h1 { font-size: 1.3rem; margin-bottom: 4px; }
.track-card .brand span { color: var(--orange); }

/* ---------- Misc ---------- */
.empty-state { text-align: center; padding: 50px 20px; color: var(--ink-soft); }
.empty-state h3 { color: var(--ink); margin-bottom: 6px; }
.flex-between { display: flex; justify-content: space-between; align-items: center; }
.muted { color: var(--ink-soft); }
.mt-16 { margin-top: 16px; }
.tag-pill {
    display: inline-block; padding: 3px 10px; border-radius: 20px;
    background: var(--orange-wash); color: var(--orange-dark);
    font-size: 0.76rem; font-weight: 600; margin-right: 4px;
}

/* ---------- Tables: scrollable on narrow screens instead of breaking layout ---------- */
.table-responsive { overflow-x: auto; -webkit-overflow-scrolling: touch; }
.table-responsive table { min-width: 640px; }

/* ============================================================
   RESPONSIVE - tablet and below (~1024px: iPads, small laptops,
   split-screen windows)
   ============================================================ */
@media (max-width: 1024px) {
    .detail-grid { grid-template-columns: 1fr; }
    .main { max-width: 100%; }
}

/* ============================================================
   RESPONSIVE - mobile (~800px and below: phones, narrow tablets)
   ============================================================ */
@media (max-width: 800px) {
    .app-shell { display: block; }

    .sidebar {
        width: 100%;
        flex-direction: column;
        padding: 0;
        position: fixed;
        top: 0;
        left: 0;
        height: auto;
        overflow-y: visible;
        z-index: 200;
    }
    .sidebar-top {
        padding: 14px 18px;
        border-bottom: none;
        margin-bottom: 0;
        position: relative;
        z-index: 210;
        background: var(--ink);
    }
    .mobile-nav-toggle { display: block; }

    /* Nav + account box slide in together as one drawer from the left edge,
       instead of dropping down under the top bar. */
    .sidebar-drawer {
        position: fixed;
        top: 0;
        left: -280px;
        width: 260px;
        max-width: 80vw;
        height: 100vh;
        background: var(--ink);
        flex-direction: column;
        z-index: 300;
        box-shadow: 6px 0 28px rgba(0,0,0,0.28);
        padding-top: 64px;
        overflow-y: auto;
        transition: left 0.28s ease;
    }
    .sidebar.nav-open .sidebar-drawer { left: 0; }

    /* Backdrop lives INSIDE .sidebar so its z-index is compared against
       sidebar-top/sidebar-drawer within the same stacking context, rather
       than against the whole .sidebar element as a sibling would be -
       otherwise it can end up covering the drawer and blocking taps. */
    .nav-backdrop {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(20, 15, 10, 0.45);
        z-index: 1;
    }
    .sidebar.nav-open .nav-backdrop { display: block; }

    .sidebar .staff-box {
        margin-top: auto;
        padding: 16px 24px 20px;
        border-top: 1px solid rgba(255,255,255,0.1);
    }

    .main { margin-left: 0; padding: 18px 16px 50px; }
    .field-row { grid-template-columns: 1fr; }
    .topbar { flex-wrap: wrap; gap: 12px; }
    .topbar h1 { font-size: 1.2rem; }

    .journey-rail { margin: 8px 0 22px; }
    .journey-step { min-width: 92px; }
}

/* ============================================================
   RESPONSIVE - small phones (~480px and below)
   ============================================================ */
@media (max-width: 480px) {
    .main { padding: 14px 12px 40px; }
    .card { padding: 16px; }
    .stat-grid { grid-template-columns: repeat(auto-fit, minmax(130px, 1fr)); gap: 10px; }
    .stat-card { padding: 12px 14px; }
    .stat-card .num { font-size: 1.4rem; }

    .journey-step { min-width: 72px; }
    .journey-step .dot { width: 13px; height: 13px; }
    .journey-step .step-label { font-size: 0.66rem; }

    .login-card, .track-card { padding: 26px 20px; }
    .login-wrap { padding: 16px; }
    .track-wrap { padding: 30px 12px; }

    .detail-header, .ticket-header { flex-direction: column; gap: 10px; align-items: flex-start; }
}
