/* css/style.css - Core design system and theme styles */

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

:root {
    --bg-main: #060913;
    --bg-gradient: linear-gradient(135deg, #060913 0%, #0c1125 100%);
    --bg-surface: rgba(15, 22, 42, 0.65);
    --bg-surface-hover: rgba(22, 32, 60, 0.8);
    --border-color: rgba(255, 255, 255, 0.06);
    --border-color-active: rgba(99, 102, 241, 0.4);
    
    --primary: #6366f1;
    --primary-glow: rgba(99, 102, 241, 0.3);
    --primary-hover: #4f46e5;
    
    --success: #10b981;
    --success-glow: rgba(16, 185, 129, 0.2);
    --success-hover: #059669;
    
    --danger: #ef4444;
    --danger-glow: rgba(239, 68, 68, 0.2);
    --danger-hover: #dc2626;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --font-sans: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    
    --shadow-sm: 0 2px 8px -2px rgba(0, 0, 0, 0.5);
    --shadow-md: 0 4px 20px -4px rgba(0, 0, 0, 0.5);
    --shadow-lg: 0 12px 40px -8px rgba(0, 0, 0, 0.7);
    
    --transition-fast: 0.15s ease;
    --transition-normal: 0.25s cubic-bezier(0.4, 0, 0.2, 1);

    --sidebar-bg: rgba(8, 12, 28, 0.85);
    --logo-gradient: linear-gradient(to right, #ffffff, #a5b4fc);
    --input-bg: rgba(0, 0, 0, 0.2);
    --hover-bg: rgba(255, 255, 255, 0.04);
    --profile-bg: rgba(255, 255, 255, 0.02);
}

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

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

/* Glassmorphism utility card */
.glass-panel {
    background: var(--bg-surface);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: 16px;
    box-shadow: var(--shadow-md);
    transition: transform var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

.glass-panel:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.glass-panel.interactive:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
    border-color: rgba(99, 102, 241, 0.2);
}

/* Scrollbar styles */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: rgba(0, 0, 0, 0.2);
}
::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.15);
    border-radius: 3px;
}
::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Typography styles */
h1, h2, h3, h4, h5, h6 {
    font-weight: 700;
    letter-spacing: -0.02em;
}

/* Layout framework */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar navigation */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-right: 1px solid var(--border-color);
    padding: 24px 16px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
}

.logo-container {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 8px;
    margin-bottom: 32px;
}

.logo-icon {
    width: 36px;
    height: 36px;
    background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 0 15px var(--primary-glow);
    font-weight: 800;
    font-size: 18px;
}

