/* ═══════════════════════════════════════════
   SyannuAI Dashboard — CSS Design System
   ═══════════════════════════════════════════ */

:root {
    --bg-primary: #0a0e17;
    --bg-secondary: #111827;
    --bg-card: #1a2235;
    --bg-card-hover: #1f2a40;
    --bg-input: #0f1622;
    --border: #2a3548;
    --border-focus: #3b82f6;

    --text-primary: #e2e8f0;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;

    --accent: #3b82f6;
    --accent-hover: #2563eb;
    --accent-glow: rgba(59, 130, 246, 0.15);

    --green: #22c55e;
    --green-bg: rgba(34, 197, 94, 0.1);
    --red: #ef4444;
    --red-bg: rgba(239, 68, 68, 0.1);
    --yellow: #f59e0b;
    --yellow-bg: rgba(245, 158, 11, 0.1);

    --font-mono: 'JetBrains Mono', 'Fira Code', 'Cascadia Code', monospace;
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;

    --radius: 12px;
    --radius-sm: 8px;
    --shadow: 0 4px 24px rgba(0, 0, 0, 0.3);
    --shadow-lg: 0 8px 40px rgba(0, 0, 0, 0.4);
}

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

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

body {
    font-family: var(--font-sans);
    background: var(--bg-primary);
    color: var(--text-primary);
    min-height: 100vh;
    overflow-x: hidden;
}

/* ── Background Pattern ── */
body::before {
    content: "";
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background:
        radial-gradient(ellipse at 20% 50%, rgba(59, 130, 246, 0.04) 0%, transparent 50%),
        radial-gradient(ellipse at 80% 20%, rgba(139, 92, 246, 0.03) 0%, transparent 50%),
        radial-gradient(ellipse at 50% 80%, rgba(34, 197, 94, 0.02) 0%, transparent 50%);
    pointer-events: none;
    z-index: 0;
}

/* ═══════════════════════════════════
   Header
   ═══════════════════════════════════ */

.header {
    position: sticky;
    top: 0;
    z-index: 100;
    background: rgba(10, 14, 23, 0.85);
    backdrop-filter: blur(20px);
    border-bottom: 1px solid var(--border);
    padding: 0 2rem;
}

