@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    /* --- COLOR PALETTE (Modern Deep Green & Teal) --- */
    --primary-green: #10b981;       /* Emerald 500 */
    --primary-green-hover: #059669; /* Emerald 600 */
    --dark-green: #064e3b;          /* Emerald 900 */
    --light-green-bg: #ecfdf5;      /* Emerald 50 */
    
    --accent-teal: #14b8a6;         /* Teal 500 */
    --accent-light-teal: #f0fdfa;   /* Teal 50 */
    
    /* --- NEUTRALS --- */
    --bg-body: #f8fafc;             /* Slate 50 */
    --bg-card: #ffffff;
    --text-main: #0f172a;           /* Slate 900 */
    --text-muted: #64748b;          /* Slate 500 */
    --border-color: #e2e8f0;        /* Slate 200 */
    
    /* --- STATUS COLORS --- */
    --success-bg: #dcfce7;
    --success-text: #166534;
    --warning-bg: #fef3c7;
    --warning-text: #92400e;
    --danger-bg: #fee2e2;
    --danger-text: #991b1b;
    
    /* --- SHADOWS --- */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);

    /* --- DIMENSIONS --- */
    --sidebar-width: 280px;
    --header-height: 72px;
    --radius-lg: 16px;
    --radius-md: 12px;
    --radius-sm: 8px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Plus Jakarta Sans', sans-serif;
}

body {
    background-color: var(--bg-body);
    color: var(--text-main);
    overflow-x: hidden; /* Prevent horizontal scroll */
    -webkit-font-smoothing: antialiased;
    line-height: 1.5;
}

/* =========================================
   1. AUTH PAGES (Login/Register Split Layout)
   ========================================= */

.container {
    display: flex;
    width: 100%;
    min-height: 100vh;
}

/* Left Side (Brand) */
.brand-side {
    flex: 1;
    width: 50%;
    background: linear-gradient(135deg, #022c22 0%, #064e3b 50%, #10b981 100%);
    color: white;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 60px 50px;
    position: relative;
    overflow: hidden;
}

.brand-side::before {
    content: '';
    position: absolute;
    top: -150px;
    right: -150px;
    width: 500px;
    height: 500px;
    background: radial-gradient(circle, rgba(16, 185, 129, 0.1) 0%, transparent 70%);
    border-radius: 50%;
}

.brand-content {
    position: relative;
    z-index: 2;
    text-align: left;
    max-width: 450px;
}

.logo-section { margin-bottom: 40px; }

.logo-text {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 8px;
    color: white;
}

.logo-subtitle {
    font-size: 1rem;
    color: var(--accent-light-teal);
    text-transform: uppercase;
    letter-spacing: 1px;
    font-weight: 600;
}

.value-proposition h2 {
    font-size: 2rem;
    font-weight: 700;
    margin-bottom: 12px;
    color: white;
}

.value-proposition p {
    font-size: 1.1rem;
    color: #d1fae5;
}

.features-list {
    list-style: none;
    margin-bottom: 40px;
}

.features-list li {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 14px;
    font-size: 1rem;
    color: #d1fae5;
}

.feature-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    font-weight: 700;
    color: #fff;
    font-size: 0.8rem;
}

/* Right Side (Form) */
.form-side {
    flex: 1;
    width: 50%;
    background: #ffffff;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 40px 50px;
    overflow-y: auto;
}

.form-wrapper {
    width: 100%;
    max-width: 420px;
}

.form-header { margin-bottom: 32px; }

.form-header h2 {
    font-size: 2rem;
    font-weight: 800;
    color: var(--text-main);
    margin-bottom: 8px;
}

.form-header p {
    font-size: 1rem;
    color: var(--text-muted);
}

/* Auth Alerts */
.alert {
    padding: 12px 16px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    font-size: 0.9rem;
    display: flex;
    align-items: center;
    gap: 10px;
}
.alert-success { background: var(--success-bg); color: var(--success-text); border: 1px solid #bbf7d0; }
.alert-error { background: var(--danger-bg); color: var(--danger-text); border: 1px solid #fecaca; }

/* =========================================
   2. DASHBOARD LAYOUT
   ========================================= */

.dashboard-wrapper {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-card);
    border-right: 1px solid var(--border-color);
    position: fixed;
    height: 100vh;
    z-index: 50;
    display: flex;
    flex-direction: column;
    padding: 24px;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 32px;
}

.logo-dashboard {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--text-main);
    text-decoration: none;
}
.logo-dashboard i { color: var(--primary-green); font-size: 1.75rem; }

