/* ============================================================================
   SHADCN-INSPIRED DESIGN SYSTEM
   A clean, minimal design system inspired by shadcn/ui
   ============================================================================ */

/* ============================================================================
   CSS VARIABLES (Design Tokens)
   ============================================================================ */
:root {
    /* Background Colors */
    --background: hsl(0, 0%, 3.9%);          /* Near black #0a0a0a */
    --foreground: hsl(0, 0%, 98%);           /* Off white #fafafa */
    --card: hsl(0, 0%, 5.9%);                /* Card background #0f0f0f */
    --card-foreground: hsl(0, 0%, 98%);      /* Card text */
    --popover: hsl(0, 0%, 5.9%);             /* Popover background */
    --popover-foreground: hsl(0, 0%, 98%);   /* Popover text */
    
    /* Primary Colors */
    --primary: hsl(210, 100%, 50%);          /* Blue #0080ff */
    --primary-foreground: hsl(0, 0%, 100%);  /* White on primary */
    
    /* Secondary/Muted */
    --secondary: hsl(0, 0%, 14.9%);          /* Dark gray #262626 */
    --secondary-foreground: hsl(0, 0%, 98%);
    --muted: hsl(0, 0%, 14.9%);
    --muted-foreground: hsl(0, 0%, 63.9%);   /* Muted text #a3a3a3 */
    
    /* Accent */
    --accent: hsl(0, 0%, 14.9%);
    --accent-foreground: hsl(0, 0%, 98%);
    
    /* Semantic Colors */
    --destructive: hsl(0, 84%, 60%);         /* Red #ef4444 */
    --destructive-foreground: hsl(0, 0%, 98%);
    --success: hsl(142, 76%, 36%);           /* Green #22c55e */
    --success-foreground: hsl(0, 0%, 98%);
    --warning: hsl(38, 92%, 50%);            /* Amber #f59e0b */
    --warning-foreground: hsl(0, 0%, 9%);
    
    /* Border & Ring */
    --border: hsl(0, 0%, 14.9%);             /* #262626 */
    --input: hsl(0, 0%, 14.9%);
    --ring: hsl(210, 100%, 50%);             /* Focus ring */
    
    /* Radius */
    --radius: 0.5rem;                        /* 8px - default border-radius */
    --radius-sm: 0.375rem;                   /* 6px */
    --radius-lg: 0.75rem;                    /* 12px */
    --radius-xl: 1rem;                       /* 16px */
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow: 0 1px 3px 0 rgb(0 0 0 / 0.1), 0 1px 2px -1px rgb(0 0 0 / 0.1);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
    
    /* Typography */
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    --font-mono: 'JetBrains Mono', 'SF Mono', 'Fira Code', monospace;
}

/* ============================================================================
   BASE STYLES
   ============================================================================ */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    border-color: var(--border);
}

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

body {
    font-family: var(--font-sans);
    color: var(--foreground);
    line-height: 1.5;
    min-height: 100vh;
    /* Grainy dark background - uniform across all pages */
    background: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E"),
        radial-gradient(ellipse 80% 60% at 20% 10%, hsla(210, 60%, 15%, 0.4) 0%, transparent 60%),
        linear-gradient(160deg, hsl(220, 30%, 7%) 0%, hsl(220, 35%, 4%) 50%, hsl(210, 25%, 3%) 100%);
    background-blend-mode: overlay, normal, normal;
    background-attachment: fixed;
    background-size: cover;
    background-color: var(--background);
}

/* ============================================================================
   TYPOGRAPHY
   ============================================================================ */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.25;
    color: var(--foreground);
}

h1 { font-size: 2.25rem; }    /* 36px */
h2 { font-size: 1.875rem; }   /* 30px */
h3 { font-size: 1.5rem; }     /* 24px */
h4 { font-size: 1.25rem; }    /* 20px */
h5 { font-size: 1.125rem; }   /* 18px */
h6 { font-size: 1rem; }       /* 16px */

p {
    color: var(--muted-foreground);
}

.text-sm { font-size: 0.875rem; }
.text-xs { font-size: 0.75rem; }
.text-lg { font-size: 1.125rem; }
.text-xl { font-size: 1.25rem; }
.text-2xl { font-size: 1.5rem; }

.text-muted { color: var(--muted-foreground); }
.text-primary { color: var(--primary); }
.text-success { color: var(--success); }
.text-destructive { color: var(--destructive); }
.text-warning { color: var(--warning); }

.font-medium { font-weight: 500; }
.font-semibold { font-weight: 600; }
.font-bold { font-weight: 700; }
.font-mono { font-family: var(--font-mono); }

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

.card-header {
    padding: 1.5rem 1.5rem 0;
}

