:root {
    --primary-color: #6c5ce7;
    /* Soft Purple */
    --secondary-color: #a29bfe;
    --accent-color: #00cec9;
    /* Teal */
    --bg-color: #f8f9fd;
    --card-bg: #ffffff;
    --text-color: #2d3436;
    --sidebar-bg: #ffffff;
    --success-color: #00b894;
    --danger-color: #d63031;
    --gradient-1: linear-gradient(135deg, #6c5ce7 0%, #a29bfe 100%);
    --gradient-2: linear-gradient(135deg, #0984e3 0%, #74b9ff 100%);
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.05);
}

[data-theme="dark"] {
    --bg-color: #1e1e2f;
    --card-bg: #27293d;
    --text-color: #ffffff;
    --sidebar-bg: #27293d;
    --shadow: 0 10px 20px rgba(0, 0, 0, 0.2);
}

body {
    background-color: var(--bg-color);
    color: var(--text-color);
    font-family: 'Poppins', sans-serif;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Auth Pages */
.auth-wrapper {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--bg-color);
}

.auth-card {
    background: var(--card-bg);
    padding: 2rem;
    border-radius: 15px;
    box-shadow: var(--shadow);
    width: 100%;
    max-width: 400px;
    border: none;
}

.auth-header h3 {
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.form-control {
    background-color: var(--bg-color);
    border: 1px solid rgba(0, 0, 0, 0.1);
    color: var(--text-color);
    border-radius: 8px;
    padding: 0.75rem;
}

.form-control:focus {
    background-color: var(--bg-color);
    color: var(--text-color);
    border-color: var(--primary-color);
    box-shadow: none;
}

.btn-primary {
    background: var(--gradient-1);
    border: none;
    padding: 0.75rem;
    border-radius: 8px;
    font-weight: 600;
    width: 100%;
}

.btn-primary:hover {
    opacity: 0.9;
}

/* Dashboard Cards */
.card-stats {
    border: none;
    border-radius: 15px;
    box-shadow: var(--shadow);
    background: var(--card-bg);
    transition: transform 0.2s;
    margin-bottom: 1.5rem;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
}

.card-stats:hover {
    transform: translateY(-5px);
}

.card-icon {
    width: 50px;
    height: 50px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* Custom Colors for Cards */
.bg-purple-light {
    background: #e0e6ed;
    color: #6c5ce7;
}

/* Edit for specific card style later */
.icon-sales {
    background: #e5d9f2;
    color: #8e44ad;
}

.icon-orders {
    background: #dff9fb;
    color: #2ecc71;
}

.icon-visitors {
    background: #dff9fb;
    color: #3498db;
}

.icon-commission {
    background: #ffeaa7;
    color: #e17055;
}

/* Welcome Card */
.welcome-card {
    background: var(--gradient-1);
    color: white;
    border-radius: 15px;
    padding: 2rem;
    margin-bottom: 2rem;
    box-shadow: var(--shadow);
}

.load-wallet-btn {
    background: #00cec9;
    color: white;
    border: none;
    padding: 0.8rem 2rem;
    border-radius: 25px;
    font-weight: bold;
    margin-top: 1rem;
    text-decoration: none;
    display: inline-block;
    transition: background 0.2s;
}

.load-wallet-btn:hover {
    background: #01b8b4;
    color: white;
}

/* Dashboard Layout */
.dashboard-container {
    display: flex;
    min-height: 100vh;
    background-color: var(--bg-color);
}

/* Sidebar */
.sidebar {
    width: 260px;
    background: var(--sidebar-bg);
    padding: 1.5rem;
    position: fixed;
    height: 100vh;
    overflow-y: auto;
    transition: all 0.3s;
    z-index: 1000;
    border-right: 1px solid rgba(0, 0, 0, 0.05);
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 2rem;
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--primary-color);
}

.nav-link {
    color: var(--text-color);
    padding: 0.8rem 1rem;
    border-radius: 10px;
    margin-bottom: 0.5rem;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: all 0.2s;
    font-weight: 500;
}

.nav-link:hover,
.nav-link.active {
    background: var(--bg-color);
    /* Light grey on hover */
    color: var(--primary-color);
}

.nav-link.active {
    background: rgba(108, 92, 231, 0.1);
    /* Light purple tint */
}

.nav-section {
    font-size: 0.8rem;
    text-transform: uppercase;
    color: var(--text-color);
    opacity: 0.6;
    margin: 1.5rem 0 0.5rem;
    padding-left: 1rem;
    font-weight: 600;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 260px;
    padding: 2rem;
    transition: margin-left 0.3s;
}

/* Navbar */
.top-navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.menu-toggle {
    display: none;
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--text-color);
    cursor: pointer;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 15px;
}

.profile-icon {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

/* Dashboard Grid */
.dashboard-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    /* Force 2 columns */
    gap: 1.5rem;
    height: 100%;
    /* Stretch to fill parent */
}

/* Welcome Section Split */
.welcome-section {
    display: grid;
    grid-template-columns: 1fr 1.2fr;
    /* Adjust proportions */
    gap: 1.5rem;
    margin-bottom: 2rem;
    align-items: stretch;
    /* Stretch children to equal height */
}

.welcome-card {
    background: var(--gradient-1);
    color: white;
    border-radius: 15px;
    padding: 2rem;
    box-shadow: var(--shadow);
    height: 100%;
    /* Fill the height */
    margin-bottom: 0;
    /* Remove margin as grid handles gap */
    display: flex;
    flex-direction: column;
    justify-content: center;
}

/* Dark Mode Text Fixes */
[data-theme="dark"] .text-muted {
    color: #b0b3b8 !important;
}

[data-theme="dark"] .table {
    color: #e4e6eb;
    border-color: #3e4042;
}

[data-theme="dark"] h1,
[data-theme="dark"] h2,
[data-theme="dark"] h3,
[data-theme="dark"] h4,
[data-theme="dark"] h5,
[data-theme="dark"] h6 {
    color: #ffffff;
}

[data-theme="dark"] .form-label {
    color: #e4e6eb;
}

@media (max-width: 991px) {
    .welcome-section {
        grid-template-columns: 1fr;
    }
}


/* Charts Area */
.charts-row {
    display: grid;
    grid-template-columns: 2fr 1fr;
    gap: 1.5rem;
    margin-bottom: 2rem;
}

@media (max-width: 991px) {
    .charts-row {
        grid-template-columns: 1fr;
    }
}

.chart-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    height: 100%;
    position: relative;
    /* Ensure canvas works with absolute positioning if needed */
}