/* User Profile Sidebar */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: var(--bg-body);
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    border: 1px solid var(--border-color);
}

.user-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--light-green-bg);
    color: var(--primary-green);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1rem;
    font-weight: 600;
}

.user-info { overflow: hidden; }
.user-info h3 { font-size: 0.875rem; font-weight: 600; margin: 0; white-space: nowrap; text-overflow: ellipsis; }
.user-info p { font-size: 0.75rem; color: var(--text-muted); margin: 0; }

/* Sidebar Nav */
.sidebar-nav {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px 16px;
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    font-size: 0.925rem;
    border-radius: var(--radius-sm);
    transition: all 0.2s ease;
}

.nav-item i {
    font-size: 1.125rem;
    color: #94a3b8;
    width: 20px;
    text-align: center;
}

.nav-item:hover { background-color: var(--bg-body); color: var(--text-main); }
.nav-item:hover i { color: var(--primary-green); }

.nav-item.active {
    background-color: var(--light-green-bg);
    color: var(--primary-green-hover);
    font-weight: 600;
}
.nav-item.active i { color: var(--primary-green); }

.sidebar-footer {
    margin-top: auto;
    border-top: 1px solid var(--border-color);
    padding-top: 16px;
}
.logout { color: var(--danger-text) !important; }
.logout:hover { background-color: var(--danger-bg) !important; }
.logout i { color: var(--danger-text) !important; }

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    transition: margin-left 0.3s ease;
    width: calc(100% - var(--sidebar-width));
}

/* Top Nav */
.top-nav {
    height: var(--header-height);
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    position: sticky;
    top: 0;
    z-index: 40;
}

.hamburger {
    display: none;
    background: none;
    border: none;
    font-size: 1.25rem;
    color: var(--text-main);
    cursor: pointer;
}

.top-nav-actions { margin-left: auto; display: flex; align-items: center; gap: 16px; }

.profile-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 50px;
    transition: background 0.2s;
    border: 1px solid transparent;
}
.profile-btn:hover { background-color: var(--bg-body); border-color: var(--border-color); }

.avatar-small {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary-green), var(--accent-teal));
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.85rem;
    font-weight: 600;
}

.page-content {
    padding: 32px;
    max-width: 1280px;
    margin: 0 auto;
    width: 100%;
}

/* =========================================
   3. COMPONENTS (Cards, Forms, Tables)
   ========================================= */

/* Dashboard Header Card */
.dashboard-header {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    padding: 32px;
    margin-bottom: 32px;
    position: relative;
    overflow: hidden;
    box-shadow: var(--shadow-sm);
    border: 1px solid var(--border-color);
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: flex-end;
    position: relative;
    z-index: 2;
}

.header-greeting h1 { font-size: 1.75rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.header-greeting p { font-size: 1rem; color: var(--text-muted); margin: 0; }
.text-teal { color: var(--primary-green); }

.date-badge {
    background: var(--bg-body);
    padding: 8px 16px;
    border-radius: 50px;
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text-muted);
    border: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Quick Actions */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.action-btn {
    display: flex;
    align-items: center;
    gap: 16px;
    background: var(--bg-card);
    padding: 20px;
    border-radius: var(--radius-lg);
    text-decoration: none;
    border: 1px solid var(--border-color);
    transition: all 0.2s ease;
    box-shadow: var(--shadow-sm);
}
.action-btn:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); border-color: var(--primary-green); }

.btn-icon {
    width: 48px;
    height: 48px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}
.btn-buy .btn-icon { background: var(--light-green-bg); color: var(--primary-green); }
.btn-sell .btn-icon { background: var(--accent-light-teal); color: var(--accent-teal); }

