/* Font */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700&family=JetBrains+Mono:wght@400;500;600&display=swap');

/* CSS Variables for Theme System */
:root {
    --primary: #2563eb;
    --secondary: #64748b;
    --success: #16a34a;
    --danger: #dc2626;
    --warning: #fb923c;
    --info: #06b6d4;

    /* 🔥 OVERRIDE BOOTSTRAP HEADING COLOR - PERMANENT FIX */
    --bs-heading-color: var(--text);

    /* Surfaces */
    --bg: #f6f8fc;
    --surface: #ffffff;
    --surface-2: #f3f6ff;
    --text: #0f172a;                
    --muted: #64748b;
    --border: rgba(15, 23, 42, 0.10);

    /* Semantic */
    --positive: #16a34a;
    --negative: #dc2626;

    /* Elevation */
    --shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06);
    --shadow-md: 0 10px 30px rgba(15, 23, 42, 0.10);
    --ring: 0 0 0 4px rgba(37, 99, 235, 0.18);
}

[data-theme="dark"] {
    --primary: #60a5fa;
    --secondary: #94a3b8;
    --success: #22c55e;
    --danger: #f87171;
    --warning: #fb923c;
    --info: #22d3ee;

    /* 🔥 OVERRIDE BOOTSTRAP HEADING COLOR - DARK MODE */
    --bs-heading-color: var(--text);

    --bg: #0b1220;
    --surface: #1a2332;
    --surface-2: #243447;
    --text: #f1f5f9;
    --muted: #94a3b8;
    --border: rgba(148, 163, 184, 0.2);

    --positive: #22c55e;
    --negative: #f87171;

    --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.25);
    --shadow-md: 0 18px 50px rgba(0, 0, 0, 0.35);
    --ring: 0 0 0 4px rgba(96, 165, 250, 0.20);
}

/* Base Theme Application */
body {
    font-family: "Plus Jakarta Sans", ui-sans-serif, system-ui, -apple-system, Segoe UI, Roboto, Helvetica, Arial, "Apple Color Emoji", "Segoe UI Emoji";
    background:
        radial-gradient(1200px 600px at 18% -10%, rgba(37, 99, 235, 0.12), transparent 55%),
        radial-gradient(900px 520px at 92% 6%, rgba(6, 182, 212, 0.10), transparent 52%),
        var(--bg);
    color: var(--text);
    transition: background-color 0.25s ease, color 0.25s ease;
}

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

a:hover {
    color: color-mix(in srgb, var(--primary), #000 18%);
}

::selection {
    background: rgba(37, 99, 235, 0.22);
}

.card {
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-radius: 14px;
    box-shadow: var(--shadow-sm);
    transition: transform 0.18s ease, box-shadow 0.18s ease, background-color 0.25s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-1px);
}

.card-header {
    background: transparent;
    border-bottom: 1px solid var(--border);
    padding: 0.9rem 1rem;
}

.card-body {
    padding: 1rem;
}

.text-muted {
    color: var(--muted) !important;
}

.badge {
    border: 1px solid rgba(255, 255, 255, 0.14);
    letter-spacing: 0.2px;
}

/* Navigation */
.navbar {
    position: sticky;
    top: 0;
    z-index: 1030;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    background: linear-gradient(
        180deg,
        rgba(15, 23, 42, 0.88),
        rgba(15, 23, 42, 0.74)
    );
    border-bottom: 1px solid rgba(148, 163, 184, 0.22);
}

.navbar-brand {
    font-weight: 700;
    font-size: 1.5rem;
    text-decoration: none;
}

.navbar-brand:hover {
    color: #ffffff !important;
}

.nav-link {
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-link:hover {
    transform: translateY(-1px);
    color: #ffffff !important;
}

.navbar .nav-link {
    color: rgba(226, 232, 240, 0.86) !important;
}

.navbar .nav-link:hover {
    color: #ffffff !important;
}

/* Navigation separators */
.navbar-nav .nav-item:not(:last-child) {
    border-right: 1px solid var(--border);
    margin-right: 0.5rem;
    padding-right: 0.5rem;
}

.navbar-nav .nav-item:last-child {
    border-right: none;
}

/* Theme Toggle Button */
.navbar .btn-outline-light {
    border-color: rgba(255, 255, 255, 0.3);
    color: rgba(255, 255, 255, 0.8);
    padding: 0.25rem 0.5rem;
    margin: 0 0.25rem;
    transition: all 0.2s ease;
}

.navbar .btn-outline-light:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: rgba(255, 255, 255, 0.5);
    color: #ffffff;
}

.navbar .btn-outline-light:focus {
    box-shadow: 0 0 0 0.2rem rgba(255, 255, 255, 0.25);
}

/* Buttons & focus */
.btn {
    border-radius: 12px;
    font-weight: 600;
}

