/* ==========================================================================
   KOMTRA TRADING PLATFORM - MODERN MINIMALIST DESIGN SYSTEM
   Theme: Light Mode
   Colors: Cyan & White Only
   Typography: Black & Cyan Text Only (No Neon Text)
   ========================================================================== */

@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&family=Inter:wght@400;500;600;700&display=swap');

:root {
    /* Color Palette */
    --bg-page: #f8fafc;
    --bg-surface: #ffffff;
    --bg-subtle: #f1f5f9;
    --bg-cyan-light: #ecfeff;
    --bg-cyan-subtle: #e0f2fe;
    
    /* Primary Cyan Colors */
    --cyan-primary: #0891b2;
    --cyan-hover: #0e7490;
    --cyan-active: #155e75;
    --cyan-border: #bae6fd;
    --cyan-soft-border: #cff4fc;
    
    /* Text Colors (Strictly Black / Dark Slate / Cyan) */
    --text-primary: #0f172a;
    --text-secondary: #334155;
    --text-muted: #64748b;
    --text-cyan: #0891b2;
    --text-cyan-dark: #0e7490;
    
    /* Borders & Dividers */
    --border-color: #e2e8f0;
    --border-hover: #cbd5e1;
    
    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(15, 23, 42, 0.04);
    --shadow-md: 0 4px 6px -1px rgba(15, 23, 42, 0.05), 0 2px 4px -2px rgba(15, 23, 42, 0.03);
    --shadow-lg: 0 10px 15px -3px rgba(15, 23, 42, 0.06), 0 4px 6px -4px rgba(15, 23, 42, 0.02);
    
    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    /* Layout */
    --sidebar-width: 260px;
    --topbar-height: 70px;
}

/* Reset & Base Setup */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Outfit', 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-page);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    overflow-x: hidden;
}

a {
    color: inherit;
    text-decoration: none;
}

button, input, select, textarea {
    font-family: inherit;
    font-size: inherit;
}

/* ==========================================================================
   APP LAYOUT (SIDEBAR & MAIN CONTENT)
   ========================================================================== */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar Navigation */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--bg-surface);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 50;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
}

.brand-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    font-weight: 700;
    font-size: 1.25rem;
    color: var(--text-primary);
    letter-spacing: -0.5px;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--cyan-primary);
    border: 1px solid var(--cyan-border);
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #ffffff;
    font-weight: 800;
}

/* SIDEBAR MENU WITH SMOOTH VERTICAL SCROLLING */
.sidebar-menu {
    padding: 20px 16px;
    display: flex;
    flex-direction: column;
    gap: 6px;
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    scrollbar-width: thin;
    scrollbar-color: var(--cyan-border) transparent;
    -webkit-overflow-scrolling: touch;
}

.sidebar-menu::-webkit-scrollbar {
    width: 5px;
}

.sidebar-menu::-webkit-scrollbar-thumb {
    background-color: var(--cyan-border);
    border-radius: 4px;
}

.menu-label {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    margin: 12px 12px 6px 12px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    color: var(--text-secondary);
    font-weight: 500;
    font-size: 0.9rem;
    transition: all 0.2s ease;
}

.nav-item:hover {
    background-color: var(--bg-cyan-light);
    color: var(--text-cyan-dark);
}

.nav-item.active {
    background-color: var(--bg-cyan-light);
    color: var(--text-cyan-dark);
    font-weight: 600;
    border-right: 3px solid var(--cyan-primary);
}

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

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-surface);
    flex-shrink: 0;
}

.user-pill {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px;
    background: var(--bg-subtle);
    border-radius: var(--radius-md);
}

.avatar {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-full);
    background: var(--bg-cyan-subtle);
    color: var(--text-cyan-dark);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 0.8rem;
}

.user-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.user-name {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-role {
    font-size: 0.7rem;
    color: var(--text-muted);
}

/* Main Content Wrapper */
.main-wrapper {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left 0.3s ease;
}

/* Topbar Header */
.topbar {
    height: var(--topbar-height);
    background-color: var(--bg-surface);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.mobile-menu-btn {
    display: none;
    background: transparent;
    border: none;
    cursor: pointer;
    color: var(--text-primary);
    padding: 6px;
    border-radius: var(--radius-sm);
}

.mobile-menu-btn:hover {
    background: var(--bg-subtle);
}

.page-title {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.topbar-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.market-status-badge {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 12px;
    background-color: var(--bg-cyan-light);
    border: 1px solid var(--cyan-border);
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
    color: var(--text-cyan-dark);
}

.pulse-dot {
    width: 8px;
    height: 8px;
    background-color: var(--cyan-primary);
    border-radius: 50%;
    box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.4);
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0% { box-shadow: 0 0 0 0 rgba(8, 145, 178, 0.4); }
    70% { box-shadow: 0 0 0 8px rgba(8, 145, 178, 0); }
    100% { box-shadow: 0 0 0 0 rgba(8, 145, 178, 0); }
}

/* Main Content Container */
.content-container {
    padding: 32px;
    flex: 1;
}

/* ==========================================================================
   UI COMPONENTS (CARDS, BUTTONS, BADGES, TABLES)
   ========================================================================== */

/* Grid Utilities */
.grid-4 { display: grid; grid-template-columns: repeat(4, 1fr); gap: 20px; }
.grid-3 { display: grid; grid-template-columns: repeat(3, 1fr); gap: 20px; }
.grid-2 { display: grid; grid-template-columns: repeat(2, 1fr); gap: 20px; }

/* Cards */
.card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 24px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
}

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

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
}