.btn-content h4 { font-size: 1.05rem; font-weight: 600; color: var(--text-main); margin-bottom: 2px; }
.btn-content p { font-size: 0.875rem; color: var(--text-muted); margin: 0; }

/* Stats Cards */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    margin-bottom: 32px;
}

.stat-card {
    background: var(--bg-card);
    padding: 24px;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    box-shadow: var(--shadow-sm);
    transition: transform 0.2s;
}
.stat-card:hover { transform: translateY(-2px); box-shadow: var(--shadow-md); }

.stat-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 12px; }
.stat-header h3 { font-size: 0.75rem; font-weight: 600; color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em; margin: 0; }
.stat-header i { font-size: 1.125rem; opacity: 0.8; }
.stat-value { font-size: 1.75rem; font-weight: 700; color: var(--text-main); margin-bottom: 4px; }
.stat-label { font-size: 0.875rem; color: var(--text-muted); }

.stat-card-primary .stat-header i { color: var(--primary-green); }
.stat-card-success .stat-header i { color: var(--accent-teal); }
.stat-card-warning .stat-header i { color: #f59e0b; }
.stat-card-info .stat-header i { color: #3b82f6; }

/* Tables */
.transactions-section {
    background: var(--bg-card);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    padding: 24px;
    margin-bottom: 32px;
    box-shadow: var(--shadow-sm);
}

.section-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 20px; }
.section-header h2 { font-size: 1.125rem; font-weight: 700; color: var(--text-main); margin: 0; }

.transactions-table { overflow-x: auto; }
table { width: 100%; border-collapse: separate; border-spacing: 0; }
thead th {
    text-align: left; padding: 12px 16px; font-size: 0.75rem; font-weight: 700;
    color: var(--text-muted); text-transform: uppercase; letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border-color); background-color: var(--bg-body);
}
thead th:first-child { border-top-left-radius: var(--radius-sm); }
thead th:last-child { border-top-right-radius: var(--radius-sm); }

tbody td { padding: 16px; font-size: 0.875rem; color: var(--text-main); border-bottom: 1px solid var(--border-color); }
tbody tr:last-child td { border-bottom: none; }
tbody tr:hover td { background-color: #f8fafc; }

/* Badges */
.type-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; display: inline-block; }
.type-buy { background: var(--light-green-bg); color: var(--primary-green-hover); }
.type-sell { background: var(--accent-light-teal); color: var(--accent-teal); }

.status-badge { padding: 4px 10px; border-radius: 50px; font-size: 0.75rem; font-weight: 600; display: inline-flex; align-items: center; gap: 6px; }
.status-success { background: var(--success-bg); color: var(--success-text); }
.status-warning { background: var(--warning-bg); color: var(--warning-text); }
.status-danger { background: var(--danger-bg); color: var(--danger-text); }

/* Forms & Inputs */
.form-card { background: var(--bg-card); border-radius: var(--radius-lg); padding: 32px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); }
.form-card-header { margin-bottom: 24px; padding-bottom: 16px; border-bottom: 1px solid var(--border-color); }
.form-card-header h2 { margin: 0 0 4px 0; font-size: 1.25rem; font-weight: 700; color: var(--text-main); }

.form-group { margin-bottom: 20px; }
.form-label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.875rem; color: var(--text-main); }
.input-group label { display: block; margin-bottom: 6px; font-weight: 600; font-size: 0.875rem; color: var(--text-main); }

.form-control, .form-select, .input-wrapper input, .input-group input {
    width: 100%; padding: 10px 14px; border: 1px solid var(--border-color);
    border-radius: var(--radius-md); font-size: 0.925rem; transition: all 0.2s;
    background: var(--bg-card); color: var(--text-main);
}
.form-control:focus, .form-select:focus, .input-wrapper input:focus, .input-group input:focus {
    outline: none; border-color: var(--primary-green); box-shadow: 0 0 0 3px rgba(16, 185, 129, 0.15);
}

.btn-primary-large, .btn-submit {
    width: 100%; padding: 12px 24px; background: var(--primary-green); color: white;
    border: none; border-radius: var(--radius-md); font-size: 0.925rem; font-weight: 600;
    cursor: pointer; transition: all 0.2s; margin-top: 20px; box-shadow: var(--shadow-sm);
}
.btn-primary-large:hover, .btn-submit:hover { background-color: var(--primary-green-hover); box-shadow: var(--shadow-md); transform: translateY(-1px); }

