/* ========================================
   Affiliate Portal — Main Styles
   ======================================== */

:root {
    --portal-primary: #4f46e5;
    --portal-primary-light: #6366f1;
    --portal-primary-dark: #3730a3;
    --portal-secondary: #10b981;
    --portal-accent: #f59e0b;
    --portal-bg: #f1f5f9;
    --portal-card-bg: #ffffff;
    --portal-text: #1e293b;
    --portal-text-muted: #64748b;
    --portal-border: #e2e8f0;
    --portal-sidebar-bg: #1e1b4b;
    --portal-sidebar-text: #c7d2fe;
    --portal-sidebar-active: #4f46e5;
    --portal-sidebar-width: 260px;
    --portal-topbar-height: 60px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    background: var(--portal-bg);
    color: var(--portal-text);
    min-height: 100vh;
}

/* ---- Sidebar ---- */
.sidebar {
    position: fixed;
    left: 0;
    top: 0;
    width: var(--portal-sidebar-width);
    height: 100vh;
    background: var(--portal-sidebar-bg);
    color: var(--portal-sidebar-text);
    display: flex;
    flex-direction: column;
    z-index: 1000;
    transition: transform 0.3s ease;
    overflow-y: auto;
}

.sidebar-brand {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid rgba(255,255,255,0.08);
}

.sidebar-brand h4 {
    color: #fff;
    font-size: 1.1rem;
    font-weight: 700;
    margin: 0;
}

.sidebar-brand small {
    color: var(--portal-sidebar-text);
    font-size: 0.75rem;
    opacity: 0.7;
}

.sidebar-nav {
    flex: 1;
    padding: 0.75rem 0;
}

.sidebar-label {
    display: block;
    padding: 0.75rem 1.5rem 0.25rem;
    font-size: 0.65rem;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: rgba(255,255,255,0.35);
    font-weight: 600;
}

.sidebar-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 1.5rem;
    color: var(--portal-sidebar-text);
    text-decoration: none;
    font-size: 0.875rem;
    transition: all 0.15s ease;
    border-left: 3px solid transparent;
}

.sidebar-link:hover {
    background: rgba(255,255,255,0.06);
    color: #fff;
}

.sidebar-link.active {
    background: rgba(79, 70, 229, 0.2);
    color: #fff;
    border-left-color: var(--portal-sidebar-active);
}

.sidebar-link i {
    font-size: 1.1rem;
    width: 20px;
    text-align: center;
}

.sidebar-footer {
    padding: 0.75rem 0;
    border-top: 1px solid rgba(255,255,255,0.08);
}

/* ---- Main Content ---- */
.main-content {
    margin-left: var(--portal-sidebar-width);
    min-height: 100vh;
}

/* ---- Top Bar ---- */
.top-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 1.5rem;
    height: var(--portal-topbar-height);
    background: var(--portal-card-bg);
    border-bottom: 1px solid var(--portal-border);
    position: sticky;
    top: 0;
    z-index: 100;
}

.top-bar h5 {
    font-weight: 600;
}

.avatar-sm {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: var(--portal-primary);
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    font-size: 0.875rem;
}

/* ---- Content Wrapper ---- */
.content-wrapper {
    padding: 1.5rem;
}

/* ---- Stat Cards ---- */
.stat-card {
    background: var(--portal-card-bg);
    border-radius: 0.75rem;
    padding: 1.25rem;
    border: 1px solid var(--portal-border);
    transition: box-shadow 0.2s ease;
}

.stat-card:hover {
    box-shadow: 0 4px 12px rgba(0,0,0,0.06);
}

.stat-card .stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.25rem;
}