.card-title {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--card-foreground);
    margin-bottom: 0.25rem;
}

.card-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

.card-content {
    padding: 1.5rem;
}

.card-footer {
    padding: 0 1.5rem 1.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

/* Card variants */
.card-hover:hover {
    border-color: var(--muted-foreground);
    transition: border-color 0.2s ease;
}

.card-interactive {
    cursor: pointer;
    transition: all 0.2s ease;
}

.card-interactive:hover {
    background-color: hsl(0, 0%, 7%);
    border-color: var(--muted-foreground);
}

/* ============================================================================
   BUTTON COMPONENT
   ============================================================================ */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: var(--radius);
    cursor: pointer;
    transition: all 0.15s ease;
    border: 1px solid transparent;
    text-decoration: none;
    white-space: nowrap;
}

.btn:disabled {
    opacity: 0.5;
    pointer-events: none;
}

/* Primary Button */
.btn-primary {
    background-color: var(--primary);
    color: var(--primary-foreground);
    border-color: var(--primary);
}

.btn-primary:hover {
    background-color: hsl(210, 100%, 45%);
    border-color: hsl(210, 100%, 45%);
}

/* Secondary Button */
.btn-secondary {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
    border-color: var(--secondary);
}

.btn-secondary:hover {
    background-color: hsl(0, 0%, 20%);
}

/* Outline Button */
.btn-outline {
    background-color: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

.btn-outline:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

/* Ghost Button */
.btn-ghost {
    background-color: transparent;
    color: var(--foreground);
    border-color: transparent;
}

.btn-ghost:hover {
    background-color: var(--accent);
    color: var(--accent-foreground);
}

/* Destructive Button */
.btn-destructive {
    background-color: var(--destructive);
    color: var(--destructive-foreground);
    border-color: var(--destructive);
}

.btn-destructive:hover {
    background-color: hsl(0, 84%, 50%);
}

/* Button Sizes */
.btn-sm {
    padding: 0.375rem 0.75rem;
    font-size: 0.75rem;
}

.btn-lg {
    padding: 0.625rem 1.5rem;
    font-size: 1rem;
}

.btn-icon {
    padding: 0.5rem;
    width: 2.25rem;
    height: 2.25rem;
}

/* ============================================================================
   INPUT COMPONENT
   ============================================================================ */
.input {
    display: flex;
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    line-height: 1.25rem;
    background-color: var(--background);
    color: var(--foreground);
    border: 1px solid var(--input);
    border-radius: var(--radius);
    transition: all 0.15s ease;
}

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

.input:focus {
    outline: none;
    border-color: var(--ring);
    box-shadow: 0 0 0 2px hsl(210 100% 50% / 0.2);
}

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

/* Fix autofill background in dark mode */
.input:-webkit-autofill,
.input:-webkit-autofill:hover,
.input:-webkit-autofill:focus,
.input:-webkit-autofill:active {
    -webkit-box-shadow: 0 0 0 30px var(--background) inset !important;
    -webkit-text-fill-color: var(--foreground) !important;
    caret-color: var(--foreground);
    transition: background-color 5000s ease-in-out 0s;
}

/* Input with icon */
.input-group {
    position: relative;
    display: flex;
    align-items: center;
}

.input-group .input {
    padding-left: 2.5rem;
}

.input-group .input-icon {
    position: absolute;
    left: 0.75rem;
    color: var(--muted-foreground);
    pointer-events: none;
}

/* ============================================================================
   LABEL COMPONENT
   ============================================================================ */
.label {
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--foreground);
    margin-bottom: 0.5rem;
}

/* ============================================================================
   BADGE COMPONENT
   ============================================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 0.125rem 0.625rem;
    font-size: 0.75rem;
    font-weight: 500;
    line-height: 1.25rem;
    border-radius: 9999px;
    border: 1px solid transparent;
}

.badge-default {
    background-color: var(--secondary);
    color: var(--secondary-foreground);
}

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

.badge-success {
    background-color: hsl(142, 76%, 36%, 0.2);
    color: var(--success);
    border-color: hsl(142, 76%, 36%, 0.3);
}

.badge-destructive {
    background-color: hsl(0, 84%, 60%, 0.2);
    color: var(--destructive);
    border-color: hsl(0, 84%, 60%, 0.3);
}

.badge-warning {
    background-color: hsl(38, 92%, 50%, 0.2);
    color: var(--warning);
    border-color: hsl(38, 92%, 50%, 0.3);
}

.badge-outline {
    background-color: transparent;
    color: var(--foreground);
    border-color: var(--border);
}

/* ============================================================================
   SEPARATOR COMPONENT
   ============================================================================ */
