@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;500;600;700&display=swap');

:root {
    --bg-dark: #0f172a;
    --bg-card: rgba(30, 41, 59, 0.7);
    --bg-sidebar: #1e293b;
    --primary: #6366f1;
    --primary-gradient: linear-gradient(135deg, #6366f1 0%, #a855f7 100%);
    --secondary: #ec4899;
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    --success: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --glass-border: 1px solid rgba(255, 255, 255, 0.1);
    --radius: 16px;
    --shadow: 0 4px 30px rgba(0, 0, 0, 0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Outfit', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    /* Prevent horizontal scroll */
}

a {
    text-decoration: none;
    color: inherit;
}

ul {
    list-style: none;
}

/* Layout */
.app-container {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 260px;
    background-color: var(--bg-sidebar);
    padding: 2rem;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    border-right: var(--glass-border);
}

.logo {
    display: flex;
    align-items: center;
    gap: 0.8rem;
    font-size: 1.5rem;
    font-weight: 700;
    margin-bottom: 3rem;
    color: var(--primary);
}

.logo i {
    font-size: 1.8rem;
    background: var(--primary-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.sidebar nav ul {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.sidebar nav li {
    cursor: pointer;
}

.sidebar nav li a {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 12px;
    color: var(--text-muted);
    transition: all 0.3s ease;
    pointer-events: none;
    /* Make LI the clickable element for simpler JS */
}

.sidebar nav li.active a,
.sidebar nav li:hover a {
    background: rgba(99, 102, 241, 0.1);
    color: var(--primary);
}

.sidebar nav li.active a i {
    color: var(--primary);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding-top: 2rem;
    border-top: var(--glass-border);
}

.avatar img {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    border: 2px solid var(--primary);
}

.user-profile .info .name {
    font-size: 0.9rem;
    font-weight: 600;
}

.user-profile .info .id {
    font-size: 0.75rem;
    color: var(--text-muted);
}

/* Main Content */
.main-content {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
}

/* Section visibility */
.content-section {
    display: block;
    animation: fadeIn 0.5s ease-out;
}

.content-section.hidden {
    display: none;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

h1 {
    font-size: 1.8rem;
    font-weight: 600;
}

.actions {
    display: flex;
    gap: 1rem;
}

.icon-btn {
    background: var(--bg-card);
    border: var(--glass-border);
    color: var(--text-main);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: 0.3s;
}

.icon-btn:hover {
    background: rgba(255, 255, 255, 0.1);
}

.btn-primary {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 0.6rem 1.2rem;
    border-radius: 50px;
    font-weight: 500;
    cursor: pointer;
    box-shadow: 0 4px 15px rgba(99, 102, 241, 0.4);
    transition: transform 0.2s;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    justify-content: center;
}

.btn-primary:hover {
    transform: translateY(-2px);
}

.btn-block {
    width: 100%;
}

.btn-lg {
    padding: 1rem;
    font-size: 1.1rem;
    border-radius: 12px;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: 2fr 1.2fr;
    grid-template-rows: auto auto;
    gap: 1.5rem;
}

/* Cards General */
.card {
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    border-radius: var(--radius);
    padding: 1.5rem;
    border: var(--glass-border);
    box-shadow: var(--shadow);
}

/* Balance Card */
.balance-card {
    background: linear-gradient(135deg, rgba(30, 41, 59, 0.9) 0%, rgba(15, 23, 42, 0.9) 100%);
    position: relative;
    overflow: hidden;
    grid-column: 1 / 2;
    grid-row: 1 / 2;
}

/* Add a subtle decorative shape */
.balance-card::before {
    content: '';
    position: absolute;
    top: -50px;
    right: -50px;
    width: 200px;
    height: 200px;
    background: radial-gradient(circle, rgba(99, 102, 241, 0.2) 0%, transparent 70%);
    border-radius: 50%;
    z-index: 0;
}

.balance-header {
    display: flex;
    justify-content: space-between;
    color: var(--text-muted);
    font-size: 0.9rem;
    position: relative;
    z-index: 1;
}

.currency-select {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-family: inherit;
    cursor: pointer;
}

.total-amount {
    font-size: 3rem;
    font-weight: 700;
    margin: 0.5rem 0;
    background: linear-gradient(to right, #fff, #cbd5e1);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    position: relative;
    z-index: 1;
}

.profit-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.3rem 0.8rem;
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
    border-radius: 20px;
    font-size: 0.85rem;
    margin-bottom: 2rem;
    position: relative;
    z-index: 1;
}

.quick-actions {
    display: flex;
    gap: 2rem;
    position: relative;
    z-index: 1;
}

.action-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.5rem;
    cursor: pointer;
    font-size: 0.8rem;
    transition: color 0.3s;
}

.action-btn:hover {
    color: var(--text-main);
}

.action-btn .icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    transition: all 0.3s;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.action-btn:hover .icon {
    background: var(--primary);
    color: white;
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(99, 102, 241, 0.3);
}

/* Chart Card */
.chart-card {
    grid-column: 2 / 3;
    grid-row: 1 / 2;
    min-height: 250px;
    display: flex;
    flex-direction: column;
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.time-filters {
    display: flex;
    background: rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    padding: 2px;
}

.filter-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    padding: 4px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8rem;
    transition: 0.3s;
}

.filter-btn.active {
    background: var(--bg-card);
    color: var(--text-main);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

.chart-container {
    flex: 1;
    position: relative;
    min-height: 200px;
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

#marketChart {
    width: 100%;
    height: 100%;
}

/* Assets List */
.assets-list {
    grid-column: 1 / 2;
    grid-row: 2 / 3;
}

.assets-list h3 {
    margin-bottom: 1rem;
    font-size: 1.2rem;
}

.asset-item {
    display: flex;
    align-items: center;
    padding: 0.8rem 0;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.asset-item:last-child {
    border-bottom: none;
}

.asset-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    font-size: 1.2rem;
    /* overflow: hidden; */
    /* removed to allow border radius if needed */
}

/* Asset icon variants */
.asset-icon.btc {
    background: rgba(247, 147, 26, 0.2);
    color: #f7931a;
}

.asset-icon.eth {
    background: rgba(98, 126, 234, 0.2);
    color: #627eea;
}

.asset-icon.sol {
    background: rgba(20, 241, 149, 0.2);
    color: #14f195;
    font-size: 0.8rem;
    font-weight: bold;
}

.asset-icon.small {
    width: 32px;
    height: 32px;
    font-size: 1rem;
    margin-right: 0.5rem;
}

.asset-info {
    flex: 1;
}

.asset-info .symbol {
    font-weight: 600;
}

.asset-info .name {
    font-size: 0.8rem;
    color: var(--text-muted);
    text-transform: uppercase;
}

.asset-value {
    text-align: right;
}

.asset-value .amount {
    font-weight: 600;
}

.asset-value .fiat {
    font-size: 0.8rem;
    color: var(--text-muted);
}

/* Transactions List */
.transactions-list {
    grid-column: 2 / 3;
    grid-row: 2 / 3;
}

.transaction-item {
    display: flex;
    align-items: center;
    margin-bottom: 1rem;
    padding: 0.8rem;
    background: rgba(255, 255, 255, 0.03);
    border-radius: 12px;
}

.tx-icon {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 0.8rem;
    font-size: 0.9rem;
}

.tx-icon.received {
    background: rgba(16, 185, 129, 0.2);
    color: var(--success);
}

.tx-icon.sent {
    background: rgba(239, 68, 68, 0.2);
    color: var(--danger);
}

.tx-icon.swap {
    background: rgba(59, 130, 246, 0.2);
    color: #3b82f6;
}

.tx-details {
    flex: 1;
}

.tx-details .tx-type {
    font-size: 0.9rem;
    font-weight: 500;
}

.tx-details .tx-date {
    font-size: 0.75rem;
    color: var(--text-muted);
}

.tx-amount {
    font-weight: 600;
    font-size: 0.9rem;
}

.tx-amount.positive {
    color: var(--success);
}

.tx-amount.negative {
    color: var(--danger);
}

.tx-amount.neutral {
    color: var(--text-muted);
}

/* --- NEW SECTIONS STYLES --- */

/* Wallet Section */
.wallet-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.5rem;
}

.wallet-card {
    height: 180px;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    background: linear-gradient(120deg, #2c3e50, #4ca1af);
    /* Default gradient */
    border: none;
    position: relative;
    overflow: hidden;
}

.primary-wallet {
    background: var(--primary-gradient);
}

.secondary-wallet {
    background: linear-gradient(120deg, #f093fb 0%, #f5576c 100%);
}

.card-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 1.1rem;
    opacity: 0.9;
}

.card-balance h2 {
    font-size: 2rem;
    margin-bottom: 0.5rem;
}

.card-balance p {
    letter-spacing: 2px;
    opacity: 0.8;
}

.card-bottom {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    opacity: 0.8;
}

/* Exchange Section */
.exchange-container {
    max-width: 500px;
    margin: 0 auto;
}

.exchange-card {
    padding: 2rem;
}

.exchange-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.exchange-header span {
    font-size: 0.8rem;
    padding: 4px 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    color: var(--text-muted);
}

.swap-box {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 12px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    border: 1px solid transparent;
    transition: 0.3s;
}

.swap-box:hover,
.swap-box:focus-within {
    border-color: rgba(99, 102, 241, 0.5);
}

.swap-box label {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    display: block;
}

.input-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.input-row input {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-main);
    width: 60%;
    outline: none;
}

.token-badge {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: rgba(255, 255, 255, 0.1);
    padding: 0.4rem 0.8rem;
    border-radius: 20px;
    cursor: pointer;
    transition: 0.3s;
}

.token-badge:hover {
    background: rgba(255, 255, 255, 0.2);
}

.balance-row {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--text-muted);
}

.max-btn {
    color: var(--primary);
    cursor: pointer;
    font-weight: 600;
}

.swap-divider {
    display: flex;
    justify-content: center;
    margin: -15px 0;
    position: relative;
    z-index: 10;
}

.swap-direction-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--bg-card);
    /* Should contrast against the darker inputs */
    border: 2px solid var(--bg-sidebar);
    /* Matches card bg? no sidebar bg */
    color: var(--primary);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: 0.3s;
}

.swap-direction-btn:hover {
    transform: rotate(180deg);
}

.exchange-info {
    margin: 1.5rem 0;
    padding: 1rem;
    background: rgba(99, 102, 241, 0.1);
    border-radius: 8px;
    font-size: 0.8rem;
    color: var(--text-muted);
    display: flex;
    justify-content: space-between;
}

/* Market Section */
.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-card);
    padding: 0.5rem 1rem;
    border-radius: 20px;
    border: var(--glass-border);
    gap: 0.5rem;
    width: 300px;
}

