/* ============================================
   Page Decay Dashboard — Swifty Design System
   Gold/Amber + Dark theme matching Swifty brand
   ============================================ */

:root {
    --primary: #CC8016;
    --primary-light: #D9A050;
    --primary-lighter: #F5E6CC;
    --primary-dark: #A86A10;
    --primary-bg: #FFF8EE;
    --dark-1: #181A20;
    --dark-2: #1F222A;
    --dark-3: #35383F;
    --bg: #F5F5F5;
    --card-bg: #ffffff;
    --border: #EEEEEE;
    --border-strong: #E0E0E0;
    --text: #212121;
    --text-secondary: #424242;
    --text-muted: #757575;
    --text-light: #9E9E9E;
    --success: #4CAF50;
    --warning: #FFC107;
    --danger: #F44336;
    --info: #2196F3;
    --radius: 12px;
    --radius-sm: 8px;
    --radius-pill: 20px;
    --shadow: 0 1px 3px rgba(0,0,0,0.04), 0 2px 8px rgba(0,0,0,0.06);
    --shadow-lg: 0 4px 16px rgba(0,0,0,0.1);
    --shadow-hover: 0 8px 24px rgba(0,0,0,0.12);
    --font: 'Montserrat', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

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

body {
    font-family: var(--font);
    background: var(--bg);
    color: var(--text);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    line-height: 1.4;
    font-size: 14px;
}

/* Navbar — Dark like Swifty sidebar */
.navbar {
    background: var(--dark-1);
    padding: 0 28px;
    height: 60px;
    display: flex;
    align-items: center;
    gap: 32px;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-brand a {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    letter-spacing: -0.02em;
}

.nav-brand .brand-accent {
    color: var(--primary-light);
}

.nav-icon { display: flex; align-items: center; }
.nav-icon img { height: 32px; width: auto; }

.nav-links {
    display: flex;
    gap: 4px;
    flex: 1;
}

.nav-links a {
    padding: 8px 18px;
    border-radius: var(--radius-pill);
    text-decoration: none;
    color: rgba(255,255,255,0.6);
    font-size: 13px;
    font-weight: 500;
    transition: all 0.2s;
    letter-spacing: -0.01em;
}

.nav-links a:hover {
    background: var(--dark-3);
    color: #fff;
}

.nav-links a.active {
    background: var(--primary);
    color: #fff;
}

.nav-actions { display: flex; gap: 8px; align-items: center; }

.nav-actions .btn-outline {
    border-color: rgba(255,255,255,0.25);
    color: rgba(255,255,255,0.8);
}
.nav-actions .btn-outline:hover {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}
.nav-actions .btn-icon {
    border-color: rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
}
.nav-actions .btn-icon:hover {
    background: var(--dark-3);
    color: #fff;
    border-color: rgba(255,255,255,0.3);
}

/* Buttons */
.btn {
    padding: 10px 20px;
    border-radius: var(--radius);
    font-size: 13px;
    font-weight: 600;
    font-family: var(--font);
    cursor: pointer;
    border: none;
    transition: all 0.2s;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    letter-spacing: -0.01em;
}

.btn-sm { padding: 7px 14px; font-size: 12px; }

.btn-primary {
    background: var(--primary);
    color: #fff;
    box-shadow: 0 2px 4px rgba(204, 128, 22, 0.25);
}
.btn-primary:hover {
    background: var(--primary-dark);
    box-shadow: 0 4px 8px rgba(204, 128, 22, 0.35);
    transform: translateY(-1px);
}

.btn-outline {
    background: transparent;
    color: var(--primary);
    border: 1.5px solid var(--primary);
}
.btn-outline:hover {
    background: var(--primary);
    color: #fff;
}

.btn-success { background: var(--success); color: #fff; }
.btn-success:hover { background: #43A047; }
.btn-danger { background: var(--danger); color: #fff; }
.btn-danger:hover { background: #E53935; }

.btn-icon {
    background: transparent;
    color: var(--text-muted);
    padding: 8px 12px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius);
}
.btn-icon:hover {
    background: var(--bg);
    color: var(--text);
    border-color: var(--text-light);
}

/* Container */
.container {
    max-width: 1320px;
    margin: 0 auto;
    padding: 28px;
    flex: 1;
    width: 100%;
}

/* Cards */
.card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 24px;
    margin-bottom: 20px;
}

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

.card-title {
    font-size: 16px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.card-subtitle {
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 2px;
}

/* Grid */
.grid { display: grid; gap: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }
.grid-7 { grid-template-columns: repeat(7, 1fr); }

@media (max-width: 768px) {
    .grid-2, .grid-3, .grid-4, .grid-7 { grid-template-columns: 1fr; }
}

/* KPI Cards */
.kpi-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px 24px;
    text-align: center;
    transition: box-shadow 0.2s, transform 0.2s;
}

.kpi-card:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-1px);
}

.kpi-value {
    font-size: 28px;
    font-weight: 700;
    line-height: 1.2;
    color: var(--text);
}

.kpi-label {
    font-size: 11px;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.6px;
    margin-top: 6px;
    font-weight: 500;
}

/* Grade badge */
.grade {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 18px;
    font-weight: 800;
    color: #fff;
}

.grade-lg {
    width: 56px;
    height: 56px;
    font-size: 26px;
}

.grade-A { background: #4CAF50; }
.grade-B { background: #66BB6A; }
.grade-C { background: #FFC107; color: #212121; }
.grade-D { background: #FF9800; }
.grade-F { background: #F44336; }
.grade-NA { background: #9E9E9E; }

/* Status badges */
.status-badge {
    display: inline-block;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    font-size: 11px;
    font-weight: 600;
    text-transform: capitalize;
    letter-spacing: 0.02em;
}

.status-healthy    { background: #E8F5E9; color: #2E7D32; }
.status-emerging   { background: #E3F2FD; color: #1565C0; }
.status-declining  { background: #FFF8E1; color: #F57F17; }
.status-decaying   { background: #FFF3E0; color: #E65100; }
.status-critical   { background: #FFEBEE; color: #C62828; }
.status-dead       { background: #F5F5F5; color: #424242; }
.status-never_indexed { background: #FAFAFA; color: #757575; }

/* Tables */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius-sm);
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

thead th {
    background: #FAFAFA;
    padding: 12px 14px;
    text-align: left;
    font-weight: 600;
    color: var(--text-muted);
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 2px solid var(--border-strong);
    white-space: nowrap;
}

tbody td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

tbody tr { transition: background 0.15s; }
tbody tr:hover { background: #FAFAFA; }

.url-cell {
    max-width: 350px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    font-family: 'SF Mono', Monaco, 'Cascadia Code', monospace;
    font-size: 12px;
    color: var(--primary);
}

.num-cell { text-align: right; font-variant-numeric: tabular-nums; }

/* Trend indicators */
.trend-up { color: var(--success); font-weight: 600; }
.trend-down { color: var(--danger); font-weight: 600; }
.trend-flat { color: var(--text-light); font-weight: 600; }

.trend-up::before { content: "\25B2 "; font-size: 10px; }
.trend-down::before { content: "\25BC "; font-size: 10px; }
.trend-flat::before { content: "\25CF "; font-size: 10px; }

/* Property cards (portfolio grid) */
.property-card {
    background: var(--card-bg);
    border-radius: var(--radius);
    border: 1px solid var(--border);
    box-shadow: var(--shadow);
    padding: 20px;
    transition: all 0.25s ease;
    text-decoration: none;
    color: inherit;
    display: block;
    border-left: 4px solid transparent;
}

.property-card:hover {
    box-shadow: var(--shadow-hover);
    transform: translateY(-3px);
    border-color: var(--border-strong);
}

.property-card.grade-border-A { border-left-color: #4CAF50; }
.property-card.grade-border-B { border-left-color: #66BB6A; }
.property-card.grade-border-C { border-left-color: #FFC107; }
.property-card.grade-border-D { border-left-color: #FF9800; }
.property-card.grade-border-F { border-left-color: #F44336; }
.property-card.grade-border-NA { border-left-color: #9E9E9E; }

.property-card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 12px;
}

.property-card-name {
    font-size: 15px;
    font-weight: 600;
    color: var(--text);
    letter-spacing: -0.01em;
}

.property-card-folder {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 3px;
}

.property-card-stats {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 4px;
}

.mini-stat {
    font-size: 11px;
    color: var(--text-muted);
    font-weight: 500;
}

.mini-stat strong { color: var(--text); }

/* Sparkline bar chart */
.spark-bar {
    display: flex;
    gap: 1px;
    height: 32px;
    align-items: flex-end;
    margin-top: 12px;
}

.spark-bar-segment {
    flex: 1;
    border-radius: 3px 3px 0 0;
    min-width: 3px;
}

/* Page header */
.page-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    margin-bottom: 28px;
}

.page-title {
    font-size: 24px;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.02em;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 4px;
    font-weight: 400;
}

.page-actions { display: flex; gap: 8px; align-items: center; }

/* Status distribution bar */
.status-bar {
    display: flex;
    height: 10px;
    border-radius: 5px;
    overflow: hidden;
    margin: 8px 0;
    background: var(--border);
}

.status-bar-segment { transition: width 0.3s ease; }
.status-bar-segment.healthy    { background: #4CAF50; }
.status-bar-segment.emerging   { background: #2196F3; }
.status-bar-segment.declining  { background: #FFC107; }
.status-bar-segment.decaying   { background: #FF9800; }
.status-bar-segment.critical   { background: #F44336; }
.status-bar-segment.dead       { background: #616161; }
.status-bar-segment.never_indexed { background: #BDBDBD; }

/* Chart container */
.chart-container {
    width: 100%;
    height: 300px;
    position: relative;
}

.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Toast */
.toast-container {
    position: fixed;
    top: 72px;
    right: 24px;
    z-index: 200;
}

.toast {
    padding: 14px 22px;
    border-radius: var(--radius);
    background: var(--dark-2);
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--shadow-lg);
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 3.5s forwards;
}

.toast-success { background: #4CAF50; }
.toast-error { background: #F44336; }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    to { opacity: 0; transform: translateY(-10px); }
}

/* Empty state */
.empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--text-muted);
}

.empty-state-icon {
    font-size: 48px;
    margin-bottom: 16px;
}

.empty-state h3 {
    font-size: 18px;
    margin-bottom: 8px;
    color: var(--text);
    font-weight: 600;
}

/* Loading */
.htmx-indicator {
    opacity: 0;
    transition: opacity 0.2s;
}
.htmx-request .htmx-indicator { opacity: 1; }

/* Section spacing */
.section { margin-bottom: 32px; }
.section-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 16px;
    color: var(--text);
    letter-spacing: -0.01em;
}

/* Recommendation cards */
.rec-group { margin-bottom: 16px; }

.rec-priority {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
    padding: 4px 12px;
    border-radius: var(--radius-pill);
    display: inline-block;
}

.rec-priority.high { background: #FFEBEE; color: #C62828; }
.rec-priority.medium { background: #FFF8E1; color: #F57F17; }
.rec-priority.low { background: #E3F2FD; color: #1565C0; }

.rec-item {
    padding: 10px 0 10px 16px;
    border-left: 3px solid var(--border-strong);
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    transition: border-color 0.2s;
}

.rec-item:hover { border-left-color: var(--primary); }

/* Footer */
.footer {
    text-align: center;
    padding: 20px;
    font-size: 12px;
    color: var(--text-light);
    border-top: 1px solid var(--border);
    margin-top: auto;
    font-weight: 500;
}

/* Login page */
.login-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: linear-gradient(135deg, #F5F5F5 0%, #FFF8EE 100%);
}

.login-card {
    background: var(--card-bg);
    border-radius: 16px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    padding: 48px 40px;
    width: 100%;
    max-width: 420px;
    text-align: center;
}

.login-card h1 {
    font-size: 24px;
    font-weight: 700;
    margin-bottom: 8px;
    color: var(--text);
    letter-spacing: -0.02em;
}

.login-card p {
    color: var(--text-muted);
    margin-bottom: 28px;
    font-size: 14px;
}

.login-card input {
    width: 100%;
    padding: 12px 16px;
    border: 1.5px solid var(--border-strong);
    border-radius: var(--radius);
    font-size: 14px;
    font-family: var(--font);
    margin-bottom: 16px;
    transition: border-color 0.2s, box-shadow 0.2s;
    color: var(--text);
}

.login-card input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(204, 128, 22, 0.15);
}

.login-error {
    color: var(--danger);
    font-size: 13px;
    margin-bottom: 12px;
    font-weight: 500;
}

/* Scrollbar styling */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #BDBDBD; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9E9E9E; }

/* Links */
a { color: var(--primary); }
a:hover { color: var(--primary-dark); }

/* Utility classes */
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }
.text-muted { color: var(--text-muted); }
