/* =====================================================
   FIRESAFE TRACK — Mobile Technician App
   ===================================================== */

:root {
    --bg:             #0f172a;
    --card:           #1e293b;
    --primary:        #ef4444;
    --text:           #f8fafc;
    --accent-green:   #10b981;

    --bg-surface:     #000;
    --border:         #334155;
    --text-primary:   var(--text);
    --text-secondary: #94a3b8;
    --text-muted:     #64748b;

    --accent:         var(--primary);
    --green:          var(--accent-green);
    --yellow:         #f5a623;
    --red:            var(--primary);
    --blue:           #3b82f6;

    --font-mono:      'DM Mono', monospace;
    --font-body:      'DM Sans', sans-serif;

    --transition:     0.2s ease;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 16px; }

body {
    background: var(--bg);
    color: var(--text-primary);
    font-family: var(--font-body);
    min-height: 100vh;
    overflow: hidden;
}

::-webkit-scrollbar { width: 4px; }
::-webkit-scrollbar-thumb { background: var(--border); border-radius: 99px; }

/* ── LAYOUT ── */
.app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    max-width: 100%;
}

/* ── HEADER BAR ── */
.header-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-surface);
    border-bottom: 1px solid var(--border);
    gap: 16px;
    flex-shrink: 0;
}

.header-logo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    font-size: 13px;
    letter-spacing: 1px;
    color: var(--accent);
}

.header-logo svg { width: 18px; height: 18px; }

.header-status {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 11px;
    color: var(--text-muted);
}

.header-status .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    animation: pulse-small 2s infinite;
}

@keyframes pulse-small {
    0%, 100% { box-shadow: 0 0 0 0 rgba(16,185,129,0.4); }
    50%      { box-shadow: 0 0 0 4px rgba(16,185,129,0); }
}

/* ── PAGES ── */
main.page {
    display: none;
    flex: 1;
    flex-direction: column;
    overflow: hidden;
    animation: fadeIn 0.3s ease;
}

main.page.active { display: flex; }

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

.page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--card);
    border-bottom: 1px solid var(--border);
    flex-shrink: 0;
}

.page-header h1 {
    font-size: 18px;
    font-weight: 600;
    flex: 1;
    text-align: center;
}

.btn-back {
    background: transparent;
    border: none;
    color: var(--text-primary);
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: all var(--transition);
}

.btn-back:active { background: rgba(255,255,255,0.08); }
.btn-back svg { width: 20px; height: 20px; }

.page-content {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    padding-bottom: 80px;
}

/* ── WELCOME CARD ── */
.welcome-card {
    text-align: center;
    padding: 32px 20px 24px;
    margin-bottom: 24px;
}

.welcome-icon {
    width: 56px;
    height: 56px;
    background: rgba(239,68,68,0.12);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 16px;
    color: var(--red);
}

.welcome-icon svg { width: 28px; height: 28px; }

.welcome-card h1 {
    font-size: 26px;
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 8px;
}

.welcome-card p {
    font-size: 13px;
    color: var(--text-muted);
    line-height: 1.5;
}

/* ── BUTTONS ── */
.action-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    margin-bottom: 24px;
}

.btn-large {
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: white;
    padding: 16px;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    transition: all var(--transition);
    box-shadow: 0 2px 8px rgba(239,68,68,0.2);
}

.btn-large:active { transform: scale(0.96); }
.btn-large.secondary { background: var(--card); color: var(--text-primary); box-shadow: none; border: 1px solid var(--border); }

.btn-large svg { width: 24px; height: 24px; }

.btn-submit-form {
    width: 100%;
    background: var(--primary);
    border: none;
    border-radius: 10px;
    color: white;
    font-family: var(--font-body);
    font-size: 14px;
    font-weight: 600;
    padding: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all var(--transition);
    margin-top: 8px;
}

.btn-submit-form:active { transform: scale(0.98); }
.btn-submit-form svg { width: 16px; height: 16px; }

.btn-text {
    background: transparent;
    border: none;
    color: var(--accent);
    font-family: var(--font-body);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    padding: 8px;
    transition: all var(--transition);
}

.btn-text:active { opacity: 0.7; }

.btn-danger-small {
    background: rgba(239,68,68,0.1);
    border: 1px solid var(--red);
    border-radius: 8px;
    color: var(--red);
    font-family: var(--font-body);
    font-size: 12px;
    font-weight: 600;
    padding: 8px 14px;
    cursor: pointer;
    transition: all var(--transition);
    margin-top: 12px;
}

