/* ============================================================
   Revio — Review Intelligence Platform
   Design System v1: Linear/Stripe-inspired premium aesthetic
   Primary: Deep Indigo (#4F46E5) | Three-layer light system
   ============================================================ */

:root {
    /* Brand */
    --primary: #4F46E5;
    --primary-hover: #4338CA;
    --primary-light: #EEF2FF;
    --primary-muted: #818CF8;

    /* Surfaces — three-layer light system */
    --bg: #FAFAFB;
    --surface: #FFFFFF;
    --border: #E5E7EB;
    --border-hover: #D1D5DB;

    /* Text */
    --text: #111827;
    --text-secondary: #6B7280;
    --text-tertiary: #9CA3AF;

    /* Grays */
    --gray-50: #f9fafb;
    --gray-100: #f3f4f6;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-500: #6b7280;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;

    /* Sentiment */
    --positive: #10B981;
    --positive-light: #ECFDF5;
    --negative: #EF4444;
    --negative-light: #FEF2F2;
    --warning: #F59E0B;
    --warning-light: #FFFBEB;
    --info: #3b82f6;
    --info-light: #dbeafe;

    /* Radii — no shadows */
    --radius: 8px;
    --radius-sm: 6px;
    --radius-xs: 4px;

    /* Fonts */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;

    --topbar-height: 56px;
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
    font-family: var(--font-sans);
    background: var(--bg);
    color: var(--text);
    font-size: 13px;
    line-height: 1.5;
}

a { color: var(--text); text-decoration: none; }

/* ============================================================
   LAYOUT
   ============================================================ */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* MAIN CONTENT */
