:root {
    --bg-light: #f0f2f5;
    --sidebar-light: #ffffff;
    --card-bg-light: #ffffff;
    --text-main-light: #1a1a1a;
    --text-muted-light: #65676b;
    --border-light: #e4e6eb;
    --shadow-light: rgba(0, 0, 0, 0.08);

    --bg-dark: #0a0a0a;
    --sidebar-dark: #111111;
    --card-bg-dark: #1a1a1a;
    --text-main-dark: #ffffff;
    --text-muted-dark: #a0a0a0;
    --border-dark: #2d2d2d;
    --shadow-dark: rgba(0, 0, 0, 0.6);
    
    --neon-green: #00ff9d;
    --neon-pink: #ff0055;
    --neon-blue: #00d4ff;
    --neon-purple: #bc13fe;
    
    --success: #00b894;
    --danger: #ff4757;
    --radius: 16px;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

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

html, body {
    overflow-x: hidden;
    width: 100%;
    max-width: 100vw;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background-color: var(--bg-light);
    color: var(--text-main-light);
    transition: background-color 0.5s ease, color 0.5s ease;
}

body.dark-mode {
    background-color: var(--bg-dark);
    color: var(--text-main-dark);
}

.dashboard-container {
    display: flex;
    width: 100%;
    min-height: 100vh;
    position: relative;
}

/* Sidebar */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--sidebar-light);
    border-right: 1px solid var(--border-light);
    padding: 25px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    z-index: 100;
    transition: var(--transition);
    box-shadow: 4px 0 30px var(--shadow-light);
    overflow-y: auto;
}

body.dark-mode .sidebar {
    background: var(--sidebar-dark);
    border-color: var(--border-dark);
    box-shadow: 4px 0 30px var(--shadow-dark);
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 30px;
    padding-bottom: 20px;
    border-bottom: 2px solid var(--border-light);
}

body.dark-mode .sidebar-header { border-color: var(--border-dark); }

.sidebar-header h2 {
    font-size: 1.3rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    margin: 0;
    color: var(--text-main-light);
}
body.dark-mode .sidebar-header h2 {
    color: var(--text-main-dark);
}

/* Theme Toggle */
.theme-switch-wrapper { 
    display: flex; 
    align-items: center; 
    gap: 8px; 
}
.theme-icon {
    font-size: 1.1rem;
    transition: opacity 0.3s ease;
}
.theme-icon.sun { opacity: 1; }
.theme-icon.moon { opacity: 0.4; }
body.dark-mode .theme-icon.sun { opacity: 0.4; }
body.dark-mode .theme-icon.moon { opacity: 1; }

.theme-switch {
    position: relative;
    width: 46px;
    height: 24px;
}
.theme-switch input { display: none; }
.slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #ccc;
    border-radius: 30px;
    transition: var(--transition);
}
.slider::before {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: var(--transition);
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}
input:checked + .slider { background: linear-gradient(135deg, var(--neon-purple), var(--neon-pink)); }
input:checked + .slider::before { transform: translateX(22px); }

/* Filters */
.filters { 
    flex: 1; 
    margin-bottom: 20px; 
    overflow-y: auto;
}
.filter-item { margin-bottom: 18px; }
.filter-item label {
    display: block;
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-muted-light);
    margin-bottom: 8px;
}
body.dark-mode .filter-item label { color: var(--text-muted-dark); }

.filter-item select, .filter-item input {
    width: 100%;
    padding: 10px 12px;
    border: 2px solid var(--border-light);
    border-radius: 10px;
    background: var(--bg-light);
    color: var(--text-main-light);
    font-size: 0.85rem;
    transition: var(--transition);
}
body.dark-mode .filter-item select,
body.dark-mode .filter-item input {
    background: #222;
    border-color: var(--border-dark);
    color: var(--text-main-dark);
}
.filter-item select:focus, .filter-item input:focus {
    border-color: var(--neon-blue);
    box-shadow: 0 0 0 3px rgba(0, 212, 255, 0.15);
}

