/* ============================================
   hzDash Theme System - CSS Custom Properties
   ============================================ */

:root,
[data-theme="light"] {
    --hz-bg-primary: #ffffff;
    --hz-bg-secondary: #f5f5f7;
    --hz-bg-tertiary: #e8e8ed;
    --hz-bg-card: #ffffff;
    --hz-bg-input: #ffffff;
    --hz-bg-hover: #f0f0f3;
    --hz-bg-nav: #f5f5f7;

    --hz-text-primary: #1d1d1f;
    --hz-text-secondary: #6e6e73;
    --hz-text-muted: #a1a1a6;
    --hz-text-inverse: #ffffff;

    --hz-border: #d2d2d7;
    --hz-border-light: #e8e8ed;

    --hz-accent: #0071e3;
    --hz-accent-hover: #0077ed;
    --hz-accent-light: rgba(0, 113, 227, 0.1);

    --hz-success: #34c759;
    --hz-warning: #ff9f0a;
    --hz-danger: #ff3b30;
    --hz-info: #5ac8fa;

    --hz-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.08);
    --hz-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.1);
    --hz-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.12);

    --hz-radius-sm: 6px;
    --hz-radius-md: 10px;
    --hz-radius-lg: 16px;

    --hz-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --hz-font-mono: 'Cascadia Code', 'Fira Code', Consolas, monospace;

    --hz-transition: 0.2s ease;
}

[data-theme="dark"] {
    --hz-bg-primary: #1a1a1d;
    --hz-bg-secondary: #232326;
    --hz-bg-tertiary: #2c2c2f;
    --hz-bg-card: #232326;
    --hz-bg-input: #2c2c2f;
    --hz-bg-hover: #333338;
    --hz-bg-nav: #1a1a1d;

    --hz-text-primary: #f5f5f7;
    --hz-text-secondary: #a1a1a6;
    --hz-text-muted: #6e6e73;
    --hz-text-inverse: #1d1d1f;

    --hz-border: #3a3a3d;
    --hz-border-light: #2c2c2f;

    --hz-accent: #2997ff;
    --hz-accent-hover: #40a3ff;
    --hz-accent-light: rgba(41, 151, 255, 0.15);

    --hz-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.3);
    --hz-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.4);
    --hz-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.5);
}

[data-theme="vscode"] {
    --hz-bg-primary: #1e1e2e;
    --hz-bg-secondary: #252535;
    --hz-bg-tertiary: #2d2d3f;
    --hz-bg-card: #252535;
    --hz-bg-input: #2d2d3f;
    --hz-bg-hover: #353549;
    --hz-bg-nav: #191928;

    --hz-text-primary: #cdd6f4;
    --hz-text-secondary: #9399b2;
    --hz-text-muted: #6c7086;
    --hz-text-inverse: #1e1e2e;

    --hz-border: #3b3b54;
    --hz-border-light: #2d2d3f;

    --hz-accent: #007acc;
    --hz-accent-hover: #1a8ad4;
    --hz-accent-light: rgba(0, 122, 204, 0.2);

    --hz-success: #a6e3a1;
    --hz-warning: #f9e2af;
    --hz-danger: #f38ba8;
    --hz-info: #89b4fa;

    --hz-shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --hz-shadow-md: 0 4px 12px rgba(0, 0, 0, 0.5);
    --hz-shadow-lg: 0 8px 30px rgba(0, 0, 0, 0.6);
}

/* ============================================
   Global Reset & Base Styles
   ============================================ */

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

html, body {
    height: 100%;
    font-family: var(--hz-font);
    background: var(--hz-bg-primary);
    color: var(--hz-text-primary);
    transition: background var(--hz-transition), color var(--hz-transition);
    -webkit-font-smoothing: antialiased;
}

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

.hz-app {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.hz-sidebar {
    width: 260px;
    background: var(--hz-bg-nav);
    border-right: 1px solid var(--hz-border);
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
    transition: background var(--hz-transition);
}

.hz-sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--hz-border-light);
}

.hz-sidebar-brand {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--hz-accent);
    text-decoration: none;
    letter-spacing: -0.02em;
}

.hz-sidebar-nav {
    flex: 1;
    padding: 12px;
    overflow-y: auto;
}

