/* ============================================
   APGAR.AI - SHARED DESIGN SYSTEM
   ============================================ */

/* ============================================
   CSS VARIABLES / DESIGN TOKENS
   ============================================ */
:root {
    /* Primary Colors */
    --primary: #0D9488;
    --primary-light: #14B8A6;
    --primary-dark: #0F766E;
    --primary-glow: rgba(13, 148, 136, 0.15);
    
    /* Accent Colors */
    --accent: #F59E0B;
    --accent-light: #FBBF24;
    --accent-glow: rgba(245, 158, 11, 0.15);
    
    /* Background Colors - Dark Theme */
    --bg-darker: #020617;
    --bg-dark: #0F172A;
    --bg-card: #1E293B;
    --bg-card-hover: #334155;
    
    /* Background Colors - Light Theme (for documents) */
    --bg-white: #FFFFFF;
    --bg-light: #F8FAFC;
    --bg-light-hover: #F1F5F9;
    
    /* Text Colors */
    --text-primary: #F1F5F9;
    --text-secondary: #94A3B8;
    --text-muted: #64748B;
    --text-dark: #1E293B;
    --text-dark-secondary: #334155;
    
    /* Border Colors */
    --border: #334155;
    --border-light: #E2E8F0;
    
    /* Status Colors */
    --success: #10B981;
    --success-glow: rgba(16, 185, 129, 0.15);
    --warning: #F59E0B;
    --warning-glow: rgba(245, 158, 11, 0.15);
    --danger: #EF4444;
    --danger-glow: rgba(239, 68, 68, 0.15);
    --info: #3B82F6;
    --info-glow: rgba(59, 130, 246, 0.15);
    
    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #0D9488 0%, #0891B2 100%);
    --gradient-accent: linear-gradient(135deg, #F59E0B 0%, #D97706 100%);
    --gradient-dark: linear-gradient(135deg, #0F172A 0%, #1E293B 100%);
    
    /* Shadows */
    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 12px rgba(0, 0, 0, 0.15);
    --shadow-lg: 0 12px 40px rgba(0, 0, 0, 0.25);
    --shadow-glow: 0 0 20px rgba(13, 148, 136, 0.3);
    
    /* Border Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 20px;
    --radius-full: 100px;
    
    /* Spacing */
    --space-xs: 4px;
    --space-sm: 8px;
    --space-md: 16px;
    --space-lg: 24px;
    --space-xl: 32px;
    --space-2xl: 48px;
    
    /* Typography */
    --font-family: 'Heebo', -apple-system, BlinkMacSystemFont, sans-serif;
    --font-size-xs: 10px;
    --font-size-sm: 12px;
    --font-size-base: 14px;
    --font-size-lg: 16px;
    --font-size-xl: 20px;
    --font-size-2xl: 24px;
    --font-size-3xl: 32px;
    
    /* Transitions */
    --transition-fast: 0.15s ease;
    --transition-base: 0.2s ease;
    --transition-slow: 0.3s ease;
    
    /* Z-Index Scale */
    --z-dropdown: 100;
    --z-sticky: 200;
    --z-modal: 300;
    --z-tooltip: 400;
    --z-toast: 500;
}

/* ============================================
   RESET & BASE STYLES
   ============================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body {
    font-family: var(--font-family);
    background: var(--bg-darker);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.5;
}

/* RTL Support */
[dir="rtl"] {
    text-align: right;
}

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

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

@keyframes slideDown {
    from { 
        opacity: 0; 
        max-height: 0;
    }
    to { 
        opacity: 1; 
        max-height: 500px;
    }
}

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

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

/* ============================================
   TYPOGRAPHY
   ============================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
}

h1 { font-size: var(--font-size-3xl); }
h2 { font-size: var(--font-size-2xl); }
h3 { font-size: var(--font-size-xl); }
h4 { font-size: var(--font-size-lg); }

a {
    color: var(--primary-light);
    text-decoration: none;
    transition: color var(--transition-fast);
}

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

/* ============================================
   BUTTONS
   ============================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-sm);
    padding: 12px 24px;
    border: none;
    border-radius: var(--radius-md);
    font-size: var(--font-size-base);
    font-weight: 600;
    font-family: inherit;
    cursor: pointer;
    transition: all var(--transition-base);
    white-space: nowrap;
}

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

.btn-primary {
    background: var(--gradient-primary);
    color: white;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: var(--shadow-glow);
}

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

.btn-secondary:hover:not(:disabled) {
    border-color: var(--primary);
    background: var(--bg-card);
}

.btn-danger {
    background: var(--danger);
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #DC2626;
}

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

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

.btn-sm {
    padding: 8px 16px;
    font-size: var(--font-size-sm);
}

.btn-lg {
    padding: 16px 32px;
    font-size: var(--font-size-lg);
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    border-radius: var(--radius-sm);
}

.btn-icon.btn-sm {
    width: 32px;
    height: 32px;
}

/* ============================================
   FORM ELEMENTS
   ============================================ */
.form-group {
    margin-bottom: var(--space-md);
}

.form-label {
    display: block;
    font-size: var(--font-size-sm);
    font-weight: 500;
    color: var(--text-secondary);
    margin-bottom: var(--space-xs);
}

.form-input,
.form-select,
.form-textarea {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    font-family: inherit;
    transition: border-color var(--transition-fast);
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
    outline: none;
    border-color: var(--primary);
}

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

.form-textarea {
    resize: vertical;
    min-height: 100px;
}

.form-select {
    cursor: pointer;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: var(--space-md);
}

/* Toggle Switch */
.toggle {
    width: 44px;
    height: 24px;
    background: var(--border);
    border-radius: 12px;
    position: relative;
    cursor: pointer;
    transition: background var(--transition-fast);
}

.toggle.active {
    background: var(--primary);
}

.toggle::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    background: white;
    border-radius: 50%;
    top: 3px;
    right: 3px;
    transition: transform var(--transition-base);
}

[dir="rtl"] .toggle.active::after {
    transform: translateX(20px);
}

[dir="ltr"] .toggle.active::after {
    transform: translateX(-20px);
}

/* ============================================
   CARDS
   ============================================ */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: var(--font-size-lg);
    font-weight: 600;
}