.search-bar input {
    background: transparent;
    border: none;
    color: var(--text-main);
    outline: none;
    width: 100%;
}

.market-table-card {
    overflow-x: auto;
}

.market-table {
    width: 100%;
    border-collapse: collapse;
}

.market-table th {
    text-align: left;
    padding: 1rem;
    color: var(--text-muted);
    font-weight: 500;
    font-size: 0.9rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.market-table td {
    padding: 1rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    vertical-align: middle;
}

.market-table tr:last-child td {
    border-bottom: none;
}

.asset-cell {
    display: flex;
    align-items: center;
}

.asset-text {
    display: flex;
    flex-direction: column;
}

.asset-text small {
    color: var(--text-muted);
}

.positive {
    color: var(--success);
}

.negative {
    color: var(--danger);
}

.neutral {
    color: var(--text-muted);
}

.btn-sm {
    padding: 0.4rem 0.8rem;
    font-size: 0.8rem;
    border-radius: 6px;
    background: rgba(255, 255, 255, 0.1);
    color: var(--text-main);
    border: none;
    cursor: pointer;
    transition: 0.3s;
}

.btn-sm:hover {
    background: var(--primary);
}

/* Settings Section */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
    gap: 1.5rem;
}

.settings-form {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.form-group label {
    font-size: 0.9rem;
    color: var(--text-muted);
}

.form-group input,
.form-group select {
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 0.8rem;
    border-radius: 8px;
    color: var(--text-main);
    outline: none;
    transition: 0.3s;
}

.form-group input:focus,
.form-group select:focus {
    border-color: var(--primary);
}

.toggle-list {
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
}

.toggle-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.toggle-info {
    display: flex;
    flex-direction: column;
}

.toggle-info small {
    color: var(--text-muted);
    font-size: 0.8rem;
}

/* Switch Toggle */
.switch {
    position: relative;
    display: inline-block;
    width: 50px;
    height: 24px;
}

.switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #334155;
    transition: .4s;
    border-radius: 34px;
}

.slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .4s;
    border-radius: 50%;
}

input:checked+.slider {
    background-color: var(--primary);
}

input:checked+.slider:before {
    transform: translateX(26px);
}


/* Responsive Update */
@media (max-width: 1024px) {
    .dashboard-grid {
        grid-template-columns: 1fr;
    }

    .balance-card,
    .assets-list,
    .chart-card,
    .transactions-list {
        grid-column: 1 / -1;
        grid-row: auto;
    }
}

@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }

    .sidebar {
        width: 100%;
        height: auto;
        padding: 1rem;
        flex-direction: row;
        align-items: center;
        border-right: none;
        border-bottom: var(--glass-border);
        overflow-x: auto;
        /* allow horizontal scroll if menu too long */
    }

    .sidebar nav ul {
        flex-direction: row;
        gap: 0.5rem;
    }

    .sidebar nav li span,
    .user-profile {
        display: none;
    }

    .logo {
        margin-bottom: 0;
        padding-right: 1rem;
    }

    /* Settings Grid responsive */
    .settings-grid {
        grid-template-columns: 1fr;
    }

    /* Market table responsive */
    .market-table th:nth-child(4),
    .market-table td:nth-child(4),
    .market-table th:nth-child(5),
    .market-table td:nth-child(5) {
        display: none;
    }
}

