/* ============================================================
   GuardTrack — global stylesheet
   Dark theme, orange accent, mobile-first, LTR (Inter font).
   Reference look: native app bar + bottom tab navigation.
   ============================================================ */

:root {
    --bg:        #12151c;   /* app background          */
    --surface:   #1b2029;   /* cards / panels          */
    --surface-2: #232a36;   /* inputs, table header    */
    --border:    #2e3644;
    --text:      #e8ecf3;
    --muted:     #98a2b5;
    --accent:    #ff7a1a;   /* brand orange            */
    --accent-d:  #e5650a;
    --accent-soft: rgba(255, 122, 26, .14);
    --success:   #34d399;
    --success-soft: rgba(52, 211, 153, .14);
    --danger:    #f05252;
    --danger-soft:  rgba(240, 82, 82, .15);
    --warning:   #fbbf24;
    --warning-soft: rgba(251, 191, 36, .15);
    --radius:    12px;
    --radius-sm: 9px;
    --shadow:    0 2px 10px rgba(0, 0, 0, .35);
    /* safe-area for notched phones (iOS) */
    --sab: env(safe-area-inset-bottom, 0px);
}

* { box-sizing: border-box; margin: 0; padding: 0; }
html { -webkit-text-size-adjust: 100%; }

body {
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Arial, sans-serif;
    font-size: 15px;
    line-height: 1.55;
    color: var(--text);
    background: var(--bg);
    direction: ltr;
    min-height: 100vh;
    /* room for the fixed bottom tab bar on mobile */
    padding-bottom: calc(74px + var(--sab));
}
@media (min-width: 860px) {
    body { padding-bottom: 0; }
}

/* ================= Top bar ================= */
.topbar {
    background: rgba(27, 32, 41, .92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 50;
}
.topbar-inner {
    max-width: 1080px;
    margin: 0 auto;
    padding: 10px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
}
.brand {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    font-weight: 700;
    font-size: 16.5px;
    color: var(--text);
    text-decoration: none;
    white-space: nowrap;
}
.brand-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--accent);
    box-shadow: 0 0 10px var(--accent);
}
/* top nav — hidden on phones, shown on desktop */
.topnav { display: none; }
@media (min-width: 860px) {
    .topnav { display: flex; align-items: center; gap: 4px; flex-wrap: wrap; }
    .topnav a {
        color: var(--muted);
        text-decoration: none;
        font-weight: 500;
        font-size: 13.5px;
        padding: 7px 11px;
        border-radius: 8px;
    }
    .topnav a:hover { background: var(--surface-2); color: var(--text); }
    .topnav a.active { background: var(--accent-soft); color: var(--accent); }
    .topnav a.nav-logout:hover { background: var(--danger-soft); color: var(--danger); }
}

/* ================= Bottom tab bar (mobile) ================= */
.tabbar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 60;
    display: flex;
    background: rgba(20, 24, 31, .97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
    padding-bottom: var(--sab);
}
.tabbar a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
    padding: 8px 2px 7px;
    text-decoration: none;
    color: var(--muted);
    font-size: 10.5px;
    font-weight: 500;
    min-height: 48px;
    justify-content: center;
}
.tabbar a svg { width: 21px; height: 21px; }
.tabbar a.active { color: var(--accent); }
.tabbar a.active .tab-dot { opacity: 1; }
.tab-dot {
    width: 4px; height: 4px; border-radius: 50%;
    background: var(--accent);
    opacity: 0;
    margin-top: 1px;
}
@media (min-width: 860px) { .tabbar { display: none; } }

/* ================= Layout ================= */
.container {
    max-width: 1080px;
    margin: 0 auto;
    padding: 18px 14px 30px;
}
.page-head { margin-bottom: 16px; }
.page-head h1 { font-size: 21px; font-weight: 700; letter-spacing: -.01em; }
.page-head p  { color: var(--muted); font-size: 13.5px; margin-top: 2px; }

.grid-2 { display: grid; grid-template-columns: 1fr; gap: 16px; }
@media (min-width: 860px) { .grid-2 { grid-template-columns: 1fr 1fr; } }

/* ================= Cards ================= */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 18px 16px;
    margin-bottom: 16px;
}
.card h2 { font-size: 15.5px; font-weight: 700; margin-bottom: 14px; }
.card .hint { color: var(--muted); font-size: 13px; margin-top: -8px; margin-bottom: 12px; }

/* Live caption under a photo preview: shows what will be stamped on it. */
.stamp-caption {
    margin-top: 8px;
    padding: 9px 12px;
    border: 1px solid var(--border);
    border-radius: 9px;
    background: var(--surface-2);
    display: flex;
    flex-direction: column;
    gap: 2px;
    font-size: 12.5px;
}
.stamp-caption .stamp-line { color: var(--text); font-weight: 600; }
.stamp-caption .stamp-hint { color: var(--muted); font-size: 11.5px; margin-top: 2px; }

