/* =====================================================
   MyLinks - Premium Design System
   Professional Trading Platform
   ===================================================== */

/* ===== CSS Reset ===== */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* ===== CSS Variables ===== */
:root {
    /* Primary Colors */
    --primary: #0066FF;
    --primary-rgb: 0, 102, 255;
    --primary-dark: #0052CC;
    --primary-light: #E6F0FF;
    
    /* Accent */
    --accent: #00D4AA;
    --accent-rgb: 0, 212, 170;
    
    /* Status Colors */
    --success: #00C853;
    --danger: #FF3B30;
    --warning: #FF9500;
    
    /* Neutral Colors */
    --black: #000000;
    --gray-950: #0A0A0B;
    --gray-900: #111113;
    --gray-800: #1A1A1D;
    --gray-700: #2D2D30;
    --gray-600: #48484A;
    --gray-500: #636366;
    --gray-400: #8E8E93;
    --gray-300: #AEAEB2;
    --gray-200: #D1D1D6;
    --gray-100: #E5E5EA;
    --gray-50: #F2F2F7;
    --white: #FFFFFF;
    
    /* Backgrounds */
    --bg-primary: #FFFFFF;
    --bg-secondary: #FAFAFA;
    --bg-tertiary: #F5F5F7;
    --bg-elevated: #FFFFFF;
    --bg-dark: #0A0A0B;
    
    /* Text */
    --text-primary: #1D1D1F;
    --text-secondary: #6E6E73;
    --text-tertiary: #86868B;
    --text-inverse: #FFFFFF;
    
    /* Borders */
    --border-primary: #E5E5EA;
    --border-secondary: #F2F2F7;
    --border-focus: var(--primary);
    
    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0, 0, 0, 0.04);
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.04), 0 1px 2px rgba(0, 0, 0, 0.06);
    --shadow-md: 0 4px 8px rgba(0, 0, 0, 0.04), 0 2px 4px rgba(0, 0, 0, 0.06);
    --shadow-lg: 0 12px 24px rgba(0, 0, 0, 0.06), 0 4px 8px rgba(0, 0, 0, 0.04);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.08), 0 12px 24px rgba(0, 0, 0, 0.04);
    --shadow-glow: 0 0 0 1px rgba(var(--primary-rgb), 0.1), 0 4px 16px rgba(var(--primary-rgb), 0.15);
    
    /* Spacing */
    --space-1: 4px;
    --space-2: 8px;
    --space-3: 12px;
    --space-4: 16px;
    --space-5: 20px;
    --space-6: 24px;
    --space-8: 32px;
    --space-10: 40px;
    --space-12: 48px;
    --space-16: 64px;
    --space-20: 80px;
    --space-24: 96px;
    
    /* Border Radius */
    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;
    --radius-2xl: 28px;
    --radius-full: 9999px;
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', Monaco, Consolas, monospace;
    
    /* 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: 2rem;
    --text-4xl: 2.5rem;
    --text-5xl: 3.5rem;
    --text-6xl: 4.5rem;
    
    /* Line Heights */
    --leading-tight: 1.1;
    --leading-snug: 1.25;
    --leading-normal: 1.5;
    --leading-relaxed: 1.625;
    
    /* Transitions */
    --ease-out: cubic-bezier(0.16, 1, 0.3, 1);
    --ease-in-out: cubic-bezier(0.65, 0, 0.35, 1);
    --duration-fast: 150ms;
    --duration-normal: 250ms;
    --duration-slow: 400ms;
}

/* ===== Base Styles ===== */
body {
    font-family: var(--font-sans);
    font-size: var(--text-base);
    line-height: var(--leading-normal);
    color: var(--text-primary);
    background: var(--bg-primary);
    overflow-x: hidden;
}

/* ===== Typography ===== */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: var(--leading-tight);
    color: var(--text-primary);
    letter-spacing: -0.02em;
}

h1 {
    font-size: clamp(2.5rem, 5vw, var(--text-6xl));
    font-weight: 700;
    letter-spacing: -0.03em;
}

h2 {
    font-size: clamp(2rem, 4vw, var(--text-4xl));
    font-weight: 600;
}

h3 {
    font-size: var(--text-2xl);
}

h4 {
    font-size: var(--text-xl);
}

