/**
 * FILE: /var/138casino/public/agent/agent-portal.css
 * CSS cho Cổng Đại Lý
 */

/* =====================================================
   CSS VARIABLES
   ===================================================== */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #10b981;
    --danger: #ef4444;
    --warning: #f59e0b;
    --info: #06b6d4;
    --purple: #8b5cf6;
    
    --bg-dark: #0f172a;
    --bg-darker: #0a0f1a;
    --bg-card: #1e293b;
    --bg-card-hover: #273449;
    
    --text-primary: #f8fafc;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --border: #334155;
    --border-light: #475569;
    
    --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.3), 0 2px 4px -2px rgba(0, 0, 0, 0.2);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.3), 0 4px 6px -4px rgba(0, 0, 0, 0.2);
    
    --sidebar-width: 260px;
    --header-height: 70px;
    
    --gradient-blue: linear-gradient(135deg, #3b82f6, #1d4ed8);
    --gradient-green: linear-gradient(135deg, #10b981, #059669);
    --gradient-purple: linear-gradient(135deg, #8b5cf6, #6d28d9);
    --gradient-orange: linear-gradient(135deg, #f59e0b, #d97706);
    --gradient-red: linear-gradient(135deg, #ef4444, #dc2626);
}

/* =====================================================
   RESET & BASE
   ===================================================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    background: var(--bg-dark);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
}

a {
    color: var(--primary);
    text-decoration: none;
}

/* =====================================================
   LOGIN SCREEN
   ===================================================== */
.login-screen {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 80px;
    padding: 40px;
    background: var(--bg-darker);
    background-image: 
        radial-gradient(circle at 20% 80%, rgba(59, 130, 246, 0.1) 0%, transparent 50%),
        radial-gradient(circle at 80% 20%, rgba(139, 92, 246, 0.1) 0%, transparent 50%);
}

.login-container {
    width: 100%;
    max-width: 420px;
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
}

.login-header {
    text-align: center;
    margin-bottom: 32px;
}

.login-header .logo {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 28px;
    font-weight: 700;
    color: var(--text-primary);
    margin-bottom: 16px;
}

.login-header .logo i {
    color: var(--warning);
    font-size: 32px;
}

.login-header h1 {
    font-size: 24px;
    font-weight: 600;
    margin-bottom: 8px;
}

.login-header p {
    color: var(--text-secondary);
    font-size: 14px;
}

.login-form .form-group {
    margin-bottom: 20px;
}

.login-form label {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.login-form label i {
    color: var(--primary);
}

.login-form input[type="text"],
.login-form input[type="password"] {
    width: 100%;
    padding: 14px 16px;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 15px;
    transition: all 0.2s;
}

.login-form input:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.password-input {
    position: relative;
}

.password-input input {
    padding-right: 50px;
}

.toggle-password {
    position: absolute;
    right: 12px;
    top: 50%;
    transform: translateY(-50%);
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 4px;
}

.remember-me label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-size: 14px;
}

.remember-me input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--primary);
}

.btn-login {
    width: 100%;
    padding: 14px 24px;
    background: var(--gradient-blue);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.btn-login:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.login-footer {
    text-align: center;
    margin-top: 24px;
    padding-top: 24px;
    border-top: 1px solid var(--border);
}

.login-footer p {
    color: var(--text-muted);
    font-size: 14px;
    margin-bottom: 8px;
}

.login-footer a {
    color: var(--primary);
    font-weight: 500;
}

.login-features {
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 300px;
}

.login-features .feature {
    display: flex;
    align-items: flex-start;
    gap: 16px;
    padding: 20px;
    background: var(--bg-card);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.login-features .feature i {
    font-size: 24px;
    color: var(--primary);
    padding: 12px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
}

.login-features .feature h3 {
    font-size: 16px;
    font-weight: 600;
    margin-bottom: 4px;
}

.login-features .feature p {
    font-size: 13px;
    color: var(--text-secondary);
}

/* =====================================================
   MAIN APP LAYOUT
   ===================================================== */
.main-app {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-darker);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    z-index: 100;
    transition: transform 0.3s;
}

.sidebar-header {
    padding: 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid var(--border);
}

.sidebar-header .logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: 700;
}

.sidebar-header .logo i {
    color: var(--warning);
}

.agent-badge {
    font-size: 10px;
    font-weight: 700;
    padding: 4px 8px;
    background: var(--gradient-purple);
    border-radius: 4px;
    letter-spacing: 1px;
}

.agent-info-card {
    padding: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
    background: var(--bg-card);
    margin: 16px;
    border-radius: 12px;
    border: 1px solid var(--border);
}

.agent-avatar {
    width: 48px;
    height: 48px;
    background: var(--gradient-blue);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
}

.agent-details {
    flex: 1;
    min-width: 0;
}

.agent-name {
    font-weight: 600;
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.agent-code {
    font-size: 12px;
    color: var(--text-muted);
    font-family: monospace;
}

.agent-tier {
    font-size: 11px;
    padding: 4px 8px;
    background: var(--warning);
    color: #000;
    border-radius: 4px;
    font-weight: 600;
}

.sidebar-nav {
    flex: 1;
    padding: 16px 0;
    overflow-y: auto;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 24px;
    color: var(--text-secondary);
    transition: all 0.2s;
    position: relative;
}

.nav-item:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.05);
}

.nav-item.active {
    color: var(--primary);
    background: rgba(59, 130, 246, 0.1);
}

.nav-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 3px;
    background: var(--primary);
    border-radius: 0 3px 3px 0;
}