.card-body {
    padding: var(--space-lg);
}

.card-footer {
    padding: var(--space-md) var(--space-lg);
    border-top: 1px solid var(--border);
    background: var(--bg-dark);
}

/* ============================================
   BADGES & TAGS
   ============================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: var(--font-size-xs);
    font-weight: 600;
}

.badge-primary {
    background: var(--primary-glow);
    color: var(--primary-light);
}

.badge-success {
    background: var(--success-glow);
    color: var(--success);
}

.badge-warning {
    background: var(--warning-glow);
    color: var(--warning);
}

.badge-danger {
    background: var(--danger-glow);
    color: var(--danger);
}

.badge-info {
    background: var(--info-glow);
    color: var(--info);
}

/* ============================================
   AVATAR
   ============================================ */
.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.avatar-sm { width: 32px; height: 32px; }
.avatar-lg { width: 56px; height: 56px; }
.avatar-xl { width: 80px; height: 80px; }

.avatar-square {
    border-radius: var(--radius-md);
}

/* ============================================
   LAYOUT COMPONENTS
   ============================================ */

/* App Layout */
.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 240px;
    background: var(--bg-dark);
    border-left: 1px solid var(--border);
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    display: flex;
    flex-direction: column;
    z-index: var(--z-sticky);
}

[dir="ltr"] .sidebar {
    right: auto;
    left: 0;
    border-left: none;
    border-right: 1px solid var(--border);
}

.sidebar-header {
    padding: var(--space-lg);
    border-bottom: 1px solid var(--border);
}

.sidebar-logo {
    font-size: var(--font-size-2xl);
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
    padding: var(--space-md);
    overflow-y: auto;
}

.sidebar-footer {
    padding: var(--space-md);
    border-top: 1px solid var(--border);
}

/* Navigation */
.nav-section {
    margin-bottom: var(--space-lg);
}

.nav-section-title {
    font-size: var(--font-size-xs);
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 1px;
    padding: var(--space-sm) var(--space-md);
}

.nav-item {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 11px 14px;
    border-radius: var(--radius-sm);
    color: var(--text-secondary);
    cursor: pointer;
    transition: all var(--transition-fast);
    margin-bottom: 2px;
}

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

.nav-item.active {
    background: var(--primary-glow);
    color: var(--primary-light);
}

.nav-item svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}