p {
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

.lead {
    font-size: var(--text-xl);
    color: var(--text-secondary);
    line-height: var(--leading-relaxed);
}

a {
    color: var(--primary);
    text-decoration: none;
    transition: color var(--duration-fast) var(--ease-out);
}

a:hover {
    color: var(--primary-dark);
}

/* ===== Gradient Text ===== */
.gradient-text {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ===== Container ===== */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 var(--space-6);
}

.container-sm { max-width: 640px; }
.container-md { max-width: 800px; }
.container-lg { max-width: 1024px; }
.container-xl { max-width: 1400px; }

/* ===== Buttons ===== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    font-family: var(--font-sans);
    font-size: var(--text-sm);
    font-weight: 500;
    line-height: 1;
    text-align: center;
    border: none;
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--duration-normal) var(--ease-out);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none !important;
}

.btn-primary {
    background: var(--primary);
    color: var(--white);
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1), 
                0 0 0 1px rgba(var(--primary-rgb), 0.1);
}

.btn-primary:hover:not(:disabled) {
    background: var(--primary-dark);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3),
                0 0 0 1px rgba(var(--primary-rgb), 0.1);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--gray-100);
    color: var(--text-primary);
}

.btn-secondary:hover:not(:disabled) {
    background: var(--gray-200);
    transform: translateY(-1px);
}

.btn-ghost {
    background: transparent;
    color: var(--text-primary);
}

.btn-ghost:hover:not(:disabled) {
    background: var(--gray-100);
}

.btn-outline {
    background: transparent;
    color: var(--text-primary);
    box-shadow: inset 0 0 0 1.5px var(--border-primary);
}

.btn-outline:hover:not(:disabled) {
    background: var(--gray-50);
    box-shadow: inset 0 0 0 1.5px var(--gray-300);
}

.btn-dark {
    background: var(--gray-900);
    color: var(--white);
}

.btn-dark:hover:not(:disabled) {
    background: var(--black);
    transform: translateY(-1px);
    box-shadow: var(--shadow-lg);
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: var(--text-xs);
    border-radius: var(--radius-sm);
}

.btn-lg {
    padding: var(--space-4) var(--space-8);
    font-size: var(--text-base);
    border-radius: var(--radius-lg);
}

.btn-xl {
    padding: var(--space-5) var(--space-10);
    font-size: var(--text-lg);
    border-radius: var(--radius-lg);
}

.btn-block {
    width: 100%;
}

.btn-icon {
    padding: var(--space-3);
    width: 40px;
    height: 40px;
}

/* Button loading state */
.btn.loading {
    color: transparent;
    pointer-events: none;
}

.btn.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.btn-primary.loading::after {
    border-color: rgba(255, 255, 255, 0.3);
    border-right-color: var(--white);
}

/* ===== Form Elements ===== */
.form-group {
    margin-bottom: var(--space-6);
}

.form-label {
    display: block;
    margin-bottom: var(--space-2);
    font-size: var(--text-sm);
    font-weight: 500;
    color: var(--text-primary);
}

.form-input,
.form-textarea,
.form-select {
    width: 100%;
    padding: var(--space-3) var(--space-4);
    font-family: var(--font-sans);
    font-size: var(--text-base);
    color: var(--text-primary);
    background: var(--bg-primary);
    border: 1.5px solid var(--border-primary);
    border-radius: var(--radius-md);
    transition: all var(--duration-fast) var(--ease-out);
    outline: none;
}

.form-input:hover,
.form-textarea:hover,
.form-select:hover {
    border-color: var(--gray-300);
}

.form-input:focus,
.form-textarea:focus,
.form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(var(--primary-rgb), 0.1);
}

.form-input::placeholder {
    color: var(--text-tertiary);
}

.form-input.error {
    border-color: var(--danger);
}

.form-input.error:focus {
    box-shadow: 0 0 0 3px rgba(255, 59, 48, 0.1);
}

.form-textarea {
    min-height: 120px;
    resize: vertical;
}

.form-hint {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--text-tertiary);
}

.form-error {
    margin-top: var(--space-2);
    font-size: var(--text-sm);
    color: var(--danger);
}

/* Input with icon */
.input-group {
    position: relative;
}