.nav-item i {
    font-size: 18px;
    width: 24px;
    text-align: center;
}

.nav-item .badge {
    margin-left: auto;
    font-size: 11px;
    padding: 2px 8px;
    background: var(--primary);
    color: white;
    border-radius: 10px;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border);
}

.btn-logout {
    width: 100%;
    padding: 12px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-secondary);
    font-size: 14px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: var(--danger);
    border-color: var(--danger);
    color: white;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: var(--sidebar-width);
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.main-header {
    height: var(--header-height);
    background: var(--bg-darker);
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    padding: 0 24px;
    gap: 20px;
    position: sticky;
    top: 0;
    z-index: 50;
}

.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    color: var(--text-primary);
    font-size: 24px;
    cursor: pointer;
}

.header-title h1 {
    font-size: 20px;
    font-weight: 600;
}

.header-actions {
    margin-left: auto;
    display: flex;
    align-items: center;
    gap: 16px;
}

.balance-display {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: var(--bg-card);
    border-radius: 10px;
    border: 1px solid var(--border);
}

.balance-display .label {
    font-size: 13px;
    color: var(--text-muted);
}

.balance-display .value {
    font-size: 16px;
    font-weight: 700;
    color: var(--secondary);
}

.content-area {
    flex: 1;
    padding: 24px;
    background: var(--bg-dark);
}

/* =====================================================
   PAGES
   ===================================================== */
.page {
    display: none;
}

.page.active {
    display: block;
}

.page-header {
    margin-bottom: 24px;
}

.filters {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
}

/* =====================================================
   STATS GRID
   ===================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.stat-card {
    padding: 24px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    gap: 16px;
    color: white;
}

.stat-card.gradient-blue { background: var(--gradient-blue); }
.stat-card.gradient-green { background: var(--gradient-green); }
.stat-card.gradient-purple { background: var(--gradient-purple); }
.stat-card.gradient-orange { background: var(--gradient-orange); }

.stat-card .stat-icon {
    width: 56px;
    height: 56px;
    background: rgba(255, 255, 255, 0.2);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
}

.stat-card .stat-value {
    font-size: 24px;
    font-weight: 700;
}

.stat-card .stat-label {
    font-size: 13px;
    opacity: 0.9;
}

/* =====================================================
   CARDS
   ===================================================== */
.card {
    background: var(--bg-card);
    border-radius: 16px;
    border: 1px solid var(--border);
    margin-bottom: 24px;
}