/* ================= Forms ================= */
.form-grid { display: grid; grid-template-columns: 1fr; gap: 13px; }
@media (min-width: 640px) { .form-grid.cols-2 { grid-template-columns: 1fr 1fr; } }

.field { display: flex; flex-direction: column; gap: 6px; }
.field label { font-size: 13px; font-weight: 500; }
.field .req { color: var(--accent); }
.field input,
.field select,
.field textarea {
    font: inherit;
    color: var(--text);
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 13px;
    width: 100%;
    min-height: 46px;             /* comfortable touch target */
    outline: none;
    appearance: none;
    -webkit-appearance: none;
}
.field select {
    background-image: url("data:image/svg+xml;charset=UTF-8,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%2398a2b5' stroke-width='2' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 13px center;
    padding-right: 34px;
}
.field textarea { min-height: 96px; resize: vertical; }
.field input:focus,
.field select:focus,
.field textarea:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px var(--accent-soft);
}
.field input::placeholder,
.field textarea::placeholder { color: #5d6877; }
.field small { color: var(--muted); font-size: 12px; }

/* checkbox rows (URGENT / Close issue style) */
.check-row {
    display: flex;
    align-items: center;
    gap: 10px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 12px 13px;
    min-height: 46px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    user-select: none;
}
.check-row input[type="checkbox"] {
    width: 19px; height: 19px;
    accent-color: var(--accent);
    flex: none;
}
.check-row.urgent { color: var(--warning); }
.check-row.urgent input { accent-color: var(--warning); }
.check-row.urgent.checked {
    border-color: var(--warning);
    background: var(--warning-soft);
}

/* ================= Buttons ================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    font: inherit;
    font-weight: 600;
    font-size: 14px;
    border: 1px solid transparent;
    border-radius: var(--radius-sm);
    padding: 11px 16px;
    min-height: 46px;
    cursor: pointer;
    text-decoration: none;
    background: var(--accent);
    color: #16110b;
    transition: filter .15s ease, transform .05s ease;
}
.btn:hover  { background: var(--accent-d); }
.btn:active { transform: scale(.985); }
.btn:disabled { opacity: .5; cursor: not-allowed; }
.btn svg { width: 17px; height: 17px; }

.btn-secondary { background: var(--surface-2); color: var(--text); border-color: var(--border); }
.btn-secondary:hover { background: var(--border); }
.btn-danger { background: var(--danger); color: #1d0808; }
.btn-danger:hover { background: #d63c3c; }
.btn-ghost  { background: transparent; color: var(--muted); border-color: var(--border); }
.btn-ghost:hover { color: var(--text); background: var(--surface-2); }
.btn-sm { padding: 7px 11px; min-height: 36px; font-size: 13px; border-radius: 8px; }
.btn-sm svg { width: 14px; height: 14px; }
.btn-block { width: 100%; }

/* sticky action bar (mobile forms) */
.action-bar {
    position: fixed;
    bottom: calc(58px + var(--sab));
    left: 0; right: 0;
    z-index: 55;
    display: flex;
    gap: 8px;
    padding: 10px 12px;
    background: rgba(20, 24, 31, .97);
    backdrop-filter: blur(10px);
    border-top: 1px solid var(--border);
}
.action-bar .btn { flex: 1; }
.action-bar .btn.icon-action { flex-direction: column; gap: 3px; font-size: 11px; padding: 8px 4px; }
.action-bar .btn.icon-action svg { width: 19px; height: 19px; }
@media (min-width: 860px) {
    .action-bar { position: static; background: transparent; border: 0; padding: 0; backdrop-filter: none; }
}

/* Reserves room on mobile so the fixed action bar never covers content. */
.action-spacer { display: none; }
@media (max-width: 859px) { .action-spacer { display: block; height: 76px; } }

/* ================= Tables → stacked cards on mobile ================= */
.table-wrap {
    border: 1px solid var(--border);
    border-radius: var(--radius);
    background: var(--surface);
    overflow: hidden;
}
table { width: 100%; border-collapse: collapse; font-size: 13.5px; }
th, td { text-align: left; padding: 11px 12px; border-bottom: 1px solid var(--border); }
th {
    display: none;              /* labels move onto the rows on mobile */
    font-weight: 600;
    font-size: 11.5px;
    text-transform: uppercase;
    letter-spacing: .05em;
    color: var(--muted);
    background: var(--surface-2);
}
td { display: flex; justify-content: space-between; align-items: center; gap: 12px; }
td::before {
    content: attr(data-label);
    color: var(--muted);
    font-weight: 500;
    font-size: 12px;
    flex: none;
}
td.td-actions::before,
td.td-id::before { content: none; }
tr:last-child td { border-bottom: none; }
td code { color: var(--accent); font-size: 12.5px; word-break: break-all; }

@media (min-width: 760px) {
    th { display: table-cell; }
    td { display: table-cell; }
    td::before { content: none; }
    .table-wrap { overflow-x: auto; }
}

/* ================= Badges ================= */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 11.5px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 999px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--muted);
    white-space: nowrap;
}
.badge-success { background: var(--success-soft); border-color: rgba(52,211,153,.35); color: var(--success); }
.badge-warning { background: var(--warning-soft); border-color: rgba(251,191,36,.35); color: var(--warning); }
.badge-danger  { background: var(--danger-soft);  border-color: rgba(240,82,82,.4);   color: var(--danger); }
.badge-urgent  { background: var(--danger-soft);  border-color: var(--danger);        color: var(--danger); }
.badge-urgent::before { content: "●"; font-size: 8px; }