.card-title {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Stat Cards */
.stat-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.stat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.stat-title {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.stat-icon {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
    background-color: var(--bg-cyan-light);
    color: var(--text-cyan-dark);
    display: flex;
    align-items: center;
    justify-content: center;
}

.stat-value {
    font-size: 1.75rem;
    font-weight: 700;
    color: var(--text-primary);
}

.stat-cyan {
    color: var(--text-cyan-dark);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.875rem;
    cursor: pointer;
    border: 1px solid transparent;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--cyan-primary);
    color: #ffffff;
}

.btn-primary:hover {
    background-color: var(--cyan-hover);
}

.btn-secondary {
    background-color: var(--bg-surface);
    border-color: var(--border-color);
    color: var(--text-secondary);
}

.btn-secondary:hover {
    background-color: var(--bg-subtle);
    border-color: var(--border-hover);
}

.btn-cyan-soft {
    background-color: var(--bg-cyan-light);
    color: var(--text-cyan-dark);
    border-color: var(--cyan-border);
}

.btn-cyan-soft:hover {
    background-color: var(--bg-cyan-subtle);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 0.8rem;
    border-radius: var(--radius-sm);
}

/* Badges */
.badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.badge-buy {
    background-color: var(--bg-cyan-light);
    color: var(--text-cyan-dark);
    border: 1px solid var(--cyan-border);
}

.badge-sell {
    background-color: #f1f5f9;
    color: #475569;
    border: 1px solid #cbd5e1;
}

.badge-active {
    background-color: #e0f2fe;
    color: #0369a1;
}

.badge-hit {
    background-color: var(--bg-cyan-light);
    color: var(--text-cyan-dark);
}

.badge-loss {
    background-color: #f8fafc;
    color: #64748b;
}

.badge-high {
    background-color: #fef2f2;
    color: #dc2626;
    border: 1px solid #fecaca;
}

.badge-medium {
    background-color: #fffbebfb;
    color: #d97706;
    border: 1px solid #fde68a;
}

/* Table */
.table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
    font-size: 0.9rem;
}

.table th {
    padding: 12px 16px;
    background-color: var(--bg-subtle);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    border-bottom: 1px solid var(--border-color);
}

.table td {
    padding: 16px;
    border-bottom: 1px solid var(--border-color);
    color: var(--text-secondary);
}

.table tr:last-child td {
    border-bottom: none;
}

/* AI Chat Assistant UI */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 180px);
    background-color: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    overflow: hidden;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.chat-bubble {
    max-width: 80%;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 0.9rem;
    line-height: 1.6;
}

.chat-bubble-user {
    align-self: flex-end;
    background-color: var(--cyan-primary);
    color: #ffffff;
    border-bottom-right-radius: 4px;
}

.chat-bubble-ai {
    align-self: flex-start;
    background-color: var(--bg-cyan-light);
    color: var(--text-primary);
    border: 1px solid var(--cyan-border);
    border-bottom-left-radius: 4px;
}

.chat-input-area {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background-color: var(--bg-surface);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.prompt-chips {
    display: flex;
    gap: 8px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.chip {
    white-space: nowrap;
    padding: 6px 14px;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-full);
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-secondary);
    cursor: pointer;
    transition: all 0.2s ease;
}

.chip:hover {
    background-color: var(--bg-cyan-subtle);
    color: var(--text-cyan-dark);
    border-color: var(--cyan-border);
}

.input-group {
    display: flex;
    gap: 12px;
}

.input-field {
    flex: 1;
    padding: 12px 18px;
    background-color: var(--bg-subtle);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    color: var(--text-primary);
    outline: none;
    transition: border-color 0.2s ease, background-color 0.2s ease;
}

.input-field:focus {
    border-color: var(--cyan-primary);
    background-color: var(--bg-surface);
}

/* Modal Overlay */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.4);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-backdrop.active {
    display: flex;
}

.modal-content {
    background: var(--bg-surface);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 560px;
    max-height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-lg);
    overflow: hidden;
    animation: modalSlide 0.25s ease-out;
}

.modal-content form {
    display: flex;
    flex-direction: column;
    flex: 1;
    min-height: 0;
    overflow: hidden;
}

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

.modal-header {
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}

.modal-body {
    padding: 20px 24px;
    display: flex;
    flex-direction: column;
    gap: 14px;
    overflow-y: auto;
    flex: 1;
}

.modal-footer {
    padding: 16px 24px;
    border-top: 1px solid var(--border-color);
    background: var(--bg-subtle);
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    flex-shrink: 0;
}

/* Mobile Sidebar Backdrop Overlay */
.sidebar-mobile-backdrop {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.5);
    backdrop-filter: blur(2px);
    z-index: 45;
}

/* ==========================================================================
   RESPONSIVE DESIGN MEDIA QUERIES (MOBILE & TABLET OPTIMIZATION)
   ========================================================================== */

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

@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
        width: 280px;
        box-shadow: var(--shadow-lg);
    }
    
    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-mobile-backdrop.active {
        display: block;
    }

    .main-wrapper {
        margin-left: 0;
    }

    .topbar {
        padding: 0 16px;
    }

    .mobile-menu-btn {
        display: inline-flex;
    }

    .content-container {
        padding: 16px;
    }

    .grid-4, .grid-3, .grid-2 {
        grid-template-columns: 1fr;
    }

    .card {
        padding: 16px;
    }

    .stat-value {
        font-size: 1.4rem;
    }

    .chat-container {
        height: calc(100vh - 140px);
    }

    .chat-bubble {
        max-width: 90%;
    }

    .page-title {
        font-size: 1.05rem;
    }
}