.card-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.card-header h3 {
    font-size: 16px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.card-header h3 i {
    color: var(--primary);
}

.card-header .view-all {
    font-size: 14px;
    color: var(--primary);
}

.card-body {
    padding: 24px;
}

/* =====================================================
   DASHBOARD SPECIFIC
   ===================================================== */
.dashboard-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 24px;
    margin-bottom: 24px;
}

.commission-info-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px;
}

.commission-info-grid .info-item {
    text-align: center;
    padding: 16px;
    background: var(--bg-darker);
    border-radius: 12px;
}

.commission-info-grid .info-item .label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 8px;
}

.commission-info-grid .info-item .value {
    font-size: 20px;
    font-weight: 700;
}

.commission-info-grid .info-item .value.highlight { color: var(--primary); }
.commission-info-grid .info-item .value.bonus { color: var(--secondary); }
.commission-info-grid .info-item .value.total { color: var(--warning); }
.commission-info-grid .info-item .value.tier { color: var(--purple); }

.month-stats {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.month-stat {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px;
    background: var(--bg-darker);
    border-radius: 12px;
}

.month-stat .icon {
    width: 44px;
    height: 44px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 18px;
}

.month-stat .info .value {
    display: block;
    font-size: 16px;
    font-weight: 700;
}

.month-stat .info .label {
    font-size: 12px;
    color: var(--text-muted);
}

.month-stat.highlight {
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.month-stat.highlight .icon {
    background: rgba(16, 185, 129, 0.2);
    color: var(--secondary);
}

.month-stat.highlight .value {
    color: var(--secondary);
}

/* =====================================================
   TABLES
   ===================================================== */
.table-container {
    overflow-x: auto;
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th,
.table td {
    padding: 14px 16px;
    text-align: left;
    border-bottom: 1px solid var(--border);
}

.table th {
    font-size: 12px;
    font-weight: 600;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.5px;
    background: var(--bg-darker);
}

.table td {
    font-size: 14px;
}

.table tbody tr:hover {
    background: var(--bg-card-hover);
}

.text-center {
    text-align: center;
}

.text-right {
    text-align: right;
}

.text-success { color: var(--secondary); }
.text-danger { color: var(--danger); }
.text-warning { color: var(--warning); }

/* =====================================================
   COMMISSION PAGE
   ===================================================== */
.commission-summary {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
    margin-bottom: 24px;
}

.summary-card {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 24px;
    display: flex;
    align-items: center;
    gap: 16px;
}

.summary-card .icon {
    width: 56px;
    height: 56px;
    background: rgba(59, 130, 246, 0.1);
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    font-size: 22px;
}

.summary-card .info .value {
    display: block;
    font-size: 22px;
    font-weight: 700;
}

.summary-card .info .label {
    font-size: 13px;
    color: var(--text-muted);
}

/* =====================================================
   WITHDRAW PAGE
   ===================================================== */
.withdraw-grid {
    display: grid;
    grid-template-columns: 400px 1fr;
    gap: 24px;
}

.withdraw-form-card .balance-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px;
    background: rgba(16, 185, 129, 0.1);
    border: 1px solid rgba(16, 185, 129, 0.2);
    border-radius: 12px;
    margin-bottom: 24px;
}

.withdraw-form-card .balance-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--secondary);
}

.amount-input {
    position: relative;
}

.amount-input input {
    padding-right: 50px;
}

.amount-input .currency {
    position: absolute;
    right: 16px;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
}

.bank-info {
    padding: 16px;
    background: var(--bg-darker);
    border-radius: 10px;
    margin-bottom: 20px;
}

.bank-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.bank-info .info-row:last-child {
    border-bottom: none;
}

.withdraw-history {
    max-height: 500px;
    overflow-y: auto;
}

.withdraw-item {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 16px;
    background: var(--bg-darker);
    border-radius: 12px;
    margin-bottom: 12px;
}