.nav-item span {
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.nav-badge {
    margin-right: auto;
    padding: 2px 7px;
    background: var(--danger);
    color: white;
    font-size: var(--font-size-xs);
    font-weight: 600;
    border-radius: var(--radius-full);
}

[dir="ltr"] .nav-badge {
    margin-right: 0;
    margin-left: auto;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-right: 240px;
    background: var(--bg-darker);
}

[dir="ltr"] .main-content {
    margin-right: 0;
    margin-left: 240px;
}

/* Top Bar */
.top-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-md) var(--space-lg);
    background: var(--bg-dark);
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: var(--z-sticky);
}

/* Search Box */
.search-box {
    display: flex;
    align-items: center;
    gap: var(--space-sm);
    padding: 10px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    min-width: 300px;
    transition: border-color var(--transition-fast);
}

.search-box:focus-within {
    border-color: var(--primary);
}

.search-box svg {
    width: 16px;
    height: 16px;
    color: var(--text-muted);
    flex-shrink: 0;
}

.search-box input {
    flex: 1;
    background: transparent;
    border: none;
    color: var(--text-primary);
    font-size: var(--font-size-sm);
    font-family: inherit;
}

.search-box input:focus {
    outline: none;
}

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

/* Page Content */
.page-content {
    padding: var(--space-lg);
}

/* ============================================
   TABLES
   ============================================ */
.table-container {
    overflow-x: auto;
}

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

.table th,
.table td {
    padding: var(--space-md);
    text-align: right;
    border-bottom: 1px solid var(--border);
}

[dir="ltr"] .table th,
[dir="ltr"] .table td {
    text-align: left;
}

.table th {
    font-size: var(--font-size-sm);
    font-weight: 600;
    color: var(--text-secondary);
    background: var(--bg-dark);
}

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

/* ============================================
   TOOLTIPS
   ============================================ */
.tooltip {
    position: absolute;
    background: var(--bg-darker);
    border: 1px solid var(--primary);
    border-radius: var(--radius-sm);
    padding: var(--space-sm) var(--space-md);
    font-size: var(--font-size-sm);
    max-width: 260px;
    z-index: var(--z-tooltip);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-fast);
    box-shadow: var(--shadow-lg);
}

.tooltip.visible {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   LOADING STATES
   ============================================ */
.spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

.skeleton {
    background: linear-gradient(
        90deg,
        var(--bg-card) 25%,
        var(--bg-card-hover) 50%,
        var(--bg-card) 75%
    );
    background-size: 200% 100%;
    animation: skeleton-loading 1.5s infinite;
    border-radius: var(--radius-sm);
}

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

/* ============================================
   UTILITIES
   ============================================ */

/* Display */
.hidden { display: none !important; }
.block { display: block; }
.flex { display: flex; }
.grid { display: grid; }

/* Flex utilities */
.flex-center { align-items: center; justify-content: center; }
.flex-between { align-items: center; justify-content: space-between; }
.flex-col { flex-direction: column; }
.gap-sm { gap: var(--space-sm); }
.gap-md { gap: var(--space-md); }
.gap-lg { gap: var(--space-lg); }

/* Text */
.text-center { text-align: center; }
.text-primary { color: var(--primary-light); }
.text-secondary { color: var(--text-secondary); }
.text-muted { color: var(--text-muted); }
.text-success { color: var(--success); }
.text-warning { color: var(--warning); }
.text-danger { color: var(--danger); }
.font-bold { font-weight: 700; }
.font-semibold { font-weight: 600; }

/* Spacing */
.mt-sm { margin-top: var(--space-sm); }
.mt-md { margin-top: var(--space-md); }
.mt-lg { margin-top: var(--space-lg); }
.mb-sm { margin-bottom: var(--space-sm); }
.mb-md { margin-bottom: var(--space-md); }
.mb-lg { margin-bottom: var(--space-lg); }
.p-md { padding: var(--space-md); }
.p-lg { padding: var(--space-lg); }

/* ============================================
   SCREEN / PAGE TRANSITIONS
   ============================================ */
.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s ease;
}

.screen.active {
    display: block;
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 1024px) {
    .sidebar {
        width: 200px;
    }
    
    .main-content {
        margin-right: 200px;
    }
    
    [dir="ltr"] .main-content {
        margin-left: 200px;
    }
}

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(100%);
        transition: transform var(--transition-base);
    }
    
    [dir="ltr"] .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-right: 0;
    }
    
    [dir="ltr"] .main-content {
        margin-left: 0;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
}
