/* ============================================================
   ITSM Helpdesk - Stylesheet (Trubyte theme)
   Navy text, bright green accent, white cards with soft shadows,
   pill badges and rounded buttons. Class names are unchanged, so
   every existing page picks up the new look automatically.
   ============================================================ */

@import url('https://fonts.googleapis.com/css2?family=Archivo:wght@600;700;800&family=Inter:wght@400;500;600&family=IBM+Plex+Mono:wght@500;600&display=swap');

:root {
    /* ---- Brand palette ---- */
    --tb-navy:        #0c1b5c;  /* headings, primary text on light      */
    --tb-navy-deep:   #0a1530;  /* dark bars, ticket stub               */
    --tb-green:       #00c817;  /* primary accent / buttons             */
    --tb-green-hover: #00b014;
    --tb-green-dark:  #0a6b16;  /* text on light-green pills            */
    --tb-green-tint:  #e6f9ea;  /* pill / active-nav background         */
    --tb-green-glow:  rgba(0, 200, 23, 0.14);

    /* ---- Names used by the rest of the stylesheet ---- */
    --tsa-blue-dark:  var(--tb-navy);
    --tsa-blue-main:  var(--tb-green);
    --tsa-blue-light: #4fe063;
    --tsa-blue-hover: var(--tb-green-hover);

    --bg-app:        #f7faf8;
    --bg-card:       #ffffff;
    --text-heading:  var(--tb-navy);
    --text-body:     #3d4a63;
    --text-subtle:   #6b7790;
    --border-color:  #dde4ee;
    --border-subtle: #e9eef5;

    /* ---- Legacy variable names (still used inline by some pages) ---- */
    --ink-900: var(--tb-navy);
    --ink-800: #24325f;
    --ink-700: #3d4a63;

    --indigo-600: var(--tb-green);
    --indigo-500: var(--tb-green-hover);

    --brass-600: var(--tb-green-dark);
    --brass-500: var(--tb-green);
    --brass-400: #4fe063;
    --brass-100: var(--tb-green-tint);

    /* Status colors */
    --coral-600: #dc2626;
    --coral-100: #fee2e2;
    --sage-600:  #0a8f1c;
    --sage-100:  var(--tb-green-tint);
    --amber-600: #b78103;
    --amber-100: #fff8e1;
    --slate-600: #6b7790;
    --slate-500: #6b7790;
    --slate-200: #dde4ee;
    --slate-100: #e9eef5;

    /* Surfaces */
    --paper-0: #f7faf8;
    --paper-1: #ffffff;
    --white:   #ffffff;

    --radius: 10px;
    --shadow-sm: 0 2px 8px rgba(12, 27, 92, 0.05);
    --shadow-md: 0 8px 24px rgba(12, 27, 92, 0.08);
    --shadow-lg: 0 18px 48px rgba(12, 27, 92, 0.12);
    --shadow-green: 0 6px 18px rgba(0, 200, 23, 0.28);

    --font-display: 'Archivo', 'Inter', 'Segoe UI', sans-serif;
    --font-body: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    --font-mono: 'IBM Plex Mono', 'SFMono-Regular', Consolas, monospace;
}

* { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
    margin: 0;
    font-family: var(--font-body);
    background-color: var(--paper-0);
    background-image:
        radial-gradient(ellipse 60% 40% at 100% 0%, var(--tb-green-glow), transparent 70%),
        radial-gradient(ellipse 50% 35% at 0% 100%, rgba(12, 27, 92, 0.04), transparent 70%);
    background-attachment: fixed;
    color: var(--text-body);
    font-size: 14px;
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

img { max-width: 100%; }

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

h1, h2, h3 { font-family: var(--font-display); font-weight: 700; letter-spacing: -0.02em; color: var(--text-heading); }

::selection { background: var(--tb-green-tint); color: var(--tb-navy); }

/* ---------- Topbar ---------- */
.topbar {
    background: #ffffff;
    color: var(--tb-navy);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px 20px;
    padding: 10px 28px;
    min-height: 68px;
    border-bottom: 1px solid var(--border-subtle);
    box-shadow: 0 1px 0 rgba(12, 27, 92, 0.02);
    position: relative;
    z-index: 10;
    flex-wrap: wrap;
}
.topbar-brand {
    font-family: var(--font-display);
    font-weight: 800;
    font-size: 18px;
    letter-spacing: -0.02em;
    color: var(--tb-navy);
    display: flex;
    align-items: center;
    gap: 10px;
    min-width: 0;
}
.topbar-brand span:last-child {
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}
.brand-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 34px; height: 34px;
    background: var(--tb-green-tint);
    color: var(--tb-green-dark);
    border-radius: 50%;
    font-size: 16px;
    flex-shrink: 0;
}
.topbar-nav {
    display: flex;
    gap: 2px;
    flex-wrap: wrap;
    flex: 1 1 auto;
    justify-content: center;
}
.topbar-nav a {
    color: var(--tb-navy);
    font-size: 13.5px;
    font-weight: 500;
    padding: 9px 14px;
    border-radius: 10px;
    transition: background 0.15s, color 0.15s;
    white-space: nowrap;
}
.topbar-nav a:hover { background: #f1f5fb; color: var(--tb-navy); text-decoration: none; }
.topbar-nav a.active {
    background: var(--tb-green-tint);
    color: var(--tb-green-dark);
    font-weight: 600;
}
.topbar-user {
    display: flex;
    align-items: center;
    gap: 14px;
    font-size: 13px;
    color: var(--text-subtle);
    flex-wrap: wrap;
}
.topbar-user small { color: var(--text-subtle); }
.topbar-user strong { color: var(--tb-navy); font-weight: 600; }
.topbar-user .topbar-link {
    color: var(--tb-navy);
    font-weight: 500;
    padding: 7px 12px;
    border-radius: 10px;
    transition: background 0.15s;
}
.topbar-user .topbar-link:hover { background: #f1f5fb; text-decoration: none; }
.topbar-user .topbar-link.active { background: var(--tb-green-tint); color: var(--tb-green-dark); font-weight: 600; }
.btn-logout {
    background: #ffffff;
    color: var(--tb-navy) !important;
    padding: 8px 16px;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 600;
    border: 1.5px solid var(--tb-navy);
    transition: all 0.15s;
    white-space: nowrap;
}
.btn-logout:hover { background: var(--tb-navy); color: #ffffff !important; text-decoration: none; }

/* ---------- Layout ---------- */
.main-container {
    max-width: 1100px;
    margin: 32px auto;
    padding: 0 20px;
    animation: fadeUp 0.35s ease-out;
    width: 100%;
}
.main-container:has(.card table) { max-width: 1440px; }

@keyframes fadeUp {
    from { opacity: 0; transform: translateY(6px); }
    to   { opacity: 1; transform: translateY(0); }
}

.card {
    background: var(--paper-1);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    box-shadow: var(--shadow-sm);
    padding: 26px;
    margin-bottom: 22px;
    transition: box-shadow 0.2s, border-color 0.2s;
    max-width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}
.card:hover { box-shadow: var(--shadow-md); }
.card h2, .card h1 { margin-top: 0; }

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 22px;
    flex-wrap: wrap;
    gap: 10px;
}
.page-header h1 {
    font-size: 26px;
    font-weight: 800;
    color: var(--tb-navy);
    margin: 0;
    position: relative;
    padding-left: 16px;
}
.page-header h1::before {
    content: '';
    position: absolute;
    left: 0; top: 5px; bottom: 5px;
    width: 5px;
    background: var(--tb-green);
    border-radius: 3px;
}

/* ---------- Forms ---------- */
label { display: block; font-family: var(--font-display); font-weight: 600; margin-bottom: 6px; font-size: 13px; color: var(--tb-navy); }
input[type=text], input[type=password], input[type=email], input[type=file],
select, textarea {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius);
    font-size: 16px; /* 16px prevents iOS Safari from auto-zooming on focus */
    font-family: var(--font-body);
    margin-bottom: 16px;
    background: var(--white);
    color: var(--tb-navy);
    transition: border-color 0.15s, box-shadow 0.15s;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--tb-green);
    box-shadow: 0 0 0 4px var(--tb-green-glow);
}
textarea { resize: vertical; min-height: 100px; }

