/* =============================================================================
   Life Hub Base Styles
   Shared across all dashboard templates
   ============================================================================= */

/* =============================================================================
   CSS Custom Properties (Design Tokens)
   ============================================================================= */
:root {
    /* Brand Colors */
    --color-brand-primary: #6366f1;
    --color-brand-primary-hover: #4f46e5;
    --color-brand-secondary: #818cf8;
    --color-neon-cyan: #06b6d4;

    /* Intent Colors */
    --color-intent-success: #22c55e;
    --color-intent-success-muted: rgba(34, 197, 94, 0.15);
    --color-intent-warning: #f59e0b;
    --color-intent-warning-muted: rgba(245, 158, 11, 0.15);
    --color-intent-error: #ef4444;
    --color-intent-error-muted: rgba(239, 68, 68, 0.15);

    /* Text Colors */
    --color-text-primary: #fafafa;
    --color-text-secondary: #a1a1aa;
    --color-text-muted: #71717a;

    /* Surface Colors */
    --color-surface-page: #09090b;
    --color-surface-section: #18181b;
    --color-surface-card: #27272a;
    --color-surface-elevated: #3f3f46;

    /* Glass Surfaces */
    --surface-glass-1: rgba(255, 255, 255, 0.03);
    --surface-glass-2: rgba(255, 255, 255, 0.07);
    --border-glass-1: rgba(255, 255, 255, 0.08);

    /* Typography */
    --font-family-base: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-family-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Effects */
    --shadow-card: 0 8px 32px rgba(0, 0, 0, 0.4);

    /* Border Radius */
    --radius-md: 8px;
    --radius-lg: 16px;
    --radius-full: 9999px;
}

/* =============================================================================
   Reset & Base Styles
   ============================================================================= */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: var(--font-family-base);
    background: var(--color-surface-page);
    color: var(--color-text-primary);
    min-height: 100vh;
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: color 150ms;
}

a:hover {
    color: var(--color-text-primary);
}

a:focus-visible {
    outline: 2px solid var(--color-brand-primary);
    outline-offset: 2px;
    border-radius: 4px;
}

/* Background gradient overlay */
body::before {
    content: '';
    position: fixed;
    inset: 0;
    background:
        radial-gradient(ellipse 80% 50% at 20% 40%, rgba(99, 102, 241, 0.12) 0%, transparent 50%),
        radial-gradient(ellipse 60% 40% at 80% 60%, rgba(6, 182, 212, 0.08) 0%, transparent 50%),
        radial-gradient(ellipse 50% 30% at 50% 80%, rgba(168, 85, 247, 0.06) 0%, transparent 50%);
    pointer-events: none;
    z-index: -1;
}

/* =============================================================================
   Layout
   ============================================================================= */
.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    padding: 24px;
    max-width: 1600px;
    margin: 0 auto;
}

/* =============================================================================
   Header Component
   ============================================================================= */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid var(--border-glass-1);
}

.header__brand {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header__logo {
    width: 40px;
    height: 40px;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.header__logo::before {
    content: '';
    position: absolute;
    width: 12px;
    height: 12px;
    background: linear-gradient(135deg, var(--color-brand-primary) 0%, var(--color-neon-cyan) 100%);
    border-radius: 50%;
    box-shadow: 0 0 12px rgba(99, 102, 241, 0.6), 0 0 24px rgba(6, 182, 212, 0.3);
    animation: pulse-core 3s ease-in-out infinite;
}

.header__logo::after {
    content: '';
    position: absolute;
    width: 32px;
    height: 32px;
    border: 2px solid transparent;
    border-radius: 50%;
    background: conic-gradient(from 45deg, rgba(99, 102, 241, 0.6) 0deg, transparent 90deg, rgba(6, 182, 212, 0.6) 180deg, transparent 270deg, rgba(99, 102, 241, 0.6) 360deg);
    -webkit-mask: linear-gradient(#fff 0 0) padding-box, linear-gradient(#fff 0 0);
    -webkit-mask-composite: xor;
    mask-composite: exclude;
    animation: rotate-ring 8s linear infinite;
}

.header__logo .node {
    position: absolute;
    width: 4px;
    height: 4px;
    background: var(--color-neon-cyan);
    border-radius: 50%;
    box-shadow: 0 0 6px rgba(6, 182, 212, 0.8);
}

.header__logo .node:nth-child(1) { top: 4px; left: 50%; transform: translateX(-50%); }
.header__logo .node:nth-child(2) { right: 4px; top: 50%; transform: translateY(-50%); }
.header__logo .node:nth-child(3) { bottom: 4px; left: 50%; transform: translateX(-50%); }
.header__logo .node:nth-child(4) { left: 4px; top: 50%; transform: translateY(-50%); }

.header__title {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: -0.025em;
    color: var(--color-text-primary);
}

.header__actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* =============================================================================
   Navigation Component
   ============================================================================= */
.nav {
    display: flex;
    gap: 4px;
    margin-bottom: 24px;
    padding: 4px;
    background: var(--surface-glass-1);
    border: 1px solid var(--border-glass-1);
    border-radius: var(--radius-md);
    width: fit-content;
    max-width: 100%;
    overflow-x: auto;
    overflow-y: hidden;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: var(--color-surface-elevated) transparent;
}

/* Custom scrollbar for webkit browsers */
.nav::-webkit-scrollbar {
    height: 4px;
}

.nav::-webkit-scrollbar-track {
    background: transparent;
}

.nav::-webkit-scrollbar-thumb {
    background: var(--color-surface-elevated);
    border-radius: var(--radius-full);
}

.nav::-webkit-scrollbar-thumb:hover {
    background: var(--color-text-muted);
}

.nav__link {
    padding: 8px 20px;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: calc(var(--radius-md) - 2px);
    color: var(--color-text-secondary);
    text-decoration: none;
    transition: all 150ms;
    cursor: pointer;
    white-space: nowrap;
    flex-shrink: 0;
}

.nav__link:hover {
    color: var(--color-text-primary);
    background: var(--surface-glass-2);
}

.nav__link--active {
    color: var(--color-text-primary);
    background: var(--color-brand-primary);
}

.nav__link--active:hover {
    background: var(--color-brand-primary-hover);
}

/* =============================================================================
   Button Component
   ============================================================================= */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    height: 36px;
    padding: 0 16px;
    font-family: var(--font-family-base);
    font-size: 0.8125rem;
    font-weight: 500;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-glass-1);
    background: var(--surface-glass-2);
    color: var(--color-text-primary);
    cursor: pointer;
    transition: all 150ms;
}

.btn:hover {
    background: var(--color-surface-elevated);
    border-color: var(--color-brand-primary);
}

/* =============================================================================
   Refresh Button Component
   ============================================================================= */
.btn-refresh {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    font-size: 0.75rem;
    background: var(--surface-glass-2);
    border: 1px solid var(--border-glass-1);
    border-radius: var(--radius-md);
    color: var(--color-text-secondary);
    cursor: pointer;
    transition: all 150ms;
}

.btn-refresh:hover {
    background: var(--color-brand-primary);
    color: var(--color-text-primary);
}

.btn-refresh:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

.btn-refresh.loading .refresh-icon {
    animation: spin 1s linear infinite;
}

/* =============================================================================
   Status Badge Component
   ============================================================================= */
.status-badge {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 6px 16px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    transition: all 300ms;
}

.status-badge--healthy { background: var(--color-intent-success-muted); color: var(--color-intent-success); }
.status-badge--warning { background: var(--color-intent-warning-muted); color: var(--color-intent-warning); }
.status-badge--critical { background: var(--color-intent-error-muted); color: var(--color-intent-error); }
.status-badge--unknown { background: var(--surface-glass-2); color: var(--color-text-muted); }

/* =============================================================================
   Status Dot Component
   ============================================================================= */
.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    animation: pulse 2s infinite;
    transition: background 300ms;
}

