/*
 * RWA Design System v1.0
 * Modern SaaS design with Inter font, refined spacing, micro-interactions
 * Palette: navy/slate base + cyan accent (preserved from original)
 */

/* ============================================================
   GOOGLE FONTS
   ============================================================ */
@import url('https://fonts.googleapis.com/css2?family=Manrope:wght@300;400;500;600;700;800&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* ============================================================
   CSS CUSTOM PROPERTIES
   ============================================================ */
:root {
    /* Typography */
    --font-sans: 'Manrope', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'Fira Code', monospace;

    /* Font Sizes - Fluid Scale */
    --text-xs: 0.75rem;     /* 12px */
    --text-sm: 0.8125rem;   /* 13px */
    --text-base: 0.875rem;  /* 14px */
    --text-md: 1rem;        /* 16px */
    --text-lg: 1.125rem;    /* 18px */
    --text-xl: 1.25rem;     /* 20px */
    --text-2xl: 1.5rem;     /* 24px */
    --text-3xl: 1.875rem;   /* 30px */
    --text-4xl: 2.25rem;    /* 36px */
    --text-5xl: 3rem;       /* 48px */

    /* Font Weights */
    --weight-light: 300;
    --weight-normal: 400;
    --weight-medium: 500;
    --weight-semibold: 600;
    --weight-bold: 700;
    --weight-extrabold: 800;

    /* Colors - Navy/Slate Base */
    --color-navy-950: #020617;
    --color-navy-900: #0f172a;
    --color-navy-800: #1e293b;
    --color-navy-700: #334155;
    --color-navy-600: #475569;
    --color-navy-500: #64748b;
    --color-navy-400: #94a3b8;
    --color-navy-300: #cbd5e1;
    --color-navy-200: #e2e8f0;
    --color-navy-100: #f1f5f9;
    --color-navy-50: #f8fafc;

    /* Accent - Cyan */
    --color-accent-600: #0891b2;
    --color-accent-500: #06b6d4;
    --color-accent-400: #22d3ee;
    --color-accent-300: #67e8f9;
    --color-accent-200: #a5f3fc;
    --color-accent-100: #cffafe;
    --color-accent-50: #ecfeff;

    /* Secondary - Indigo/Purple */
    --color-secondary-600: #4f46e5;
    --color-secondary-500: #6366f1;
    --color-secondary-400: #818cf8;

    /* Semantic */
    --color-success-600: #059669;
    --color-success-500: #10b981;
    --color-success-100: #d1fae5;
    --color-success-50: #ecfdf5;

    --color-warning-600: #d97706;
    --color-warning-500: #f59e0b;
    --color-warning-100: #fef3c7;
    --color-warning-50: #fffbeb;

    --color-danger-600: #dc2626;
    --color-danger-500: #ef4444;
    --color-danger-100: #fee2e2;
    --color-danger-50: #fef2f2;

    --color-info-600: #2563eb;
    --color-info-500: #3b82f6;
    --color-info-100: #dbeafe;
    --color-info-50: #eff6ff;

    /* Spacing Scale - 4px base */
    --space-0: 0;
    --space-1: 0.25rem;   /* 4px */
    --space-2: 0.5rem;    /* 8px */
    --space-3: 0.75rem;   /* 12px */
    --space-4: 1rem;      /* 16px */
    --space-5: 1.25rem;   /* 20px */
    --space-6: 1.5rem;    /* 24px */
    --space-8: 2rem;      /* 32px */
    --space-10: 2.5rem;   /* 40px */
    --space-12: 3rem;     /* 48px */
    --space-16: 4rem;     /* 64px */

    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --radius-xl: 16px;
    --radius-2xl: 20px;
    --radius-full: 9999px;

    /* Shadows - Layered for depth */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.06), 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.08), 0 4px 6px -4px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 8px 10px -6px rgba(0, 0, 0, 0.04);
    --shadow-2xl: 0 25px 50px -12px rgba(0, 0, 0, 0.15);
    --shadow-inner: inset 0 2px 4px rgba(0, 0, 0, 0.04);
    --shadow-accent: 0 4px 14px rgba(6, 182, 212, 0.25);
    --shadow-navy: 0 4px 14px rgba(30, 41, 59, 0.25);

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

    /* Layout */
    --sidebar-width: 280px;
    --header-height: 64px;
}