/* Referral Card */
.referral-card {
    background: linear-gradient(135deg, var(--dark-green), var(--primary-green));
    border-radius: var(--radius-lg); padding: 32px; color: white;
    display: flex; align-items: center; justify-content: space-between; gap: 32px;
    position: relative; overflow: hidden; box-shadow: var(--shadow-md);
}
.referral-card::after {
    content: ''; position: absolute; right: -20px; bottom: -40px; width: 240px; height: 240px;
    background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%); border-radius: 50%;
}
.referral-content h3 { font-size: 1.25rem; margin-bottom: 6px; font-weight: 700; color: white;}
.referral-input-group {
    background: rgba(255, 255, 255, 0.15); backdrop-filter: blur(8px); padding: 4px;
    border-radius: var(--radius-md); display: flex; border: 1px solid rgba(255, 255, 255, 0.2);
    min-width: 320px;
}
.referral-input-group input { flex: 1; background: transparent; border: none; color: white; padding: 0 12px; outline: none; }
.btn-copy { background: white; color: var(--dark-green); border: none; padding: 8px 16px; border-radius: var(--radius-sm); font-weight: 600; cursor: pointer; }

/* Buy/Sell Page Grid */
.buy-crypto-container {
    display: grid; grid-template-columns: 1.6fr 1fr; gap: 24px; margin-top: 24px; align-items: start;
}
.info-card { background: var(--bg-card); border-radius: var(--radius-lg); padding: 24px; box-shadow: var(--shadow-sm); border: 1px solid var(--border-color); margin-bottom: 24px; }
.info-card-header h3 { margin: 0; font-size: 1rem; font-weight: 700; display: flex; align-items: center; gap: 8px; }
.steps-list { list-style: none; margin: 0; padding: 0; }
.steps-list li { display: flex; gap: 12px; margin-bottom: 16px; }
.step-number { width: 28px; height: 28px; background: var(--light-green-bg); border-radius: 50%; border: 1px solid #d1fae5; color: var(--primary-green); font-weight: 700; display: flex; justify-content: center; align-items: center; flex-shrink: 0; font-size: 0.8rem; }
.tips-list li { padding-left: 24px; position: relative; margin-bottom: 8px; font-size: 0.875rem; color: var(--text-muted); }
.tips-list li::before { content: '✓'; position: absolute; left: 0; color: var(--primary-green); font-weight: 700; }

/* =========================================
   4. RESPONSIVE QUERIES
   ========================================= */

@media (max-width: 1024px) {
    .brand-side { display: none; } /* Hide brand on auth pages for tablet/mobile */
    .form-side { width: 100%; }
    .buy-crypto-container { grid-template-columns: 1fr; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); }
}

@media (max-width: 768px) {
    /* Layout */
    .sidebar { transform: translateX(-100%); box-shadow: none; }
    .sidebar.active { transform: translateX(0); box-shadow: 20px 0 25px -5px rgb(0 0 0 / 0.1); }
    .main-content { margin-left: 0; width: 100%; }
    
    /* Nav */
    .top-nav { padding: 0 16px; height: 64px; }
    .hamburger { display: block; }
    .sidebar-close { display: block; position: absolute; top: 20px; right: 20px; }
    
    /* Content */
    .dashboard-header { padding: 24px; }
    .header-content { flex-direction: column; align-items: flex-start; gap: 16px; }
    .stats-grid { grid-template-columns: 1fr; }
    .quick-actions { grid-template-columns: 1fr; }
    
    /* Auth Pages (Mobile) */
    .container { flex-direction: column; }
    .form-side { width: 100%; height: 100vh; padding: 24px; }
    .brand-side { display: none; } /* Ensure brand side is hidden */
    
    /* Tables */
    .transactions-table th:nth-child(4), .transactions-table td:nth-child(4) { display: none; }
    
    /* Referral */
    .referral-card { flex-direction: column; text-align: center; padding: 24px; }
    .referral-input-group { min-width: auto; }
}