.header-inner {
    max-width: 1600px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 64px;
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.logo-text {
    font-size: 1.25rem;
    font-weight: 700;
    background: linear-gradient(135deg, #e2e8f0, #94a3b8);
    -webkit-background-clip: text;
    background-clip: text;
    -webkit-text-fill-color: transparent;
    letter-spacing: -0.02em;
}

.logo-badge {
    font-size: 0.65rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 3px 8px;
    border-radius: 6px;
    background: var(--accent-glow);
    color: var(--accent);
    border: 1px solid rgba(59, 130, 246, 0.2);
}

.header-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

.connection-status {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 6px 14px;
    border-radius: 20px;
    font-size: 0.8rem;
    font-weight: 500;
    transition: all 0.3s ease;
}

.connection-status.connected {
    background: var(--green-bg);
    color: var(--green);
    border: 1px solid rgba(34, 197, 94, 0.2);
}

.connection-status.disconnected {
    background: var(--red-bg);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.connection-status.connecting {
    background: var(--yellow-bg);
    color: var(--yellow);
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background: currentColor;
    animation: pulse-dot 2s infinite;
}

@keyframes pulse-dot {

    0%,
    100% {
        opacity: 1;
        box-shadow: 0 0 0 0 currentColor;
    }

    50% {
        opacity: 0.7;
        box-shadow: 0 0 0 4px transparent;
    }
}

.clock {
    font-family: var(--font-mono);
    font-size: 0.85rem;
    color: var(--text-secondary);
}

/* ═══════════════════════════════════
   Main Content
   ═══════════════════════════════════ */

.main {
    position: relative;
    z-index: 1;
    max-width: 1600px;
    margin: 0 auto;
    padding: 1.5rem 2rem 3rem;
}

/* ── Stats Bar ── */
.stats-bar {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.stat-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: 1rem 1.25rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    transition: all 0.2s ease;
}

.stat-card:hover {
    border-color: rgba(59, 130, 246, 0.3);
    background: var(--bg-card-hover);
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
}

.stat-icon.blue {
    background: var(--accent-glow);
}

.stat-icon.green {
    background: var(--green-bg);
}

.stat-icon.red {
    background: var(--red-bg);
}

.stat-icon.yellow {
    background: var(--yellow-bg);
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.stat-value {
    font-size: 1.3rem;
    font-weight: 700;
    font-family: var(--font-mono);
}

/* ── Controls Section ── */
.controls {
    display: flex;
    gap: 1rem;
    margin-bottom: 1.5rem;
    flex-wrap: wrap;
}

.subscribe-form {
    flex: 1;
    min-width: 300px;
    display: flex;
    gap: 0.5rem;
}

.subscribe-form input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.65rem 1rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.9rem;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.subscribe-form input:focus {
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px var(--accent-glow);
}

.subscribe-form input::placeholder {
    color: var(--text-muted);
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 0.65rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    font-family: var(--font-sans);
    font-size: 0.85rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    white-space: nowrap;
}

.btn-primary {
    background: var(--accent);
    color: white;
}

.btn-primary:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.3);
}

.btn-danger {
    background: rgba(239, 68, 68, 0.15);
    color: var(--red);
    border: 1px solid rgba(239, 68, 68, 0.3);
}

.btn-danger:hover {
    background: rgba(239, 68, 68, 0.25);
}

.btn-secondary {
    background: rgba(148, 163, 184, 0.1);
    color: var(--text-secondary);
    border: 1px solid var(--border);
}

.btn-secondary:hover {
    background: rgba(148, 163, 184, 0.15);
    color: var(--text-primary);
}

/* ═══════════════════════════════════
   Data Table
   ═══════════════════════════════════ */

.table-container {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.table-title {
    font-size: 0.95rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 8px;
}

.table-title .count {
    font-size: 0.75rem;
    padding: 2px 8px;
    border-radius: 10px;
    background: var(--accent-glow);
    color: var(--accent);
    font-weight: 600;
}

.table-scroll {
    overflow-x: auto;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

thead th {
    position: sticky;
    top: 0;
    background: var(--bg-secondary);
    color: var(--text-muted);
    font-weight: 600;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    padding: 0.75rem 1rem;
    text-align: right;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

thead th:first-child {
    text-align: left;
}

tbody tr {
    border-bottom: 1px solid rgba(42, 53, 72, 0.5);
    transition: background 0.15s;
}

tbody tr:hover {
    background: var(--bg-card-hover);
}

tbody tr:last-child {
    border-bottom: none;
}

tbody td {
    padding: 0.7rem 1rem;
    text-align: right;
    font-family: var(--font-mono);
    font-size: 0.82rem;
    white-space: nowrap;
    transition: background 0.3s;
}

tbody td:first-child {
    text-align: left;
    font-family: var(--font-sans);
    font-weight: 600;
    color: var(--text-primary);
}

.symbol-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.symbol-badge {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    background: linear-gradient(135deg, var(--accent-glow), rgba(139, 92, 246, 0.1));
    border: 1px solid rgba(59, 130, 246, 0.15);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--accent);
}

.stock-name {
    cursor: pointer;
}

.stock-name:hover {
    color: var(--accent);
}

.ltp-cell {
    font-weight: 600;
    font-size: 0.9rem;
}

.change-positive {
    color: var(--green) !important;
}

.change-negative {
    color: var(--red) !important;
}

.flash-green {
    animation: flash-g 0.5s ease;
}

.flash-red {
    animation: flash-r 0.5s ease;
}

@keyframes flash-g {
    0% {
        background: rgba(34, 197, 94, 0.2);
    }

    100% {
        background: transparent;
    }
}

@keyframes flash-r {
    0% {
        background: rgba(239, 68, 68, 0.2);
    }

    100% {
        background: transparent;
    }
}

.remove-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.9rem;
    transition: all 0.2s;
}

.remove-btn:hover {
    color: var(--red);
    background: var(--red-bg);
}

/* ── Empty State ── */
.empty-state {
    text-align: center;
    padding: 3rem;
    color: var(--text-muted);
}

.empty-state .icon {
    font-size: 2.5rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

.empty-state p {
    font-size: 0.95rem;
}

/* ═══════════════════════════════════
   History Section
   ═══════════════════════════════════ */

.history-section {
    margin-top: 1.5rem;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

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

.history-controls {
    display: flex;
    gap: 0.5rem;
    align-items: center;
    flex-wrap: wrap;
}

.history-controls select,
.history-controls input {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.5rem 0.75rem;
    color: var(--text-primary);
    font-family: var(--font-sans);
    font-size: 0.8rem;
    outline: none;
}

.history-controls select:focus,
.history-controls input:focus {
    border-color: var(--border-focus);
}

.history-table-scroll {
    max-height: 400px;
    overflow-y: auto;
}

/* ═══════════════════════════════════
   Toast Notifications
   ═══════════════════════════════════ */

.toast-container {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.toast {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 0.8rem 1.2rem;
    font-size: 0.85rem;
    box-shadow: var(--shadow-lg);
    animation: toast-in 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
}

.toast.success {
    border-left: 3px solid var(--green);
}

.toast.error {
    border-left: 3px solid var(--red);
}

.toast.info {
    border-left: 3px solid var(--accent);
}

@keyframes toast-in {
    from {
        opacity: 0;
        transform: translateX(20px);
    }

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

/* ═══════════════════════════════════
   Scrollbar
   ═══════════════════════════════════ */

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

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

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

/* ═══════════════════════════════════
   Chart Modal
   ═══════════════════════════════════ */

.chart-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1.5rem;
    animation: modal-fade-in 0.25s ease;
}

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

@keyframes modal-fade-in {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.chart-modal-content {
    width: 100%;
    max-width: 1400px;
    height: 85vh;
    background: var(--bg-secondary);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    box-shadow: 0 24px 80px rgba(0, 0, 0, 0.6), 0 0 60px rgba(59, 130, 246, 0.08);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    animation: modal-slide-up 0.3s ease;
}

@keyframes modal-slide-up {
    from {
        opacity: 0;
        transform: translateY(30px) scale(0.98);
    }

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

/* ── Chart Header ── */
.chart-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.75rem 1.25rem;
    border-bottom: 1px solid var(--border);
    background: var(--bg-card);
    gap: 1rem;
    flex-shrink: 0;
}

.chart-header-left {
    display: flex;
    align-items: center;
    gap: 12px;
    min-width: 0;
}

.chart-symbol-badge {
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--accent), #8b5cf6);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    font-weight: 800;
    color: white;
    flex-shrink: 0;
    box-shadow: 0 0 20px rgba(59, 130, 246, 0.25);
}

.chart-symbol-info {
    min-width: 0;
}

.chart-symbol-name {
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.chart-symbol-ltp {
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: var(--font-mono);
    font-size: 0.85rem;
}

.chart-symbol-ltp span:first-child {
    font-weight: 600;
    color: var(--text-primary);
}

/* ── Interval Buttons ── */
.chart-header-center {
    flex-shrink: 0;
}

.interval-group {
    display: flex;
    gap: 4px;
    background: var(--bg-primary);
    border-radius: 8px;
    padding: 3px;
    border: 1px solid var(--border);
}

.interval-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: var(--font-mono);
    font-size: 0.75rem;
    font-weight: 600;
    padding: 6px 14px;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.2s ease;
    letter-spacing: 0.02em;
}

.interval-btn:hover {
    color: var(--text-primary);
    background: rgba(59, 130, 246, 0.08);
}

.interval-btn.active {
    background: var(--accent);
    color: white;
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.3);
}

/* ── Close Button ── */
.chart-header-right {
    flex-shrink: 0;
}

.chart-close-btn {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-muted);
    font-size: 1rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.chart-close-btn:hover {
    color: var(--red);
    border-color: rgba(239, 68, 68, 0.3);
    background: var(--red-bg);
}

/* ── Chart Container ── */
.chart-container {
    flex: 1;
    min-height: 0;
    position: relative;
    background: var(--bg-primary);
}

/* ── Chart Button in Table Row ── */
.chart-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 1rem;
    transition: all 0.2s;
    opacity: 0.5;
    filter: grayscale(0.5);
}

.chart-btn:hover {
    opacity: 1;
    filter: grayscale(0);
    background: var(--accent-glow);
    box-shadow: 0 0 12px rgba(59, 130, 246, 0.2);
    transform: scale(1.15);
}

/* ═══════════════════════════════════
   Responsive
   ═══════════════════════════════════ */

@media (max-width: 768px) {
    .header {
        padding: 0 1rem;
    }

    .main {
        padding: 1rem;
    }

    .stats-bar {
        grid-template-columns: 1fr 1fr;
    }

    .subscribe-form {
        min-width: unset;
    }

    .controls {
        flex-direction: column;
    }

    .logo-badge {
        display: none;
    }

    .chart-modal {
        padding: 0.5rem;
    }

    .chart-modal-content {
        height: 95vh;
    }

    .chart-header {
        flex-wrap: wrap;
    }

    .interval-group {
        order: 3;
        width: 100%;
        justify-content: center;
    }
}