.btn-danger-small:active { background: rgba(239,68,68,0.2); }

/* ── RECENT CARD ── */
.recent-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.recent-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
}

.recent-header h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
}

.recent-header h3 svg { width: 16px; height: 16px; color: var(--accent); }

.badge {
    font-family: var(--font-mono);
    font-size: 10px;
    padding: 3px 8px;
    border-radius: 4px;
    background: rgba(239,68,68,0.12);
    border: 1px solid rgba(239,68,68,0.2);
    color: var(--red);
}

.recent-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.recent-item {
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 12px;
    font-size: 12px;
    cursor: pointer;
    transition: all var(--transition);
    animation: slideUp 0.3s ease;
}

.recent-item:active { background: rgba(255,255,255,0.04); }

.recent-serial { font-family: var(--font-mono); font-weight: 600; color: var(--text-primary); }
.recent-meta   { font-size: 11px; color: var(--text-muted); margin-top: 3px; }

.empty-state {
    text-align: center;
    color: var(--text-muted);
    font-size: 12px;
    padding: 20px 16px;
}

/* ── BARCODE INPUT ── */
.barcode-input-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}

.input-icon {
    width: 48px;
    height: 48px;
    background: rgba(239,68,68,0.12);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    color: var(--red);
}

.input-icon svg { width: 24px; height: 24px; }

.barcode-input-card h3 {
    font-size: 15px;
    font-weight: 600;
    margin-bottom: 4px;
}

.barcode-input-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 16px;
}

/* ── FORM GROUPS ── */
.form-group {
    text-align: left;
    margin-bottom: 14px;
}

.form-group label {
    display: block;
    font-size: 11px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    font-family: var(--font-body);
    font-size: 13px;
    padding: 11px;
    outline: none;
    transition: border-color var(--transition);
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
    border-color: var(--accent);
    box-shadow: 0 0 0 3px rgba(239,68,68,0.1);
}

.form-group input::placeholder,
.form-group textarea::placeholder {
    color: var(--text-muted);
}

.hint {
    display: block;
    font-size: 11px;
    color: var(--text-muted);
    margin-top: 4px;
}

/* ── DIVIDER ── */
.divider {
    text-align: center;
    margin: 20px 0;
    color: var(--text-muted);
    font-size: 12px;
}

.divider span {
    background: var(--bg);
    padding: 0 8px;
    position: relative;
    z-index: 1;
}

.divider::before {
    content: '';
    position: absolute;
    top: 50%;
    left: 0;
    right: 0;
    height: 1px;
    background: var(--border);
}

/* ── QR UPLOAD ── */
.qr-image-upload {
    margin-bottom: 20px;
}