/* New Modal Styles */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
}

.modal-overlay:not(.hidden) {
    opacity: 1;
    visibility: visible;
}

.modal-content {
    background: var(--bg-card);
    backdrop-filter: blur(15px);
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 2rem;
    border-radius: var(--radius);
    width: 90%;
    max-width: 450px;
    box-shadow: var(--shadow);
    transform: translateY(20px);
    transition: transform 0.3s ease;
    color: var(--text-main);
    display: none;
}

.modal-overlay:not(.hidden) .modal-content {
    transform: translateY(0);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.modal-header h3 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
}

.close-modal {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
    transition: color 0.2s;
}

.close-modal:hover {
    color: var(--primary);
}

.input-field {
    width: 100%;
    padding: 1rem;
    background: rgba(0, 0, 0, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.1);
    border-radius: 10px;
    color: #fff;
    margin-top: 0.5rem;
    font-size: 1rem;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: var(--primary);
}

.input-field option {
    background: var(--bg-dark);
    color: #fff;
}

/* Toast Notifications */
.toast {
    background: var(--bg-card);
    color: var(--text-main);
    padding: 1rem 1.5rem;
    margin-bottom: 0.5rem;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    min-width: 300px;
    animation: slideIn 0.3s ease, fadeOut 0.3s ease 2.7s forwards;
    border-left: 4px solid var(--primary);
}

.toast.success { border-left-color: var(--success); }
.toast.error { border-left-color: var(--danger); }
.toast.info { border-left-color: var(--primary); }

.toast i { font-size: 1.2rem; }
.toast.success i { color: var(--success); }
.toast.error i { color: var(--danger); }
.toast.info i { color: var(--primary); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}