.logo-text {
    font-size: 20px;
    font-weight: 800;
    background: var(--logo-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.logo-text span {
    color: var(--primary);
    -webkit-text-fill-color: initial;
}

.nav-menu {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 8px;
    flex-grow: 1;
}

.nav-item a {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 12px 16px;
    color: var(--text-secondary);
    text-decoration: none;
    border-radius: 12px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.nav-item a:hover {
    color: var(--text-primary);
    background: var(--hover-bg);
}

.nav-item.active a {
    color: #ffffff;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(139, 92, 246, 0.05) 100%);
    border: 1px solid rgba(99, 102, 241, 0.25);
    box-shadow: inset 0 0 8px rgba(99, 102, 241, 0.05);
}

.nav-item.active a i {
    color: var(--primary);
    filter: drop-shadow(0 0 5px var(--primary-glow));
}

.sidebar-footer {
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}

.user-profile-summary {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px;
    background: var(--profile-bg);
    border-radius: 12px;
    border: 1px solid var(--border-color);
}

.avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: linear-gradient(135deg, #4338ca 0%, #6d28d9 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 16px;
}

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

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

.user-wallet {
    font-size: 12px;
    color: var(--success);
    font-weight: 500;
}

/* Main Content Area */
.main-wrapper {
    flex-grow: 1;
    margin-left: 260px;
    padding: 32px;
    min-height: 100vh;
}

/* Header/Navbar (Top) */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 32px;
    flex-wrap: wrap;
    gap: 16px;
}

.page-title h1 {
    font-size: 28px;
    font-weight: 800;
}

.page-title p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-top: 4px;
}

.quick-stats {
    display: flex;
    align-items: center;
    gap: 16px;
}

.quick-stat-card {
    padding: 10px 16px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.stat-icon-wrapper {
    width: 32px;
    height: 32px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
}

.stat-info-mini {
    display: flex;
    flex-direction: column;
}

.stat-label-mini {
    font-size: 11px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.stat-value-mini {
    font-size: 14px;
    font-weight: 600;
}

/* Dashboard grid layout */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1100px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
}

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

.card-title {
    font-size: 18px;
    font-weight: 700;
}

.card-body {
    padding: 24px;
}

/* Indicators */
.trend-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 600;
    font-size: 13px;
    padding: 4px 8px;
    border-radius: 6px;
}

.trend-up {
    color: var(--success);
    background: var(--success-glow);
}

.trend-down {
    color: var(--danger);
    background: var(--danger-glow);
}

/* Tables styling */
.market-table-container {
    overflow-x: auto;
}

.market-table {
    width: 100%;
    border-collapse: collapse;
    text-align: left;
}

.market-table th {
    padding: 16px 20px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid var(--border-color);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.market-table td {
    padding: 18px 20px;
    border-bottom: 1px solid var(--border-color);
    font-size: 14px;
    vertical-align: middle;
}

.market-table tbody tr {
    transition: background-color var(--transition-fast);
}

.market-table tbody tr:hover {
    background: rgba(255, 255, 255, 0.02);
}

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

.stock-info-cell {
    display: flex;
    align-items: center;
    gap: 12px;
}

.stock-symbol-badge {
    width: 48px;
    height: 48px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 13px;
    color: var(--text-primary);
}

.stock-name-wrapper {
    display: flex;
    flex-direction: column;
}

.stock-name-cell {
    font-weight: 600;
    color: var(--text-primary);
}

.stock-cat-cell {
    font-size: 11px;
    color: var(--text-secondary);
}

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 10px 20px;
    border-radius: 10px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: all var(--transition-fast);
    border: none;
    text-decoration: none;
}

.btn-primary {
    background: var(--primary);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    background: var(--primary-hover);
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transform: translateY(-1px);
}

.btn-secondary {
    background: rgba(255, 255, 255, 0.06);
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-success {
    background: var(--success);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(16, 185, 129, 0.25);
}

.btn-success:hover {
    background: var(--success-hover);
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    transform: translateY(-1px);
}

.btn-danger {
    background: var(--danger);
    color: #ffffff;
    box-shadow: 0 4px 15px rgba(239, 68, 68, 0.25);
}

.btn-danger:hover {
    background: var(--danger-hover);
    box-shadow: 0 4px 20px rgba(239, 68, 68, 0.4);
    transform: translateY(-1px);
}

.btn-sm {
    padding: 6px 12px;
    font-size: 12px;
    border-radius: 6px;
}

/* Gainers / Losers Sidebar panels */
.gainer-loser-widget {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.gl-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 12px 16px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-color);
}

.gl-item:hover {
    background: rgba(255, 255, 255, 0.04);
}

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

.gl-symbol {
    font-weight: 700;
    font-size: 14px;
}

.gl-name {
    font-size: 12px;
    color: var(--text-secondary);
}

.gl-values {
    text-align: right;
}

.gl-price {
    font-weight: 600;
    font-size: 14px;
}

/* Portfolio summary cards */
.portfolio-header-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 24px;
}

.portfolio-card {
    padding: 24px;
}