/* ============================================================
   GLOBAL RESET & BASE
   ============================================================ */
*, *::before, *::after {
    box-sizing: border-box;
}

body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: 1.6;
    color: var(--color-navy-800);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    font-feature-settings: 'cv02', 'cv03', 'cv04', 'cv11';
}

/* ============================================================
   TYPOGRAPHY
   ============================================================ */
h1, h2, h3, h4, h5, h6 {
    font-family: var(--font-sans);
    font-weight: var(--weight-bold);
    line-height: 1.25;
    letter-spacing: -0.025em;
    color: var(--color-navy-900);
}

h1 { font-size: var(--text-4xl); font-weight: var(--weight-extrabold); letter-spacing: -0.035em; }
h2 { font-size: var(--text-2xl); font-weight: var(--weight-bold); }
h3 { font-size: var(--text-xl); font-weight: var(--weight-semibold); }
h4 { font-size: var(--text-lg); font-weight: var(--weight-semibold); }

p { color: var(--color-navy-600); line-height: 1.7; }

.text-gradient {
    background: linear-gradient(135deg, var(--color-navy-800), var(--color-accent-500));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.text-mono { font-family: var(--font-mono); }
.text-muted { color: var(--color-navy-500); }
.text-accent { color: var(--color-accent-500); }

/* Label / Overline */
.label {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-navy-500);
}

/* ============================================================
   BUTTONS
   ============================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    font-weight: var(--weight-semibold);
    line-height: 1;
    padding: 10px 18px;
    border: 1px solid transparent;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-base);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:active {
    transform: scale(0.98);
}

/* Primary - Solid Navy */
.btn-primary {
    background: var(--color-navy-800);
    color: #fff;
    border-color: var(--color-navy-800);
    box-shadow: var(--shadow-navy);
}
.btn-primary:hover {
    background: var(--color-navy-900);
    box-shadow: 0 6px 20px rgba(30, 41, 59, 0.35);
    transform: translateY(-1px);
}

/* Accent - Cyan */
.btn-accent {
    background: var(--color-accent-500);
    color: #fff;
    border-color: var(--color-accent-500);
    box-shadow: var(--shadow-accent);
}
.btn-accent:hover {
    background: var(--color-accent-600);
    box-shadow: 0 6px 20px rgba(6, 182, 212, 0.35);
    transform: translateY(-1px);
}

/* Ghost / Outline */
.btn-ghost {
    background: transparent;
    color: var(--color-navy-700);
    border-color: var(--color-navy-200);
}
.btn-ghost:hover {
    background: var(--color-navy-50);
    border-color: var(--color-navy-300);
}

/* Subtle */
.btn-subtle {
    background: var(--color-navy-100);
    color: var(--color-navy-700);
    border-color: transparent;
}
.btn-subtle:hover {
    background: var(--color-navy-200);
}

/* Danger */
.btn-danger {
    background: var(--color-danger-500);
    color: #fff;
    border-color: var(--color-danger-500);
}
.btn-danger:hover {
    background: var(--color-danger-600);
    transform: translateY(-1px);
}

/* Success */
.btn-success {
    background: var(--color-success-500);
    color: #fff;
    border-color: var(--color-success-500);
}
.btn-success:hover {
    background: var(--color-success-600);
    transform: translateY(-1px);
}

/* Sizes */
.btn-xs { font-size: var(--text-xs); padding: 6px 10px; border-radius: var(--radius-sm); }
.btn-sm { font-size: var(--text-sm); padding: 8px 14px; }
.btn-lg { font-size: var(--text-md); padding: 12px 24px; border-radius: var(--radius-lg); }
.btn-xl { font-size: var(--text-lg); padding: 16px 32px; border-radius: var(--radius-lg); }

/* Icon only */
.btn-icon {
    padding: 8px;
    border-radius: var(--radius-md);
}

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: #fff;
    border: 1px solid var(--color-navy-200);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}

.card-hover:hover {
    border-color: var(--color-accent-400);
    box-shadow: var(--shadow-lg);
    transform: translateY(-2px);
}

.card-elevated {
    border: none;
    box-shadow: var(--shadow-md);
}

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