.main-content {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* TOPBAR */
.topbar {
    background: var(--surface);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: 16px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.topbar h1 {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.02em;
    flex: 1;
}

.date-filter {
    display: flex;
    gap: 2px;
    background: var(--bg);
    border-radius: var(--radius-sm);
    padding: 3px;
}

.date-filter a {
    padding: 5px 12px;
    border-radius: var(--radius-xs);
    font-size: 12px;
    font-weight: 400;
    color: var(--text-secondary);
    transition: all 0.15s;
}

.date-filter a:hover { background: rgba(0,0,0,0.03); }

.date-filter a.active {
    background: var(--surface);
    color: var(--text);
    font-weight: 500;
    border: 1px solid var(--border);
}

.topbar-badge {
    display: inline-block;
    font-size: 11px;
    font-weight: 500;
    padding: 3px 10px;
    border-radius: 9999px;
    letter-spacing: 0.3px;
}

/* PAGE CONTENT */
.page-content {
    flex: 1;
    padding: 24px 28px 40px;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* ============================================================
   COMPONENTS
   ============================================================ */

/* KPI Cards */
.kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 12px;
    margin-bottom: 24px;
}

.kpi-card {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 16px 20px;
    border: 1px solid var(--border);
    position: relative;
}

.kpi-card.alert-card { border: 1px solid var(--negative); }
.kpi-card.alert-card::after {
    content: '⚠ ACTION';
    position: absolute;
    top: 10px;
    right: 12px;
    font-size: 11px;
    font-weight: 600;
    color: var(--negative);
}

.kpi-label {
    font-size: 12px;
    color: var(--text-secondary);
    font-weight: 500;
    margin-bottom: 4px;
}

.kpi-value {
    font-size: 24px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--text);
    line-height: 1.1;
    letter-spacing: -0.03em;
}

.kpi-sub { font-size: 12px; color: var(--text-secondary); margin-top: 4px; }

.kpi-trend { font-size: 12px; font-weight: 500; margin-top: 6px; }
.kpi-trend.up { color: var(--positive); }
.kpi-trend.down { color: var(--negative); }
.kpi-trend.neutral { color: var(--text-tertiary); }

/* Cards / Panels */
.panel {
    background: var(--surface);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.panel-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.panel-title { font-size: 14px; font-weight: 600; letter-spacing: -0.01em; }
.panel-subtitle { font-size: 12px; color: var(--text-tertiary); margin-top: 2px; }
.panel-body { padding: 20px; }

/* Two column layout */
.grid-2 {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 16px;
    margin-bottom: 24px;
}

.grid-2.equal { grid-template-columns: 1fr 1fr; }

/* Alert rows */
.alert-row {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    margin-bottom: 6px;
    font-size: 13px;
}

.alert-row.high {
    background: var(--negative-light);
    border-left: 3px solid var(--negative);
}

.alert-row.medium {
    background: var(--warning-light);
    border-left: 3px solid var(--warning);
}

.alert-row.resolved {
    background: var(--positive-light);
    border-left: 3px solid var(--positive);
}

.alert-row .loc-name { font-weight: 600; min-width: 220px; }
.alert-row .alert-msg { color: var(--gray-600); flex: 1; }

.alert-severity {
    font-size: 11px;
    font-weight: 500;
    padding: 2px 8px;
    border-radius: 9999px;
    text-transform: uppercase;
}

.alert-severity.high { background: var(--negative-light); color: var(--negative); }
.alert-severity.medium { background: var(--warning-light); color: var(--warning); }

/* Location table */
.loc-table { width: 100%; border-collapse: collapse; }

.loc-table th {
    text-align: left;
    padding: 8px 16px;
    font-size: 11px;
    font-weight: 500;
    color: var(--text-tertiary);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border);
}

.loc-table th.center { text-align: center; }

.loc-table td {
    padding: 12px 16px;
    border-bottom: 1px solid var(--gray-100);
    font-size: 13px;
}

.loc-table tr:hover { background: var(--gray-50); }

.loc-table .loc-name-cell a {
    font-weight: 500;
    color: var(--text);
}

.loc-table .loc-name-cell a:hover {
    color: var(--primary);
}

.rating-value { font-weight: 600; font-family: var(--font-mono); text-align: center; }
.rating-value.good { color: var(--positive); }
.rating-value.mid { color: var(--warning); }
.rating-value.bad { color: var(--negative); }

/* Progress bar */
.progress-bar {
    display: flex;
    align-items: center;
    gap: 6px;
}

.progress-track {
    flex: 1;
    height: 6px;
    border-radius: 3px;
    background: var(--gray-200);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: 3px;
    transition: width 0.3s;
}

.progress-fill.good { background: var(--positive); }
.progress-fill.mid { background: var(--warning); }
.progress-fill.bad { background: var(--negative); }

.progress-label { font-size: 11px; font-family: var(--font-mono); width: 35px; text-align: right; }
.progress-label.bad { color: var(--negative); font-weight: 600; }

/* Sentiment dot */
.sentiment-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.sentiment-dot.good { background: var(--positive); }
.sentiment-dot.mid { background: var(--warning); }
.sentiment-dot.bad { background: var(--negative); }

/* Callout banners */
.callout {
    padding: 14px 18px;
    border-radius: var(--radius);
    margin-bottom: 20px;
    font-size: 13px;
    display: flex;
    align-items: flex-start;
    gap: 8px;
}

.callout.info {
    background: var(--primary-light);
    border: 1px solid #C7D2FE;
    color: #3730A3;
}

.callout.danger {
    background: var(--negative-light);
    border: 1px solid #fca5a5;
    color: #991b1b;
}

.callout .icon { font-size: 16px; flex-shrink: 0; margin-top: 1px; }

/* Search + controls */
.controls-bar {
    padding: 14px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    gap: 12px;
    align-items: center;
}

.search-input {
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px;
    font-family: var(--font-sans);
    width: 260px;
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
}

.search-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.sort-select {
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px;
    font-family: var(--font-sans);
    background: var(--surface);
    cursor: pointer;
}

.controls-count { margin-left: auto; font-size: 12px; color: var(--text-tertiary); }

/* Bar chart (CSS-only) */
.bar-chart-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
    font-size: 13px;
}

.bar-label {
    width: 150px;
    text-align: right;
    color: var(--gray-600);
    font-weight: 500;
}

.bar-track {
    flex: 1;
    height: 22px;
    background: var(--gray-100);
    border-radius: var(--radius-xs);
    overflow: hidden;
}