.p-label {
    font-size: 12px;
    color: var(--text-secondary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 8px;
}

.p-value {
    font-size: 28px;
    font-weight: 800;
}

.p-subtext {
    font-size: 13px;
    margin-top: 8px;
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Stock details styles */
.detail-grid {
    display: grid;
    grid-template-columns: 2.2fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

@media (max-width: 1024px) {
    .detail-grid {
        grid-template-columns: 1fr;
    }
}

.chart-container {
    height: 380px;
    position: relative;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.stat-box {
    background: rgba(255, 255, 255, 0.015);
    border: 1px solid var(--border-color);
    padding: 16px;
    border-radius: 12px;
}

.stat-box-label {
    font-size: 12px;
    color: var(--text-secondary);
    margin-bottom: 4px;
}

.stat-box-val {
    font-size: 16px;
    font-weight: 600;
}

/* Trading Widget */
.trade-widget {
    height: fit-content;
}

.trade-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-color);
}

.trade-tab {
    flex: 1;
    padding: 16px;
    text-align: center;
    font-weight: 700;
    cursor: pointer;
    transition: all var(--transition-fast);
    color: var(--text-secondary);
}

.trade-tab.active-buy {
    color: var(--success);
    border-bottom: 2px solid var(--success);
    background: rgba(16, 185, 129, 0.03);
}

.trade-tab.active-sell {
    color: var(--danger);
    border-bottom: 2px solid var(--danger);
    background: rgba(239, 68, 68, 0.03);
}

.trade-form {
    padding: 24px;
}

.form-group {
    margin-bottom: 20px;
}

.form-label {
    display: block;
    font-size: 12px;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
    text-transform: uppercase;
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    background: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 16px;
    font-weight: 600;
    outline: none;
    transition: border-color var(--transition-fast);
}

.form-input:focus {
    border-color: var(--primary);
}

.input-suffix {
    position: absolute;
    right: 16px;
    color: var(--text-secondary);
    font-weight: 600;
    font-size: 14px;
}

.trade-summary-line {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px dashed var(--border-color);
    font-size: 14px;
}

.trade-summary-line.total {
    border-bottom: none;
    font-weight: 700;
    font-size: 16px;
    padding-top: 16px;
}

.alert-message {
    padding: 12px 16px;
    border-radius: 10px;
    margin-bottom: 20px;
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.3);
    color: #a7f3d0;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.3);
    color: #fecaca;
}

/* Wallet Page Styles */
.wallet-grid {
    display: grid;
    grid-template-columns: 1fr 1.8fr;
    gap: 24px;
}

@media (max-width: 900px) {
    .wallet-grid {
        grid-template-columns: 1fr;
    }
}

/* Live indicators */
.flash-up {
    animation: flashGreen 1s ease-out;
}

.flash-down {
    animation: flashRed 1s ease-out;
}

@keyframes flashGreen {
    0% { background-color: rgba(16, 185, 129, 0.25); }
    100% { background-color: transparent; }
}

@keyframes flashRed {
    0% { background-color: rgba(239, 68, 68, 0.25); }
    100% { background-color: transparent; }
}

/* Quick Search in markets */
.search-filter-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    gap: 16px;
    flex-wrap: wrap;
}

.search-input-wrapper {
    flex-grow: 1;
    max-width: 400px;
    position: relative;
}

.search-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-secondary);
}

.search-input-wrapper input {
    padding-left: 48px;
}

.filter-pills {
    display: flex;
    gap: 8px;
}

.filter-pill {
    padding: 8px 16px;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    transition: all var(--transition-fast);
}

.filter-pill.active {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
}

.filter-pill:hover:not(.active) {
    background: rgba(255, 255, 255, 0.08);
}

/* Responsive fixes */
@media (max-width: 768px) {
    .sidebar {
        width: 70px;
        padding: 24px 8px;
    }
    .logo-text, .user-info, .nav-item a span, .sidebar-footer {
        display: none;
    }
    .main-wrapper {
        margin-left: 70px;
        padding: 20px;
    }
    .logo-container {
        margin-bottom: 20px;
        justify-content: center;
    }
    .nav-item a {
        justify-content: center;
        padding: 12px;
    }
}

/* Light Theme Variables and Overrides */
body.light-theme {
    --bg-main: #f1f5f9;
    --bg-gradient: linear-gradient(135deg, #f1f5f9 0%, #e2e8f0 100%);
    --bg-surface: rgba(255, 255, 255, 0.7);
    --bg-surface-hover: rgba(255, 255, 255, 0.85);
    --border-color: rgba(15, 23, 42, 0.08);
    --border-color-active: rgba(99, 102, 241, 0.6);
    
    --primary: #4f46e5;
    --primary-glow: rgba(79, 70, 229, 0.15);
    --primary-hover: #4338ca;
    
    --success: #059669;
    --success-glow: rgba(5, 150, 105, 0.1);
    --success-hover: #047857;
    
    --danger: #dc2626;
    --danger-glow: rgba(220, 38, 38, 0.1);
    --danger-hover: #b91c1c;
    
    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;

    --sidebar-bg: rgba(255, 255, 255, 0.8);
    --logo-gradient: linear-gradient(to right, #0f172a, #4f46e5);
    --input-bg: rgba(0, 0, 0, 0.04);
    --hover-bg: rgba(0, 0, 0, 0.04);
    --profile-bg: rgba(0, 0, 0, 0.02);
}

/* Light Theme Component Overrides */
body.light-theme .nav-item a {
    color: #475569;
}
body.light-theme .nav-item a:hover {
    color: #0f172a;
}
body.light-theme .nav-item.active a {
    color: #4f46e5;
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.12) 0%, rgba(139, 92, 246, 0.04) 100%);
    border: 1px solid rgba(99, 102, 241, 0.2);
}

/* Smooth Theme Transition Rule */
body, .sidebar, .glass-panel, .form-input, .user-profile-summary, .nav-item a, .logo-text, .filter-pill, .btn {
    transition: background var(--transition-normal), background-color var(--transition-normal), color var(--transition-normal), border-color var(--transition-normal), box-shadow var(--transition-normal);
}