.status-dot--healthy { background: var(--color-intent-success); }
.status-dot--warning { background: var(--color-intent-warning); }
.status-dot--critical { background: var(--color-intent-error); }
.status-dot--unknown { background: var(--color-text-muted); }

/* =============================================================================
   Metric Component (Shared)
   ============================================================================= */
.metric {
    background: var(--color-surface-card);
    border: 1px solid var(--border-glass-1);
    border-radius: var(--radius-md);
    padding: 12px;
    transition: background 150ms;
}

.metric:hover { background: var(--color-surface-elevated); }

.metric__label {
    font-size: 0.6875rem;
    font-weight: 500;
    color: var(--color-text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.metric__value {
    font-family: var(--font-family-mono);
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--color-text-primary);
    transition: color 300ms;
}

.metric__value--warning { color: var(--color-intent-warning); }
.metric__value--critical { color: var(--color-intent-error); }

.metric__value.changed {
    animation: flash 600ms ease-out;
}

/* =============================================================================
   Footer Component
   ============================================================================= */
.footer {
    margin-top: auto;
    padding-top: 24px;
    border-top: 1px solid var(--border-glass-1);
    text-align: center;
}

.footer__timestamp { font-size: 0.75rem; color: var(--color-text-muted); }
.footer__refresh { font-size: 0.6875rem; color: var(--color-text-muted); margin-top: 4px; opacity: 0.7; }

/* =============================================================================
   Animations
   ============================================================================= */
@keyframes pulse-core {
    0%, 100% { transform: scale(1); opacity: 1; }
    50% { transform: scale(1.1); opacity: 0.9; }
}

@keyframes rotate-ring {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.5; }
}

@keyframes flash {
    0% { background: rgba(99, 102, 241, 0.3); }
    100% { background: transparent; }
}

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

/* =============================================================================
   Media Queries (Shared Responsive Behavior)
   ============================================================================= */
@media (max-width: 768px) {
    .app { padding: 16px; }
    .header { flex-direction: column; gap: 16px; align-items: flex-start; }
    .header__actions { width: 100%; justify-content: space-between; }

    /* Mobile nav: full-width scrollable bar */
    .nav {
        width: 100%;
        margin-left: -16px;
        margin-right: -16px;
        padding-left: 16px;
        padding-right: 16px;
        border-radius: 0;
        border-left: none;
        border-right: none;
        /* Fade edges to indicate scrollable content */
        mask-image: linear-gradient(
            to right,
            transparent 0,
            black 16px,
            black calc(100% - 16px),
            transparent 100%
        );
        -webkit-mask-image: linear-gradient(
            to right,
            transparent 0,
            black 16px,
            black calc(100% - 16px),
            transparent 100%
        );
    }

    .nav__link {
        padding: 8px 14px;
        font-size: 0.8125rem;
    }
}

@media (max-width: 480px) {
    .app { padding: 12px; }

    .nav {
        margin-left: -12px;
        margin-right: -12px;
        padding-left: 12px;
        padding-right: 12px;
        mask-image: linear-gradient(
            to right,
            transparent 0,
            black 12px,
            black calc(100% - 12px),
            transparent 100%
        );
        -webkit-mask-image: linear-gradient(
            to right,
            transparent 0,
            black 12px,
            black calc(100% - 12px),
            transparent 100%
        );
    }

    .nav__link {
        padding: 6px 12px;
        font-size: 0.75rem;
    }

    .header__title {
        font-size: 1.25rem;
    }
}