.bar-fill {
    height: 100%;
    background: var(--primary);
    border-radius: var(--radius-xs);
    display: flex;
    align-items: center;
    padding-left: 8px;
    font-size: 11px;
    font-weight: 600;
    font-family: var(--font-mono);
    color: #fff;
    min-width: 30px;
}

/* Needs ranking */
.needs-row {
    display: flex;
    align-items: center;
    padding: 14px 20px;
    gap: 16px;
    border-bottom: 1px solid var(--gray-100);
}

.needs-row:last-child { border-bottom: none; }

.needs-rank {
    width: 28px;
    height: 28px;
    border-radius: 9999px;
    background: var(--primary-light);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: var(--primary);
    font-size: 12px;
    flex-shrink: 0;
}

.needs-name { flex: 2; font-weight: 500; font-size: 13px; }
.needs-mentions { flex: 0.5; font-size: 12px; font-family: var(--font-mono); color: var(--text-secondary); }
.needs-bar { flex: 1; }
.needs-pct { width: 40px; text-align: right; font-weight: 600; font-family: var(--font-mono); font-size: 13px; }

/* Star distribution */
.star-dist-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.star-dist-label {
    width: 30px;
    text-align: right;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--gray-700);
}

.star-dist-bar {
    flex: 1;
    height: 10px;
    background: var(--gray-100);
    border-radius: 5px;
    overflow: hidden;
}

.star-dist-fill { height: 100%; border-radius: 5px; }
.star-dist-fill.star-5 { background: var(--positive); }
.star-dist-fill.star-4 { background: #6EE7B7; }
.star-dist-fill.star-3 { background: var(--warning); }
.star-dist-fill.star-2 { background: #FB923C; }
.star-dist-fill.star-1 { background: var(--negative); }

.star-dist-count { width: 50px; font-family: var(--font-mono); color: var(--text-secondary); font-size: 12px; }

/* Review cards (for location detail + unreplied queue) */
.review-card {
    padding: 16px 20px;
    border-bottom: 1px solid var(--gray-100);
}

.review-card:last-child { border-bottom: none; }

.review-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
    font-size: 13px;
}

.review-stars { color: #FBBF24; font-weight: 600; }
.review-author { font-weight: 500; color: var(--text); }
.review-date { color: var(--text-tertiary); margin-left: auto; font-size: 12px; }

.review-text { font-size: 13px; color: var(--text-secondary); line-height: 1.6; margin-bottom: 8px; }

.review-tags {
    display: flex;
    gap: 4px;
    flex-wrap: wrap;
}

.review-tag {
    display: inline-block;
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 9999px;
    background: var(--gray-100);
    color: var(--gray-600);
    font-weight: 500;
}

.review-tag.sentiment-positive { background: var(--positive-light); color: #065F46; }
.review-tag.sentiment-negative { background: var(--negative-light); color: #991b1b; }
.review-tag.unreplied { background: var(--negative-light); color: var(--negative); font-weight: 600; }

.review-reply {
    margin-top: 8px;
    padding: 10px 14px;
    background: var(--gray-50);
    border-left: 2px solid var(--border);
    border-radius: var(--radius-xs);
    font-size: 12px;
    color: var(--text-secondary);
}

/* Reply quality examples */
.reply-example {
    padding: 14px;
    border-radius: var(--radius);
    margin-bottom: 12px;
    font-size: 13px;
}

.reply-example.good {
    background: var(--positive-light);
    border-left: 3px solid var(--positive);
}

.reply-example.bad {
    background: var(--negative-light);
    border-left: 3px solid var(--negative);
}

.reply-example .label {
    font-weight: 600;
    margin-bottom: 4px;
}

.reply-example.good .label { color: var(--positive); }
.reply-example.bad .label { color: var(--negative); }

/* Settings */
.setting-row {
    display: flex;
    align-items: center;
    padding: 12px 0;
    border-bottom: 1px solid var(--gray-100);
    gap: 16px;
    font-size: 13px;
}

.setting-row:last-child { border-bottom: none; }

.setting-row .label { flex: 1; }
.setting-row .label strong { display: block; font-weight: 500; }
.setting-row .label span { font-size: 11px; color: var(--text-tertiary); }

.setting-value {
    padding: 5px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 13px;
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    margin-right: 4px;
}

.status-dot.ok { background: var(--positive); }
.status-dot.running { background: var(--info); }
.status-dot.error { background: var(--negative); }

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    font-family: var(--font-sans);
    cursor: pointer;
    border: none;
    transition: all 0.15s;
    letter-spacing: -0.01em;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
}

.btn-primary:hover { background: var(--primary-hover); }

.btn-outline {
    background: none;
    border: 1px solid var(--border);
    color: var(--text-secondary);
}

.btn-outline:hover {
    background: var(--gray-50);
    border-color: var(--border-hover);
}

.btn-danger {
    background: var(--negative);
    color: #fff;
}

.btn-danger:hover { background: #DC2626; }

.btn-ghost {
    background: none;
    border: none;
    color: var(--text-secondary);
}

.btn-ghost:hover { color: var(--text); }

.btn-sm { padding: 6px 12px; font-size: 12px; }

/* Login & 2FA pages */
.login-page {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg);
}

.login-box {
    background: var(--surface);
    border-radius: var(--radius);
    padding: 44px 40px 36px;
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border);
}

.login-logo {
    text-align: center;
    margin-bottom: 32px;
}

.login-logo h1 {
    font-size: 20px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.03em;
}

.login-logo p {
    font-size: 13px;
    color: var(--text-secondary);
    margin-top: 6px;
    line-height: 1.4;
}

.form-group { margin-bottom: 20px; }

.form-group label {
    display: block;
    font-size: 12px;
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: 6px;
}

.form-input {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text);
    outline: none;
    transition: border-color 0.15s, box-shadow 0.15s;
    font-family: var(--font-sans);
}

.form-input:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px var(--primary-light);
}

