/* ═══════════════════════════════════════════════════════════════════════
   HomeSpecs Portal — Design System
   Fonts: Outfit (display) + Plus Jakarta Sans (body) via Google Fonts
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Variables ──────────────────────────────────────────────────────── */
:root {
    --navy:         #0B1628;
    --navy-90:      #0F1D33;
    --navy-80:      #1A2D54;
    --slate-dark:   #1E293B;
    --teal:         #14B8A6;
    --teal-light:   #5EEAD4;
    --teal-dark:    #0D9488;
    --teal-glow:    rgba(20,184,166,0.15);
    --teal-subtle:  rgba(20,184,166,0.06);
    --white:        #FAFBFD;
    --light:        #F1F5F9;
    --surface:      #F8FAFC;
    --slate:        #64748B;
    --slate-light:  #94A3B8;
    --sev-low:      #22C55E;
    --sev-medium:   #F59E0B;
    --sev-high:     #EA580C;
    --sev-critical: #EF4444;
    --border-dark:  rgba(255,255,255,0.07);
    --border-light: rgba(0,0,0,0.06);
    --ease:         cubic-bezier(0.16,1,0.3,1);
    --radius-sm:    6px;
    --radius-md:    10px;
    --radius-lg:    16px;
    --shadow-card:  0 1px 3px rgba(0,0,0,0.04), 0 8px 32px rgba(11,22,40,0.08);
    --shadow-teal:  0 8px 30px rgba(20,184,166,0.2);
}

/* ── Reset ──────────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 16px; -webkit-text-size-adjust: 100%; }
body {
    font-family: 'Plus Jakarta Sans', -apple-system, sans-serif;
    font-weight: 300;
    color: var(--slate-dark);
    background: var(--light);
    line-height: 1.7;
    min-height: 100vh;
}
img { display: block; max-width: 100%; }
a { color: inherit; text-decoration: none; }
button { cursor: pointer; font-family: inherit; border: none; background: none; }
input, textarea, select {
    font-family: inherit;
    font-size: inherit;
    color: inherit;
    border: none;
    outline: none;
}

/* ── Typography ─────────────────────────────────────────────────────── */
h1, h2, h3, h4 { font-family: 'Outfit', sans-serif; font-weight: 700; line-height: 1.2; letter-spacing: -0.3px; color: var(--navy); }
h1 { font-size: 2rem; letter-spacing: -0.5px; }
h2 { font-size: 1.5rem; }
h3 { font-size: 1.125rem; }
h4 { font-size: 1rem; }
.eyebrow { font-size: 0.6875rem; font-weight: 600; text-transform: uppercase; letter-spacing: 2.5px; color: var(--teal); }

/* ── Buttons ────────────────────────────────────────────────────────── */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: 'Plus Jakarta Sans', sans-serif;
    font-weight: 600;
    font-size: 0.9375rem;
    padding: 0.75rem 1.5rem;
    border-radius: var(--radius-sm);
    transition: background 0.3s, transform 0.2s, box-shadow 0.3s, color 0.3s, border-color 0.3s;
    white-space: nowrap;
    line-height: 1;
}
.btn-solid {
    background: var(--teal);
    color: var(--navy);
}
.btn-solid:hover {
    background: var(--teal-light);
    transform: translateY(-2px);
    box-shadow: var(--shadow-teal);
}
.btn-solid:active { transform: translateY(0); }

.btn-outline {
    background: transparent;
    color: var(--slate);
    border: 1px solid var(--border-light);
    font-weight: 500;
}
.btn-outline:hover { border-color: var(--teal); color: var(--teal-dark); }

.btn-ghost {
    background: transparent;
    color: var(--slate);
    padding: 0.625rem 0.875rem;
}
.btn-ghost:hover { color: var(--navy); background: var(--light); border-radius: var(--radius-sm); }

.btn-danger {
    background: transparent;
    color: var(--sev-critical);
    border: 1px solid rgba(239,68,68,0.2);
}
.btn-danger:hover { background: rgba(239,68,68,0.06); }

.btn-sm { padding: 0.5rem 1rem; font-size: 0.8125rem; }
.btn-lg { padding: 1rem 2rem; font-size: 1rem; }
.btn-full { width: 100%; }
.btn:disabled { opacity: 0.5; cursor: not-allowed; pointer-events: none; }

