/* ============================================================
   Apex Admin Panel - Custom Styles
   ============================================================ */

:root {
    --sidebar-bg:      #1a2236;
    --sidebar-hover:   #243047;
    --sidebar-active:  #2d6cdf;
    --sidebar-text:    #a8b4cc;
    --sidebar-width:   250px;
    --topbar-height:   60px;
    --content-bg:      #f0f2f7;
    --card-shadow:     0 1px 4px rgba(0,0,0,.08);
    --primary:         #2d6cdf;
    --success:         #1db87e;
    --danger:          #e54b4b;
    --warning:         #f4a124;
    --info:            #17a2b8;
}

/* ---------- Reset / Base ---------- */
*, *::before, *::after { box-sizing: border-box; }

body {
    margin: 0;
    font-family: 'Segoe UI', system-ui, -apple-system, sans-serif;
    font-size: 14px;
    background: var(--content-bg);
    color: #333;
}

/* ---------- Layout ---------- */
#wrapper {
    display: flex;
    min-height: 100vh;
}

/* ---------- Sidebar ---------- */
#sidebar {
    width: var(--sidebar-width);
    height: 100vh;
    background: var(--sidebar-bg);
    position: fixed;
    top: 0; left: 0;
    display: flex;
    flex-direction: column;
    z-index: 1050;
    transition: transform .25s ease;
    overflow: hidden;
}

.sidebar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 18px 20px;
    border-bottom: 1px solid rgba(255,255,255,.08);
    text-decoration: none;
}

.sidebar-brand img { height: 32px; width: auto; }

.sidebar-brand-text {
    font-size: 18px;
    font-weight: 700;
    color: #fff;
    letter-spacing: .5px;
}

.sidebar-brand-text span {
    display: block;
    font-size: 10px;
    font-weight: 400;
    color: var(--sidebar-text);
    letter-spacing: 1px;
    text-transform: uppercase;
    margin-top: 1px;
}

.sidebar-nav {
    flex: 1;
    padding: 12px 0 4px;
    overflow-y: auto;
    overflow-x: hidden;
}

/* Thin scrollbar inside sidebar */
.sidebar-nav::-webkit-scrollbar { width: 4px; }
.sidebar-nav::-webkit-scrollbar-track { background: transparent; }
.sidebar-nav::-webkit-scrollbar-thumb {
    background: rgba(255,255,255,.18);
    border-radius: 2px;
}

.sidebar-section {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px 4px 20px;
    font-size: 10px;
    font-weight: 600;
    letter-spacing: 1.2px;
    text-transform: uppercase;
    color: rgba(168,180,204,.5);
    cursor: pointer;
    user-select: none;
}

.sidebar-section:hover { color: rgba(168,180,204,.75); }

.sidebar-chevron {
    font-size: 9px;
    transition: transform .2s ease;
    flex-shrink: 0;
}

.sidebar-section.collapsed .sidebar-chevron {
    transform: rotate(-90deg);
}

.sidebar-nav a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
    border-left: 3px solid transparent;
}

.sidebar-nav a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

.sidebar-nav a.active {
    background: rgba(45,108,223,.18);
    color: #fff;
    border-left-color: var(--sidebar-active);
}

.sidebar-nav a i {
    width: 18px;
    text-align: center;
    font-size: 14px;
    flex-shrink: 0;
}

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

.sidebar-footer a {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 9px 20px;
    color: var(--sidebar-text);
    text-decoration: none;
    font-size: 13.5px;
    transition: background .15s, color .15s;
}

.sidebar-footer a:hover {
    background: var(--sidebar-hover);
    color: #fff;
}

/* Collapsible nav group */
.sidebar-group {
    overflow: hidden;
    transition: max-height .22s ease, opacity .22s ease;
    max-height: 600px;    /* large enough for any section */
    opacity: 1;
}

.sidebar-group.nav-collapsed {
    max-height: 0 !important;
    opacity: 0;
}

/* ---------- Main Content ---------- */
#main-content {
    margin-left: var(--sidebar-width);
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* ---------- Topbar ---------- */
.topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e4e8ef;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    position: sticky;
    top: 0;
    z-index: 900;
    box-shadow: 0 1px 3px rgba(0,0,0,.06);
}

.topbar-left h5 {
    margin: 0;
    font-size: 16px;
    font-weight: 600;
    color: #1a2236;
}