.btn-login {
    width: 100%;
    padding: 10px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: background 0.15s;
    font-family: var(--font-sans);
    letter-spacing: -0.01em;
}

.btn-login:hover {
    background: var(--primary-hover);
}

.login-error {
    background: var(--negative-light);
    color: #991b1b;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 20px;
    border: 1px solid #FCA5A5;
}

.login-footer {
    text-align: center;
    margin-top: 20px;
    padding-top: 16px;
    border-top: 1px solid var(--border);
}

.login-footer p {
    font-size: 12px;
    color: var(--text-tertiary);
    margin-bottom: 6px;
}

.login-footer a {
    font-size: 12px;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.1s;
}

.login-footer a:hover {
    color: var(--primary);
}

/* Chart container */
.chart-container {
    position: relative;
    width: 100%;
    height: 220px;
}

/* Scrollbar — appears on hover, hidden otherwise */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: transparent;
    border-radius: 3px;
    transition: background 0.2s;
}
*:hover::-webkit-scrollbar-thumb {
    background: rgba(0,0,0,0.12);
}
*:hover::-webkit-scrollbar-thumb:hover {
    background: rgba(0,0,0,0.25);
}
* {
    scrollbar-width: thin;
    scrollbar-color: transparent transparent;
}
*:hover {
    scrollbar-color: rgba(0,0,0,0.12) transparent;
}

/* Toggle switch */
.toggle {
    position: relative;
    display: inline-block;
    width: 40px;
    height: 22px;
    cursor: pointer;
}

.toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    inset: 0;
    background: var(--gray-300);
    border-radius: 11px;
    transition: background 0.2s;
}

.toggle-slider::before {
    content: '';
    position: absolute;
    width: 16px;
    height: 16px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: transform 0.2s;
}

.toggle input:checked + .toggle-slider {
    background: var(--primary);
}

.toggle input:checked + .toggle-slider::before {
    transform: translateX(18px);
}

/* Responsive */
@media (max-width: 1024px) {
    .grid-2 { grid-template-columns: 1fr; }
    .kpi-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    .kpi-grid { grid-template-columns: 1fr; }
    .controls-bar { flex-wrap: wrap; }
    .search-input { width: 100%; }
    .page-content { padding: 16px; }
    .alert-row { flex-wrap: wrap; }
    .alert-row .loc-name { min-width: unset; width: 100%; }
}