.qr-image-upload h3 {
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.upload-area {
    background: var(--bg);
    border: 2px dashed var(--border);
    border-radius: 10px;
    padding: 24px 16px;
    text-align: center;
    cursor: pointer;
    transition: all var(--transition);
}

.upload-area:active { border-color: var(--accent); background: rgba(239,68,68,0.04); }

.upload-area svg {
    width: 32px;
    height: 32px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.upload-area p {
    font-size: 12px;
    color: var(--text-muted);
}

/* ── SEARCH BOX ── */
.search-box {
    display: flex;
    align-items: center;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 10px 14px;
    margin-bottom: 16px;
    gap: 10px;
}

.search-box svg { width: 18px; height: 18px; color: var(--text-muted); }

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: 14px;
    outline: none;
    font-family: var(--font-body);
}

.search-box input::placeholder { color: var(--text-muted); }

.search-results {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.search-result-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    cursor: pointer;
    transition: all var(--transition);
    animation: slideUp 0.2s ease;
}

.search-result-item:active { background: rgba(255,255,255,0.04); }

.result-serial { font-family: var(--font-mono); font-weight: 600; font-size: 13px; }
.result-meta   { font-size: 11px; color: var(--text-muted); margin-top: 4px; }

/* ── UNIT SUMMARY ── */
.unit-summary {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.unit-detail {
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.unit-label {
    font-size: 10px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
}

.unit-serial {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 13px;
    color: var(--accent);
}

.unit-location {
    font-size: 12px;
    color: var(--text-primary);
}

.unit-company {
    font-size: 11px;
    color: var(--text-secondary);
}

/* ── INSPECTION FORM ── */
.inspection-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-section {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
}

.form-section h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.form-section h3 svg { width: 16px; height: 16px; color: var(--accent); }

/* ── RADIO GROUP ── */
.radio-group {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.radio-label {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    padding: 10px;
    border-radius: 8px;
    transition: all var(--transition);
}

.radio-label:active { background: rgba(255,255,255,0.04); }

.radio-label input {
    appearance: none;
    width: 0;
    height: 0;
    margin: 0;
}

.radio-circle {
    width: 18px;
    height: 18px;
    border: 2px solid var(--border);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    flex-shrink: 0;
}

.radio-label input:checked + .radio-circle {
    border-color: var(--accent);
    background: var(--accent);
}

.radio-circle::after {
    content: '✓';
    color: white;
    font-size: 12px;
    opacity: 0;
}

.radio-label input:checked + .radio-circle::after {
    opacity: 1;
}

.radio-text {
    flex: 1;
    font-size: 13px;
}

/* ── TEXTAREA ── */
textarea {
    resize: vertical;
    line-height: 1.5;
}

/* ── SUBMISSIONS LIST ── */
.submissions-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.submission-item {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 14px;
    animation: slideUp 0.3s ease;
}

.submission-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    margin-bottom: 8px;
}

.submission-serial {
    font-family: var(--font-mono);
    font-weight: 600;
    font-size: 12px;
    color: var(--accent);
}

.submission-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 10px;
    font-weight: 600;
    padding: 3px 8px;
    border-radius: 4px;
}

.submission-status.pending {
    background: rgba(245,166,35,0.12);
    color: var(--yellow);
    border: 1px solid rgba(245,166,35,0.2);
}

.submission-status.sent {
    background: rgba(16,185,129,0.12);
    color: var(--green);
    border: 1px solid rgba(16,185,129,0.2);
}

.submission-status.error {
    background: rgba(239,68,68,0.12);
    color: var(--red);
    border: 1px solid rgba(239,68,68,0.2);
}

.submission-meta {
    font-size: 11px;
    color: var(--text-muted);
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

.submission-meta span { display: flex; align-items: center; gap: 4px; }

.submission-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.btn-small {
    flex: 1;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 6px;
    color: var(--text-secondary);
    font-size: 11px;
    font-weight: 600;
    padding: 6px;
    cursor: pointer;
    transition: all var(--transition);
}

.btn-small:active { background: rgba(255,255,255,0.04); }

.btn-small.error { border-color: var(--red); color: var(--red); }

/* ── SETTINGS ── */
.settings-card {
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 16px;
    margin-bottom: 12px;
}

.settings-card h3 {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 600;
    margin-bottom: 12px;
}

.settings-card h3 svg { width: 16px; height: 16px; color: var(--accent); }

.settings-card p {
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 12px;
}

.settings-card.danger {
    border-color: rgba(239,68,68,0.3);
    background: rgba(239,68,68,0.04);
}

.info-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 8px 0;
    font-size: 12px;
    border-bottom: 1px solid var(--border);
}

.info-item:last-child { border-bottom: none; }

.info-item span:first-child { color: var(--text-muted); }
.info-item .mono { font-family: var(--font-mono); color: var(--text-primary); }

/* ── NAVIGATION ── */
.nav-bottom {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 0;
    background: var(--card);
    border-top: 1px solid var(--border);
    padding-bottom: max(0px, env(safe-area-inset-bottom));
    z-index: 50;
}

.nav-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 12px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    font-family: var(--font-body);
    font-size: 11px;
    font-weight: 600;
    transition: all var(--transition);
}

.nav-btn:active { color: var(--accent); }

.nav-btn.active { color: var(--accent); }

.nav-btn svg { width: 20px; height: 20px; }

/* ── TOAST ── */
.toast {
    position: fixed;
    bottom: 28px;
    left: 16px;
    right: 16px;
    max-width: 320px;
    margin: 0 auto;
    background: var(--card);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 12px;
    padding: 12px 16px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.4);
    transform: translateY(8px);
    opacity: 0;
    transition: all 0.3s ease;
    pointer-events: none;
    z-index: 999;
    display: flex;
    align-items: center;
    gap: 10px;
}

.toast.show {
    transform: translateY(0);
    opacity: 1;
}

.toast-icon { flex-shrink: 0; }
.toast.success { border-left: 3px solid var(--green); }
.toast.error   { border-left: 3px solid var(--red); }
.toast.info    { border-left: 3px solid var(--blue); }
