/**
 * SnowFlake Property Management Design System
 * Version: 4.0 — Executive Precision
 *
 * Design Philosophy:
 * - Typography: Space Grotesk (display) + Outfit (body) — geometric, commanding, readable
 * - Color: Deep navy foundation, teal accent, clean surfaces
 * - Motion: Purposeful entrances, restrained micro-interactions
 * - Depth: Layered shadows that inform, not decorate
 * - Hierarchy: Every element knows its place
 */

/* ============================================
   FORCE LIGHT MODE
   ============================================ */
html, html.light, html:root { color-scheme: light !important; }
html.dark { color-scheme: light !important; }

@media (prefers-color-scheme: dark) {
    html, html:root {
        color-scheme: light !important;
        background-color: #F6F7FB !important;
    }
    body {
        background-color: #F6F7FB !important;
        color: #0B1D3E !important;
    }
}

/* ============================================
   TYPOGRAPHY — DISTINCTIVE FONTS
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=Space+Grotesk:wght@400;500;600;700&family=Outfit:wght@300;400;500;600;700&display=swap');

/* ============================================
   CSS VARIABLES — DESIGN TOKENS
   ============================================ */
:root {
    /* Typography */
    --font-display: 'Space Grotesk', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-body: 'Outfit', -apple-system, BlinkMacSystemFont, sans-serif;

    /* Brand Colors — Navy (Primary) */
    --navy-950: #040D1F;
    --navy-900: #0B1D3E;
    --navy-800: #122850;
    --navy-700: #1B3A6B;
    --navy-600: #234D87;
    --navy-500: #2D62A3;
    --navy-400: #4A7EC0;
    --navy-300: #6E9DD6;
    --navy-200: #9DBEE8;
    --navy-100: #CDDDF6;
    --navy-50: #EBF2FC;

    /* Teal (Accent) */
    --teal-900: #0D3330;
    --teal-800: #104E49;
    --teal-700: #0F766E;
    --teal-600: #0D9488;
    --teal-500: #14B8A6;
    --teal-400: #2DD4BF;
    --teal-300: #5EEAD4;
    --teal-200: #99F6E4;
    --teal-100: #CCFBF1;
    --teal-50: #F0FDFA;

    /* Neutrals — Slate */
    --slate-950: #020617;
    --slate-900: #0F172A;
    --slate-800: #1E293B;
    --slate-700: #334155;
    --slate-600: #475569;
    --slate-500: #64748B;
    --slate-400: #94A3B8;
    --slate-300: #CBD5E1;
    --slate-200: #E2E8F0;
    --slate-150: #EDF0F5;
    --slate-100: #F1F5F9;
    --slate-50: #F8FAFC;

    /* Semantic Colors */
    --color-success: #059669;
    --color-success-light: #ECFDF5;
    --color-success-border: #A7F3D0;
    --color-warning: #D97706;
    --color-warning-light: #FFFBEB;
    --color-warning-border: #FDE68A;
    --color-danger: #DC2626;
    --color-danger-light: #FEF2F2;
    --color-danger-border: #FECACA;
    --color-info: #0284C7;
    --color-info-light: #EFF6FF;
    --color-info-border: #BAE6FD;

    /* Surface Colors */
    --surface-base: #F6F7FB;
    --surface-white: #FFFFFF;
    --surface-raised: #FFFFFF;
    --surface-overlay: rgba(255, 255, 255, 0.92);

    /* Border Colors */
    --border-subtle: #EDF0F5;
    --border-default: #E2E8F0;
    --border-strong: #CBD5E1;

    /* Text Colors */
    --text-primary: #0B1D3E;
    --text-secondary: #475569;
    --text-muted: #94A3B8;
    --text-disabled: #CBD5E1;
    --text-inverse: #FFFFFF;
    --text-link: #0D9488;

    /* Font Sizes */
    --text-xs: 0.75rem;
    --text-sm: 0.875rem;
    --text-base: 1rem;
    --text-lg: 1.125rem;
    --text-xl: 1.25rem;
    --text-2xl: 1.5rem;
    --text-3xl: 1.875rem;
    --text-4xl: 2.25rem;
    --text-5xl: 3rem;
    --text-6xl: 3.75rem;

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-5: 1.25rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-10: 2.5rem;
    --space-12: 3rem;
    --space-16: 4rem;

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 18px;
    --radius-2xl: 24px;
    --radius-3xl: 32px;
    --radius-full: 9999px;

    /* Shadows */
    --shadow-xs: 0 1px 2px 0 rgba(11, 29, 62, 0.04);
    --shadow-sm: 0 2px 6px 0 rgba(11, 29, 62, 0.06), 0 1px 2px 0 rgba(11, 29, 62, 0.04);
    --shadow-md: 0 4px 12px -2px rgba(11, 29, 62, 0.08), 0 2px 4px -1px rgba(11, 29, 62, 0.05);
    --shadow-lg: 0 8px 24px -4px rgba(11, 29, 62, 0.12), 0 4px 8px -2px rgba(11, 29, 62, 0.06);
    --shadow-xl: 0 16px 40px -6px rgba(11, 29, 62, 0.16), 0 6px 12px -3px rgba(11, 29, 62, 0.08);
    --shadow-2xl: 0 24px 64px -8px rgba(11, 29, 62, 0.22);
    --shadow-teal: 0 4px 14px -2px rgba(20, 184, 166, 0.28);
    --shadow-navy: 0 4px 14px -2px rgba(11, 29, 62, 0.22);

    /* Transitions */
    --transition-fast: 120ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 220ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 380ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 500ms cubic-bezier(0.34, 1.56, 0.64, 1);

    /* Layout */
    --sidebar-width: 15rem;
    --sidebar-collapsed: 4rem;
    --navbar-height: 4rem;
}