/* Refresh Button */
.refresh-button {
    background: linear-gradient(135deg, var(--neon-blue), #0099ff);
    color: white;
    border: none;
    padding: 14px;
    border-radius: 12px;
    font-weight: 700;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(0, 212, 255, 0.3);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-top: auto;
}
.refresh-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(0, 212, 255, 0.5);
}
body.dark-mode .refresh-button {
    background: linear-gradient(135deg, var(--neon-green), #00b894);
    box-shadow: 0 4px 15px rgba(0, 255, 157, 0.2);
}
body.dark-mode .refresh-button:hover {
    box-shadow: 0 6px 20px rgba(0, 255, 157, 0.4);
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 20px 30px;
    width: calc(100% - 280px);
    min-height: auto;
    transition: margin-left 0.3s ease;
    padding-bottom: 0;
}

.main-header {
    text-align: center;
    margin-bottom: 25px;
    position: relative;
}
.main-header h1 {
    font-size: 2.5rem;
    font-weight: 900;
    letter-spacing: -1px;
    margin: 0;
    background: linear-gradient(135deg, var(--text-main-light), var(--text-muted-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
body.dark-mode .main-header h1 {
    background: linear-gradient(135deg, #fff, var(--text-muted-dark));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}
.main-header::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    margin: 15px auto 0;
    border-radius: 2px;
}

/* Crypto Cards Grid */
.crypto-cards {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 25px;
    padding-bottom: 20px;
    width: 100%;
}

/* Crypto Card */
.crypto-card {
    background: var(--card-bg-light);
    border: 1px solid var(--border-light);
    border-radius: var(--radius);
    padding: 20px;
    position: relative;
    transition: var(--transition);
    box-shadow: 0 4px 20px var(--shadow-light);
    display: flex;
    flex-direction: column;
    overflow: visible;
}
body.dark-mode .crypto-card {
    background: var(--card-bg-dark);
    border-color: var(--border-dark);
    box-shadow: 0 4px 20px var(--shadow-dark);
}
.crypto-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--neon-blue), var(--neon-purple));
    opacity: 0;
    transition: var(--transition);
    border-radius: var(--radius) var(--radius) 0 0;
}
.crypto-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px var(--shadow-light);
    border-color: var(--neon-blue);
}
body.dark-mode .crypto-card:hover {
    box-shadow: 0 15px 35px var(--shadow-dark);
    border-color: var(--neon-purple);
}
.crypto-card:hover::before { opacity: 1; }

/* Card Header */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
}
.card-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 8px;
    color: var(--text-main-light);
}
body.dark-mode .card-header h3 { color: var(--text-main-dark); }
.card-header h3 img {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
}
.rank {
    font-size: 0.7rem;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 20px;
    background: var(--bg-light);
    color: var(--text-muted-light);
}
body.dark-mode .rank {
    background: #2a2a2a;
    color: var(--text-muted-dark);
}