.hz-nav-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 14px;
    border-radius: var(--hz-radius-sm);
    color: var(--hz-text-secondary);
    text-decoration: none;
    font-size: 0.9rem;
    font-weight: 500;
    transition: all var(--hz-transition);
    cursor: pointer;
}

.hz-nav-item:hover {
    background: var(--hz-bg-hover);
    color: var(--hz-text-primary);
}

.hz-nav-item.active {
    background: var(--hz-accent-light);
    color: var(--hz-accent);
}

.hz-sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--hz-border-light);
}

.hz-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.hz-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 24px;
    background: var(--hz-bg-secondary);
    border-bottom: 1px solid var(--hz-border);
    flex-shrink: 0;
}

.hz-topbar-title {
    font-size: 1.1rem;
    font-weight: 600;
}

.hz-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
}

/* ============================================
   Cards & Modules
   ============================================ */

.hz-card {
    background: var(--hz-bg-card);
    border: 1px solid var(--hz-border);
    border-radius: var(--hz-radius-md);
    box-shadow: var(--hz-shadow-sm);
    transition: all var(--hz-transition);
}

.hz-card:hover {
    box-shadow: var(--hz-shadow-md);
}

.hz-card-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--hz-border-light);
    font-weight: 600;
    font-size: 0.95rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.hz-card-body {
    padding: 20px;
}

.hz-module-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(400px, 1fr));
    gap: 20px;
}

.hz-module-span-2 {
    grid-column: span 2;
}

.hz-module-span-3 {
    grid-column: span 3;
}

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

.hz-input {
    width: 100%;
    padding: 10px 14px;
    background: var(--hz-bg-input);
    border: 1px solid var(--hz-border);
    border-radius: var(--hz-radius-sm);
    color: var(--hz-text-primary);
    font-family: var(--hz-font);
    font-size: 0.9rem;
    transition: all var(--hz-transition);
    outline: none;
}

.hz-input:focus {
    border-color: var(--hz-accent);
    box-shadow: 0 0 0 3px var(--hz-accent-light);
}

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

.hz-select {
    appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%236e6e73' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 10px center;
    background-size: 16px;
    padding-right: 36px;
}

.hz-label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--hz-text-secondary);
    margin-bottom: 6px;
}

.hz-form-group {
    margin-bottom: 18px;
}

.hz-checkbox-label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 0.9rem;
}

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

.hz-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--hz-radius-sm);
    font-family: var(--hz-font);
    font-size: 0.875rem;
    font-weight: 600;
    border: none;
    cursor: pointer;
    transition: all var(--hz-transition);
    text-decoration: none;
    line-height: 1;
}

.hz-btn-primary {
    background: var(--hz-accent);
    color: #fff;
}

.hz-btn-primary:hover {
    background: var(--hz-accent-hover);
    box-shadow: var(--hz-shadow-sm);
}

.hz-btn-secondary {
    background: var(--hz-bg-tertiary);
    color: var(--hz-text-primary);
    border: 1px solid var(--hz-border);
}

.hz-btn-secondary:hover {
    background: var(--hz-bg-hover);
}

.hz-btn-danger {
    background: var(--hz-danger);
    color: #fff;
}

.hz-btn-danger:hover {
    opacity: 0.9;
}

.hz-btn-ghost {
    background: transparent;
    color: var(--hz-text-secondary);
    padding: 8px 12px;
}

.hz-btn-ghost:hover {
    background: var(--hz-bg-hover);
    color: var(--hz-text-primary);
}

.hz-btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
}

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

.hz-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.875rem;
}

.hz-table th {
    text-align: left;
    padding: 10px 14px;
    font-weight: 600;
    color: var(--hz-text-secondary);
    border-bottom: 2px solid var(--hz-border);
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

.hz-table td {
    padding: 12px 14px;
    border-bottom: 1px solid var(--hz-border-light);
}

.hz-table tr:hover td {
    background: var(--hz-bg-hover);
}

/* ============================================
   Badges & Status
   ============================================ */

.hz-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: 100px;
    font-size: 0.75rem;
    font-weight: 600;
    letter-spacing: 0.02em;
}