.btn {
    display: inline-block;
    padding: 11px 22px;
    border-radius: var(--radius);
    border: none;
    font-size: 14px;
    font-family: var(--font-display);
    font-weight: 700;
    cursor: pointer;
    transition: transform 0.12s, box-shadow 0.12s, background 0.12s;
}
.btn:active { transform: translateY(1px); }
.btn-primary { background: var(--tb-green); color: #052e10; box-shadow: var(--shadow-green); }
.btn-primary:hover { background: var(--tb-green-hover); color: #052e10; box-shadow: 0 8px 22px rgba(0, 200, 23, 0.38); text-decoration: none; }
.btn-secondary { background: var(--white); color: var(--tb-navy); border: 2px solid var(--tb-navy); padding: 9px 20px; }
.btn-secondary:hover { background: var(--tb-navy); color: #ffffff; text-decoration: none; }
.btn-danger { background: #dc2626; color: var(--white); }
.btn-danger:hover { background: #b91c1c; color: var(--white); }

.form-error {
    background: var(--coral-100);
    border-left: 4px solid var(--coral-600);
    color: #8f2e24;
    padding: 12px 16px;
    border-radius: 0 10px 10px 0;
    margin-bottom: 16px;
    font-size: 13px;
}
.form-success {
    background: var(--tb-green-tint);
    border-left: 4px solid var(--tb-green);
    color: var(--tb-green-dark);
    padding: 12px 16px;
    border-radius: 0 10px 10px 0;
    margin-bottom: 16px;
    font-size: 13px;
}

/* ---------- Login ---------- */
body:has(.login-wrap) {
    background-image:
        radial-gradient(ellipse 70% 50% at 85% 10%, rgba(0, 200, 23, 0.20), transparent 70%),
        radial-gradient(ellipse 50% 40% at 10% 90%, rgba(12, 27, 92, 0.07), transparent 70%);
}
.login-wrap {
    max-width: 420px;
    margin: 64px auto;
    animation: fadeUp 0.4s ease-out;
    width: 100%;
    padding: 0 16px;
}
.login-wrap .card {
    text-align: left;
    padding: 36px 34px 30px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-subtle);
    border-radius: 20px;
}
.login-wrap h1 {
    font-size: 24px;
    font-weight: 800;
    text-align: center;
    color: var(--tb-navy);
    margin-bottom: 8px;
}
.login-wrap .subtitle {
    display: table;
    margin: 0 auto 26px;
    padding: 5px 14px;
    background: var(--tb-green-tint);
    color: var(--tb-green-dark);
    border: 1px solid #c9f0d0;
    border-radius: 999px;
    text-align: center;
    font-family: var(--font-body);
    font-size: 11.5px;
    font-weight: 700;
    letter-spacing: 0.08em;
    text-transform: uppercase;
}

/* ---------- Tables ---------- */
table { width: 100%; border-collapse: collapse; }
th, td {
    text-align: left;
    padding: 13px 12px;
    border-bottom: 1px solid var(--slate-100);
    font-size: 13px;
}
th {
    color: var(--tb-navy);
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    background: #f3f7fb;
    border-bottom: 2px solid var(--tb-green);
}
th:first-child { border-top-left-radius: 10px; }
th:last-child  { border-top-right-radius: 10px; }
tr { transition: background 0.12s; }
tr:hover td { background: #f6fcf7; }

/* ---------- Badges ---------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 5px 12px;
    border-radius: 999px;
    font-size: 11.5px;
    font-weight: 700;
    font-family: var(--font-display);
    letter-spacing: 0.03em;
    white-space: nowrap;
}
.badge::before {
    content: '';
    width: 6px; height: 6px;
    border-radius: 50%;
    background: currentColor;
    flex-shrink: 0;
}
.badge-open        { background: #e8eefc; color: #1f3a9e; }
.badge-progress    { background: #fff8e1; color: #a06f00; }
.badge-hold        { background: #ece7fb; color: #5b3fa3; }
.badge-pending-requester { background: var(--coral-100); color: #a3352a; }
.badge-resolved    { background: var(--tb-green-tint); color: var(--tb-green-dark); }
.badge-closed      { background: #e9eef5; color: #4a5775; }
.badge-reopened    { background: var(--coral-100); color: var(--coral-600); }

.priority-low       { color: var(--sage-600); font-weight: 700; font-family: var(--font-display); font-size: 13px; white-space: nowrap; }
.priority-medium    { color: #1f3a9e; font-weight: 700; font-family: var(--font-display); font-size: 13px; white-space: nowrap; }
.priority-high      { color: var(--amber-600); font-weight: 700; font-family: var(--font-display); font-size: 13px; white-space: nowrap; }
.priority-critical  { color: var(--coral-600); font-weight: 800; font-family: var(--font-display); font-size: 13px; white-space: nowrap; }

/* ---------- Ticket stub (signature element) ---------- */
.ticket-code {
    position: relative;
    display: inline-flex;
    align-items: center;
    font-family: var(--font-mono);
    font-weight: 600;
    background: var(--tb-navy-deep);
    color: #ffffff;
    padding: 5px 13px 5px 17px;
    border-radius: 6px;
    font-size: 12.5px;
    letter-spacing: 0.02em;
    border-left: 2px dashed var(--tb-green);
    white-space: nowrap;
}
.ticket-code::before,
.ticket-code::after {
    content: '';
    position: absolute;
    left: -5px;
    width: 8px; height: 8px;
    background: var(--paper-1);
    border-radius: 50%;
    border: 1px solid var(--border-color);
}
.ticket-code::before { top: -4px; }
.ticket-code::after { bottom: -4px; }

/* ---------- Stat tiles (dashboard) ---------- */
.stat-row { display: flex; gap: 16px; flex-wrap: wrap; }
.stat-tile {
    flex: 1;
    min-width: 140px;
    background: var(--paper-1);
    border: 1px solid var(--border-subtle);
    border-radius: 16px;
    padding: 18px 20px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    transition: transform 0.15s, box-shadow 0.15s;
}
.stat-tile:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }
.stat-tile::before {
    content: '';
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--tile-color, var(--tb-green));
}
.stat-tile .stat-value {
    font-family: var(--font-display);
    font-size: 32px;
    font-weight: 800;
    color: var(--tile-color, var(--tb-navy));
    line-height: 1.1;
    margin-top: 4px;
}
.stat-tile .stat-label {
    font-size: 12px;
    color: var(--text-subtle);
    margin-top: 6px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

/* ---------- Footer ---------- */
.footer {
    text-align: center;
    color: var(--text-subtle);
    font-size: 12px;
    padding: 28px 0;
    font-family: var(--font-body);
}

/* ============================================================
   RESPONSIVE / MOBILE
   ============================================================ */

/* Tablets and large phones */
@media (max-width: 768px) {
    .topbar {
        flex-direction: column;
        align-items: flex-start;
        height: auto;
        padding: 12px 16px;
        gap: 10px;
    }
    .topbar-brand { width: 100%; }
    .topbar-nav {
        width: 100%;
        justify-content: flex-start;
        gap: 2px;
    }
    .topbar-nav a { padding: 6px 9px; font-size: 12.5px; }
    .topbar-user {
        width: 100%;
        justify-content: space-between;
        gap: 10px;
    }

    .main-container { padding: 0 14px; margin: 18px auto; }
    .card { padding: 18px; }

    .page-header { flex-direction: column; align-items: flex-start; }
    .page-header h1 { font-size: 19px; }

    .stat-row { flex-direction: column; }

    /* Tables: scroll horizontally within their own card instead of
       blowing out the whole page width. The table keeps a sensible
       minimum width so columns stay legible — you scroll sideways to
       see the rest rather than everything being squeezed illegibly. */
    .card { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .card table { min-width: 620px; }

    /* "Quick action" button rows — buttons that sit as DIRECT children
       of a .card (the common pattern used for dashboard shortcut links)
       stack to full width for easier tapping. This does NOT affect
       buttons inside forms/table cells elsewhere, which stay as-is. */
    .card > .btn { display: block; width: 100%; margin-bottom: 8px; text-align: center; }
    .card > .btn:last-child { margin-bottom: 0; }
}

/* Phones */
@media (max-width: 480px) {
    .login-wrap { margin: 40px auto; }
    .login-wrap .card { padding: 24px 20px; }

    .ticket-code { font-size: 11px; padding: 3px 10px 3px 14px; }
    th, td { padding: 8px 9px; font-size: 12.5px; }

    .topbar-brand { font-size: 15px; }
    .brand-icon { width: 26px; height: 26px; font-size: 13px; }

    .btn { padding: 9px 16px; font-size: 13.5px; }
}