/* Dark Card */
.card-dark {
    background: linear-gradient(135deg, var(--color-navy-800), var(--color-navy-700));
    border: 1px solid rgba(255, 255, 255, 0.08);
    color: #fff;
}

.card-dark h1, .card-dark h2, .card-dark h3, .card-dark h4 {
    color: #fff;
}
.card-dark p, .card-dark .text-muted {
    color: var(--color-navy-300);
}

/* ============================================================
   INPUTS & FORMS
   ============================================================ */
.input, .select, .textarea,
input[type="text"], input[type="email"], input[type="password"],
input[type="number"], input[type="tel"], input[type="url"],
input[type="search"], select, textarea {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    padding: 10px 14px;
    border: 1.5px solid var(--color-navy-200);
    border-radius: var(--radius-md);
    background: #fff;
    color: var(--color-navy-800);
    transition: all var(--transition-fast);
    width: 100%;
    outline: none;
}

.input:hover, select:hover, textarea:hover,
input[type="text"]:hover, input[type="email"]:hover,
input[type="password"]:hover, input[type="number"]:hover {
    border-color: var(--color-navy-300);
}

.input:focus, select:focus, textarea:focus,
input[type="text"]:focus, input[type="email"]:focus,
input[type="password"]:focus, input[type="number"]:focus,
input[type="tel"]:focus, input[type="url"]:focus {
    border-color: var(--color-accent-400);
    box-shadow: 0 0 0 3px rgba(6, 182, 212, 0.12);
}

.form-label, label {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-navy-700);
    margin-bottom: var(--space-1);
    display: block;
}

.form-hint {
    font-size: var(--text-xs);
    color: var(--color-navy-400);
    margin-top: var(--space-1);
}

/* ============================================================
   BADGES & PILLS
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    padding: 3px 10px;
    border-radius: var(--radius-full);
    line-height: 1.4;
}

.badge-success { background: var(--color-success-100); color: var(--color-success-600); }
.badge-warning { background: var(--color-warning-100); color: var(--color-warning-600); }
.badge-danger  { background: var(--color-danger-100);  color: var(--color-danger-600);  }
.badge-info    { background: var(--color-info-100);    color: var(--color-info-600);    }
.badge-accent  { background: var(--color-accent-100);  color: var(--color-accent-600);  }
.badge-neutral { background: var(--color-navy-100);    color: var(--color-navy-600);    }

/* ============================================================
   TABLES
   ============================================================ */
.table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
}

.table th {
    font-size: var(--text-xs);
    font-weight: var(--weight-semibold);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--color-navy-500);
    padding: var(--space-3) var(--space-4);
    border-bottom: 1.5px solid var(--color-navy-200);
    text-align: left;
    background: var(--color-navy-50);
}

.table td {
    padding: var(--space-3) var(--space-4);
    border-bottom: 1px solid var(--color-navy-100);
    color: var(--color-navy-700);
    font-size: var(--text-base);
}

.table tbody tr {
    transition: background var(--transition-fast);
}

.table tbody tr:hover {
    background: var(--color-navy-50);
}

/* ============================================================
   STAT CARDS
   ============================================================ */
.stat-card-ds {
    background: #fff;
    border: 1px solid var(--color-navy-200);
    border-radius: var(--radius-xl);
    padding: var(--space-5);
    display: flex;
    align-items: flex-start;
    gap: var(--space-4);
    transition: all var(--transition-base);
}

.stat-card-ds:hover {
    border-color: var(--color-navy-300);
    box-shadow: var(--shadow-md);
}

.stat-icon-ds {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-lg);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.stat-icon-ds svg {
    width: 22px;
    height: 22px;
    stroke: #fff;
}

.stat-label-ds {
    font-size: var(--text-sm);
    font-weight: var(--weight-medium);
    color: var(--color-navy-500);
    margin-bottom: 2px;
}

.stat-value-ds {
    font-size: var(--text-2xl);
    font-weight: var(--weight-extrabold);
    color: var(--color-navy-900);
    letter-spacing: -0.025em;
    line-height: 1.2;
}

/* ============================================================
   PROGRESS BAR
   ============================================================ */