.input-group .form-input {
    padding-left: 44px;
}

.input-icon {
    position: absolute;
    left: var(--space-4);
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-tertiary);
    pointer-events: none;
}

/* ===== Cards ===== */
.card {
    background: var(--bg-primary);
    border: 1px solid var(--border-primary);
    border-radius: var(--radius-xl);
    padding: var(--space-6);
    transition: all var(--duration-normal) var(--ease-out);
}

.card:hover {
    border-color: var(--gray-200);
    box-shadow: var(--shadow-md);
}

.card-elevated {
    border: none;
    box-shadow: var(--shadow-lg);
}

.card-elevated:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-xl);
}

.card-interactive {
    cursor: pointer;
}

.card-interactive:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-xl);
}

/* ===== Badges ===== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--space-1);
    padding: var(--space-1) var(--space-3);
    font-size: var(--text-xs);
    font-weight: 500;
    border-radius: var(--radius-full);
}

.badge-primary {
    background: var(--primary-light);
    color: var(--primary);
}

.badge-success {
    background: rgba(0, 200, 83, 0.1);
    color: var(--success);
}

.badge-warning {
    background: rgba(255, 149, 0, 0.1);
    color: var(--warning);
}

.badge-danger {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.badge-pro {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: var(--white);
}

/* ===== Verified Badge ===== */
.verified-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 20px;
    height: 20px;
    margin-left: 6px;
    flex-shrink: 0;
}

.verified-badge svg {
    width: 100%;
    height: 100%;
    filter: drop-shadow(0 1px 2px rgba(var(--primary-rgb), 0.3));
}

/* ===== Skeleton Loading ===== */
.skeleton {
    position: relative;
    overflow: hidden;
    background: var(--gray-100);
    border-radius: var(--radius-md);
}

.skeleton::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(
        90deg,
        transparent,
        rgba(255, 255, 255, 0.6),
        transparent
    );
    animation: shimmer 1.5s infinite;
}

.skeleton-text {
    height: 16px;
    margin-bottom: var(--space-2);
    border-radius: var(--radius-sm);
}

.skeleton-text:last-child {
    width: 70%;
}

.skeleton-circle {
    border-radius: 50%;
}

.skeleton-card {
    padding: var(--space-6);
    border-radius: var(--radius-xl);
}

@keyframes shimmer {
    0% { transform: translateX(-100%); }
    100% { transform: translateX(100%); }
}

/* ===== Loading Spinner ===== */
.spinner {
    width: 24px;
    height: 24px;
    border: 2.5px solid var(--gray-200);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
}

.spinner-sm { width: 16px; height: 16px; border-width: 2px; }
.spinner-lg { width: 40px; height: 40px; border-width: 3px; }

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* ===== Alerts ===== */
.alert {
    display: flex;
    align-items: flex-start;
    gap: var(--space-3);
    padding: var(--space-4);
    border-radius: var(--radius-lg);
    font-size: var(--text-sm);
}

.alert-icon {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
}

.alert-success {
    background: rgba(0, 200, 83, 0.08);
    color: var(--success);
    border: 1px solid rgba(0, 200, 83, 0.2);
}

.alert-danger {
    background: rgba(255, 59, 48, 0.08);
    color: var(--danger);
    border: 1px solid rgba(255, 59, 48, 0.2);
}

.alert-warning {
    background: rgba(255, 149, 0, 0.08);
    color: var(--warning);
    border: 1px solid rgba(255, 149, 0, 0.2);
}

.alert-info {
    background: rgba(var(--primary-rgb), 0.08);
    color: var(--primary);
    border: 1px solid rgba(var(--primary-rgb), 0.2);
}

/* ===== Modal ===== */
.modal-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--space-6);
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all var(--duration-normal) var(--ease-out);
}

.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}

.modal {
    background: var(--bg-primary);
    border-radius: var(--radius-2xl);
    max-width: 480px;
    width: 100%;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.95) translateY(20px);
    transition: transform var(--duration-normal) var(--ease-out);
    box-shadow: var(--shadow-xl);
}

.modal-overlay.active .modal {
    transform: scale(1) translateY(0);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: var(--space-6);
    border-bottom: 1px solid var(--border-secondary);
}

.modal-title {
    font-size: var(--text-lg);
    font-weight: 600;
    margin: 0;
}

