/* ============================================================
   FireWatchHQ — Application Stylesheet
   ============================================================ */

:root {
    --fwh-primary: #c0392b;
    --fwh-primary-dark: #96281b;
    --fwh-secondary: #2c3e50;
    --fwh-accent: #e67e22;
    --fwh-sidebar-bg: #1a2332;
    --fwh-sidebar-width: 260px;
    --fwh-topbar-height: 56px;
    --fwh-text: #2c3e50;
    --fwh-muted: #6c757d;
    --fwh-border: #dee2e6;
    --fwh-bg: #f8f9fa;
    --fwh-white: #ffffff;
    --fwh-success: #27ae60;
    --fwh-warning: #f39c12;
    --fwh-danger: #c0392b;
    --fwh-info: #2980b9;
    --fwh-card-shadow: 0 2px 8px rgba(0,0,0,0.08);
    --fwh-radius: 8px;
}

html, body {
    font-family: 'Segoe UI', -apple-system, BlinkMacSystemFont, sans-serif;
    font-size: 14px;
    color: var(--fwh-text);
    background: var(--fwh-bg);
    margin: 0;
    padding: 0;
    height: 100%;
}

/* ============================================================
   Layout
   ============================================================ */

.fwh-layout {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.fwh-sidebar-container {
    width: var(--fwh-sidebar-width);
    flex-shrink: 0;
    height: 100vh;
    overflow-y: auto;
    background: var(--fwh-sidebar-bg);
    transition: width 0.25s ease;
}

.fwh-layout.sidebar-collapsed .fwh-sidebar-container {
    width: 56px;
}

.fwh-main-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
}

.fwh-topbar {
    height: var(--fwh-topbar-height);
    background: var(--fwh-white);
    border-bottom: 1px solid var(--fwh-border);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 1.5rem;
    flex-shrink: 0;
}

.fwh-topbar-user {
    font-weight: 500;
    color: var(--fwh-secondary);
}

.fwh-sidebar-toggle {
    background: none;
    border: none;
    font-size: 1.25rem;
    cursor: pointer;
    color: var(--fwh-secondary);
    padding: 4px 8px;
    border-radius: 4px;
}

.fwh-sidebar-toggle:hover {
    background: var(--fwh-bg);
}

.fwh-content {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* ============================================================
   Sidebar
   ============================================================ */

.fwh-sidebar {
    display: flex;
    flex-direction: column;
    height: 100%;
    color: #ffffff;
}

.fwh-brand {
    padding: 1.25rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: var(--fwh-primary);
}

.fwh-logo-icon { font-size: 1.5rem; }

.fwh-logo-text {
    font-size: 1.1rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    color: #fff;
    white-space: nowrap;
}

.fwh-nav { flex: 1; padding: 0.5rem 0; }

.fwh-nav-list {
    list-style: none;
    margin: 0;
    padding: 0;
}

.fwh-nav-section {
    padding: 0.75rem 1rem 0.25rem;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: 1.5px;
    color: rgba(255,255,255,0.4);
    text-transform: uppercase;
}

.fwh-nav-link {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    padding: 0.6rem 1rem;
    color: rgba(255,255,255,0.75);
    text-decoration: none;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
    font-size: 0.875rem;
}

.fwh-nav-link:hover {
    color: #ffffff;
    background: rgba(255,255,255,0.08);
    border-left-color: rgba(255,255,255,0.3);
}

.fwh-nav-link.active {
    color: #ffffff;
    background: rgba(192,57,43,0.25);
    border-left-color: var(--fwh-primary);
    font-weight: 600;
}

.fwh-sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
}

.fwh-user-info {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fwh-user-name {
    font-size: 0.8rem;
    color: rgba(255,255,255,0.6);
    font-weight: 500;
}

.fwh-logout-btn {
    background: none;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    cursor: pointer;
    width: 100%;
    text-align: left;
}

.fwh-logout-btn:hover {
    background: rgba(255,255,255,0.1);
    color: #fff;
}

/* ============================================================
   Cards & KPI Widgets
   ============================================================ */

.fwh-card {
    background: var(--fwh-white);
    border-radius: var(--fwh-radius);
    box-shadow: var(--fwh-card-shadow);
    padding: 1.25rem;
    border: 1px solid var(--fwh-border);
}

.fwh-kpi-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.fwh-kpi {
    background: var(--fwh-white);
    border-radius: var(--fwh-radius);
    padding: 1.25rem;
    box-shadow: var(--fwh-card-shadow);
    border-left: 4px solid var(--fwh-primary);
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.fwh-kpi.kpi-warning  { border-left-color: var(--fwh-warning); }
.fwh-kpi.kpi-success  { border-left-color: var(--fwh-success); }
.fwh-kpi.kpi-danger   { border-left-color: var(--fwh-danger);  }
.fwh-kpi.kpi-info     { border-left-color: var(--fwh-info);    }

.fwh-kpi-label {
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.8px;
    color: var(--fwh-muted);
}

.fwh-kpi-value {
    font-size: 2rem;
    font-weight: 700;
    color: var(--fwh-secondary);
    line-height: 1;
}

.fwh-kpi-sub {
    font-size: 0.75rem;
    color: var(--fwh-muted);
}

/* ============================================================
   Page headers
   ============================================================ */

.fwh-page-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.25rem;
}

.fwh-page-title {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--fwh-secondary);
    margin: 0;
}

