/**
 * ============================================================================
 * DASHBOARD ENHANCED STYLES — v3 (Branding-Safe)
 * All colors use CSS variables set dynamically by inject_custom_css()
 * NO hardcoded hex colors — fully responsive to admin branding settings
 * ============================================================================
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

/* ------------------------------------------------------------------
   COMPUTED ALIASES — all derived from the two dynamic vars:
   --primary-color and --secondary-color (set by inject_custom_css)
   ------------------------------------------------------------------ */
:root {
    /* Layout */
    --sidebar-width: 260px;
    --header-height: 64px;

    /* Semantic aliases that track the primary/secondary vars */
    --primary-light: color-mix(in srgb, var(--primary-color) 12%, white);
    --secondary-light: color-mix(in srgb, var(--secondary-color) 15%, white);

    /* Fixed semantic colors (not brand-related) */
    --danger-color: #ef4444;
    --danger-light: #fee2e2;
    --warning-color: #f59e0b;
    --warning-light: #fef3c7;
    --info-color: #3b82f6;
    --info-light: #dbeafe;

    /* Neutrals */
    --light-bg: #f5f7ff;
    --border-color: #e5e7eb;
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --card-bg: #ffffff;

    /* Shadows */
    --shadow-xs: 0 1px 2px rgba(0,0,0,0.05);
    --shadow-sm: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
    --shadow-md: 0 4px 6px rgba(0,0,0,0.07), 0 2px 4px rgba(0,0,0,0.06);
    --shadow-lg: 0 10px 15px rgba(0,0,0,0.1), 0 4px 6px rgba(0,0,0,0.05);

    /* Radius */
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-xl: 20px;

    --transition: all 0.2s cubic-bezier(0.4,0,0.2,1);
}

body {
    background: var(--light-bg);
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
}

/* -----------------------------------------------------------------------
   SIDEBAR — uses primary color for theming
----------------------------------------------------------------------- */
.sidebar {
    background: var(--primary-color);
    border-right: none;
    box-shadow: 4px 0 20px rgba(0,0,0,0.2);
}

.sidebar-logo {
    background: transparent;
    border-bottom: 1px solid rgba(255,255,255,0.15);
    padding: 20px 22px;
}

.sidebar-logo a,
.sidebar-logo span {
    color: white;
    font-size: 18px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.sidebar-nav { padding: 12px 0 20px; }

.nav-item {
    margin: 2px 10px;
    padding: 10px 14px;
    border-radius: var(--radius-sm);
    color: rgba(255,255,255,0.75);
    border-left: none;
    font-size: 14px;
    font-weight: 500;
    transition: var(--transition);
    gap: 10px;
}

.nav-item:hover {
    background: rgba(255,255,255,0.12);
    color: white;
}

.nav-item.active {
    background: rgba(255,255,255,0.2);
    color: white;
    font-weight: 600;
}

.nav-icon {
    width: 18px;
    font-size: 15px;
    flex-shrink: 0;
    opacity: 0.85;
}

.sidebar-overlay {
    background: rgba(0,0,0,0.4);
    backdrop-filter: blur(2px);
}

/* -----------------------------------------------------------------------
   HEADER
----------------------------------------------------------------------- */
.header {
    background: rgba(255,255,255,0.95);
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--shadow-xs);
    height: 64px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 28px;
    position: sticky;
    top: 0;
    z-index: 100;
    backdrop-filter: blur(8px);
}

.greeting {
    font-size: 15px;
    font-weight: 600;
    color: var(--text-primary);
}