.hz-badge-success { background: rgba(52, 199, 89, 0.15); color: var(--hz-success); }
.hz-badge-warning { background: rgba(255, 159, 10, 0.15); color: var(--hz-warning); }
.hz-badge-danger { background: rgba(255, 59, 48, 0.15); color: var(--hz-danger); }
.hz-badge-info { background: rgba(90, 200, 250, 0.15); color: var(--hz-info); }
.hz-badge-accent { background: var(--hz-accent-light); color: var(--hz-accent); }

/* ============================================
   Theme Selector
   ============================================ */

.hz-theme-switcher {
    display: flex;
    gap: 4px;
    background: var(--hz-bg-tertiary);
    padding: 3px;
    border-radius: var(--hz-radius-sm);
}

.hz-theme-btn {
    width: 28px;
    height: 28px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
    transition: all var(--hz-transition);
}

.hz-theme-btn:hover {
    transform: scale(1.1);
}

.hz-theme-btn.active {
    border-color: var(--hz-accent);
    box-shadow: 0 0 0 2px var(--hz-accent-light);
}

.hz-theme-btn-light { background: #f5f5f7; }
.hz-theme-btn-dark { background: #1a1a1d; }
.hz-theme-btn-vscode { background: linear-gradient(135deg, #1e1e2e, #007acc); }

/* ============================================
   Utility Classes
   ============================================ */

.hz-flex { display: flex; }
.hz-flex-col { flex-direction: column; }
.hz-items-center { align-items: center; }
.hz-justify-between { justify-content: space-between; }
.hz-gap-sm { gap: 8px; }
.hz-gap-md { gap: 16px; }
.hz-gap-lg { gap: 24px; }
.hz-mt-sm { margin-top: 8px; }
.hz-mt-md { margin-top: 16px; }
.hz-mb-md { margin-bottom: 16px; }
.hz-p-md { padding: 16px; }
.hz-text-center { text-align: center; }
.hz-text-muted { color: var(--hz-text-muted); }
.hz-text-sm { font-size: 0.85rem; }
.hz-w-full { width: 100%; }

/* ============================================
   Auth Pages
   ============================================ */

.hz-auth-container {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    background: var(--hz-bg-primary);
}

.hz-auth-card {
    width: 100%;
    max-width: 420px;
    padding: 40px;
    background: var(--hz-bg-card);
    border: 1px solid var(--hz-border);
    border-radius: var(--hz-radius-lg);
    box-shadow: var(--hz-shadow-lg);
}

.hz-auth-title {
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 8px;
    letter-spacing: -0.02em;
}

.hz-auth-subtitle {
    color: var(--hz-text-secondary);
    font-size: 0.9rem;
    margin-bottom: 32px;
}

.hz-error-message {
    padding: 10px 14px;
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.2);
    border-radius: var(--hz-radius-sm);
    color: var(--hz-danger);
    font-size: 0.85rem;
    margin-bottom: 16px;
}

/* ============================================
   Dashboard Grid
   ============================================ */

.hz-dashboard-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 16px;
}

.hz-dashboard-card {
    padding: 20px;
    cursor: pointer;
}

.hz-dashboard-card h3 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 8px;
}

.hz-dashboard-card .hz-meta {
    display: flex;
    gap: 12px;
    color: var(--hz-text-secondary);
    font-size: 0.8rem;
}

/* ============================================
   Modal / Dialog
   ============================================ */

.hz-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.15s ease;
}

.hz-modal {
    background: var(--hz-bg-card);
    border: 1px solid var(--hz-border);
    border-radius: var(--hz-radius-lg);
    box-shadow: var(--hz-shadow-lg);
    width: 100%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.2s ease;
}

.hz-modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--hz-border-light);
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-weight: 600;
    font-size: 1.05rem;
}

.hz-modal-body {
    padding: 24px;
}

.hz-modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--hz-border-light);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

/* ============================================
   Loading & Errors
   ============================================ */

.loading-progress {
    position: absolute;
    display: block;
    width: 8rem;
    height: 8rem;
    inset: 20vh 0 auto 0;
    margin: 0 auto;
}

