/* ═══════════════════════════════════════════════════════════════════════
   ADMIN SHELL — Shared styles for all XI Royale admin pages
   css/admin-shell.css   v1.0
   ═══════════════════════════════════════════════════════════════════════ */

/* ── Imports ─────────────────────────────────────────────────────────── */
@import url('https://fonts.googleapis.com/css2?family=Outfit:wght@300;400;600;800&family=Rajdhani:wght@600;700&display=swap');

/* ── CSS Custom Properties ───────────────────────────────────────────── */
:root {
    --primary: #00D2BE;
    --pitch: #0F172A;
    --matte-grey: #2C2C2C;
    --bg-dark: #1a1a1a;
    --card-bg: rgba(44, 44, 44, 0.9);
    --card-border: rgba(255, 255, 255, 0.08);
    --glass-bg: rgba(26, 26, 26, 0.9);
    --text-muted: rgba(255, 255, 255, 0.5);
    --sidebar-width: 256px;
    --header-height: 64px;
    --mobile-header-height: 56px;
}

/* ── Base Reset ──────────────────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: 'Outfit', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-dark);
    background-image:
        radial-gradient(circle at 0% 0%, rgba(0, 210, 190, 0.05) 0%, transparent 50%),
        radial-gradient(circle at 100% 100%, rgba(0, 210, 190, 0.05) 0%, transparent 50%),
        linear-gradient(180deg, var(--matte-grey) 0%, var(--bg-dark) 100%);
    background-attachment: fixed;
    min-height: 100vh;
    color: white;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

body::before {
    content: '';
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    width: 150px; height: 150px;
    border: 1px solid rgba(255, 255, 255, 0.03);
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
}

body::after {
    content: '';
    position: fixed;
    top: 0; left: 50%;
    transform: translateX(-50%);
    width: 1px; height: 100vh;
    background: rgba(255, 255, 255, 0.03);
    pointer-events: none;
    z-index: 0;
}

/* ── Scrollbar Hiding ────────────────────────────────────────────────── */
.no-scrollbar::-webkit-scrollbar { display: none; }
.no-scrollbar { -ms-overflow-style: none; scrollbar-width: none; }

/* ── Layout Shell ────────────────────────────────────────────────────── */
.admin-shell {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

.admin-shell > .admin-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    overflow: hidden;
    position: relative;
}

.admin-shell > .admin-main > .admin-content {
    flex: 1;
    overflow-x: hidden;
    overflow-y: auto;
    padding: 24px;
    padding-bottom: 96px;
}

/* ── Desktop Sidebar ─────────────────────────────────────────────────── */
.admin-sidebar {
    width: var(--sidebar-width);
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    z-index: 20;
    box-shadow: 10px 0 30px -10px rgba(0, 0, 0, 0.3);
    flex-shrink: 0;
    max-height: 100vh;
}