/* ── Cards ──────────────────────────────────────────────────────────── */
.card {
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-card);
}
.card-body { padding: 1.5rem; }
.card-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
}
.card-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid var(--border-light);
    display: flex;
    align-items: center;
    justify-content: flex-end;
    gap: 0.75rem;
}

/* ── Badges ─────────────────────────────────────────────────────────── */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 3px 10px;
    border-radius: 4px;
    font-size: 0.6875rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    white-space: nowrap;
}
.badge-critical { background: rgba(239,68,68,0.1);   color: var(--sev-critical); }
.badge-high     { background: rgba(249,115,22,0.1);  color: var(--sev-high); }
.badge-medium   { background: rgba(245,158,11,0.1);  color: var(--sev-medium); }
.badge-low      { background: rgba(34,197,94,0.1);   color: var(--sev-low); }
.badge-info     { background: rgba(100,116,139,0.1); color: var(--slate); }

.badge-draft      { background: rgba(100,116,139,0.1); color: var(--slate); }
.badge-in_progress{ background: rgba(20,184,166,0.1);  color: var(--teal-dark); }
.badge-processing { background: rgba(245,158,11,0.1);  color: var(--sev-medium); }
.badge-completed  { background: rgba(34,197,94,0.1);   color: #16A34A; }
.badge-delivered  { background: rgba(11,22,40,0.08);   color: var(--navy); }

/* ── Form elements ──────────────────────────────────────────────────── */
.form-group { display: flex; flex-direction: column; gap: 0.375rem; }
.form-label { font-size: 0.8125rem; font-weight: 600; color: var(--navy); }
.form-label.required::after { content: ' *'; color: var(--sev-critical); }

.form-input, .form-select, .form-textarea {
    padding: 0.75rem 1rem;
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    font-size: 0.9375rem;
    color: var(--slate-dark);
    transition: border-color 0.25s, box-shadow 0.25s;
    width: 100%;
}
.form-input:focus, .form-select:focus, .form-textarea:focus {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-glow);
}
.form-input::placeholder, .form-textarea::placeholder { color: var(--slate-light); font-weight: 400; }
.form-textarea { resize: vertical; min-height: 100px; line-height: 1.6; }
.form-select { appearance: none; cursor: pointer; }
.form-error { font-size: 0.75rem; color: var(--sev-critical); }
.form-hint  { font-size: 0.75rem; color: var(--slate-light); }

/* ── Chips (category selector) ──────────────────────────────────────── */
.chips { display: flex; flex-wrap: wrap; gap: 6px; }
.chip {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 5px 12px;
    border-radius: 20px;
    font-size: 0.75rem;
    font-weight: 500;
    background: rgba(0,0,0,0.04);
    color: var(--slate);
    border: 1px solid var(--border-light);
    cursor: pointer;
    transition: background 0.2s, color 0.2s, border-color 0.2s;
    user-select: none;
}
.chip:hover { border-color: var(--teal); color: var(--teal-dark); }
.chip.active {
    background: var(--teal-subtle);
    color: var(--teal-dark);
    border-color: rgba(20,184,166,0.25);
    font-weight: 600;
}

/* ── Sidebar Layout ─────────────────────────────────────────────────── */
.portal-layout { display: flex; min-height: 100vh; }

.sidebar {
    width: 240px;
    background: var(--navy);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 100;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.5rem 1.25rem 1rem;
    border-bottom: 1px solid var(--border-dark);
}
.sidebar-brand-text {
    font-family: 'Outfit', sans-serif;
    font-size: 1.25rem;
    font-weight: 700;
    color: #fff;
    letter-spacing: -0.3px;
}
.sidebar-brand-text span { color: var(--teal); }

.sidebar-nav { flex: 1; padding: 1rem 0.75rem; }

.nav-section-label {
    font-size: 0.625rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 2px;
    color: rgba(255,255,255,0.25);
    padding: 0.75rem 0.5rem 0.375rem;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.625rem 0.75rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    font-weight: 500;
    color: rgba(255,255,255,0.55);
    transition: background 0.2s, color 0.2s;
    margin-bottom: 2px;
}
.nav-item svg { flex-shrink: 0; opacity: 0.7; }
.nav-item:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.85); }
.nav-item.active { background: var(--teal-glow); color: var(--teal-light); font-weight: 600; }
.nav-item.active svg { opacity: 1; }