.separator {
    height: 1px;
    width: 100%;
    background-color: var(--border);
}

.separator-vertical {
    width: 1px;
    height: 100%;
    background-color: var(--border);
}

/* ============================================================================
   AVATAR COMPONENT
   ============================================================================ */
.avatar {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 9999px;
    background-color: var(--muted);
    overflow: hidden;
}

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

.avatar-fallback {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
}

.avatar-sm {
    width: 2rem;
    height: 2rem;
}

.avatar-lg {
    width: 3rem;
    height: 3rem;
}

/* ============================================================================
   DROPDOWN / MENU
   ============================================================================ */
.dropdown {
    position: relative;
    display: inline-block;
}

.dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    z-index: 50;
    min-width: 12rem;
    margin-top: 0.25rem;
    background-color: var(--popover);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 0.25rem;
    box-shadow: var(--shadow-lg);
    display: none;
}

.dropdown-content.active {
    display: block;
}

.dropdown-item {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    color: var(--popover-foreground);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: background-color 0.15s ease;
    text-decoration: none;
}

.dropdown-item:hover {
    background-color: var(--accent);
}

.dropdown-separator {
    height: 1px;
    margin: 0.25rem -0.25rem;
    background-color: var(--border);
}

.dropdown-label {
    padding: 0.5rem 0.75rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
}

/* ============================================================================
   SIDEBAR LAYOUT
   ============================================================================ */
.app-container {
    display: flex;
    min-height: 100vh;
}

.sidebar {
    width: 16rem;
    flex-shrink: 0;
    background-color: var(--card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    z-index: 40;
}

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

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--foreground);
    text-decoration: none;
}

.sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 1.5rem;
}

.sidebar-section-title {
    padding: 0 0.5rem;
    margin-bottom: 0.5rem;
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--muted-foreground);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--muted-foreground);
    border-radius: var(--radius);
    text-decoration: none;
    transition: all 0.15s ease;
}

.sidebar-link:hover {
    color: var(--foreground);
    background-color: var(--accent);
}

.sidebar-link.active {
    color: var(--foreground);
    background-color: var(--accent);
}

.sidebar-link i {
    width: 1.25rem;
    text-align: center;
}

.sidebar-footer {
    padding: 1rem;
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0));
    border-top: 1px solid var(--border);
}

/* Mobile sidebar footer - extra safe area for Safari home indicator */
@media (max-width: 768px) {
    .sidebar-footer {
        padding-bottom: calc(1.5rem + env(safe-area-inset-bottom, 16px));
    }
}

/* Main content area when sidebar is present */
.main-content {
    flex: 1;
    margin-left: 16rem;
    min-height: 100vh;
    background-color: var(--background);
}

/* ============================================================================
   PAGE HEADER
   ============================================================================ */
.page-header {
    padding: 1.5rem 2rem;
    border-bottom: 1px solid var(--border);
    background-color: var(--background);
}

.page-title {
    font-size: 1.5rem;
    font-weight: 600;
    margin-bottom: 0.25rem;
}

.page-description {
    font-size: 0.875rem;
    color: var(--muted-foreground);
}

/* ============================================================================
   SIGNAL CARD (App-specific)
   ============================================================================ */
.signal-card {
    background-color: var(--card);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: border-color 0.2s ease;
}

.signal-card:hover {
    border-color: var(--muted-foreground);
}

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

