/* =========================================
   1. GLOBAL RESET & VARIABLES
   ========================================= */
:root {
    --primary: #0083e9;       /* The bright dashboard blue */
    --primary-dark: #0056b3;
    --bg-body: #f1f5f9;       /* Light gray background */
    --bg-white: #ffffff;
    --text-main: #333333;
    --text-muted: #6c757d;
    --border-color: #e2e8f0;
    
    /* Icon Colors */
    --icon-green: #00b894;
    --icon-blue: #0984e3;
    --icon-orange: #e17055;
    --icon-purple: #6c5ce7;
    
    --sidebar-width: 250px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
}

body.dashboard-body {
    background-color: var(--bg-body);
    display: flex;
    min-height: 100vh;
}

a { text-decoration: none; color: inherit; }
ul { list-style: none; }

/* =========================================
   2. SIDEBAR
   ========================================= */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-white);
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    border-right: 1px solid var(--border-color);
    z-index: 100;
    overflow-y: auto;
}

.user-profile {
    padding: 2rem 1rem;
    text-align: center;
    border-bottom: 1px solid var(--border-color);
}

.user-img {
    width: 60px;
    height: 60px;
    background: #e0f2fe;
    color: var(--primary);
    border-radius: 50%;
    margin: 0 auto 10px auto;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
}

.sidebar-menu {
    padding-top: 1rem;
}

.sidebar-menu li a {
    display: flex;
    align-items: center;
    padding: 12px 25px;
    color: var(--text-muted);
    font-weight: 500;
    transition: all 0.3s;
    border-left: 4px solid transparent;
}

.sidebar-menu li a i {
    width: 25px;
    margin-right: 10px;
}

.sidebar-menu li a:hover, 
.sidebar-menu li a.active {
    background: #f8fafc;
    color: var(--primary);
    border-left-color: var(--primary);
}

.sidebar-submenu {
    display: none; /* Must be hidden by default */
    background: #f1f5f9;
    padding-left: 0;
}

.sidebar-submenu.show {
    display: block !important; /* Force it to show when class is added */
}

/* =========================================
   11. SIDEBAR & SETTINGS TOGGLES
   ========================================= */

/* --- Settings Submenu --- */
.sidebar-submenu {
    display: none; /* Hidden by default */
    background: #f1f5f9;
    padding-left: 0;
    border-top: 1px solid #e2e8f0;
    border-bottom: 1px solid #e2e8f0;
}

.sidebar-submenu.show {
    display: block; /* Shown when active */
}

.sidebar-submenu li a {
    padding-left: 50px;
    font-size: 0.85rem;
}

/* Arrow Rotation */
.rotate-icon {
    transform: rotate(180deg);
}
.fa-chevron-down {
    transition: transform 0.3s ease;
}

/* --- Responsive Sidebar (Mobile) --- */
@media (max-width: 768px) {
    .sidebar {
        left: -250px; /* Hide sidebar by default on mobile */
        transition: left 0.3s ease;
    }
    
    /* When JavaScript adds this class, show the sidebar */
    .sidebar.active {
        left: 0;
        box-shadow: 5px 0 15px rgba(0,0,0,0.1);
    }

    .main-content {
        margin-left: 0; /* Content takes full width */
    }
}

/* =========================================
   12. MOBILE CLOSE BUTTON
   ========================================= */

/* Default: Hide close button on desktop */
.sidebar-close {
    display: none; 
}

/* Mobile Only */
@media (max-width: 768px) {
    .sidebar-close {
        display: block;
        position: absolute;
        top: 15px;
        right: 15px;
        font-size: 1.5rem;
        color: var(--text-muted);
        cursor: pointer;
        z-index: 1001;
        width: 30px;
        height: 30px;
        text-align: center;
        line-height: 30px;
        border-radius: 4px;
    }
    
    .sidebar-close:hover {
        background: #f1f5f9;
        color: var(--primary);
    }
}