.btn-primary {
    background: linear-gradient(180deg, color-mix(in srgb, var(--primary), #fff 8%), var(--primary));
    border-color: color-mix(in srgb, var(--primary), #000 10%);
    box-shadow: 0 10px 18px rgba(37, 99, 235, 0.18);
}

.btn-primary:hover {
    background: color-mix(in srgb, var(--primary), #000 10%);
    border-color: color-mix(in srgb, var(--primary), #000 18%);
}

.btn:focus, .btn:focus-visible,
.form-control:focus, .form-select:focus,
.form-check-input:focus {
    box-shadow: var(--ring);
}

/* Tables / DataTables */
.table {
    color: var(--text);
    background-color: var(--surface);
    border: 1px solid var(--border);
    border-collapse: separate;
    border-spacing: 0;
    font-size: 14px;
}

.table thead th {
    color: var(--text) !important;
    background-color: var(--surface-2) !important;
    border-bottom: 2px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
    font-weight: 600;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    padding: 12px 8px;
}

.table thead th:last-child {
    border-right: none !important;
}

.table tbody td {
    color: var(--text) !important;
    background-color: var(--surface) !important;
    border-bottom: 1px solid var(--border) !important;
    border-right: 1px solid var(--border) !important;
}

.table tbody td:last-child {
    border-right: none !important;
}

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

.table tbody tr:hover td {
    background-color: var(--surface-2) !important;
}

/* Dark mode specific table enhancements */
[data-theme="dark"] .table thead th {
    color: #ffffff !important;
    font-weight: 700;
}

[data-theme="dark"] .table tbody td {
    color: #f1f5f9 !important;
}

/* Ensure all table text is visible */
.table td,
.table th {
    color: var(--text) !important;
}

/* Specific table text visibility fixes */
.table .text-muted,
.table .text-secondary {
    color: var(--muted) !important;
}

.table .text-success {
    color: var(--positive) !important;
}

.table .text-danger {
    color: var(--negative) !important;
}

.table .text-warning {
    color: var(--warning) !important;
}

.table .text-info {
    color: var(--info) !important;
}

/* Force warning color visibility in all contexts */
.text-warning,
[data-theme="dark"] .text-warning,
[data-theme="light"] .text-warning,
.table .text-warning,
.dataTables_wrapper .text-warning {
    color: var(--warning) !important;
}

/* DataTables specific styling */
.dataTables_wrapper .dataTables_filter input,
.dataTables_wrapper .dataTables_length select {
    background-color: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}

.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text) !important;
}

/* 🔥 CRITICAL FIX: DataTables label text (Show entries, Search) - BROWN COLOR ISSUE */
.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label {
    color: var(--muted) !important;
    font-size: 12px;
}

/* FULL DataTables text fix - Complete solution */
.dataTables_wrapper {
    color: var(--text);
}

.dataTables_wrapper .dataTables_length label,
.dataTables_wrapper .dataTables_filter label,
.dataTables_wrapper .dataTables_info,
.dataTables_wrapper .dataTables_paginate {
    color: var(--text) !important;
}

.page-link {
    background-color: var(--surface) !important;
    color: var(--text) !important;
    border: 1px solid var(--border) !important;
}

.page-link:hover {
    background-color: var(--surface-2) !important;
    color: var(--text) !important;
}

.page-item.active .page-link {
    background: var(--primary);
    border-color: color-mix(in srgb, var(--primary), #000 12%);
}

/* Sorting Colors - CRITICAL FOR GLOBAL SORTING */
th.sorting-asc {
    color: var(--positive) !important;
    font-weight: 600;
}

th.sorting-desc {
    color: var(--negative) !important;
    font-weight: 600;
}

/* Performance Optimizations */
/* ✅ REMOVED: will-change: transform from table rows - risky under heavy load */
/* ✅ REMOVED: Empty rule - was causing lint error */

/* Faster hover - no transition for performance */
.table-hover tbody tr:hover {
    transition: none;
}

/* Remove sorting arrows - clean and simple */
table.dataTable thead .sorting:before,
table.dataTable thead .sorting:after,
table.dataTable thead .sorting_asc:before,
table.dataTable thead .sorting_asc:after,
table.dataTable thead .sorting_desc:before,
table.dataTable thead .sorting_desc:after {
    display: none !important;
    content: none !important;
}

table.dataTable thead .sorting,
table.dataTable thead .sorting_asc,
table.dataTable thead .sorting_desc,
table.dataTable thead th.sorting,
table.dataTable thead th.sorting_asc,
table.dataTable thead th.sorting_desc {
    background-image: none !important;
}

/* Layout container */
.app-container {
    max-width: 1480px;
    margin: 0 auto;
}

/* Loading Spinner */
.loading-spinner {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .theme-toggle {
        top: 0.5rem;
        right: 0.5rem;
        padding: 0.4rem 0.8rem;
        font-size: 0.875rem;
    }
    
    .navbar-brand {
        font-size: 1.25rem;
    }
    
    .dataTables_wrapper {
        font-size: 0.85rem;
    }
}

/* Page Specific Styles */

/* 
================================================================================

IMPORTANT USAGE POLICY:

- ALLOWED: DataTables overrides, Bootstrap conflicts, theme enforcement
- AVOID: layout, spacing, custom components  
- REASON: Prevent cascade conflicts in dynamic tables

================================================================================
*/

/* Professional Trading Dashboard Styles */
.metric-card {
    padding: 18px;
    border-radius: 14px;
    border: 1px solid var(--border);
    text-align: center;
    background: var(--surface);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}

.metric-card:hover {
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.metric-label {
    font-size: 13px;
    color: var(--muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 8px;
}

.metric-value {
    font-size: 26px;
    font-weight: 600;
    line-height: 1;
    color: var(--text);
}

/* Professional Tabs */
.nav-tabs {
    border-bottom: 1px solid var(--border);
    margin-bottom: 20px;
}

.nav-tabs .nav-link {
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--muted);
    font-weight: 500;
    padding: 12px 20px;
    transition: all 0.2s ease;
}

.nav-tabs .nav-link:hover {
    border-bottom-color: var(--primary);
    color: var(--primary);
}

.nav-tabs .nav-link.active {
    border-bottom-color: var(--primary);
    color: var(--primary);
    background: none;
    font-weight: 600;
}

/* Disabled tab styling */
.nav-tabs .nav-link.disabled {
    color: var(--muted);
    opacity: 0.6;
    cursor: not-allowed;
    pointer-events: none;
}

.nav-tabs .nav-link.disabled:hover {
    border-bottom-color: transparent;
    color: var(--muted);
    cursor: not-allowed;
}

/* Professional Table */
/* ✅ REMOVED: Duplicate .table definition - consolidated above */

/* ✅ REMOVED: Duplicate .table thead th definition - consolidated above */

.table tbody tr:hover {
    background-color: color-mix(in srgb, var(--surface-2), transparent 8%);
}

.table tbody td {
    padding: 12px 8px;
    vertical-align: middle;
    border-bottom: 1px solid var(--border);
}

/* PNL Color Coding */
.pnl-positive {
    color: var(--positive);
    font-weight: 600;
}

.pnl-negative {
    color: var(--negative);
    font-weight: 600;
}

.pnl-neutral {
    color: var(--muted);
}

/* Signal Strength Indicator */
.signal-strength {
    display: inline-flex;
    align-items: center;
    gap: 2px;
}

.signal-bar {
    width: 4px;
    height: 12px;
    background: color-mix(in srgb, var(--muted), transparent 75%);
    border-radius: 2px;
}

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

/* Last Updated Time */
.last-updated {
    font-size: 12px;
    color: var(--muted);
    text-align: right;
    margin-bottom: 10px;
}

/* Status bar */
.status-bar {
    background: var(--surface) !important;
    border-radius: 12px !important;
    border: 1px solid var(--border);
    border-left: 4px solid var(--primary) !important;
    box-shadow: var(--shadow-sm);
}

/* LTP Highlighting Classes */
.sl-breached {
    background-color: rgba(220, 38, 38, 0.1) !important;
    color: var(--danger) !important;
    font-weight: 600;
}

.breakout {
    background-color: rgba(34, 197, 94, 0.1) !important;
    color: var(--success) !important;
    font-weight: 600;
}

.near-resistance {
    background-color: rgba(245, 158, 11, 0.1) !important;
    color: var(--warning) !important;
    font-weight: 600;
}

/* Symbol Links */
.symbol-link {
    color: var(--primary);
    text-decoration: none;
    font-weight: 600;
    transition: color 0.2s ease;
}

.symbol-link:hover {
    color: var(--primary);
    text-decoration: underline;
}

.symbol-link.positive {
    color: var(--positive);
}

.symbol-link.negative {
    color: var(--negative);
}

/* Technical Indicators */
.tech-indicator {
    font-family: "JetBrains Mono", monospace;
    font-size: 0.85rem;
    padding: 2px 4px;
    border-radius: 4px;
}

/* Decision Badges */
.decision-badge {
    font-size: 0.75rem;
    font-weight: 600;
    padding: 2px 6px;
    border-radius: 8px;
}

.decision-badge.buy {
    background-color: rgba(34, 197, 94, 0.1);
    color: var(--success);
}

.decision-badge.sell {
    background-color: rgba(220, 38, 38, 0.1);
    color: var(--danger);
}

.decision-badge.hold {
    background-color: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

/* Responsive for terminal */
@media (max-width: 768px) {
    .metric-value {
        font-size: 20px;
    }
    
    .metric-label {
        font-size: 11px;
    }
    
    .table {
        font-size: 12px;
    }
}