/* ============================================
   BASE STYLES
   ============================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    font-weight: 400;
    color: var(--text-primary);
    background-color: var(--surface-base);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
}

/* ============================================
   TYPOGRAPHY CLASSES
   ============================================ */
.sf-page-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-3xl);
    letter-spacing: -0.025em;
    line-height: 1.15;
    color: var(--text-primary);
}

.sf-section-title {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: var(--text-2xl);
    letter-spacing: -0.02em;
    color: var(--text-primary);
}

.sf-card-title {
    font-family: var(--font-display);
    font-weight: 600;
    font-size: var(--text-lg);
    letter-spacing: -0.01em;
    color: var(--text-primary);
}

.sf-label {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    color: var(--text-primary);
    letter-spacing: 0;
    display: block;
    margin-bottom: var(--space-1);
}

.sf-subtitle {
    font-family: var(--font-body);
    font-weight: 500;
    font-size: var(--text-xs);
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.07em;
}

.sf-metric-value {
    font-family: var(--font-display);
    font-weight: 700;
    font-size: 2rem;
    letter-spacing: -0.035em;
    line-height: 1;
    color: var(--text-primary);
}

.sf-body-lg {
    font-family: var(--font-body);
    font-size: var(--text-lg);
    line-height: 1.7;
    color: var(--text-secondary);
}

.sf-body-base {
    font-family: var(--font-body);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--text-secondary);
}

.sf-body-sm {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    line-height: 1.5;
    color: var(--text-secondary);
}

.sf-help-text {
    font-size: var(--text-xs);
    color: var(--text-muted);
    margin-top: var(--space-1);
    line-height: 1.4;
}

.sf-error-text {
    font-size: var(--text-xs);
    font-weight: 500;
    color: var(--color-danger);
    margin-top: var(--space-1);
}

/* ============================================
   BUTTON SYSTEM
   ============================================ */
.sf-btn {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-sm);
    padding: 0.5625rem 1.125rem;
    border-radius: var(--radius-lg);
    transition: all var(--transition-base);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.375rem;
    cursor: pointer;
    border: 1.5px solid transparent;
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    outline: none;
    -webkit-user-select: none;
    user-select: none;
}

.sf-btn:focus-visible {
    outline: 2px solid var(--teal-500);
    outline-offset: 2px;
}

.sf-btn:active {
    transform: scale(0.97);
}