.modal-close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: none;
    border: none;
    border-radius: var(--radius-sm);
    cursor: pointer;
    color: var(--text-tertiary);
    transition: all var(--duration-fast) var(--ease-out);
}

.modal-close:hover {
    background: var(--gray-100);
    color: var(--text-primary);
}

.modal-body {
    padding: var(--space-6);
    overflow-y: auto;
}

.modal-footer {
    display: flex;
    gap: var(--space-3);
    justify-content: flex-end;
    padding: var(--space-6);
    border-top: 1px solid var(--border-secondary);
}

/* ===== Icons ===== */
.icon {
    width: 24px;
    height: 24px;
    stroke-width: 2;
    stroke: currentColor;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon-sm { width: 16px; height: 16px; }
.icon-lg { width: 32px; height: 32px; }
.icon-xl { width: 48px; height: 48px; }

/* ===== Animations ===== */
.fade-in {
    animation: fadeIn var(--duration-normal) var(--ease-out);
}

.fade-in-up {
    animation: fadeInUp var(--duration-slow) var(--ease-out);
}

.fade-in-down {
    animation: fadeInDown var(--duration-slow) var(--ease-out);
}

.scale-in {
    animation: scaleIn var(--duration-normal) var(--ease-out);
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes fadeInDown {
    from {
        opacity: 0;
        transform: translateY(-20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes scaleIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }
    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* Stagger animation */
.stagger > * {
    opacity: 0;
    animation: fadeInUp var(--duration-slow) var(--ease-out) forwards;
}

.stagger > *:nth-child(1) { animation-delay: 0ms; }
.stagger > *:nth-child(2) { animation-delay: 80ms; }
.stagger > *:nth-child(3) { animation-delay: 160ms; }
.stagger > *:nth-child(4) { animation-delay: 240ms; }
.stagger > *:nth-child(5) { animation-delay: 320ms; }
.stagger > *:nth-child(6) { animation-delay: 400ms; }

/* ===== Utilities ===== */
.text-center { text-align: center; }
.text-left { text-align: left; }
.text-right { text-align: right; }

.text-primary { color: var(--text-primary); }
.text-secondary { color: var(--text-secondary); }
.text-tertiary { color: var(--text-tertiary); }
.text-accent { color: var(--primary); }
.text-success { color: var(--success); }
.text-danger { color: var(--danger); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }

.d-none { display: none; }
.d-block { display: block; }
.d-flex { display: flex; }
.d-grid { display: grid; }
.d-inline-flex { display: inline-flex; }

.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.items-start { align-items: flex-start; }
.items-end { align-items: flex-end; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.justify-end { justify-content: flex-end; }
.flex-wrap { flex-wrap: wrap; }
.flex-1 { flex: 1; }

.gap-1 { gap: var(--space-1); }
.gap-2 { gap: var(--space-2); }
.gap-3 { gap: var(--space-3); }
.gap-4 { gap: var(--space-4); }
.gap-6 { gap: var(--space-6); }
.gap-8 { gap: var(--space-8); }

.mt-0 { margin-top: 0; }
.mt-2 { margin-top: var(--space-2); }
.mt-4 { margin-top: var(--space-4); }
.mt-6 { margin-top: var(--space-6); }
.mt-8 { margin-top: var(--space-8); }
.mt-12 { margin-top: var(--space-12); }

.mb-0 { margin-bottom: 0; }
.mb-2 { margin-bottom: var(--space-2); }
.mb-4 { margin-bottom: var(--space-4); }
.mb-6 { margin-bottom: var(--space-6); }
.mb-8 { margin-bottom: var(--space-8); }

.p-4 { padding: var(--space-4); }
.p-6 { padding: var(--space-6); }
.p-8 { padding: var(--space-8); }

.w-full { width: 100%; }
.h-full { height: 100%; }

.rounded { border-radius: var(--radius-md); }
.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;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    border: 0;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    :root {
        --text-5xl: 2.5rem;
        --text-6xl: 3rem;
    }
    
    .container {
        padding: 0 var(--space-4);
    }
    
    .hide-mobile {
        display: none !important;
    }
}

@media (min-width: 769px) {
    .hide-desktop {
        display: none !important;
    }
}