.user-menu {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* -----------------------------------------------------------------------
   MAIN CONTENT
----------------------------------------------------------------------- */
.dashboard-content { padding: 28px; max-width: 1400px; }

.page-title {
    font-size: 22px;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.4px;
}

.page-subtitle {
    font-size: 14px;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* -----------------------------------------------------------------------
   STAT CARDS
----------------------------------------------------------------------- */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 18px;
    margin-bottom: 24px;
}

.stat-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    padding: 22px 24px;
    box-shadow: var(--shadow-sm);
    border: 1px solid rgba(0,0,0,0.04);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.stat-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

/* Colored variants use primary/secondary */
.stat-card.primary {
    background: var(--primary-color);
    color: white;
}
.stat-card.success {
    background: var(--secondary-color);
    color: white;
}
.stat-card.info {
    background: var(--info-color);
    color: white;
}
.stat-card.warning {
    background: var(--warning-color);
    color: white;
}
.stat-card.danger {
    background: var(--danger-color);
    color: white;
}
/* Purple and cyan use fixed accent colors (not brand) */
.stat-card.purple {
    background: linear-gradient(135deg, #8b5cf6, #6d28d9);
    color: white;
}
.stat-card.cyan {
    background: linear-gradient(135deg, #06b6d4, #0891b2);
    color: white;
}

.stat-icon {
    width: 42px;
    height: 42px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    margin-bottom: 14px;
    background: rgba(0,0,0,0.06);
    color: var(--primary-color);
}

.stat-card.primary .stat-icon,
.stat-card.success .stat-icon,
.stat-card.info .stat-icon,
.stat-card.warning .stat-icon,
.stat-card.danger .stat-icon,
.stat-card.purple .stat-icon,
.stat-card.cyan .stat-icon {
    background: rgba(255,255,255,0.2);
    color: white;
}

.stat-label {
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.6px;
    color: var(--text-secondary);
    margin-bottom: 6px;
    border: none;
    padding: 0;
}

.stat-card.primary .stat-label,
.stat-card.success .stat-label,
.stat-card.info .stat-label,
.stat-card.warning .stat-label,
.stat-card.danger .stat-label,
.stat-card.purple .stat-label,
.stat-card.cyan .stat-label { color: rgba(255,255,255,0.8); }

.stat-value {
    font-size: 28px;
    font-weight: 800;
    color: var(--text-primary);
    letter-spacing: -1px;
    line-height: 1.1;
}

.stat-card.primary .stat-value,
.stat-card.success .stat-value,
.stat-card.info .stat-value,
.stat-card.warning .stat-value,
.stat-card.danger .stat-value,
.stat-card.purple .stat-value,
.stat-card.cyan .stat-value { color: white; }

.stat-meta {
    font-size: 12px;
    color: var(--text-muted);
    margin-top: 6px;
}

.stat-card.primary .stat-meta,
.stat-card.success .stat-meta,
.stat-card.info .stat-meta,
.stat-card.warning .stat-meta,
.stat-card.danger .stat-meta,
.stat-card.purple .stat-meta,
.stat-card.cyan .stat-meta { color: rgba(255,255,255,0.75); }

/* -----------------------------------------------------------------------
   CARDS
----------------------------------------------------------------------- */
.card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid rgba(0,0,0,0.05);
    box-shadow: var(--shadow-sm);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition);
}
.card:hover { box-shadow: var(--shadow-md); }

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 18px 24px;
    border-bottom: 1px solid var(--border-color);
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 15px;
    font-weight: 700;
    color: var(--text-primary);
    margin: 0;
    letter-spacing: -0.2px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title-icon {
    width: 30px;
    height: 30px;
    border-radius: 8px;
    background: var(--primary-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    opacity: 0.85;
}

.card-body { padding: 24px; }

/* -----------------------------------------------------------------------
   TABLES
----------------------------------------------------------------------- */
.table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table { width: 100%; border-collapse: collapse; font-size: 14px; }
thead { background: #f8fafc; }

th {
    padding: 11px 16px;
    text-align: left;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.7px;
    color: var(--text-secondary);
    white-space: nowrap;
    border-bottom: 1px solid var(--border-color);
}

td {
    padding: 13px 16px;
    color: var(--text-primary);
    font-size: 13.5px;
    border-bottom: 1px solid #f3f4f6;
    vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr { transition: background 0.15s ease; }
tbody tr:hover { background: #f8fafc; }

/* -----------------------------------------------------------------------
   BADGES
----------------------------------------------------------------------- */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 10px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
    white-space: nowrap;
}

.badge-completed, .badge-success, .badge-active { background: #d1fae5; color: #065f46; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-failed, .badge-rejected, .badge-cancelled { background: #fee2e2; color: #991b1b; }
.badge-processing, .badge-approved { background: #dbeafe; color: #1e40af; }
.badge-draft { background: #f3f4f6; color: #6b7280; }

/* -----------------------------------------------------------------------
   BUTTONS — use primary/secondary vars
----------------------------------------------------------------------- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 9px 18px;
    border-radius: var(--radius-sm);
    font-size: 13.5px;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    text-decoration: none;
    white-space: nowrap;
    letter-spacing: 0.1px;
}

.btn:active { transform: scale(0.97); }

.btn-primary {
    background: var(--primary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.15);
}
.btn-primary:hover { filter: brightness(1.08); box-shadow: 0 4px 14px rgba(0,0,0,0.2); }

.btn-success {
    background: var(--secondary-color);
    color: white;
    box-shadow: 0 2px 8px rgba(0,0,0,0.12);
}
.btn-success:hover { filter: brightness(1.08); }

.btn-danger {
    background: var(--danger-color);
    color: white;
    box-shadow: 0 2px 8px rgba(239,68,68,0.3);
}
.btn-danger:hover { filter: brightness(1.05); }

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 1.5px solid var(--primary-color);
}
.btn-outline:hover { background: var(--primary-color); color: white; }

.btn-ghost {
    background: #f3f4f6;
    color: var(--text-secondary);
    border: none;
}
.btn-ghost:hover { background: #e5e7eb; color: var(--text-primary); }

.btn-sm { padding: 6px 12px; font-size: 12px; border-radius: 6px; }
.btn-icon { width: 34px; height: 34px; padding: 0; border-radius: 8px; }

/* -----------------------------------------------------------------------
   ALERTS
----------------------------------------------------------------------- */
.alert {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    padding: 14px 18px;
    border-radius: var(--radius-md);
    font-size: 14px;
    margin-bottom: 20px;
    border: 1px solid transparent;
}
.alert-warning { background: #fef3c7; color: #92400e; border-color: #fcd34d; }
.alert-success { background: #d1fae5; color: #065f46; border-color: #6ee7b7; }
.alert-error, .alert-danger { background: #fee2e2; color: #991b1b; border-color: #fca5a5; }
.alert-info { background: #dbeafe; color: #1e40af; border-color: #93c5fd; }
.alert i { margin-top: 1px; flex-shrink: 0; }

/* -----------------------------------------------------------------------
   FORMS
----------------------------------------------------------------------- */
.form-group { margin-bottom: 18px; }
.form-label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
    margin-bottom: 6px;
}
.form-control,
input[type=text]:not([class*="datepicker"]),
input[type=email],
input[type=password],
input[type=number],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    border: 1.5px solid var(--border-color);
    border-radius: var(--radius-sm);
    font-size: 14px;
    color: var(--text-primary);
    background: white;
    transition: border-color 0.2s, box-shadow 0.2s;
    font-family: inherit;
}
.form-control:focus,
input[type=text]:focus,
input[type=email]:focus,
input[type=password]:focus,
input[type=number]:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0,0,0,0.06);
}

/* -----------------------------------------------------------------------
   QUICK ACTIONS
----------------------------------------------------------------------- */
.quick-actions {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    gap: 12px;
    padding: 20px 24px;
}
.quick-action {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 16px 12px;
    background: var(--light-bg);
    border-radius: var(--radius-md);
    text-align: center;
    text-decoration: none;
    color: var(--text-primary);
    font-size: 13px;
    font-weight: 600;
    transition: var(--transition);
    border: 1.5px solid transparent;
}
.quick-action:hover {
    background: white;
    border-color: var(--primary-color);
    color: var(--primary-color);
    transform: translateY(-1px);
    box-shadow: var(--shadow-sm);
}
.quick-action i { font-size: 22px; color: var(--primary-color); }

/* -----------------------------------------------------------------------
   EMPTY STATES
----------------------------------------------------------------------- */
.empty-state {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 48px 24px;
    text-align: center;
    color: var(--text-secondary);
}
.empty-state i { font-size: 40px; color: var(--border-color); margin-bottom: 16px; }
.empty-state h4 { font-size: 15px; font-weight: 600; color: var(--text-secondary); margin-bottom: 6px; }
.empty-state p { font-size: 13px; color: var(--text-muted); max-width: 300px; }

/* -----------------------------------------------------------------------
   RANK DISPLAY
----------------------------------------------------------------------- */
.rank-display {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 20px 24px;
}
.rank-badge {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    flex-shrink: 0;
    box-shadow: 0 4px 14px rgba(0,0,0,0.2);
}
.rank-info h3 { font-size: 18px; font-weight: 700; color: var(--text-primary); margin-bottom: 2px; }
.rank-info small { font-size: 13px; color: var(--text-secondary); }
.rank-progress { margin-top: 12px; height: 6px; background: var(--border-color); border-radius: 10px; overflow: hidden; }
.rank-progress-fill { height: 100%; background: var(--primary-color); border-radius: 10px; transition: width 0.5s ease; }

/* -----------------------------------------------------------------------
   ANNOUNCEMENTS
----------------------------------------------------------------------- */
.announcement-item {
    padding: 16px 24px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    gap: 14px;
    align-items: flex-start;
    transition: background 0.15s;
}
.announcement-item:last-child { border-bottom: none; }
.announcement-item:hover { background: #fafafa; }
.announcement-dot { width: 8px; height: 8px; border-radius: 50%; background: var(--primary-color); margin-top: 6px; flex-shrink: 0; }
.announcement-item h4 { font-size: 14px; font-weight: 600; color: var(--text-primary); margin-bottom: 4px; }
.announcement-item p { font-size: 13px; color: var(--text-secondary); margin-bottom: 4px; }
.announcement-item time { font-size: 11.5px; color: var(--text-muted); }

/* -----------------------------------------------------------------------
   PRODUCT CARDS
----------------------------------------------------------------------- */
.product-card {
    background: var(--card-bg);
    border-radius: var(--radius-lg);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: var(--transition);
    display: flex;
    flex-direction: column;
}
.product-card:hover { transform: translateY(-3px); box-shadow: var(--shadow-lg); border-color: transparent; }
.product-card-body { padding: 16px; flex: 1; display: flex; flex-direction: column; }
.product-card-title {
    font-size: 14px; font-weight: 700; color: var(--text-primary);
    margin-bottom: 4px;
    display: -webkit-box; -webkit-line-clamp: 2; -webkit-box-orient: vertical; overflow: hidden;
}
.product-card-vendor { font-size: 12px; color: var(--text-secondary); margin-bottom: 10px; }
.product-card-price { font-size: 17px; font-weight: 800; color: var(--primary-color); margin-bottom: 6px; }
.product-card-commission {
    font-size: 12px; font-weight: 600; color: var(--secondary-color);
    background: rgba(0,0,0,0.04);
    display: inline-block;
    padding: 2px 8px;
    border-radius: 20px;
    margin-bottom: 14px;
}
.product-card-footer { margin-top: auto; }

/* -----------------------------------------------------------------------
   DASHBOARD HERO BANNER
----------------------------------------------------------------------- */
.dashboard-hero {
    background: var(--primary-color);
    border-radius: var(--radius-xl);
    padding: 24px 28px;
    color: white;
    margin-bottom: 24px;
    position: relative;
    overflow: hidden;
}
.dashboard-hero::before {
    content: '';
    position: absolute; top: -40px; right: -40px;
    width: 180px; height: 180px;
    background: rgba(255,255,255,0.06);
    border-radius: 50%;
}
.dashboard-hero::after {
    content: '';
    position: absolute; bottom: -60px; right: 60px;
    width: 240px; height: 240px;
    background: rgba(255,255,255,0.04);
    border-radius: 50%;
}
.dashboard-hero h2 { font-size: 20px; font-weight: 700; margin-bottom: 4px; position: relative; z-index: 1; }
.dashboard-hero p { font-size: 14px; opacity: 0.85; position: relative; z-index: 1; }

/* -----------------------------------------------------------------------
   PAGINATION
----------------------------------------------------------------------- */
.pagination {
    display: flex; align-items: center; gap: 6px;
    padding: 16px 24px; justify-content: center; flex-wrap: wrap;
}
.page-btn {
    width: 34px; height: 34px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 8px; font-size: 13px; font-weight: 600;
    color: var(--text-secondary);
    background: white; border: 1.5px solid var(--border-color);
    text-decoration: none; transition: var(--transition);
}
.page-btn:hover { background: var(--primary-color); color: white; border-color: var(--primary-color); }
.page-btn.active { background: var(--primary-color); color: white; border-color: var(--primary-color); }

/* -----------------------------------------------------------------------
   RESPONSIVE
----------------------------------------------------------------------- */
@media (max-width: 767px) {
    .dashboard-content { padding: 16px; }
    .stats-grid { grid-template-columns: repeat(2, 1fr); gap: 12px; }
    .stat-card { padding: 16px; }
    .stat-value { font-size: 22px; }
    .card-header { padding: 14px 16px; }
    .card-body { padding: 16px; }
    td, th { padding: 10px 12px; }
    .dashboard-hero { padding: 18px 16px; }
    .dashboard-hero h2 { font-size: 17px; }
    .quick-actions { grid-template-columns: repeat(3, 1fr); }
}
@media (max-width: 400px) {
    .stats-grid { grid-template-columns: 1fr; }
}