.signal-symbol {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.signal-icon {
    width: 2.25rem;
    height: 2.25rem;
    border-radius: 9999px;
    background-color: var(--muted);
    overflow: hidden;
}

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

.signal-name {
    font-weight: 600;
    color: var(--foreground);
}

.signal-pair {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.signal-time {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    display: flex;
    align-items: center;
    gap: 0.375rem;
}

.signal-body {
    padding: 1.25rem;
}

.signal-action {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
}

.signal-direction {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.375rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: var(--radius);
}

.signal-direction.long {
    background-color: hsl(142, 76%, 36%, 0.15);
    color: var(--success);
}

.signal-direction.short {
    background-color: hsl(0, 84%, 60%, 0.15);
    color: var(--destructive);
}

.signal-price {
    text-align: right;
}

.signal-price-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
    margin-bottom: 0.125rem;
}

.signal-price-value {
    font-size: 1.25rem;
    font-weight: 600;
    font-family: var(--font-mono);
    color: var(--foreground);
}

.signal-targets {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.75rem;
    padding: 0.75rem;
    background-color: hsl(0, 0%, 3%);
    border-radius: var(--radius);
    margin-bottom: 1rem;
}

.signal-target {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.signal-target-label {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

.signal-target-value {
    font-family: var(--font-mono);
    font-size: 0.875rem;
    font-weight: 500;
}

.signal-target-value.tp {
    color: var(--success);
}

.signal-target-value.sl {
    color: var(--destructive);
}

.signal-reasoning {
    font-size: 0.875rem;
    color: var(--muted-foreground);
    padding: 0.75rem;
    background-color: hsl(0, 0%, 5%);
    border-left: 2px solid var(--primary);
    border-radius: 0 var(--radius-sm) var(--radius-sm) 0;
}

.signal-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.75rem 1.25rem;
    border-top: 1px solid var(--border);
    background-color: hsl(0, 0%, 4%);
}

.signal-confidence {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.confidence-bar {
    width: 4rem;
    height: 0.25rem;
    background-color: var(--muted);
    border-radius: 9999px;
    overflow: hidden;
}

.confidence-fill {
    height: 100%;
    background-color: var(--primary);
    border-radius: 9999px;
}

.confidence-text {
    font-size: 0.75rem;
    color: var(--muted-foreground);
}

/* ============================================================================
   UTILITIES
   ============================================================================ */
.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-center { justify-content: center; }
.justify-between { justify-content: space-between; }
.gap-1 { gap: 0.25rem; }
.gap-2 { gap: 0.5rem; }
.gap-3 { gap: 0.75rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.gap-8 { gap: 2rem; }

.p-1 { padding: 0.25rem; }
.p-2 { padding: 0.5rem; }
.p-3 { padding: 0.75rem; }
.p-4 { padding: 1rem; }
.p-6 { padding: 1.5rem; }
.p-8 { padding: 2rem; }

.mt-1 { margin-top: 0.25rem; }
.mt-2 { margin-top: 0.5rem; }
.mt-4 { margin-top: 1rem; }
.mt-6 { margin-top: 1.5rem; }
.mt-8 { margin-top: 2rem; }

.mb-1 { margin-bottom: 0.25rem; }
.mb-2 { margin-bottom: 0.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }

.w-full { width: 100%; }
.max-w-md { max-width: 28rem; }
.max-w-lg { max-width: 32rem; }
.max-w-xl { max-width: 36rem; }
.max-w-2xl { max-width: 42rem; }

.mx-auto { margin-left: auto; margin-right: auto; }
.text-center { text-align: center; }

.hidden { display: none; }
.block { display: block; }
.inline-block { display: inline-block; }

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

.border { border: 1px solid var(--border); }
.border-t { border-top: 1px solid var(--border); }
.border-b { border-bottom: 1px solid var(--border); }

.overflow-hidden { overflow: hidden; }
.overflow-auto { overflow: auto; }

/* Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        transition: transform 0.3s ease;
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-only {
        display: block;
    }
    
    .desktop-only {
        display: none;
    }
}

@media (min-width: 769px) {
    .mobile-only {
        display: none;
    }
    
    .desktop-only {
        display: block;
    }
}

/* ============================================================================
   GRAINY BACKGROUND (for landing/opt pages)
   ============================================================================ */
.bg-grain {
    background: 
        url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.9' numOctaves='3' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)'/%3E%3C/svg%3E"),
        radial-gradient(ellipse 80% 60% at 20% 10%, hsla(210, 60%, 15%, 0.4) 0%, transparent 60%),
        linear-gradient(160deg, hsl(220, 30%, 7%) 0%, hsl(220, 35%, 4%) 50%, hsl(210, 25%, 3%) 100%);
    background-blend-mode: overlay, normal, normal;
    background-attachment: fixed;
    background-size: cover;
    min-height: 100vh;
}

/* Mobile fix for grainy bg - reduced intensity */
@media (max-width: 768px) {
    body,
    .bg-grain {
        /* Reduce noise intensity on mobile - drastically reduced to avoid white noise look */
        background: 
            url("data:image/svg+xml,%3Csvg viewBox='0 0 400 400' xmlns='http://www.w3.org/2000/svg'%3E%3Cfilter id='noiseFilter'%3E%3CfeTurbulence type='fractalNoise' baseFrequency='0.5' numOctaves='1' stitchTiles='stitch'/%3E%3C/filter%3E%3Crect width='100%25' height='100%25' filter='url(%23noiseFilter)' opacity='0.05'/%3E%3C/svg%3E"),
            radial-gradient(ellipse 80% 60% at 20% 10%, hsla(210, 60%, 15%, 0.3) 0%, transparent 60%),
            linear-gradient(160deg, hsl(220, 30%, 7%) 0%, hsl(220, 35%, 4%) 50%, hsl(210, 25%, 3%) 100%);
        background-blend-mode: overlay, normal, normal;
        background-attachment: scroll;
        background-color: var(--background);
    }
}