/* Price Section */
.price-info { margin-bottom: 12px; }
.price {
    font-size: 1.8rem;
    font-weight: 800;
    letter-spacing: -0.5px;
    color: var(--text-main-light);
    display: block;
    margin-bottom: 4px;
}
body.dark-mode .price { color: #fff; }
.change-24h {
    font-size: 0.9rem;
    font-weight: 600;
    display: inline-block;
    padding: 3px 8px;
    border-radius: 6px;
}
.change-24h.positive { color: var(--success); background: rgba(0, 184, 148, 0.1); }
.change-24h.negative { color: var(--danger); background: rgba(255, 71, 87, 0.1); }
.volume-info {
    font-size: 0.8rem;
    color: var(--text-muted-light);
    margin-bottom: 15px;
    font-weight: 500;
}
body.dark-mode .volume-info { color: var(--text-muted-dark); }

/* Canvas Chart */
.chart-container {
    height: 80px;
    width: 100%;
    margin-top: auto;
}
.chart-container canvas {
    width: 100% !important;
    height: 100% !important;
}

/* Hover Details - Fixed overlay */
.card-extra-info {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.98);
    padding: 20px;
    transform: translateY(100%);
    transition: transform 0.4s cubic-bezier(0.25, 0.8, 0.25, 1), visibility 0.4s;
    display: flex;
    flex-direction: column;
    justify-content: center;
    border-radius: var(--radius);
    box-shadow: 0 -10px 30px rgba(0,0,0,0.15);
    z-index: 20;
    overflow-y: auto;
    visibility: hidden;
    opacity: 0;
}
body.dark-mode .card-extra-info { background: rgba(20, 20, 20, 0.98); }
.crypto-card:hover .card-extra-info { 
    transform: translateY(0); 
    visibility: visible;
    opacity: 1;
}
.card-extra-info p {
    margin: 8px 0;
    font-size: 0.8rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-light);
    padding-bottom: 6px;
}
body.dark-mode .card-extra-info p { border-color: var(--border-dark); }
.card-extra-info p strong { 
    color: var(--neon-blue); 
    font-weight: 700; 
    font-size: 0.85rem;
}
body.dark-mode .card-extra-info p strong { color: var(--neon-green); }

/* Alert States */
.crypto-card.alert-positive {
    border: 2px solid var(--success);
    animation: pulse-green 2s infinite;
}
.crypto-card.alert-negative {
    border: 2px solid var(--danger);
    animation: pulse-red 2s infinite;
}