.withdraw-item .icon {
    width: 44px;
    height: 44px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.withdraw-item .icon.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.withdraw-item .icon.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

.withdraw-item .icon.rejected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.withdraw-item .icon.processing {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.withdraw-item .icon.approved {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

.withdraw-item .info {
    flex: 1;
}

.withdraw-item .amount {
    font-size: 16px;
    font-weight: 700;
}

.withdraw-item .date {
    font-size: 12px;
    color: var(--text-muted);
}

.withdraw-item .status {
    font-size: 12px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
}

.withdraw-item .status.pending {
    background: rgba(245, 158, 11, 0.1);
    color: var(--warning);
}

.withdraw-item .status.success {
    background: rgba(16, 185, 129, 0.1);
    color: var(--secondary);
}

.withdraw-item .status.rejected {
    background: rgba(239, 68, 68, 0.1);
    color: var(--danger);
}

.withdraw-item .status.processing {
    background: rgba(59, 130, 246, 0.1);
    color: var(--primary);
}

.withdraw-item .status.approved {
    background: rgba(6, 182, 212, 0.1);
    color: var(--info);
}

/* =====================================================
   REFERRAL PAGE
   ===================================================== */
.referral-card {
    max-width: 600px;
    margin: 0 auto 24px;
}

.referral-link-box {
    display: flex;
    gap: 12px;
    margin-bottom: 20px;
}

.referral-link-box input {
    flex: 1;
}

.referral-code-box {
    text-align: center;
    padding: 20px;
    background: var(--bg-darker);
    border-radius: 12px;
    margin-bottom: 24px;
}

.referral-code-box .code {
    display: block;
    font-size: 32px;
    font-weight: 700;
    font-family: monospace;
    color: var(--primary);
    margin-top: 8px;
    letter-spacing: 4px;
}

.referral-qr {
    text-align: center;
    margin-bottom: 24px;
}

.referral-qr #qrCode {
    display: inline-block;
    padding: 16px;
    background: white;
    border-radius: 12px;
    margin-bottom: 12px;
}

.referral-qr p {
    font-size: 13px;
    color: var(--text-muted);
}

.share-buttons {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.share-buttons .btn {
    flex: 1;
    max-width: 150px;
}

.btn-facebook { background: #1877f2; }
.btn-telegram { background: #0088cc; }
.btn-zalo { background: #0068ff; }

.referral-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.referral-stats .stat-item {
    text-align: center;
    padding: 24px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 16px;
}

.referral-stats .stat-item i {
    font-size: 32px;
    color: var(--primary);
    margin-bottom: 12px;
}

.referral-stats .stat-item .value {
    display: block;
    font-size: 28px;
    font-weight: 700;
    margin-bottom: 4px;
}

.referral-stats .stat-item .label {
    font-size: 13px;
    color: var(--text-muted);
}

/* =====================================================
   SETTINGS PAGE
   ===================================================== */
.settings-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 24px;
}

.profile-info .info-row {
    display: flex;
    justify-content: space-between;
    padding: 14px 0;
    border-bottom: 1px solid var(--border);
}

.profile-info .info-row:last-child {
    border-bottom: none;
}

.profile-info .info-row .label {
    color: var(--text-muted);
}

.profile-info .info-row .value {
    font-weight: 500;
}

/* =====================================================
   FORMS
   ===================================================== */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    font-size: 14px;
    font-weight: 500;
    margin-bottom: 8px;
    color: var(--text-secondary);
}

.form-control {
    width: 100%;
    padding: 12px 16px;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    font-size: 14px;
    transition: all 0.2s;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.form-control::placeholder {
    color: var(--text-muted);
}

.hint {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

/* =====================================================
   BUTTONS
   ===================================================== */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 12px 20px;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-primary {
    background: var(--gradient-blue);
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: var(--bg-card);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.btn-success {
    background: var(--gradient-green);
    color: white;
}

.btn-danger {
    background: var(--gradient-red);
    color: white;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 8px 14px;
    font-size: 13px;
}

/* =====================================================
   BADGES
   ===================================================== */
.badge {
    display: inline-block;
    padding: 4px 10px;
    font-size: 11px;
    font-weight: 600;
    border-radius: 20px;
    text-transform: uppercase;
}

.badge-success { background: rgba(16, 185, 129, 0.15); color: var(--secondary); }
.badge-warning { background: rgba(245, 158, 11, 0.15); color: var(--warning); }
.badge-danger { background: rgba(239, 68, 68, 0.15); color: var(--danger); }
.badge-info { background: rgba(6, 182, 212, 0.15); color: var(--info); }
.badge-primary { background: rgba(59, 130, 246, 0.15); color: var(--primary); }

/* =====================================================
   TOAST
   ===================================================== */
.toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 9999;
}

.toast {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 14px 20px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    box-shadow: var(--shadow-lg);
    margin-bottom: 10px;
    animation: slideIn 0.3s ease;
}

.toast.success { border-left: 4px solid var(--secondary); }
.toast.error { border-left: 4px solid var(--danger); }
.toast.warning { border-left: 4px solid var(--warning); }

.toast.success i { color: var(--secondary); }
.toast.error i { color: var(--danger); }
.toast.warning i { color: var(--warning); }

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

/* =====================================================
   LOADING
   ===================================================== */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.spinner {
    width: 48px;
    height: 48px;
    border: 4px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =====================================================
   PAGINATION
   ===================================================== */
.pagination {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding-top: 20px;
}

.pagination button {
    padding: 8px 14px;
    background: var(--bg-darker);
    border: 1px solid var(--border);
    border-radius: 8px;
    color: var(--text-primary);
    cursor: pointer;
    transition: all 0.2s;
}

.pagination button:hover {
    border-color: var(--primary);
}

.pagination button.active {
    background: var(--primary);
    border-color: var(--primary);
}

.pagination button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* =====================================================
   SUB AGENTS PAGE (MỚI)
   ===================================================== */
.subagents-info-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 20px;
}

.subagents-info-grid .info-box {
    text-align: center;
    padding: 20px;
    background: var(--bg-darker);
    border-radius: 12px;
    border: 1px solid var(--border);
}

.subagents-info-grid .info-box .label {
    display: block;
    font-size: 12px;
    color: var(--text-muted);
    margin-bottom: 10px;
}

.subagents-info-grid .info-box .value {
    font-size: 20px;
    font-weight: 700;
}

/* Actions trong table */
.table .actions {
    display: flex;
    gap: 8px;
}

.table .btn-sm {
    padding: 6px 10px;
    font-size: 12px;
}

/* =====================================================
   MODAL
   ===================================================== */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
}

.modal-content {
    position: relative;
    background: var(--bg-card);
    border-radius: 20px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border);
    animation: modalIn 0.3s ease;
}

@keyframes modalIn {
    from {
        transform: scale(0.95);
        opacity: 0;
    }
    to {
        transform: scale(1);
        opacity: 1;
    }
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-size: 18px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
}

.modal-header h3 i {
    color: var(--primary);
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 20px;
    cursor: pointer;
    padding: 8px;
    border-radius: 50%;
    transition: all 0.2s;
}

.modal-close:hover {
    background: var(--bg-darker);
    color: var(--text-primary);
}

.modal-body {
    padding: 24px;
}

/* Info box trong modal */
.modal-info-box {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: 12px;
    padding: 16px;
    margin-bottom: 24px;
}

.modal-info-box p {
    margin: 0;
    color: var(--text-secondary);
    font-size: 14px;
}

.modal-info-box i {
    color: var(--primary);
    margin-right: 8px;
}

/* Preview box trong modal tạo đại lý */
.commission-preview {
    background: var(--bg-darker);
    padding: 16px;
    border-radius: 12px;
    margin-bottom: 20px;
}

.commission-preview .preview-row {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid var(--border);
}

.commission-preview .preview-row:last-child {
    border-bottom: none;
    padding-top: 12px;
    margin-top: 4px;
    border-top: 1px solid var(--border);
}

.commission-preview .preview-row strong {
    color: var(--secondary);
}

/* Modal footer buttons */
.modal-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
}

.modal-actions .btn {
    flex: 1;
}

/* =====================================================
   RESPONSIVE
   ===================================================== */
@media (max-width: 1200px) {
    .stats-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .dashboard-grid {
        grid-template-columns: 1fr;
    }
    
    .commission-summary {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .withdraw-grid {
        grid-template-columns: 1fr;
    }
    
    .settings-grid {
        grid-template-columns: 1fr;
    }
    
    .subagents-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {
    .login-screen {
        flex-direction: column;
        padding: 20px;
    }
    
    .login-features {
        display: none;
    }
    
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: block;
    }
    
    .header-actions .balance-display {
        display: none;
    }
    
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .commission-info-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    
    .month-stats {
        grid-template-columns: 1fr;
    }
    
    .commission-summary {
        grid-template-columns: 1fr;
    }
    
    .referral-stats {
        grid-template-columns: 1fr;
    }
    
    .subagents-info-grid {
        grid-template-columns: 1fr;
    }
    
    .content-area {
        padding: 16px;
    }
    
    .page-header {
        flex-direction: column;
        align-items: stretch !important;
        gap: 12px;
    }
    
    .filters {
        flex-direction: column;
    }
    
    .filters .form-control {
        width: 100%;
    }
    
    #btnCreateSubAgent {
        width: 100%;
    }
    
    .table th,
    .table td {
        padding: 10px 12px;
        font-size: 12px;
    }
    
    .modal-content {
        margin: 10px;
        max-width: calc(100% - 20px);
    }
}
/* =====================================================
   MOBILE IMPROVEMENTS - Touch & Usability (768px)
   Appended to existing @media block above
   ===================================================== */
@media (max-width: 768px) {
    /* Prevent iOS zoom on input focus - must be 16px+ */
    input, select, textarea {
        font-size: 16px !important;
    }

    /* Touch-friendly buttons - 44px minimum touch target */
    .btn, button, .action-btn {
        min-height: 44px;
        padding: 10px 16px;
    }

    /* Tables - horizontal scroll with momentum */
    .table-container, .table-responsive {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table {
        min-width: 500px;
    }

    table th, table td {
        white-space: nowrap;
        font-size: 13px;
    }

    /* Cards - better mobile spacing */
    .card, .stat-card {
        padding: 16px;
        margin-bottom: 12px;
    }

    /* Modal improvements - full width on mobile */
    .modal-content, .modal {
        width: calc(100% - 16px) !important;
        max-width: 100% !important;
        margin: 8px auto;
        max-height: 90vh;
        overflow-y: auto;
    }

    /* Referral link input readable on mobile */
    .referral-link-box input {
        font-size: 14px;
    }

    /* Login page - full width on mobile */
    .login-container {
        padding: 20px;
        width: calc(100% - 32px);
        max-width: 100%;
    }

    .login-container input {
        padding: 14px;
        font-size: 16px;
    }

    .login-container button {
        padding: 14px;
        font-size: 16px;
    }

    /* Filter sections - stack vertically */
    .filter-section {
        flex-direction: column;
        gap: 8px;
    }
    .filter-section select,
    .filter-section input,
    .filters select,
    .filters input {
        width: 100%;
    }

    /* Header actions - compact */
    .header-actions {
        gap: 6px;
    }
    .header-actions .btn {
        font-size: 12px;
        padding: 6px 10px;
    }

    /* Sidebar menu items - bigger touch targets */
    .menu-item, .nav-item {
        padding: 14px 20px;
        font-size: 15px;
    }

    /* Content area - less padding on mobile */
    .content, .main-content, #appContent {
        padding: 12px;
    }

    /* Commission/report detail grid - single column */
    .detail-grid, .info-grid {
        grid-template-columns: 1fr !important;
        gap: 8px;
    }

    /* Withdrawal form - mobile friendly */
    .withdraw-form {
        padding: 16px;
    }
    .withdraw-form input {
        font-size: 16px;
        padding: 12px;
    }
}

/* =====================================================
   EXTRA SMALL SCREENS (480px)
   ===================================================== */
@media (max-width: 480px) {
    .stat-card .stat-value, .stat-number {
        font-size: 20px;
    }

    .stat-card .stat-label {
        font-size: 12px;
    }

    table {
        font-size: 12px;
    }

    table th, table td {
        padding: 8px;
    }

    .page-title, h2, h3 {
        font-size: 18px;
    }
}