.sf-btn-primary {
    background: var(--navy-700);
    color: white;
    border-color: var(--navy-700);
    box-shadow: var(--shadow-navy);
}

.sf-btn-primary:hover {
    background: var(--navy-800);
    border-color: var(--navy-800);
    box-shadow: 0 6px 18px -2px rgba(11, 29, 62, 0.32);
    color: white;
    transform: translateY(-1px);
}

.sf-btn-teal {
    background: var(--teal-600);
    color: white;
    border-color: var(--teal-600);
    box-shadow: var(--shadow-teal);
}

.sf-btn-teal:hover {
    background: var(--teal-700);
    border-color: var(--teal-700);
    box-shadow: 0 6px 18px -2px rgba(20, 184, 166, 0.36);
    color: white;
    transform: translateY(-1px);
}

.sf-btn-secondary {
    background: white;
    color: var(--text-primary);
    border-color: var(--border-default);
    box-shadow: var(--shadow-xs);
}

.sf-btn-secondary:hover {
    background: var(--slate-50);
    border-color: var(--border-strong);
    box-shadow: var(--shadow-sm);
    color: var(--text-primary);
    transform: translateY(-1px);
}

.sf-btn-ghost {
    background: transparent;
    color: var(--text-secondary);
    border-color: transparent;
}

.sf-btn-ghost:hover {
    background: var(--slate-100);
    color: var(--text-primary);
}

.sf-btn-danger {
    background: var(--color-danger);
    color: white;
    border-color: var(--color-danger);
    box-shadow: 0 4px 14px -2px rgba(220, 38, 38, 0.24);
}

.sf-btn-danger:hover {
    background: #b91c1c;
    border-color: #b91c1c;
    color: white;
    transform: translateY(-1px);
}

.sf-btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: var(--text-xs);
    border-radius: var(--radius-md);
}

.sf-btn-lg {
    padding: 0.75rem 1.5rem;
    font-size: var(--text-base);
    border-radius: var(--radius-xl);
}

/* ============================================
   CARD SYSTEM
   ============================================ */
.sf-card {
    background: var(--surface-white);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-subtle);
    transition: box-shadow var(--transition-base), transform var(--transition-base);
}

.sf-card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

.sf-card-elevated {
    box-shadow: var(--shadow-md);
    border-color: var(--border-default);
}

.sf-card-elevated:hover {
    box-shadow: var(--shadow-lg);
    transform: translateY(-3px);
}

/* Accent top border that slides in on hover */
.sf-card-accent-top {
    position: relative;
    overflow: hidden;
}

.sf-card-accent-top::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 3px;
    background: linear-gradient(90deg, var(--teal-500) 0%, var(--navy-600) 100%);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 350ms cubic-bezier(0.4, 0, 0.2, 1);
}

.sf-card-accent-top:hover::before {
    transform: scaleX(1);
}

/* Glass Card — for navbar, modals */
.sf-card-glass {
    background: rgba(255, 255, 255, 0.88);
    backdrop-filter: blur(16px) saturate(180%);
    -webkit-backdrop-filter: blur(16px) saturate(180%);
    border: 1px solid rgba(255, 255, 255, 0.72);
    box-shadow: var(--shadow-md);
}

/* Stat Card with gradient inner */
.sf-card-stat {
    background: white;
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    border: 1px solid var(--border-subtle);
    position: relative;
    overflow: hidden;
}

.sf-card-stat::after {
    content: '';
    position: absolute;
    bottom: -24px;
    right: -24px;
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--navy-50);
    opacity: 0.6;
}

/* ============================================
   BADGE SYSTEM
   ============================================ */
.sf-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
    padding: 0.1875rem 0.5625rem;
    border-radius: var(--radius-full);
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1;
    white-space: nowrap;
}

.sf-badge-success {
    background: var(--color-success-light);
    color: var(--color-success);
    border: 1px solid var(--color-success-border);
}

.sf-badge-warning {
    background: var(--color-warning-light);
    color: var(--color-warning);
    border: 1px solid var(--color-warning-border);
}