.stat-card .stat-icon.blue   { background: #dbeafe; color: #2563eb; }
.stat-card .stat-icon.green  { background: #d1fae5; color: #059669; }
.stat-card .stat-icon.purple { background: #e0e7ff; color: #4f46e5; }
.stat-card .stat-icon.amber  { background: #fef3c7; color: #d97706; }
.stat-card .stat-icon.red    { background: #fee2e2; color: #dc2626; }

.stat-card .stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1.2;
}

.stat-card .stat-label {
    font-size: 0.8rem;
    color: var(--portal-text-muted);
    font-weight: 500;
}

/* ---- Cards ---- */
.portal-card {
    background: var(--portal-card-bg);
    border-radius: 0.75rem;
    border: 1px solid var(--portal-border);
    overflow: hidden;
}

.portal-card-header {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--portal-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.portal-card-header h6 {
    font-weight: 600;
    margin: 0;
}

.portal-card-body {
    padding: 1.25rem;
}

/* ---- Tables ---- */
.portal-table {
    width: 100%;
    font-size: 0.875rem;
}

.portal-table thead th {
    background: #f8fafc;
    padding: 0.75rem 1rem;
    font-weight: 600;
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--portal-text-muted);
    border-bottom: 2px solid var(--portal-border);
}

.portal-table tbody td {
    padding: 0.75rem 1rem;
    border-bottom: 1px solid var(--portal-border);
    vertical-align: middle;
}

.portal-table tbody tr:hover {
    background: #f8fafc;
}

/* ---- Badges ---- */
.badge-status {
    padding: 0.3em 0.7em;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.badge-active    { background: #d1fae5; color: #065f46; }
.badge-pending   { background: #fef3c7; color: #92400e; }
.badge-approved  { background: #dbeafe; color: #1e40af; }
.badge-rejected  { background: #fee2e2; color: #991b1b; }
.badge-paid      { background: #d1fae5; color: #065f46; }
.badge-suspended { background: #fce7f3; color: #9d174d; }

/* ---- Tracking URL Box ---- */
.tracking-url-box {
    background: #f8fafc;
    border: 1px solid var(--portal-border);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-family: monospace;
    font-size: 0.8rem;
    word-break: break-all;
}

.tracking-url-box .copy-btn {
    flex-shrink: 0;
}

/* ---- Mobile Toggle ---- */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 12px;
    left: 12px;
    z-index: 1100;
    border: none;
    background: var(--portal-primary);
    color: #fff;
    width: 40px;
    height: 40px;
    border-radius: 8px;
    font-size: 1.2rem;
    cursor: pointer;
}

/* ---- Empty State ---- */
.empty-state {
    text-align: center;
    padding: 3rem 1rem;
    color: var(--portal-text-muted);
}

.empty-state i {
    font-size: 3rem;
    margin-bottom: 1rem;
    opacity: 0.5;
}

/* ---- Responsive ---- */
@media (max-width: 991.98px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.show {
        transform: translateX(0);
    }

    .mobile-toggle {
        display: flex;
        align-items: center;
        justify-content: center;
    }

    .main-content {
        margin-left: 0;
    }

    .top-bar {
        padding-left: 3.5rem;
    }
}

@media (max-width: 575.98px) {
    .content-wrapper {
        padding: 1rem;
    }

    .stat-card .stat-value {
        font-size: 1.25rem;
    }
}

/* ============================================
   Dark Mode
   ============================================ */
[data-bs-theme="dark"] {
    --portal-primary: #6366f1;
    --portal-primary-light: #818cf8;
    --portal-primary-dark: #4338ca;
    --portal-bg: #0a0d1a;
    --portal-card-bg: #141728;
    --portal-text: #e4e7ed;
    --portal-text-muted: #8b92a8;
    --portal-border: #252840;
    --portal-sidebar-bg: #0a0824;
    --portal-sidebar-text: #a5b4fc;
    --portal-sidebar-active: #6366f1;
}

[data-bs-theme="dark"] .table {
    --bs-table-bg: var(--portal-card-bg);
    --bs-table-color: var(--portal-text);
    --bs-table-border-color: var(--portal-border);
    --bs-table-striped-bg: rgba(255,255,255,0.03);
    --bs-table-hover-bg: rgba(255,255,255,0.05);
}

[data-bs-theme="dark"] .top-bar {
    background: var(--portal-card-bg);
    border-bottom-color: var(--portal-border);
}

[data-bs-theme="dark"] .stat-card {
    background: var(--portal-card-bg);
    border-color: var(--portal-border);
}

[data-bs-theme="dark"] .form-control,
[data-bs-theme="dark"] .form-select {
    background-color: #0a0d1a;
    border-color: var(--portal-border);
    color: var(--portal-text);
}

[data-bs-theme="dark"] .form-control:focus,
[data-bs-theme="dark"] .form-select:focus {
    background-color: #0a0d1a;
    border-color: var(--portal-primary);
    color: var(--portal-text);
}

[data-bs-theme="dark"] .card {
    background: var(--portal-card-bg);
    border-color: var(--portal-border);
}

[data-bs-theme="dark"] .dropdown-menu {
    background-color: var(--portal-card-bg);
    border-color: var(--portal-border);
}

[data-bs-theme="dark"] .dropdown-item {
    color: var(--portal-text);
}

[data-bs-theme="dark"] .dropdown-item:hover {
    background-color: rgba(99,102,241,0.15);
}

[data-bs-theme="dark"] .modal-content {
    background-color: var(--portal-card-bg);
    border-color: var(--portal-border);
}

[data-bs-theme="dark"] .btn-outline-secondary {
    color: var(--portal-text-muted);
    border-color: var(--portal-border);
}

/* ============================================
   High Contrast Mode
   ============================================ */
[data-bs-theme="high-contrast"] {
    --portal-primary: #7c7cff;
    --portal-primary-light: #9999ff;
    --portal-primary-dark: #4444ff;
    --portal-bg: #000000;
    --portal-card-bg: #000000;
    --portal-text: #ffffff;
    --portal-text-muted: #00ffff;
    --portal-border: #ffffff;
    --portal-sidebar-bg: #000000;
    --portal-sidebar-text: #ffffff;
    --portal-sidebar-active: #4444ff;
}

[data-bs-theme="high-contrast"] .card { border-width: 2px; }
[data-bs-theme="high-contrast"] .stat-card { border-width: 2px; }

[data-bs-theme="high-contrast"] .top-bar {
    background: #000000;
    border-bottom: 2px solid #ffffff;
}

[data-bs-theme="high-contrast"] .table {
    --bs-table-bg: #000000;
    --bs-table-color: #ffffff;
    --bs-table-border-color: #ffffff;
}

[data-bs-theme="high-contrast"] .form-control,
[data-bs-theme="high-contrast"] .form-select {
    background-color: #000000;
    border: 2px solid #ffffff;
    color: #ffffff;
}

[data-bs-theme="high-contrast"] .form-control:focus,
[data-bs-theme="high-contrast"] .form-select:focus {
    border-color: #ffff00;
    box-shadow: 0 0 0 2px #ffff00;
}

[data-bs-theme="high-contrast"] .btn-primary {
    background-color: #4444ff;
    border: 2px solid #ffffff;
    color: #ffffff;
}

[data-bs-theme="high-contrast"] .btn-outline-secondary {
    border: 2px solid #ffffff;
    color: #ffffff;
}

[data-bs-theme="high-contrast"] .dropdown-menu {
    background-color: #000000;
    border: 2px solid #ffffff;
}

[data-bs-theme="high-contrast"] .dropdown-item { color: #ffffff; }
[data-bs-theme="high-contrast"] .dropdown-item:hover,
[data-bs-theme="high-contrast"] .dropdown-item.active {
    background-color: #4444ff;
    color: #ffff00;
}

[data-bs-theme="high-contrast"] .modal-content {
    background-color: #000000;
    border: 2px solid #ffffff;
}

[data-bs-theme="high-contrast"] .sidebar { border-right: 2px solid #ffffff; }
[data-bs-theme="high-contrast"] a { color: #7c7cff; text-decoration: underline; }
[data-bs-theme="high-contrast"] .sidebar a { text-decoration: none; }

/* Theme toggle active indicator */
.theme-option.active { font-weight: 600; }
.theme-option.active::before {
    content: "";
    display: inline-block;
    width: 6px; height: 6px; border-radius: 50%;
    background: var(--portal-primary, #4f46e5);
    margin-right: 6px; vertical-align: middle;
}