/* =========================================
   3. MAIN CONTENT AREA
   ========================================= */
.main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
}

/* Top Bar (Blue Header for "New Link") */
.top-bar {
    background: var(--primary);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: white;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

.new-link-btn {
    background: rgba(255,255,255,0.2);
    color: white;
    padding: 8px 15px;
    border-radius: 4px;
    font-size: 0.9rem;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.3);
}
.new-link-btn:hover {
    background: rgba(255,255,255,0.3);
}

.content-wrapper {
    padding: 2rem;
    max-width: 1400px;
    width: 100%;
    margin: 0 auto;
}

/* =========================================
   4. DASHBOARD CARDS & REPORTS
   ========================================= */
.report-section {
    margin-bottom: 2rem;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
}

/* The Blue Header on Cards */
.report-header {
    background: var(--primary);
    color: white;
    padding: 12px 20px;
    font-weight: 600;
    font-size: 0.95rem;
}

/* The Grid inside the report card */
.stats-row {
    background: white;
    padding: 20px !important; /* Force padding */
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 20px;
    border: 1px solid var(--border-color);
    border-top: none;
}

/* Individual Stat Items */
.stat-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px;
}

.stat-label {
    font-size: 0.8rem;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 5px;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
}

/* Colored Circular Icons */
.icon-circle {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 1.2rem;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

.icon-green { background: var(--icon-green); }
.icon-blue  { background: var(--icon-blue); }
.icon-orange{ background: var(--icon-orange); }
.icon-purple{ background: var(--icon-purple); }

/* =========================================
   5. TABLES & CHARTS
   ========================================= */
.data-card {
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.05);
    overflow: hidden;
    margin-bottom: 2rem;
    border: 1px solid var(--border-color);
}

.table-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    font-weight: 600;
    color: var(--primary);
}

table {
    width: 100%;
    border-collapse: collapse;
}

th, td {
    padding: 12px 20px;
    text-align: left;
    border-bottom: 1px solid var(--border-color);
    font-size: 0.9rem;
}

th {
    background: #f8fafc;
    color: var(--text-muted);
    font-weight: 600;
}

tr:last-child td { border-bottom: none; }
tr:hover { background: #f9f9f9; }

/* Buttons */
.btn-primary {
    background: var(--primary);
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 4px;
    cursor: pointer;
}
.btn-primary:hover { background: var(--primary-dark); }

/* =========================================
   6. MANAGE LINKS PAGE
   ========================================= */

/* Top Filter Bar */
.filter-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    display: flex;
    flex-wrap: wrap;
    gap: 15px;
    align-items: center;
}

.filter-input {
    padding: 8px 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    font-size: 0.9rem;
    flex: 1; /* Grow to fill space */
    min-width: 150px;
}

/* Link Cards */
.link-card {
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 1.5rem;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    border: 1px solid var(--border-color);
    border-left: 4px solid var(--primary); /* Blue accent on left */
}

.link-title {
    color: var(--primary);
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    display: block;
}
.link-title:hover { text-decoration: underline; }

.link-meta {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
    display: flex;
    gap: 15px;
    align-items: center;
}

/* Copy Box (Input + Button) */
.copy-group {
    display: flex;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    margin-bottom: 1rem;
}

.copy-input {
    flex: 1;
    border: none;
    background: transparent;
    padding: 8px 12px;
    font-size: 0.9rem;
    color: #555;
    outline: none;
}

.copy-btn {
    background: white;
    border: none;
    border-left: 1px solid var(--border-color);
    padding: 0 15px;
    cursor: pointer;
    color: var(--text-muted);
}
.copy-btn:hover { color: var(--primary); }

/* Action Buttons (Edit/Hide) */
.action-row {
    display: flex;
    justify-content: flex-end; /* Push buttons to right */
    gap: 10px;
}