/* Fix for Graph Stretching Infinitely */
.chart-container {
    position: relative;
    height: 300px;
    /* Fixed height for the chart area */
    width: 100%;
}


/* Transactions Table */
.table-card {
    background: var(--card-bg);
    border-radius: 15px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.table {
    color: var(--text-color);
}

.table th {
    border-bottom-width: 1px;
    font-weight: 600;
}

/* Force dark background in dark mode */
[data-theme="dark"] .table-card {
    background: var(--card-bg) !important;
}

[data-theme="dark"] .table-card .table {
    background: transparent !important;
    color: var(--text-color) !important;
}

[data-theme="dark"] .table-card .table thead,
[data-theme="dark"] .table-card .table tbody,
[data-theme="dark"] .table-card .table tr,
[data-theme="dark"] .table-card .table th,
[data-theme="dark"] .table-card .table td {
    background: transparent !important;
    color: var(--text-color) !important;
    border-color: rgba(255, 255, 255, 0.1) !important;
}

[data-theme="dark"] .table-card .text-muted {
    color: rgba(255, 255, 255, 0.6) !important;
}


/* Mobile Responsive */
@media (max-width: 768px) {
    body {
        overflow-x: hidden;
    }

    .dashboard-container {
        width: 100%;
        max-width: 100vw;
    }

    .sidebar {
        margin-left: -260px;
    }

    .sidebar.active {
        margin-left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 1rem;
        width: 100%;
        max-width: 100vw;
    }

    .menu-toggle {
        display: block;
    }

    /* Make dashboard stats and hero section more readable on small screens */
    .welcome-section {
        grid-template-columns: 1fr;
        gap: 1.25rem;
    }

    .welcome-card {
        padding: 1.5rem;
    }

    .dashboard-grid {
        grid-template-columns: repeat(2, minmax(0, 1fr));
        gap: 1.25rem;
    }
}

@media (max-width: 480px) {
    .auth-card {
        padding: 1.5rem;
        margin: 1rem;
    }
}

/* Dark Mode Overrides for Dashboard Elements */
[data-theme="dark"] .bg-purple-light {
    background: rgba(108, 92, 231, 0.1);
    color: #a29bfe;
}

[data-theme="dark"] .icon-sales {
    background: rgba(142, 68, 173, 0.2);
    color: #d1c4e9;
}

[data-theme="dark"] .icon-orders {
    background: rgba(46, 204, 113, 0.2);
    color: #a5d6a7;
}

[data-theme="dark"] .icon-visitors {
    background: rgba(52, 152, 219, 0.2);
    color: #90caf9;
}

[data-theme="dark"] .icon-commission {
    background: rgba(230, 126, 34, 0.2);
    color: #ffcc80;
}

[data-theme="dark"] .nav-link:hover,
[data-theme="dark"] .nav-link.active {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

[data-theme="dark"] .sidebar {
    border-right: 1px solid rgba(255, 255, 255, 0.05);
}

[data-theme="dark"] .load-wallet-btn {
    background: #00b894;
    color: white;
}

[data-theme="dark"] .load-wallet-btn:hover {
    background: #00a884;
}