/* ================= Details / photos ================= */
.detail-list { display: grid; gap: 9px; font-size: 14px; }
.detail-list .row { display: grid; grid-template-columns: 108px 1fr; gap: 10px; }
.detail-list .row .k { color: var(--muted); font-weight: 500; }

/* Evidence photos must ALWAYS be fully visible (never cropped) — the
   timestamp watermark sits at the bottom edge, so cover-cropping would
   hide it. Full width, natural height, on every screen size. */
.report-photo {
    display: block;
    width: 100%;
    height: auto;
    max-height: none;
    object-fit: contain;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

/* Checkpoint reference photos are informational — cover-crop is fine. */
.checkpoint-photo {
    width: 100%;
    max-height: 340px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    background: var(--surface-2);
}

/* ================= Toasts ================= */
.toast {
    position: fixed;
    bottom: calc(84px + var(--sab));
    left: 50%;
    transform: translateX(-50%);
    max-width: min(92vw, 480px);
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    font-size: 13.5px;
    font-weight: 500;
    padding: 12px 18px;
    border-radius: 10px;
    z-index: 200;
    box-shadow: 0 10px 30px rgba(0, 0, 0, .5);
}
.toast-success { border-color: rgba(52,211,153,.5); }
.toast-success::before { content: "✔ "; color: var(--success); }
.toast-error { border-color: rgba(240,82,82,.55); }
.toast-error::before { content: "✖ "; color: var(--danger); }

/* ================= Auth ================= */
.auth-wrap { max-width: 400px; margin: 7vh auto 0; }
.auth-brand { text-align: center; margin-bottom: 18px; }
.auth-brand h1 { font-size: 24px; font-weight: 700; }

/* ================= Dialog ================= */
dialog {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 20px;
    width: min(480px, 92vw);
    box-shadow: 0 24px 60px rgba(0, 0, 0, .55);
}
dialog::backdrop { background: rgba(5, 8, 12, .7); }

/* ================= Map ================= */
#map {
    height: 420px;
    border-radius: var(--radius);
    border: 1px solid var(--border);
    z-index: 1;
    background: var(--surface-2);
}
@media (max-width: 859px) { #map { height: 340px; } }

/* ================= QR sheet ================= */
.qr-sheet {
    background: #ffffff;               /* QR must stay light for scanning */
    color: #111;
    padding: 28px;
    max-width: 420px;
    margin: 0 auto;
    border-radius: var(--radius);
}
.qr-sheet img { width: 100%; image-rendering: pixelated; }
.qr-meta { margin-top: 10px; font-size: 14px; }
.qr-meta strong { display: block; font-size: 16px; }
.qr-meta .muted { color: #666; font-size: 12.5px; }

@media print {
    .topbar, .tabbar, .footer, .no-print, .toast, .action-bar { display: none !important; }
    body { background: #fff; padding-bottom: 0; }
    .qr-sheet { border: 1px dashed #999; }
}

/* ================= Footer ================= */
.footer {
    border-top: 1px solid var(--border);
    color: var(--muted);
    font-size: 12px;
    display: flex;
    justify-content: space-between;
    gap: 8px;
    max-width: 1080px;
    margin: 0 auto;
    padding: 14px 16px 22px;
    flex-wrap: wrap;
}

/* ================= Photo preview ================= */
.photo-preview { margin-top: 8px; display: none; }
.photo-preview img {
    max-width: 100%;
    max-height: 220px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
}

/* ================= Stats ================= */
.stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
@media (min-width: 720px) { .stats { grid-template-columns: repeat(4, 1fr); } }
.stat {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 13px 15px;
}
.stat .n { font-size: 22px; font-weight: 700; color: var(--accent); }
.stat .l { color: var(--muted); font-size: 12px; font-weight: 500; }

.actions-row { display: flex; gap: 9px; flex-wrap: wrap; align-items: center; }

/* GPS status line */
.gps-line {
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--muted);
    font-size: 13px;
    margin-bottom: 12px;
}
.gps-line .pulse {
    width: 9px; height: 9px; border-radius: 50%;
    background: var(--success);
    box-shadow: 0 0 0 rgba(52, 211, 153, .7);
    animation: pulse 2s infinite;
    flex: none;
}
@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(52, 211, 153, .5); }
    70%  { box-shadow: 0 0 0 9px rgba(52, 211, 153, 0); }
    100% { box-shadow: 0 0 0 0 rgba(52, 211, 153, 0); }
}
