/* ===================================
   GHOST_TRADES - THEME & CORE UTILITIES
   Variables, Resets, and Global Animations
   =================================== */

/* --- CSS Variables & Theme --- */
:root {
    /* Primary Colors */
    --primary-color: #ff444f;
    --primary-hover: #e53940;
    --primary-light: #ff6b75;
    --primary-glow: rgba(255, 68, 79, 0.4);

    /* Success/Error Colors */
    --success-color: #10b981;
    --success-light: #34d399;
    --success-glow: rgba(16, 185, 129, 0.4);
    --error-color: #ef4444;
    --error-light: #f87171;
    --error-glow: rgba(239, 68, 68, 0.4);

    /* Neutral Colors */
    --bg-primary: #0f172a;
    --bg-secondary: #1e293b;
    --bg-tertiary: #334155;
    --text-primary: #f1f5f9;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;

    /* Glass Effect 2.0 */
    --glass-bg: rgba(15, 23, 42, 0.7);
    --glass-border: rgba(255, 255, 255, 0.08);
    --glass-shadow: 0 12px 40px rgba(0, 0, 0, 0.4);
    --glass-blur: blur(20px);

    /* Vibrant Gradients */
    --grad-primary: linear-gradient(135deg, #ff444f 0%, #ff6b75 100%);
    --grad-success: linear-gradient(135deg, #10b981 0%, #34d399 100%);
    --grad-ghost: linear-gradient(135deg, #0f172a 0%, #1e293b 100%);
    --grad-aurora: linear-gradient(90deg, #ff444f, #10b981, #3b82f6, #ff444f);
    --grad-glass: linear-gradient(135deg, rgba(255, 255, 255, 0.05) 0%, rgba(255, 255, 255, 0.01) 100%);

    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;

    /* Border Radius */
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.5rem;

    /* Transitions */
    --transition-fast: 150ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 300ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-slow: 500ms cubic-bezier(0.4, 0, 0.2, 1);
    --transition-bounce: 500ms cubic-bezier(0.68, -0.55, 0.265, 1.55);

    /* Shadows */
    --shadow-sm: 0 2px 4px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 8px 16px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 16px 32px rgba(0, 0, 0, 0.3);
    --shadow-xl: 0 24px 48px rgba(0, 0, 0, 0.4);
    --shadow-glow: 0 0 25px rgba(255, 68, 79, 0.3);
}

/* --- Global Reset --- */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    -webkit-overflow-scrolling: touch;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    min-height: 100vh;
    background: linear-gradient(135deg, #0f172a 0%, #1e293b 50%, #0f172a 100%);
    background-attachment: fixed;
    color: var(--text-primary);
    line-height: 1.6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Mobile Optimization */
@media (max-width: 768px) {
    body {
        font-size: 14px;
    }
}

/* Background Pattern Overlay */
body::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-image:
        radial-gradient(circle at 20% 50%, rgba(255, 68, 79, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 80%, rgba(16, 185, 129, 0.1) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* --- Core Animations --- */
@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

@keyframes aurora-bg {
    0% {
        background-position: 0% 50%;
    }

    50% {
        background-position: 100% 50%;
    }

    100% {
        background-position: 0% 50%;
    }
}

@keyframes glow-pulse {
    0% {
        box-shadow: 0 0 5px rgba(255, 68, 79, 0.2);
    }

    50% {
        box-shadow: 0 0 20px rgba(255, 68, 79, 0.5);
    }

    100% {
        box-shadow: 0 0 5px rgba(255, 68, 79, 0.2);
    }
}

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

@keyframes bounceIn {
    0% {
        opacity: 0;
        transform: scale(0.3);
    }

    50% {
        opacity: 1;
        transform: scale(1.05);
    }

    70% {
        transform: scale(0.9);
    }

    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInFromRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

@keyframes pulse-dot {

    0%,
    100% {
        transform: scale(1);
        box-shadow: 0 0 8px rgba(239, 68, 68, 0.6), 0 0 16px rgba(239, 68, 68, 0.4);
    }

    50% {
        transform: scale(1.2);
        box-shadow: 0 0 12px rgba(239, 68, 68, 0.8), 0 0 24px rgba(239, 68, 68, 0.6);
    }
}

/* --- Premium Utility Classes --- */
.glass-premium {
    background: var(--glass-bg);
    backdrop-filter: var(--glass-blur);
    -webkit-backdrop-filter: var(--glass-blur);
    border: 1px solid var(--glass-border);
    box-shadow: var(--glass-shadow);
    position: relative;
    overflow: hidden;
}

.glass-premium::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: var(--grad-glass);
    pointer-events: none;
    z-index: 0;
}

.gradient-text {
    background: var(--grad-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.glow-pulse {
    animation: glow-pulse 3s infinite ease-in-out;
}

.hover-glow {
    transition: var(--transition-base);
}

.hover-glow:hover {
    box-shadow: 0 0 15px var(--primary-glow);
    transform: translateY(-2px);
}

.shimmer-effect,
.shimmer {
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.1), transparent);
    background-size: 200% 100%;
    animation: shimmer 2s infinite linear;
}

/* --- Collapsible Sections --- */
.collapsible-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    user-select: none;
    transition: var(--transition-base);
    padding: 0.5rem 0;
}

.collapsible-header:hover {
    opacity: 0.8;
}

.collapse-arrow {
    width: 20px;
    height: 20px;
    transition: transform var(--transition-base);
    flex-shrink: 0;
    margin-left: 0.5rem;
}

.collapse-arrow.collapsed {
    transform: rotate(-90deg);
}

.collapsible-content {
    overflow: hidden;
    transition: max-height var(--transition-slow), opacity var(--transition-base);
    max-height: 5000px;
    opacity: 1;
}

.collapsible-content.collapsed {
    max-height: 0;
    opacity: 0;
}

.collapsed-placeholder {
    display: none;
    margin-top: 1rem;
    border-radius: var(--radius-lg);
    overflow: hidden;
    transition: opacity var(--transition-base);
}

.collapsed-placeholder.show {
    display: block;
    animation: fadeIn var(--transition-base);
}

.collapsed-image {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
    border-radius: var(--radius-lg);
    opacity: 0.6;
}

/* Image Scaling */
img {
    max-width: 100%;
    height: auto;
}

/* ===================================
   MOBILE UX ENHANCEMENTS
   =================================== */

/* Smooth scrolling for all scrollable containers */
* {
    scroll-behavior: smooth;
}

/* Better touch targets for mobile */
@media (max-width: 768px) {

    button,
    a,
    input[type="checkbox"],
    input[type="radio"],
    select {
        min-height: 44px;
        min-width: 44px;
    }

    /* Improve input field sizing */
    input[type="text"],
    input[type="number"],
    input[type="email"],
    input[type="password"],
    textarea,
    select {
        font-size: 16px;
        /* Prevents zoom on iOS */
        padding: 12px;
    }

    /* Custom scrollbar for webkit browsers on mobile */
    ::-webkit-scrollbar {
        width: 6px;
        height: 6px;
    }

    ::-webkit-scrollbar-track {
        background: rgba(255, 255, 255, 0.05);
        border-radius: 3px;
    }

    ::-webkit-scrollbar-thumb {
        background: var(--primary-color);
        border-radius: 3px;
    }

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

    /* Smooth momentum scrolling on iOS */
    .bot-log,
    .collapsible-content,
    #live-contracts-container,
    .ticks-visual {
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        scrollbar-color: var(--primary-color) rgba(255, 255, 255, 0.05);
    }

    /* Prevent text selection on UI controls */
    .btn-bot,
    .collapsible-header,
    button {
        -webkit-tap-highlight-color: transparent;
        -webkit-touch-callout: none;
        -webkit-user-select: none;
        user-select: none;
    }

    /* Add subtle tap feedback */
    .btn-bot:active,
    .collapsible-header:active,
    button:active {
        transform: scale(0.98);
        transition: transform 0.1s xase;
    }
}

/* Prevent horizontal overflow globally */
body,
html,
#app,
main,
section {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Ensure all containers respect viewport width */
.container,
.bot-grid,
.trading-interface,
.ghostai-interface {
    max-width: 100%;
    overflow-x: hidden;
    box-sizing: border-box;
}

/* Mobile-friendly spacing */
@media (max-width: 640px) {
    :root {
        --spacing-xs: 0.25rem;
        --spacing-sm: 0.4rem;
        --spacing-md: 0.75rem;
        --spacing-lg: 1rem;
        --spacing-xl: 1.25rem;
    }
}

/* Optimize animations for mobile */
@media (prefers-reduced-motion: reduce) {

    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* --- Trade Outcome Styling --- */
.price-up {
    color: var(--success-color) !important;
    font-weight: 600 !important;
}

.price-down {
    color: var(--error-color) !important;
    font-weight: 600 !important;
}