.btn-sm { padding: 6px 12px; font-size: 0.85rem; border-radius: 4px; border: none; cursor: pointer; color: white; }
.btn-success { background: #2ecc71; } /* Green */
.btn-warning { background: #ff7675; } /* Orange/Red */
.btn-info    { background: var(--primary); } /* Blue */
.btn-light   { background: white; border: 1px solid var(--border-color); color: var(--text-muted); }

/* =========================================
   7. WITHDRAW PAGE
   ========================================= */

/* Top Stats Cards (Balance, Pending, Total) */
.withdraw-stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 2rem;
}

.withdraw-stat-card {
    background: white;
    padding: 2rem 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
    display: flex;
    align-items: center;
    gap: 15px;
}

.w-icon-box {
    width: 50px;
    height: 50px;
    border-radius: 50%; /* Circle */
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: white;
}

.w-icon-green  { background: #00b894; }
.w-icon-orange { background: #e17055; }
.w-icon-purple { background: #6c5ce7; }

.w-content h4 {
    margin: 0;
    font-size: 0.9rem;
    color: var(--text-muted);
    font-weight: 600;
}

.w-content span {
    display: block;
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-main);
    margin-top: 5px;
}

/* Big Green Withdraw Button */
.btn-withdraw-full {
    display: block;
    width: 100%;
    background: #00b894; /* Green color from image */
    color: white;
    text-align: center;
    padding: 15px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-bottom: 2rem;
    transition: background 0.2s;
}
.btn-withdraw-full:hover {
    background: #00a383;
}

/* Info Text Area */
.withdraw-info-text {
    font-size: 0.9rem;
    color: #555;
    line-height: 1.6;
    margin-bottom: 2rem;
    background: white;
    padding: 1.5rem;
    border-radius: 8px;
    border: 1px solid var(--border-color);
}

.withdraw-info-text a { color: var(--primary); text-decoration: underline; }

/* Table Status Badges */
.badge { padding: 4px 8px; border-radius: 4px; font-size: 0.75rem; font-weight: 600; text-transform: uppercase; }
.badge-pending { background: #fff3cd; color: #856404; }
.badge-approved { background: #d1e7dd; color: #0f5132; }
.badge-complete { background: #d1e7dd; color: #0f5132; }
.badge-cancelled { background: #f8d7da; color: #721c24; }

/* Footer List */
.status-legend {
    margin-top: 2rem;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.8;
}

/* =========================================
   8. REFERRALS PAGE
   ========================================= */

.ref-description {
    font-size: 0.95rem;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    line-height: 1.6;
}

.ref-link-input {
    width: 100%;
    background: #f8fafc; /* Light gray background */
    border: 1px solid var(--border-color);
    padding: 12px 15px;
    border-radius: 4px;
    font-size: 0.95rem;
    color: #555;
    outline: none;
    font-family: monospace; /* Looks like code/link */
}

.ref-link-input:focus {
    border-color: var(--primary);
    background: white;
}

.btn-outline-primary {
    background: transparent;
    border: 1px solid var(--primary);
    color: var(--primary);
    padding: 8px 15px;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    transition: all 0.2s;
}

.btn-outline-primary:hover {
    background: var(--primary);
    color: white;
}

/* =========================================
   9. AUTH PAGES (Login / Register)
   ========================================= */

/* Center the form on the screen */
.auth-wrapper {
    min-height: 80vh; /* Takes up most of the screen height */
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 2rem 1rem;
    background: #f1f5f9; /* Match dashboard background */
}

/* The White Card */
.auth-card {
    background: white;
    width: 100%;
    max-width: 500px; /* Limits width so it looks good on desktop */
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.05);
    border: 1px solid #e2e8f0;
}

/* Header Styles */
.auth-card h2 {
    text-align: center;
    color: var(--primary); /* Blue */
    margin-bottom: 0.5rem;
    font-size: 1.8rem;
}

/* Referral Notice (Green Text) */
.ref-notice {
    text-align: center;
    color: #10b981; /* Green */
    background: #ecfdf5; /* Light Green Bg */
    padding: 10px;
    border-radius: 6px;
    font-size: 0.9rem;
    font-weight: 500;
    margin-bottom: 1.5rem;
    border: 1px solid #d1fae5;
}

/* Form Inputs styling */
.form-group {
    margin-bottom: 1.2rem;
}

.form-group label {
    display: block; /* Forces label to be on its own line */
    margin-bottom: 8px;
    font-weight: 600;
    color: #475569;
    font-size: 0.9rem;
}

.form-group input, 
.form-group select, 
.form-group textarea {
    width: 100%; /* Forces input to fill the width */
    padding: 12px 15px;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    font-size: 0.95rem;
    transition: border-color 0.2s;
    background: #fff;
    box-sizing: border-box; /* Important: keeps padding inside width */
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(0, 131, 233, 0.1);
}

/* Row for side-by-side inputs */
.form-row {
    display: flex;
    gap: 15px;
}
.form-row .form-group {
    flex: 1; /* Makes them equal width */
}

/* The Big Blue Button */
.btn-block {
    display: block;
    width: 100%;
    background: var(--primary);
    color: white;
    padding: 14px;
    font-size: 1rem;
    font-weight: 600;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 1rem;
    transition: background 0.2s;
}

.btn-block:hover {
    background: var(--primary-dark);
}

/* Footer Link */
.auth-footer {
    text-align: center;
    margin-top: 1.5rem;
    font-size: 0.9rem;
    color: #64748b;
}
.auth-footer a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}
.auth-footer a:hover {
    text-decoration: underline;
}

/* =========================================
   10. SETTINGS / PROFILE PAGE
   ========================================= */

.settings-header {
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 1.5rem;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

/* Two Column Form Grid */
.settings-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two equal columns */
    gap: 20px;
    margin-bottom: 1rem;
}

/* Make Phone Number & Textarea full width */
.full-width {
    grid-column: span 2;
}

/* Withdrawal Section Layout */
.withdrawal-section {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 30px;
    margin-top: 2rem;
}

/* The Info Table (Right side of withdrawal) */
.withdrawal-info-table {
    width: 100%;
    border-collapse: collapse;
    background: #f8fafc;
    border: 1px solid var(--border-color);
    font-size: 0.85rem;
}

.withdrawal-info-table th, 
.withdrawal-info-table td {
    padding: 10px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}
.withdrawal-info-table th { font-weight: 600; color: var(--text-main); }
.withdrawal-info-table td { text-align: right; color: var(--text-muted); }

/* =========================================
   11. SIDEBAR SUB-MENU
   ========================================= */
.sidebar-submenu {
    display: none; /* Hidden by default */
    background: #f1f5f9; /* Slightly darker than sidebar */
    padding-left: 0;
}

.sidebar-submenu.show {
    display: block; /* Show when active */
}

.sidebar-submenu li a {
    padding-left: 55px; /* Indent child items */
    font-size: 0.9rem;
    color: var(--text-muted);
}

.sidebar-submenu li a:hover,
.sidebar-submenu li a.active {
    color: var(--primary);
    background: transparent;
    font-weight: 600;
}

/* Rotate arrow icon */
.rotate-icon {
    transform: rotate(180deg);
    transition: transform 0.3s;
}

/* Responsive: Stack columns on mobile */
@media (max-width: 768px) {
    .settings-grid, .withdrawal-section {
        grid-template-columns: 1fr;
    }
    .full-width {
        grid-column: span 1;
    }
}

/* Mobile Fix */
@media (max-width: 600px) {
    .form-row {
        flex-direction: column; /* Stack inputs on mobile */
        gap: 0;
    }
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .sidebar { transform: translateX(-100%); transition: transform 0.3s; }
    .sidebar.active { transform: translateX(0); }
    .main-content { margin-left: 0; }
    .stats-row { grid-template-columns: 1fr; }
}