.progress {
    height: 6px;
    background: var(--color-navy-100);
    border-radius: var(--radius-full);
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    border-radius: var(--radius-full);
    background: linear-gradient(90deg, var(--color-accent-400), var(--color-secondary-500));
    transition: width 600ms cubic-bezier(0.4, 0, 0.2, 1);
}

/* ============================================================
   ALERTS
   ============================================================ */
.alert {
    padding: var(--space-3) var(--space-4);
    border-radius: var(--radius-md);
    font-size: var(--text-base);
    font-weight: var(--weight-medium);
    display: flex;
    align-items: center;
    gap: var(--space-3);
    border: 1px solid transparent;
}

.alert-success { background: var(--color-success-50); border-color: var(--color-success-500); color: #065f46; }
.alert-warning { background: var(--color-warning-50); border-color: var(--color-warning-500); color: #92400e; }
.alert-danger  { background: var(--color-danger-50);  border-color: var(--color-danger-500);  color: #991b1b; }
.alert-info    { background: var(--color-info-50);    border-color: var(--color-info-500);    color: #1e40af; }

/* ============================================================
   AVATAR
   ============================================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: var(--radius-full);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: var(--weight-semibold);
    font-size: var(--text-base);
    color: #fff;
    flex-shrink: 0;
}

.avatar-sm { width: 32px; height: 32px; font-size: var(--text-xs); }
.avatar-lg { width: 56px; height: 56px; font-size: var(--text-xl); }

/* ============================================================
   TABS
   ============================================================ */
.tabs-container {
    display: flex;
    gap: 2px;
    background: var(--color-navy-100);
    padding: 3px;
    border-radius: var(--radius-lg);
}

.tab {
    flex: 1;
    padding: 10px 16px;
    border: none;
    background: transparent;
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: var(--weight-semibold);
    color: var(--color-navy-500);
    cursor: pointer;
    transition: all var(--transition-fast);
    text-align: center;
}

.tab:hover {
    color: var(--color-navy-700);
    background: rgba(255, 255, 255, 0.5);
}

.tab.active {
    background: #fff;
    color: var(--color-navy-800);
    box-shadow: var(--shadow-sm);
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    animation: fadeIn var(--transition-fast);
}

.modal-box {
    background: #fff;
    border-radius: var(--radius-2xl);
    width: 90%;
    max-width: 560px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-2xl);
    animation: slideUp var(--transition-slow);
}

.modal-header {
    padding: var(--space-6) var(--space-6) var(--space-4);
    border-bottom: 1px solid var(--color-navy-100);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-4) var(--space-6) var(--space-6);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

/* ============================================================
   EMPTY STATE
   ============================================================ */
.empty-state {
    text-align: center;
    padding: var(--space-16) var(--space-8);
}

.empty-state-icon {
    width: 80px;
    height: 80px;
    border-radius: var(--radius-full);
    background: var(--color-navy-100);
    margin: 0 auto var(--space-6);
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state-icon svg {
    width: 36px;
    height: 36px;
    color: var(--color-navy-400);
}

/* ============================================================
   SCROLLBAR
   ============================================================ */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--color-navy-300); border-radius: var(--radius-full); }
::-webkit-scrollbar-thumb:hover { background: var(--color-navy-400); }

/* ============================================================
   ANIMATIONS
   ============================================================ */
@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

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

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

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

/* Skeleton loading */
.skeleton {
    background: linear-gradient(90deg, var(--color-navy-100) 25%, var(--color-navy-50) 50%, var(--color-navy-100) 75%);
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s ease-in-out infinite;
    border-radius: var(--radius-md);
}

@keyframes skeleton-loading {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ============================================================
   UTILITIES
   ============================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }

.grid { display: grid; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(4, 1fr); }

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

.rounded-lg { border-radius: var(--radius-lg); }
.rounded-xl { border-radius: var(--radius-xl); }
.rounded-full { border-radius: var(--radius-full); }

.truncate { overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.sr-only { position: absolute; width: 1px; height: 1px; overflow: hidden; clip: rect(0,0,0,0); }

/* Divider */
.divider {
    height: 1px;
    background: var(--color-navy-100);
    margin: var(--space-6) 0;
}

/* ============================================================
   ACCESSIBILITY
   ============================================================ */
@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

:focus-visible {
    outline: 2px solid var(--color-accent-400);
    outline-offset: 2px;
}