/* ============================================================
   Tables
   ============================================================ */

.fwh-table {
    width: 100%;
    border-collapse: collapse;
    background: var(--fwh-white);
    border-radius: var(--fwh-radius);
    overflow: hidden;
    box-shadow: var(--fwh-card-shadow);
}

.fwh-table th {
    background: var(--fwh-secondary);
    color: #fff;
    padding: 0.75rem 1rem;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    font-weight: 600;
    text-align: left;
}

.fwh-table td {
    padding: 0.7rem 1rem;
    border-bottom: 1px solid var(--fwh-border);
    vertical-align: middle;
}

.fwh-table tr:last-child td { border-bottom: none; }

.fwh-table tr:hover td { background: #f8f9fa; }

/* ============================================================
   Badges / Status pills
   ============================================================ */

.fwh-badge {
    display: inline-block;
    padding: 2px 10px;
    border-radius: 100px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.badge-active   { background: #d4edda; color: #155724; }
.badge-draft    { background: #e2e8f0; color: #4a5568; }
.badge-warning  { background: #fff3cd; color: #856404; }
.badge-danger   { background: #f8d7da; color: #721c24; }
.badge-success  { background: #d4edda; color: #155724; }
.badge-info     { background: #d1ecf1; color: #0c5460; }

/* ============================================================
   Forms
   ============================================================ */

.fwh-form-section {
    background: var(--fwh-white);
    border-radius: var(--fwh-radius);
    padding: 1.5rem;
    box-shadow: var(--fwh-card-shadow);
    margin-bottom: 1rem;
}

.fwh-form-section-title {
    font-size: 0.95rem;
    font-weight: 700;
    color: var(--fwh-secondary);
    margin-bottom: 1rem;
    padding-bottom: 0.5rem;
    border-bottom: 2px solid var(--fwh-primary);
    display: inline-block;
}

/* ============================================================
   Buttons
   ============================================================ */

.btn { border-radius: 6px; font-size: 0.875rem; font-weight: 500; }
.btn-primary { background: var(--fwh-primary); border-color: var(--fwh-primary); }
.btn-primary:hover { background: var(--fwh-primary-dark); border-color: var(--fwh-primary-dark); }
.btn-sm { padding: 4px 10px; font-size: 0.8rem; }

/* ============================================================
   Error boundary
   ============================================================ */

.fwh-error-boundary {
    background: #fff3f3;
    border: 1px solid #f5c6cb;
    border-radius: var(--fwh-radius);
    padding: 2rem;
    text-align: center;
    margin: 2rem auto;
    max-width: 600px;
}

#blazor-error-ui,
.fwh-blazor-error {
    background: #c0392b;
    bottom: 0;
    box-shadow: 0 -1px 6px rgba(0,0,0,.5);
    color: white;
    display: none;
    left: 0;
    padding: 0.6rem 1.25rem 0.7rem;
    position: fixed;
    width: 100%;
    z-index: 9999;
}

#blazor-error-ui .reload,
.fwh-blazor-error .reload { color: #fff; font-weight: bold; margin-left: 1rem; }

#blazor-error-ui .dismiss,
.fwh-blazor-error .dismiss { cursor: pointer; float: right; }

/* ============================================================
   Loading / Spinner
   ============================================================ */

.fwh-loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 3rem;
    color: var(--fwh-muted);
    gap: 0.75rem;
}

.fwh-spinner {
    width: 24px; height: 24px;
    border: 3px solid var(--fwh-border);
    border-top-color: var(--fwh-primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin { to { transform: rotate(360deg); } }

/* ============================================================
   Empty states
   ============================================================ */

.fwh-empty {
    text-align: center;
    padding: 3rem;
    color: var(--fwh-muted);
}

.fwh-empty-icon { font-size: 3rem; margin-bottom: 0.75rem; }

/* ============================================================
   Responsive
   ============================================================ */

@media (max-width: 768px) {
    .fwh-sidebar-container { display: none; }
    .fwh-layout.sidebar-open .fwh-sidebar-container { display: block; position: fixed; z-index: 100; height: 100%; }
    .fwh-kpi-grid { grid-template-columns: 1fr 1fr; }
}