.admin-sidebar .sidebar-brand {
    height: var(--header-height);
    display: flex;
    align-items: center;
    justify-content: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

.admin-sidebar nav {
    flex: 1;
    overflow-y: auto;
    padding: 24px 0;
    min-height: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
.admin-sidebar nav::-webkit-scrollbar { display: none; }

.admin-sidebar .sidebar-footer {
    padding: 16px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    flex-shrink: 0;
}

/* Sidebar Groups */
.sidebar-group-label {
    padding: 0 24px;
    margin-bottom: 8px;
    font-size: 10px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.25);
    text-transform: uppercase;
    letter-spacing: 0.2em;
}

.sidebar-group { margin-bottom: 16px; }

/* Sidebar Links */
.sidebar-link {
    display: flex;
    align-items: center;
    gap: 16px;
    padding: 10px 24px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 600;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s ease;
    border-right: 3px solid transparent;
}

.sidebar-link:hover {
    color: var(--primary);
    background: rgba(0, 210, 190, 0.05);
}

.sidebar-link.active {
    background: rgba(0, 210, 190, 0.1);
    color: var(--primary);
    border-right-color: var(--primary);
}

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

/* Back + Logout in sidebar footer */
.sidebar-back-link {
    display: flex;
    align-items: center;
    gap: 12px;
    font-size: 12px;
    font-weight: 700;
    color: rgba(255, 255, 255, 0.4);
    text-decoration: none;
    margin-bottom: 16px;
    padding-left: 8px;
    transition: color 0.2s;
}
.sidebar-back-link:hover { color: var(--primary); }

.sidebar-logout-btn {
    width: 100%;
    padding: 10px;
    border-radius: 12px;
    background: rgba(239, 68, 68, 0.1);
    color: #f87171;
    border: 1px solid rgba(239, 68, 68, 0.2);
    font-weight: 800;
    font-size: 11px;
    letter-spacing: 0.1em;
    cursor: pointer;
    transition: background 0.2s;
}
.sidebar-logout-btn:hover { background: rgba(239, 68, 68, 0.2); }

/* ── Desktop Header ──────────────────────────────────────────────────── */
.admin-header {
    height: var(--header-height);
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 24px;
    z-index: 10;
    flex-shrink: 0;
}

.admin-header .header-title {
    font-family: 'Rajdhani', 'Outfit', sans-serif;
    font-weight: 700;
    font-size: 20px;
    color: white;
    letter-spacing: 0.05em;
}

.admin-header .header-actions {
    display: flex;
    align-items: center;
    gap: 16px;
}

.header-avatar {
    width: 40px; height: 40px;
    border-radius: 50%;
    background: rgba(0, 210, 190, 0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    border: 1px solid rgba(0, 210, 190, 0.2);
}

/* ── Premium Card ────────────────────────────────────────────────────── */
.premium-card {
    background: var(--card-bg);
    backdrop-filter: blur(12px);
    border: 1px solid var(--card-border);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.premium-card:hover {
    background: rgba(44, 44, 44, 0.95);
    border-color: rgba(0, 210, 190, 0.2);
    transform: translateY(-2px);
    box-shadow: 0 20px 40px -20px rgba(0, 0, 0, 0.6);
}

/* Non-hoverable cards (tables, static panels) */
.premium-card.static:hover {
    transform: none;
    border-color: var(--card-border);
    box-shadow: 0 10px 30px -10px rgba(0, 0, 0, 0.5);
}

.glass-panel {
    background: var(--glass-bg);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

/* ── Toast Notifications ─────────────────────────────────────────────── */
.toast {
    position: fixed;
    bottom: 20px; right: 20px;
    padding: 12px 24px;
    border-radius: 8px;
    color: white;
    font-weight: bold;
    transform: translateY(100px);
    opacity: 0;
    transition: all 0.3s;
    z-index: 1000;
}
.toast.show { transform: translateY(0); opacity: 1; }
.toast.success { background: #10B981; }
.toast.error { background: #EF4444; }

/* ── Animations ──────────────────────────────────────────────────────── */
.pulse-dot { animation: pulse 2s infinite; }

@keyframes pulse {
    0%   { box-shadow: 0 0 0 0 rgba(0, 210, 190, 0.4); }
    70%  { box-shadow: 0 0 0 6px rgba(0, 210, 190, 0); }
    100% { box-shadow: 0 0 0 0 rgba(0, 210, 190, 0); }
}

.row-fading {
    opacity: 0;
    transform: translateX(20px);
    transition: all 0.4s;
}

/* ── Segment Toggle (League Ops / Market Ops) ────────────────────────── */
.seg-toggle {
    display: flex;
    gap: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
    padding: 4px;
    border-radius: 8px;
    background: rgba(0, 0, 0, 0.2);
}
.seg-toggle button {
    padding: 4px 12px;
    font-size: 10px;
    font-weight: bold;
    border-radius: 6px;
    color: rgba(255, 255, 255, 0.4);
    border: none;
    cursor: pointer;
    background: transparent;
}
.seg-toggle button.active-auto   { background: #3B82F6; color: white; }
.seg-toggle button.active-open   { background: #10B981; color: white; }
.seg-toggle button.active-locked { background: #EF4444; color: white; }

/* ── Inline Edit Fields ──────────────────────────────────────────────── */
.inline-edit {
    background: transparent;
    border: none;
    color: white;
    border-bottom: 1px dashed rgba(255, 255, 255, 0.2);
    max-width: 150px;
}
.inline-edit:focus {
    outline: none;
    border-bottom-color: var(--primary);
    background: rgba(255, 255, 255, 0.05);
}

/* ── Color Swatch ────────────────────────────────────────────────────── */
.color-swatch {
    display: inline-block;
    width: 16px; height: 16px;
    border-radius: 4px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

/* ── Drag Handle ─────────────────────────────────────────────────────── */
.drag-handle { cursor: grab; color: rgba(255, 255, 255, 0.2); }
.sortable-ghost { opacity: 0.4; }

/* ── JSON Dump (Settlements) ─────────────────────────────────────────── */
.json-dump {
    font-family: 'Courier New', monospace;
    font-size: 0.75rem;
    color: rgba(255, 255, 255, 0.5);
    background: rgba(0, 0, 0, 0.3);
    padding: 12px;
    border-radius: 8px;
    display: none;
    margin-top: 8px;
    border: 1px solid rgba(255, 255, 255, 0.05);
    max-width: 400px;
    overflow-x: auto;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE RESPONSIVE — applies to ALL admin pages
   ═══════════════════════════════════════════════════════════════════════ */
@media (max-width: 767px) {

    /* ── Body layout ── */
    body {
        padding-top: var(--mobile-header-height) !important;
        height: auto !important;
        min-height: 100vh !important;
        overflow-x: hidden !important;
        overflow-y: auto !important;
    }

    /* ── Kill desktop sidebar + header ── */
    .admin-sidebar { display: none !important; }
    .admin-header  { display: none !important; }

    /* ── Flatten shell ── */
    .admin-shell {
        display: block !important;
        height: auto !important;
        overflow: visible !important;
    }
    .admin-shell > .admin-main {
        height: auto !important;
        overflow: visible !important;
        flex: none !important;
        width: 100% !important;
    }
    .admin-shell > .admin-main > .admin-content {
        overflow: visible !important;
        height: auto !important;
        padding: 14px 12px !important;
        padding-bottom: 90px !important;
    }

    /* ── Tables — horizontal scroll container ── */
    .overflow-x-auto { overflow-x: auto !important; -webkit-overflow-scrolling: touch; }
    table { font-size: 11px !important; min-width: 540px; }
    table th, table td {
        padding: 9px 10px !important;
        white-space: nowrap !important;
    }
    /* Tables inside cards: let card handle overflow */
    .premium-card.static { overflow: hidden !important; }

    /* ── Grid stacking ── */
    .grid-cols-4,
    [class*="grid-cols-4"],
    .grid.grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

    .grid-cols-3,
    [class*="grid-cols-3"],
    .grid.grid-cols-3 { grid-template-columns: repeat(2, 1fr) !important; }

    .grid-cols-2,
    [class*="grid-cols-2"],
    .grid.grid-cols-2 { grid-template-columns: 1fr !important; }

    /* Tailwind responsive grid helpers */
    .sm\:grid-cols-2, .md\:grid-cols-2, .lg\:grid-cols-2 { grid-template-columns: 1fr !important; }
    .sm\:grid-cols-3, .md\:grid-cols-3, .lg\:grid-cols-3 { grid-template-columns: repeat(2, 1fr) !important; }
    .sm\:grid-cols-4, .md\:grid-cols-4, .lg\:grid-cols-4 { grid-template-columns: repeat(2, 1fr) !important; }

    /* ── KPI / Stat cards ── */
    .stat-card, [class*="stat-card"] { padding: 14px !important; }

    /* Force 2-col for KPI grids specifically */
    div.grid:has(> .premium-card):has(> .premium-card ~ .premium-card ~ .premium-card) {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* ── Flex rows that should stack ── */
    .flex-wrap { gap: 8px !important; }

    /* Search + action bar stacking */
    .flex.items-center.gap-4:has(input[type="text"]),
    .flex.gap-4:has(input[type="text"]) {
        flex-direction: column !important;
        align-items: stretch !important;
    }

    /* ── Cards ── */
    .premium-card,
    div[class*="rounded-3xl"],
    div[class*="rounded-2xl"] { border-radius: 14px !important; }

    /* ── Typography ── */
    h1, h2.text-xl, h2.text-2xl, h2.text-3xl, .text-3xl, .text-2xl {
        font-size: 16px !important;
        line-height: 1.3 !important;
    }
    .text-xl { font-size: 15px !important; }
    .header-title { font-size: 14px !important; }

    /* ── Filter pills — allow wrapping ── */
    .flex.gap-2.flex-wrap,
    div[class*="filter-pill"] { flex-wrap: wrap !important; }

    /* ── Modals / Overlays ── */
    .fixed.inset-0 > div,
    [id*="modal"] > div,
    [id*="Modal"] > div {
        max-width: calc(100vw - 16px) !important;
        margin: 8px !important;
        max-height: 90vh !important;
        border-radius: 16px !important;
        overflow-y: auto !important;
    }

    /* Swal / alert dialogs */
    .swal2-popup { width: 90vw !important; padding: 20px !important; }

    /* ── Button tap targets — minimum 44px ── */
    button, a[class*="btn"], .sidebar-link, .admin-nav-link,
    input[type="button"], input[type="submit"] {
        min-height: 36px;
    }

    /* ── Page-specific table helpers ── */
    /* Users, transactions, settlements etc */
    .comp-table, #txn-table, #users-table { min-width: 480px !important; }

    /* ── Hide non-critical desktop-only columns on very small screens ── */
    @media (max-width: 400px) {
        td:nth-child(n+6), th:nth-child(n+6) { display: none !important; }
    }

    /* ── Spacing tweaks ── */
    .mb-6 { margin-bottom: 16px !important; }
    .mb-8 { margin-bottom: 20px !important; }
    .p-6  { padding: 14px !important; }
    .p-8  { padding: 16px !important; }
    .gap-6 { gap: 14px !important; }
    .gap-8 { gap: 16px !important; }

    /* ── Pagination ── */
    #pagination { flex-wrap: wrap !important; gap: 6px !important; }

    /* ── Comp Probs drawer ── */
    #detail-drawer { width: 100vw !important; }
    .info-grid     { grid-template-columns: 1fr 1fr !important; }

    /* ── Financial dashboard adjustments ── */
    .chart-area, [id*="chart"] { min-height: 200px !important; }

    /* ── Full-width inputs on mobile ── */
    input[type="text"], input[type="number"], input[type="search"],
    select, textarea {
        font-size: 16px !important; /* prevents iOS zoom */
    }

    /* ── Segment toggles ── */
    .seg-toggle { flex-wrap: wrap !important; gap: 4px !important; }
    .seg-toggle button { font-size: 10px !important; padding: 5px 10px !important; }
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE STICKY HEADER (injected by admin-nav.js)
   ═══════════════════════════════════════════════════════════════════════ */
#admin-sticky-header {
    position: fixed;
    top: 0; left: 0; right: 0;
    height: var(--mobile-header-height);
    background: rgba(20, 20, 20, 0.97);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.07);
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 12px;
    z-index: 200;
    gap: 8px;
}

#admin-sticky-header .admin-title {
    font-weight: 900;
    font-size: 13px;
    letter-spacing: 0.15em;
    color: var(--primary);
    flex: 1;
    text-align: center;
}

/* ═══════════════════════════════════════════════════════════════════════
   MOBILE DRAWER (injected by admin-nav.js)
   ═══════════════════════════════════════════════════════════════════════ */
#admin-drawer-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.75);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 300;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.25s;
}
#admin-drawer-overlay.open {
    opacity: 1;
    pointer-events: all;
}

#admin-drawer {
    position: fixed;
    top: 0; left: 0; bottom: 0;
    width: 280px;
    max-width: 85vw;
    background: #111;
    border-right: 1px solid rgba(255, 255, 255, 0.08);
    z-index: 400;
    display: flex;
    flex-direction: column;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1);
    overflow: hidden;
    max-height: 100vh;
}
#admin-drawer.open { transform: translateX(0); }

#admin-drawer-body {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 8px 8px 24px;
    min-height: 0;
    -ms-overflow-style: none;
    scrollbar-width: none;
}
#admin-drawer-body::-webkit-scrollbar { display: none; }

/* Drawer nav links */
.admin-nav-link {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    border-radius: 12px;
    color: rgba(255, 255, 255, 0.5);
    font-weight: 700;
    font-size: 13px;
    text-decoration: none;
    transition: all 0.2s;
    min-height: 44px; /* touch target */
}
.admin-nav-link:hover { color: white; background: rgba(255, 255, 255, 0.05); }
.admin-nav-link.active {
    background: rgba(0, 210, 190, 0.1);
    color: var(--primary);
    border: 1px solid rgba(0, 210, 190, 0.2);
}

/* DESKTOP: hide mobile nav */
@media (min-width: 768px) {
    body { padding-top: 0 !important; }
    #admin-sticky-header { display: none !important; }
    #admin-drawer-overlay { display: none !important; }
    #admin-drawer { display: none !important; }
}