.topbar-left p {
    margin: 0;
    font-size: 12px;
    color: #8a94a8;
}

.topbar-right {
    display: flex;
    align-items: center;
    gap: 16px;
}

/* Notification bell */
.notif-btn {
    position: relative;
    background: none;
    border: none;
    color: #64748b;
    font-size: 18px;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 6px;
    transition: background .15s;
}

.notif-btn:hover { background: #f0f2f7; color: var(--primary); }

.notif-badge {
    position: absolute;
    top: 0; right: 0;
    background: var(--danger);
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    min-width: 16px;
    height: 16px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 3px;
}

/* User info chip */
.user-chip {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 4px 10px 4px 4px;
    border-radius: 20px;
    cursor: pointer;
    text-decoration: none;
    color: #333;
    transition: background .15s;
}

.user-chip:hover { background: #f0f2f7; }

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

.user-name {
    font-size: 13px;
    font-weight: 500;
    color: #1a2236;
}

.user-role {
    font-size: 11px;
    color: #8a94a8;
}

/* ---------- Page Content ---------- */
.page-content {
    padding: 24px;
    flex: 1;
}

/* ---------- Page Header ---------- */
.page-header {
    margin-bottom: 22px;
}

.page-header h2 {
    font-size: 20px;
    font-weight: 700;
    color: #1a2236;
    margin: 0 0 4px;
}

.page-header p {
    margin: 0;
    color: #8a94a8;
    font-size: 13px;
}

/* ---------- Cards ---------- */
.card {
    border: none;
    border-radius: 10px;
    box-shadow: var(--card-shadow);
}

.card-header {
    background: #fff;
    border-bottom: 1px solid #f0f2f7;
    border-radius: 10px 10px 0 0 !important;
    padding: 14px 18px;
    font-weight: 600;
    font-size: 14px;
    color: #1a2236;
}

.card-body { padding: 18px; }

/* ---------- Stat Cards ---------- */
.stat-card {
    background: #fff;
    border-radius: 10px;
    padding: 20px;
    box-shadow: var(--card-shadow);
    display: flex;
    align-items: center;
    gap: 16px;
}

.stat-icon {
    width: 48px;
    height: 48px;
    border-radius: 10px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
}

.stat-icon.primary { background: rgba(45,108,223,.12); color: var(--primary); }
.stat-icon.success { background: rgba(29,184,126,.12); color: var(--success); }
.stat-icon.danger  { background: rgba(229,75,75,.12);  color: var(--danger); }
.stat-icon.warning { background: rgba(244,161,36,.12); color: var(--warning); }
.stat-icon.info    { background: rgba(23,162,184,.12); color: var(--info); }

.stat-value {
    font-size: 26px;
    font-weight: 700;
    color: #1a2236;
    line-height: 1;
    margin-bottom: 4px;
}

.stat-label {
    font-size: 12px;
    color: #8a94a8;
    font-weight: 500;
}

/* ---------- Tables ---------- */
.table { font-size: 13.5px; margin: 0; }
.table th {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: .6px;
    text-transform: uppercase;
    color: #8a94a8;
    background: #f8f9fc;
    border-bottom: 1px solid #e9ecef;
    padding: 10px 14px;
}
.table td { padding: 11px 14px; vertical-align: middle; }
.table tbody tr:hover { background: #f8f9fc; }

/* ---------- Badges / Status ---------- */
.badge-status {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 20px;
    font-size: 11.5px;
    font-weight: 600;
}

.badge-status.pending          { background: #fff3cd; color: #856404; }
.badge-status.active           { background: #d1f5e8; color: #0c6641; }
.badge-status.inactive         { background: #e9ecef; color: #495057; }
.badge-status.pending_transfer { background: #cce5ff; color: #004085; }
.badge-status.banned           { background: #f8d7da; color: #721c24; }
.badge-status.disabled         { background: #e9ecef; color: #495057; }
.badge-status.refunded         { background: #d4edda; color: #155724; }
.badge-status.valid            { background: #d1f5e8; color: #0c6641; }
.badge-status.invalid          { background: #f8d7da; color: #721c24; }
.badge-status.duplicate        { background: #fff3cd; color: #856404; }
.badge-status.sent             { background: #d4edda; color: #155724; }
.badge-status.approved         { background: #d1f5e8; color: #0c6641; }
.badge-status.rejected         { background: #f8d7da; color: #721c24; }
.badge-status.completed        { background: #cce5ff; color: #004085; }
.badge-status.processing       { background: #cce5ff; color: #004085; }
.badge-status.refunded         { background: #d4edda; color: #155724; }

/* ---------- Topup Days Mini Bars ---------- */
.topup-days { display: flex; gap: 3px; }
.topup-day  {
    width: 28px;
    height: 28px;
    border-radius: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    font-weight: 600;
    background: #e9ecef;
    color: #8a94a8;
    cursor: default;
}
.topup-day.has-topup { background: #d1f5e8; color: #0c6641; }
.topup-day.today     { border: 2px solid var(--primary); }

/* ---------- Timeline ---------- */
.timeline { position: relative; padding-left: 28px; }
.timeline::before {
    content: '';
    position: absolute;
    left: 8px; top: 0; bottom: 0;
    width: 2px;
    background: #e4e8ef;
}

.timeline-item {
    position: relative;
    margin-bottom: 20px;
}

.timeline-dot {
    position: absolute;
    left: -24px;
    top: 3px;
    width: 14px;
    height: 14px;
    border-radius: 50%;
    background: var(--primary);
    border: 2px solid #fff;
    box-shadow: 0 0 0 2px var(--primary);
}

.timeline-dot.success { background: var(--success); box-shadow: 0 0 0 2px var(--success); }
.timeline-dot.warning { background: var(--warning); box-shadow: 0 0 0 2px var(--warning); }
.timeline-dot.danger  { background: var(--danger);  box-shadow: 0 0 0 2px var(--danger); }

.timeline-time {
    font-size: 11px;
    color: #8a94a8;
    margin-bottom: 2px;
}

.timeline-desc {
    font-size: 13.5px;
    color: #333;
}

/* ---------- Login Page ---------- */
.login-page {
    min-height: 100vh;
    background: linear-gradient(135deg, #1a2236 0%, #2d6cdf 100%);
    display: flex;
    align-items: center;
    justify-content: center;
}

.login-card {
    background: #fff;
    border-radius: 14px;
    padding: 40px;
    width: 380px;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
}

.login-logo {
    text-align: center;
    margin-bottom: 28px;
}

.login-logo img { height: 40px; margin-bottom: 12px; }

.login-logo h4 {
    margin: 0;
    font-size: 22px;
    font-weight: 700;
    color: #1a2236;
}

.login-logo p {
    margin: 4px 0 0;
    font-size: 13px;
    color: #8a94a8;
}

/* ---------- Forms ---------- */
.form-label {
    font-size: 13px;
    font-weight: 600;
    color: #374151;
    margin-bottom: 5px;
}

.form-control, .form-select {
    border: 1px solid #d1d5db;
    border-radius: 7px;
    padding: 8px 12px;
    font-size: 13.5px;
    transition: border-color .15s, box-shadow .15s;
}

.form-control:focus, .form-select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(45,108,223,.12);
}

.btn-primary {
    background: var(--primary);
    border-color: var(--primary);
}

.btn-primary:hover {
    background: #1e59cc;
    border-color: #1e59cc;
}

/* ---------- Alerts (flash messages) ---------- */
.alert {
    border: none;
    border-radius: 8px;
    font-size: 13.5px;
}

/* ---------- Action buttons ---------- */
.btn-xs {
    padding: 3px 8px;
    font-size: 11.5px;
    border-radius: 5px;
}

/* ---------- Notification dropdown ---------- */
.notif-dropdown {
    width: 320px;
    max-height: 400px;
    overflow-y: auto;
    border: none;
    border-radius: 10px;
    box-shadow: 0 8px 30px rgba(0,0,0,.15);
    padding: 0;
}

.notif-header {
    padding: 12px 16px;
    font-weight: 600;
    font-size: 13px;
    border-bottom: 1px solid #f0f2f7;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.notif-item {
    padding: 12px 16px;
    border-bottom: 1px solid #f8f9fc;
    cursor: pointer;
    transition: background .1s;
}

.notif-item:hover { background: #f8f9fc; }
.notif-item.unread { background: #f0f6ff; }
.notif-item p { margin: 0; font-size: 13px; color: #374151; }
.notif-item small { color: #8a94a8; font-size: 11px; }

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

    #sidebar.open {
        transform: translateX(0);
    }

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