.sf-badge-danger {
    background: var(--color-danger-light);
    color: var(--color-danger);
    border: 1px solid var(--color-danger-border);
}

.sf-badge-info {
    background: var(--color-info-light);
    color: var(--color-info);
    border: 1px solid var(--color-info-border);
}

.sf-badge-neutral {
    background: var(--slate-100);
    color: var(--slate-600);
    border: 1px solid var(--slate-200);
}

.sf-badge-teal {
    background: var(--teal-50);
    color: var(--teal-700);
    border: 1px solid var(--teal-200);
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.sf-input,
.sf-select,
.sf-textarea {
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 400;
    padding: 0.5625rem 0.875rem;
    border: 1.5px solid var(--border-default);
    border-radius: var(--radius-lg);
    background: white;
    color: var(--text-primary);
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
    width: 100%;
    line-height: 1.5;
}

.sf-input::placeholder,
.sf-textarea::placeholder {
    color: var(--text-muted);
    font-weight: 400;
}

.sf-input:hover,
.sf-select:hover,
.sf-textarea:hover {
    border-color: var(--border-strong);
}

.sf-input:focus,
.sf-select:focus,
.sf-textarea:focus {
    outline: none;
    border-color: var(--teal-500);
    box-shadow: 0 0 0 3px rgba(20, 184, 166, 0.12);
}

.sf-input.error,
.sf-select.error,
.sf-textarea.error {
    border-color: var(--color-danger);
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.08);
}

.sf-select {
    -webkit-appearance: none;
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2394A3B8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3E%3Cpath d='M6 9l6 6 6-6'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 0.75rem center;
    padding-right: 2.5rem;
    cursor: pointer;
}

/* ============================================
   TABLE SYSTEM
   ============================================ */
.sf-table-wrapper {
    background: white;
    border-radius: var(--radius-xl);
    border: 1px solid var(--border-subtle);
    overflow: hidden;
    box-shadow: var(--shadow-sm);
}

.sf-table {
    width: 100%;
    border-collapse: collapse;
}

.sf-table thead {
    background: var(--slate-50);
    border-bottom: 1.5px solid var(--border-default);
}

.sf-table thead th {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: var(--text-xs);
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    padding: 0.875rem 1.25rem;
    text-align: left;
    white-space: nowrap;
}

.sf-table tbody tr {
    border-bottom: 1px solid var(--border-subtle);
    transition: background var(--transition-fast);
}

.sf-table tbody tr:last-child {
    border-bottom: none;
}

.sf-table tbody tr:hover {
    background: var(--slate-50);
}

.sf-table tbody td {
    padding: 0.875rem 1.25rem;
    font-size: var(--text-sm);
    color: var(--text-secondary);
    vertical-align: middle;
}

/* ============================================
   STATUS INDICATORS
   ============================================ */
.sf-status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
    flex-shrink: 0;
}