.loading-progress circle {
    fill: none;
    stroke: var(--hz-border, #e0e0e0);
    stroke-width: 0.6rem;
    transform-origin: 50% 50%;
    transform: rotate(-90deg);
}

.loading-progress circle:last-child {
    stroke: var(--hz-accent, #0071e3);
    stroke-dasharray: calc(3.141 * var(--blazor-load-percentage, 0%) * 0.8), 500%;
    transition: stroke-dasharray 0.05s ease-in-out;
}

.loading-progress-text {
    position: absolute;
    text-align: center;
    font-weight: bold;
    inset: calc(20vh + 3.25rem) 0 auto 0.2rem;
}

.loading-progress-text:after {
    content: var(--blazor-load-percentage-text, "Loading");
}

#blazor-error-ui {
    background: var(--hz-danger, #ff3b30);
    color: #fff;
    padding: 0.6rem 1.25rem;
    position: fixed;
    bottom: 0;
    width: 100%;
    z-index: 9999;
    display: none;
}

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

.blazor-error-boundary {
    background: var(--hz-danger);
    padding: 1rem;
    color: white;
    border-radius: var(--hz-radius-sm);
}

.blazor-error-boundary::after {
    content: "An error has occurred.";
}

/* ============================================
   Incident Map
   ============================================ */

.hz-incident-label {
    background: rgba(0, 0, 0, 0.75) !important;
    border: none !important;
    color: #fff !important;
    padding: 2px 8px !important;
    border-radius: 4px !important;
    font-size: 11px !important;
    font-weight: 600 !important;
    box-shadow: 0 1px 4px rgba(0,0,0,0.3) !important;
}

.hz-incident-label::before { display: none !important; }

.hz-icon-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 6px;
}

.hz-icon-option {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 8px 4px;
    border: 1px solid var(--hz-border);
    border-radius: var(--hz-radius-sm);
    cursor: pointer;
    font-size: 0.7rem;
    text-align: center;
    transition: all var(--hz-transition);
}

.hz-icon-option:hover { background: var(--hz-bg-hover); }
.hz-icon-option.selected { border-color: var(--hz-accent); background: var(--hz-accent-light); }

.hz-icon-circle {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    border: 2px solid #fff;
    box-shadow: 0 1px 3px rgba(0,0,0,0.3);
}

.hz-color-swatch {
    width: 24px;
    height: 24px;
    border-radius: 4px;
    border: 2px solid transparent;
    cursor: pointer;
}

.hz-color-swatch.selected { border-color: var(--hz-text-primary); }

/* ============================================
   Incident Notes
   ============================================ */

.hz-notes-container {
    max-height: 420px;
    overflow-y: auto;
    border: 1px solid var(--hz-border);
    border-radius: var(--hz-radius-md);
    background: var(--hz-bg-secondary);
}

.hz-notes-container::-webkit-scrollbar {
    width: 8px;
}

.hz-notes-container::-webkit-scrollbar-track {
    background: var(--hz-bg-tertiary);
    border-radius: 0 var(--hz-radius-md) var(--hz-radius-md) 0;
}

.hz-notes-container::-webkit-scrollbar-thumb {
    background: var(--hz-accent);
    border-radius: 4px;
    border: 2px solid var(--hz-bg-tertiary);
}

.hz-notes-container::-webkit-scrollbar-thumb:hover {
    background: var(--hz-accent-hover);
}

.hz-notes-empty {
    padding: 40px 20px;
    text-align: center;
}

.hz-note {
    padding: 14px 18px;
    border-bottom: 1px solid var(--hz-border-light);
    transition: background var(--hz-transition);
    animation: noteSlideIn 0.25s ease;
}

.hz-note:hover {
    background: var(--hz-bg-hover);
}

.hz-note:last-child {
    border-bottom: none;
}

.hz-note-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 6px;
}

.hz-note-user {
    font-weight: 700;
    font-size: 0.85rem;
    color: var(--hz-accent);
}

.hz-note-time {
    font-size: 0.75rem;
    color: var(--hz-text-muted);
    font-family: var(--hz-font-mono);
}

.hz-note-delete {
    margin-left: auto;
    opacity: 0;
    transition: opacity var(--hz-transition);
    color: var(--hz-danger) !important;
    font-size: 1rem;
    padding: 2px 6px;
}

.hz-note:hover .hz-note-delete {
    opacity: 1;
}

.hz-note-body {
    font-size: 0.9rem;
    line-height: 1.5;
    white-space: pre-wrap;
    word-break: break-word;
    color: var(--hz-text-primary);
}

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