@keyframes pulse-green {
    0% { box-shadow: 0 0 0 0 rgba(0, 184, 148, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(0, 184, 148, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 184, 148, 0); }
}
@keyframes pulse-red {
    0% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.4); }
    70% { box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
    100% { box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

/* Toast Alerts */
.alert {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 10px;
    color: white;
    font-weight: 600;
    z-index: 1000;
    animation: slideIn 0.4s ease;
    box-shadow: 0 10px 30px rgba(0,0,0,0.3);
    backdrop-filter: blur(10px);
    max-width: 90%;
    word-wrap: break-word;
}
.alert-info { background: rgba(33, 150, 243, 0.95); }
.alert-success { background: rgba(0, 184, 148, 0.95); }
.alert-danger, .alert-error { background: rgba(255, 71, 87, 0.95); }

@keyframes slideIn {
    from { transform: translateX(120%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
@keyframes slideOut {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(120%); opacity: 0; }
}

/* Crypto Guide Section */
.crypto-guide {
    width: calc(100% - 280px);
    margin-left: 280px;
    padding: 15px 40px 30px;
    background: linear-gradient(180deg, var(--bg-light) 0%, var(--sidebar-light) 100%);
    transition: all 0.3s ease;
}
body.dark-mode .crypto-guide {
    background: linear-gradient(180deg, var(--bg-dark) 0%, var(--sidebar-dark) 100%);
}

.guide-container {
    max-width: 1200px;
    margin: 0 auto;
}

.crypto-guide h2 {
    font-size: 2rem;
    font-weight: 800;
    text-align: center;
    margin-bottom: 10px;
    color: var(--text-main-light);
}
body.dark-mode .crypto-guide h2 { color: var(--text-main-dark); }

.guide-intro {
    text-align: center;
    color: var(--text-muted-light);
    font-size: 1rem;
    margin-bottom: 25px;
    max-width: 700px;
    margin-left: auto;
    margin-right: auto;
}
body.dark-mode .guide-intro { color: var(--text-muted-dark); }

.guide-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 25px;
}

.guide-card {
    background: var(--card-bg-light);
    border: 1px solid var(--border-light);
    border-radius: 12px;
    padding: 20px;
    transition: var(--transition);
}
body.dark-mode .guide-card {
    background: var(--card-bg-dark);
    border-color: var(--border-dark);
}
.guide-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 25px var(--shadow-light);
}
body.dark-mode .guide-card:hover {
    box-shadow: 0 10px 25px var(--shadow-dark);
}

.guide-card h3 {
    font-size: 1rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--neon-blue);
}
body.dark-mode .guide-card h3 { color: var(--neon-green); }

.guide-card p {
    font-size: 0.85rem;
    color: var(--text-muted-light);
    line-height: 1.5;
}
body.dark-mode .guide-card p { color: var(--text-muted-dark); }

.guide-card .green { color: var(--success); font-weight: 600; }
.guide-card .red { color: var(--danger); font-weight: 600; }

.guide-tip {
    background: linear-gradient(135deg, rgba(0, 212, 255, 0.1), rgba(188, 19, 254, 0.1));
    border: 2px solid var(--neon-blue);
    border-radius: 12px;
    padding: 20px;
    text-align: center;
}
body.dark-mode .guide-tip {
    background: linear-gradient(135deg, rgba(0, 255, 157, 0.1), rgba(188, 19, 254, 0.1));
    border-color: var(--neon-green);
}

.guide-tip h3 {
    font-size: 1.2rem;
    font-weight: 700;
    margin-bottom: 10px;
    color: var(--text-main-light);
}
body.dark-mode .guide-tip h3 { color: var(--neon-green); }

.guide-tip p {
    font-size: 0.95rem;
    color: var(--text-muted-light);
    line-height: 1.6;
}
body.dark-mode .guide-tip p { color: var(--text-muted-dark); }

/* Footer */
footer {
    width: calc(100% - 280px);
    margin-left: 280px;
    padding: 25px;
    text-align: center;
    background: var(--sidebar-light);
    border-top: 1px solid var(--border-light);
    color: var(--text-muted-light);
    font-size: 0.8rem;
    transition: all 0.3s ease;
}
body.dark-mode footer {
    background: var(--sidebar-dark);
    border-color: var(--border-dark);
    color: var(--text-muted-dark);
}
footer a {
    color: var(--neon-blue);
    text-decoration: none;
    font-weight: 600;
    transition: var(--transition);
}
footer a:hover { color: var(--neon-purple); }

/* Responsive */
@media (max-width: 1024px) {
    .sidebar { width: 240px; min-width: 240px; padding: 20px 15px; }
    .main-content { margin-left: 240px; width: calc(100% - 240px); padding: 20px 25px; }
    footer { width: calc(100% - 240px); margin-left: 240px; }
    .crypto-guide { width: calc(100% - 240px); margin-left: 240px; padding: 15px 30px 25px; }
    .crypto-cards { grid-template-columns: repeat(auto-fill, minmax(280px, 1fr)); }
}

@media (max-width: 768px) {
    .sidebar {
        position: relative;
        width: 100%;
        height: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-light);
        padding: 15px;
        max-height: none;
    }
    body.dark-mode .sidebar { border-color: var(--border-dark); }
    
    .main-content { 
        margin-left: 0; 
        width: 100%; 
        padding: 15px; 
    }
    footer { 
        width: 100%; 
        margin-left: 0; 
        padding: 15px; 
    }
    .crypto-guide {
        width: 100%;
        margin-left: 0;
        padding: 15px;
    }
    .guide-grid {
        grid-template-columns: 1fr;
    }
    
    .main-header h1 { font-size: 1.8rem; }
    .main-header { margin-bottom: 20px; }
    
    .crypto-cards { 
        grid-template-columns: 1fr; 
        gap: 20px; 
    }
    
    .sidebar-header {
        flex-wrap: wrap;
        gap: 10px;
        justify-content: space-between;
    }
    
    .sidebar-header h2 { font-size: 1.1rem; }
}

@media (max-width: 480px) {
    .main-header h1 { font-size: 1.5rem; }
    .crypto-card { padding: 15px; }
    .price { font-size: 1.5rem; }
    .card-header h3 { font-size: 1rem; }
    .card-extra-info p { font-size: 0.75rem; }
    .card-extra-info p strong { font-size: 0.8rem; }
}