.sidebar-footer {
    padding: 1rem 0.75rem;
    border-top: 1px solid var(--border-dark);
}

/* ── Main content area ──────────────────────────────────────────────── */
.portal-main {
    margin-left: 240px;
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.topbar {
    background: var(--white);
    border-bottom: 1px solid var(--border-light);
    padding: 0.875rem 1.75rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    position: sticky;
    top: 0;
    z-index: 50;
}

.page-content { padding: 1.75rem; flex: 1; }
.page-title { font-family: 'Outfit', sans-serif; font-size: 1.5rem; font-weight: 700; color: var(--navy); }
.page-subtitle { font-size: 0.875rem; color: var(--slate); margin-top: 2px; }

/* ── Stats grid ─────────────────────────────────────────────────────── */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
    gap: 1rem;
    margin-bottom: 1.75rem;
}
.stat-card {
    background: var(--white);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-md);
    padding: 1.25rem;
    box-shadow: var(--shadow-card);
}
.stat-value { font-family: 'Outfit', sans-serif; font-size: 2rem; font-weight: 700; color: var(--navy); line-height: 1; }
.stat-label { font-size: 0.75rem; font-weight: 600; text-transform: uppercase; letter-spacing: 1.5px; color: var(--slate-light); margin-top: 6px; }

/* ── Inspection list ────────────────────────────────────────────────── */
.inspection-row {
    display: grid;
    grid-template-columns: 1fr auto auto auto;
    align-items: center;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--border-light);
    transition: background 0.15s;
    cursor: pointer;
}
.inspection-row:last-child { border-bottom: none; }
.inspection-row:hover { background: var(--surface); }

.inspection-ref { font-size: 0.75rem; font-weight: 600; color: var(--teal-dark); font-family: 'Outfit', sans-serif; }
.inspection-address { font-size: 0.9375rem; font-weight: 500; color: var(--navy); margin-top: 1px; }
.inspection-meta { font-size: 0.75rem; color: var(--slate-light); margin-top: 2px; }

/* ── Severity pill row ──────────────────────────────────────────────── */
.severity-row { display: flex; gap: 5px; flex-wrap: wrap; }

/* ── Voice capture button ───────────────────────────────────────────── */
.mic-btn {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--teal);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s, transform 0.15s;
    position: relative;
}
.mic-btn:hover { background: var(--teal-dark); transform: scale(1.05); }
.mic-btn.recording { background: var(--sev-critical); }
.mic-btn.recording::after {
    content: '';
    position: absolute;
    inset: -8px;
    border-radius: 50%;
    border: 2px solid var(--sev-critical);
    opacity: 0.4;
    animation: mic-pulse 1.5s ease-out infinite;
}
@keyframes mic-pulse {
    0%   { transform: scale(0.9); opacity: 0.4; }
    100% { transform: scale(1.3); opacity: 0; }
}

.transcript-box {
    background: var(--surface);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem;
    font-size: 0.875rem;
    font-style: italic;
    color: var(--slate);
    line-height: 1.6;
    min-height: 60px;
}

/* ── Photo upload grid ──────────────────────────────────────────────── */
.photo-grid { display: grid; grid-template-columns: repeat(3, 1fr); gap: 8px; }
.photo-thumb {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    overflow: hidden;
    border: 1px solid var(--border-light);
    position: relative;
    background: var(--surface);
}
.photo-thumb img { width: 100%; height: 100%; object-fit: cover; }
.photo-thumb .remove-btn {
    position: absolute;
    top: 4px;
    right: 4px;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    background: rgba(0,0,0,0.6);
    color: #fff;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0;
    transition: opacity 0.2s;
}
.photo-thumb:hover .remove-btn { opacity: 1; }
.photo-add {
    aspect-ratio: 1;
    border-radius: var(--radius-sm);
    border: 2px dashed var(--border-light);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    cursor: pointer;
    color: var(--slate-light);
    font-size: 0.6875rem;
    transition: border-color 0.2s, color 0.2s;
    background: var(--surface);
}
.photo-add:hover { border-color: var(--teal); color: var(--teal-dark); }