.sf-status-dot-pulse {
    animation: sfPulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes sfPulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.sf-status-success { background: var(--color-success); }
.sf-status-warning { background: var(--color-warning); }
.sf-status-danger { background: var(--color-danger); }
.sf-status-info { background: var(--color-info); }
.sf-status-teal { background: var(--teal-500); }

/* ============================================
   GRADIENT UTILITIES
   ============================================ */
.sf-gradient-text-teal {
    background: linear-gradient(135deg, var(--teal-500) 0%, var(--teal-700) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sf-gradient-text-navy {
    background: linear-gradient(135deg, var(--navy-900) 0%, var(--navy-600) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sf-gradient-mesh {
    background-color: var(--surface-base);
    background-image:
        radial-gradient(at 20% 10%, rgba(13, 148, 136, 0.04) 0px, transparent 50%),
        radial-gradient(at 80% 20%, rgba(27, 58, 107, 0.03) 0px, transparent 50%),
        radial-gradient(at 50% 80%, rgba(20, 184, 166, 0.03) 0px, transparent 50%);
}

/* ============================================
   ANIMATIONS — PURPOSEFUL
   ============================================ */
@keyframes sfFadeInUp {
    from {
        opacity: 0;
        transform: translateY(16px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

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

@keyframes sfSlideInLeft {
    from {
        opacity: 0;
        transform: translateX(-20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes sfScaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes sfShimmer {
    0% { background-position: -1000px 0; }
    100% { background-position: 1000px 0; }
}

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

.sf-animate-fade-in-up {
    animation: sfFadeInUp 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.sf-animate-fade-in {
    animation: sfFadeIn 0.4s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.sf-animate-slide-in {
    animation: sfSlideInLeft 0.5s cubic-bezier(0.4, 0, 0.2, 1) both;
}

.sf-animate-scale-in {
    animation: sfScaleIn 0.3s cubic-bezier(0.4, 0, 0.2, 1) both;
}

/* Stagger delays — keep under 15 for perf */
.sf-stagger-1 { animation-delay: 0.04s; }
.sf-stagger-2 { animation-delay: 0.08s; }
.sf-stagger-3 { animation-delay: 0.12s; }
.sf-stagger-4 { animation-delay: 0.16s; }
.sf-stagger-5 { animation-delay: 0.20s; }
.sf-stagger-6 { animation-delay: 0.24s; }
.sf-stagger-7 { animation-delay: 0.28s; }
.sf-stagger-8 { animation-delay: 0.32s; }

/* ============================================
   SHIMMER SKELETON
   ============================================ */
.sf-shimmer {
    background: linear-gradient(90deg,
        var(--slate-100) 0%,
        var(--slate-50) 40%,
        var(--slate-100) 80%,
        var(--slate-100) 100%
    );
    background-size: 1000px 100%;
    animation: sfShimmer 1.8s linear infinite;
    border-radius: var(--radius-md);
}

/* ============================================
   SIDEBAR-SPECIFIC
   ============================================ */
.sf-nav-item {
    display: flex;
    align-items: center;
    gap: 0.625rem;
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-family: var(--font-body);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-secondary);
    text-decoration: none;
    transition: all var(--transition-fast);
    width: 100%;
    cursor: pointer;
    border: none;
    background: none;
    white-space: nowrap;
}

.sf-nav-item:hover {
    background: var(--slate-100);
    color: var(--text-primary);
}

.sf-nav-item.active {
    background: var(--navy-50);
    color: var(--navy-700);
    font-weight: 600;
}

.sf-nav-item.active svg,
.sf-nav-item.active i {
    color: var(--navy-700);
}

.sf-nav-section-label {
    font-family: var(--font-body);
    font-weight: 600;
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.09em;
    padding: 0 0.75rem;
    margin-bottom: 0.25rem;
    margin-top: 0.25rem;
}

/* ============================================
   SCROLLBAR
   ============================================ */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

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

::-webkit-scrollbar-thumb {
    background: var(--slate-300);
    border-radius: var(--radius-full);
}

::-webkit-scrollbar-thumb:hover {
    background: var(--slate-400);
}

/* ============================================
   FOCUS STATES
   ============================================ */
*:focus-visible {
    outline: 2px solid var(--teal-500);
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE ADJUSTMENTS
   ============================================ */
@media (max-width: 768px) {
    .sf-page-title {
        font-size: var(--text-2xl);
    }
    .sf-metric-value {
        font-size: 1.625rem;
    }
    .sf-section-title {
        font-size: var(--text-xl);
    }
}

/* ============================================
   ALERT COMPONENTS
   ============================================ */
.sf-alert {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    padding: 1rem 1.25rem;
    border-radius: var(--radius-lg);
    border: 1px solid;
    font-size: var(--text-sm);
}

.sf-alert-success {
    background: var(--color-success-light);
    border-color: var(--color-success-border);
    color: #065f46;
}

.sf-alert-warning {
    background: var(--color-warning-light);
    border-color: var(--color-warning-border);
    color: #92400e;
}

.sf-alert-danger {
    background: var(--color-danger-light);
    border-color: var(--color-danger-border);
    color: #991b1b;
}

.sf-alert-info {
    background: var(--color-info-light);
    border-color: var(--color-info-border);
    color: #075985;
}