/* ── Empty states ───────────────────────────────────────────────────── */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4rem 2rem;
    text-align: center;
    color: var(--slate-light);
}
.empty-state-icon { margin-bottom: 1rem; opacity: 0.4; }
.empty-state h3 { font-size: 1rem; color: var(--slate); margin-bottom: 0.5rem; }
.empty-state p { font-size: 0.875rem; max-width: 300px; margin: 0 auto 1.5rem; }

/* ── Processing state ───────────────────────────────────────────────── */
.processing-banner {
    background: rgba(245,158,11,0.08);
    border: 1px solid rgba(245,158,11,0.2);
    border-radius: var(--radius-md);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 0.875rem;
    color: #92400E;
    margin-bottom: 1.5rem;
}

/* ── Toast notifications ────────────────────────────────────────────── */
#toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 8px;
    pointer-events: none;
}
.toast {
    background: var(--navy);
    color: #fff;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    font-size: 0.875rem;
    box-shadow: 0 4px 24px rgba(0,0,0,0.2);
    display: flex;
    align-items: center;
    gap: 0.625rem;
    animation: toast-in 0.3s var(--ease);
    pointer-events: auto;
    max-width: 320px;
}
.toast.toast-success { border-left: 3px solid var(--teal); }
.toast.toast-error   { border-left: 3px solid var(--sev-critical); }
@keyframes toast-in { from { opacity:0; transform:translateY(8px); } to { opacity:1; transform:translateY(0); } }

/* ── Offline banner ─────────────────────────────────────────────────── */
#offline-banner {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: var(--sev-high);
    color: #fff;
    text-align: center;
    font-size: 0.8125rem;
    font-weight: 600;
    padding: 0.5rem;
    z-index: 9998;
}
body.offline #offline-banner { display: block; }
body.offline .portal-main { margin-top: 34px; }

/* ── Search bar ─────────────────────────────────────────────────────── */
.search-bar {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 0.625rem 1rem;
    background: var(--light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius-sm);
    transition: border-color 0.25s, box-shadow 0.25s;
}
.search-bar:focus-within {
    border-color: var(--teal);
    box-shadow: 0 0 0 3px var(--teal-glow);
    background: var(--white);
}
.search-bar input { background: none; flex: 1; font-size: 0.875rem; }
.search-bar svg { color: var(--slate-light); flex-shrink: 0; }

/* ── Separator ──────────────────────────────────────────────────────── */
.divider { height: 1px; background: var(--border-light); margin: 1.5rem 0; }

/* ── Utilities ──────────────────────────────────────────────────────── */
.flex       { display: flex; }
.flex-col   { display: flex; flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-sm     { gap: 0.5rem; }
.gap-md     { gap: 1rem; }
.gap-lg     { gap: 1.5rem; }
.mt-sm      { margin-top: 0.5rem; }
.mt-md      { margin-top: 1rem; }
.mt-lg      { margin-top: 1.5rem; }
.text-sm    { font-size: 0.875rem; }
.text-xs    { font-size: 0.75rem; }
.text-muted { color: var(--slate-light); }
.text-teal  { color: var(--teal-dark); }
.text-navy  { color: var(--navy); }
.font-600   { font-weight: 600; }
.font-700   { font-weight: 700; font-family: 'Outfit', sans-serif; }
.w-full     { width: 100%; }
.hidden     { display: none !important; }
.spin       { animation: spin 1s linear infinite; }
@keyframes spin { to { transform: rotate(360deg); } }

/* ── Responsive ─────────────────────────────────────────────────────── */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s var(--ease); }
    .sidebar.open { transform: translateX(0); }
    .portal-main { margin-left: 0; }
    .page-content { padding: 1rem; }
    .topbar { padding: 0.75rem 1rem; }
    .inspection-row { grid-template-columns: 1fr auto; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
    h1 { font-size: 1.5rem; }
}

@media (max-width: 480px) {
    .stats-grid { grid-template-columns: 1fr 1fr; }
    .btn-lg { padding: 0.875rem 1.5rem; }
}
