/* ==========================================================================
   ARABIAN SERVERS CMS — Custom Stylesheet
   Extracted & enhanced from index.html
   ========================================================================== */

/* ---- CSS Custom Properties ---- */
/* ==========================================================================
   THEME SYSTEM
   Four selectable themes. The accent ("hud") + base surfaces are driven by
   CSS variables so the whole UI — including Tailwind utility classes that are
   wired to these vars in index.html — recolors instantly.
   Default theme (gold & black) lives on :root so it applies before JS runs.
   ========================================================================== */
:root,
[data-theme="gold"] {
    /* accent */
    --hud: #d3af37;
    --hud-dim: #977e27;
    --hud-hover: #f1c95a;
    --hud-glow: rgba(211, 175, 55, .55);
    --hud-soft: rgba(211, 175, 55, .10);
    --hud-line: rgba(211, 175, 55, .30);
    --hud-contrast: #1a1408; /* text/icon color on top of accent fills */
    /* base */
    --bg: #0a0c0b;
    --bg-rgb: 10, 12, 11;
    --header-bg: rgba(10, 12, 11, .80);
    --surf: #0f1311;
    --panel-a: rgba(26, 31, 28, .92);
    --panel-b: rgba(18, 22, 20, .86);
    --line: rgba(120, 140, 120, .14);
    /* ink (text) */
    --ink-0: #e7eae3;
    --ink-1: #c5cac3;
    --ink-2: #8a9388;
    --ink-3: #5f6961;
    /* status */
    --on: #6fcf5f;
    --ct: #5b9bd5;
    --t: #d9534f;
    /* geometry / motion */
    --radius: 12px;
    --radius-sm: 8px;
    --transition-fast: .15s ease;
    --transition-smooth: .3s cubic-bezier(.4, 0, .2, 1);
    --theme-transition: background-color .35s ease, color .35s ease, border-color .35s ease;
}

/* ---- White & Blue (light theme) ---- */
[data-theme="white-blue"] {
    --hud: #2563eb;
    --hud-dim: #1d4ed8;
    --hud-hover: #3b82f6;
    --hud-glow: rgba(37, 99, 235, .45);
    --hud-soft: rgba(37, 99, 235, .10);
    --hud-line: rgba(37, 99, 235, .28);
    --hud-contrast: #ffffff;
    --bg: #f4f6fb;
    --bg-rgb: 244, 246, 251;
    --header-bg: rgba(244, 246, 251, .85);
    --surf: #ffffff;
    --panel-a: rgba(255, 255, 255, .96);
    --panel-b: rgba(248, 250, 253, .92);
    --line: rgba(30, 58, 95, .14);
    --ink-0: #0f1b2d;
    --ink-1: #243349;
    --ink-2: #475569;
    --ink-3: #7c8aa0;
    --on: #16a34a;
    --ct: #2563eb;
    --t: #dc2626;
}

/* ---- Black & Red ---- */
[data-theme="black-red"] {
    --hud: #e23b3b;
    --hud-dim: #a51f1f;
    --hud-hover: #ff5a5a;
    --hud-glow: rgba(226, 59, 59, .55);
    --hud-soft: rgba(226, 59, 59, .12);
    --hud-line: rgba(226, 59, 59, .32);
    --hud-contrast: #1a0606;
    --bg: #0a0808;
    --bg-rgb: 10, 8, 8;
    --header-bg: rgba(10, 8, 8, .80);
    --surf: #140f0f;
    --panel-a: rgba(34, 22, 22, .92);
    --panel-b: rgba(24, 16, 16, .86);
    --line: rgba(150, 110, 110, .16);
    --ink-0: #ece3e3;
    --ink-1: #cabcbc;
    --ink-2: #9a8888;
    --ink-3: #6e5a5a;
    --on: #4ade80;
    --ct: #60a5fa;
    --t: #ff4d4d;
}

/* ---- White & Red (light theme) ---- */
[data-theme="white-red"] {
    --hud: #dc2626;
    --hud-dim: #b91c1c;
    --hud-hover: #ef4444;
    --hud-glow: rgba(220, 38, 38, .40);
    --hud-soft: rgba(220, 38, 38, .09);
    --hud-line: rgba(220, 38, 38, .26);
    --hud-contrast: #ffffff;
    --bg: #faf6f6;
    --bg-rgb: 250, 246, 246;
    --header-bg: rgba(250, 246, 246, .85);
    --surf: #ffffff;
    --panel-a: rgba(255, 255, 255, .96);
    --panel-b: rgba(252, 248, 248, .92);
    --line: rgba(95, 30, 30, .14);
    --ink-0: #2a0f0f;
    --ink-1: #432020;
    --ink-2: #6b4545;
    --ink-3: #9c7a7a;
    --on: #16a34a;
    --ct: #2563eb;
    --t: #dc2626;
}

/* Smooth recolor when switching themes */
html, body, .panel, .connect-row, header, footer,
.toast, .confirm-dialog, input, .nav-link, button {
    transition: var(--theme-transition);
}

/* Theme-aware translucent header/footer backdrop */
.bg-header {
    background: var(--header-bg) !important;
}

/* ==========================================================================
   HERO LAYOUT SAFETY NET
   The slider's slides are position:absolute, so the slider container has no
   intrinsic height; combined with `h-full` inside an auto-height grid row this
   can collapse the hero panels to ~0px before/while JS and the API populate
   them. Pin explicit heights so the layout is solid no matter what.
   Scoped to the hero row only (the home view's first grid).
   ========================================================================== */
#slider-container {
    min-height: 260px;
}
#view-home > .grid:first-child > .panel {
    min-height: 260px;
}
@media (min-width: 1024px) {
    #slider-container,
    #view-home > .grid:first-child > .panel {
        min-height: 420px;
    }
}

/* ==========================================================================
   LIGHT-THEME TEXT READABILITY
   On dark themes "text-white" is correct. On light themes (white-blue,
   white-red) white headings/labels/site-name become invisible, so remap
   them to the theme's dark ink color. Elements that genuinely sit on a dark
   or colored fill (gold buttons, dark inputs, slider arrows on black) opt
   back in with .keep-white.
   ========================================================================== */
[data-theme="white-blue"] .text-white,
[data-theme="white-red"] .text-white {
    color: var(--ink-0) !important;
}
/* Hover-to-white in nav should become hover-to-dark on light themes */
[data-theme="white-blue"] .hover\:text-white:hover,
[data-theme="white-red"] .hover\:text-white:hover {
    color: var(--ink-0) !important;
}
/* Inputs / editor text stays dark-on-light automatically via --ink-0 above.
   Re-assert white where the background is intentionally dark or colored. */
[data-theme="white-blue"] .keep-white,
[data-theme="white-red"] .keep-white,
[data-theme="white-blue"] .keep-white:hover,
[data-theme="white-red"] .keep-white:hover {
    color: #fff !important;
}

/* ---- Base ---- */
html, body {
    background: var(--bg);
}

body {
    color: var(--ink-0);
    overflow-x: hidden;
    background:
        radial-gradient(1100px 600px at 85% -10%, var(--hud-soft), transparent 60%),
        radial-gradient(900px 700px at -10% 110%, rgba(var(--bg-rgb), .04), transparent 55%),
        repeating-linear-gradient(0deg, transparent 0 2px, rgba(0, 0, 0, .07) 2px 3px),
        var(--bg);
    background-attachment: fixed;
}

/* ---- Skip to Content (Accessibility) ---- */
.skip-link {
    position: absolute;
    top: -100%;
    left: 16px;
    z-index: 9999;
    padding: 10px 18px;
    background: var(--hud);
    color: var(--hud-contrast);
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    text-decoration: none;
    transition: top .2s ease;
}
.skip-link:focus {
    top: 10px;
    outline: 3px solid #fff;
    outline-offset: 2px;
}

/* ---- Scrollbar ---- */
::-webkit-scrollbar {
    width: 9px;
    height: 9px;
}
::-webkit-scrollbar-track {
    background: transparent;
}
::-webkit-scrollbar-thumb {
    background: var(--hud-dim);
    border-radius: 20px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--hud);
}

/* ---- Selection ---- */
::selection {
    background: var(--hud);
    color: var(--hud-contrast);
}

/* ---- Typography ---- */
.font-display {
    letter-spacing: .02em;
}

/* ---- Navigation Links ---- */
.nav-link {
    position: relative;
    transition: color var(--transition-fast);
}
.nav-link::after {
    content: '';
    position: absolute;
    left: 0;
    right: 0;
    bottom: -6px;
    height: 2px;
    background: var(--hud);
    transform: scaleX(0);
    transform-origin: left;
    transition: transform .25s ease;
}
.nav-link:hover::after,
.nav-link.active::after {
    transform: scaleX(1);
}
.nav-link.active {
    color: #fff;
}

/* ---- Eyebrow / Console Label ---- */
.eyebrow {
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    letter-spacing: .18em;
    text-transform: uppercase;
    color: var(--hud-dim);
}
.eyebrow::before {
    content: '> ';
    color: var(--hud);
}

/* ---- Panel ---- */
.panel {
    background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
    border: 1px solid var(--line);
    border-radius: var(--radius);
}
.panel-hot {
    border-left: 3px solid var(--hud);
}

/* ---- Slider ---- */
.slide {
    opacity: 0;
    position: absolute;
    inset: 0;
    transition: opacity .6s ease-in-out;
    pointer-events: none;
}
.slide.active {
    opacity: 1;
    pointer-events: auto;
}
.slide {
    touch-action: pan-y; /* allow vertical scroll but we handle horizontal swipe */
}

/* ---- Rich Text Editor ---- */
.editor-content {
    min-height: 150px;
    outline: none;
}
.editor-content:empty:before {
    content: attr(placeholder);
    color: var(--ink-3);
    pointer-events: none;
    display: block;
}

/* ---- Content Blocks (rendered HTML from editor) ---- */
.content-block img {
    max-width: 100%;
    border-radius: var(--radius-sm);
    margin: 10px 0;
}
.content-block a {
    color: var(--hud);
    text-decoration: underline;
    cursor: pointer;
}
.content-block a:hover {
    color: var(--hud-hover);
}

/* ---- Connect Row ---- */
.connect-row {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 10px;
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    background: var(--surf);
    border: 1px solid var(--line);
    color: var(--ink-0);
    transition: border-color var(--transition-fast), background var(--transition-fast);
}
.connect-row:hover {
    border-color: var(--hud-dim);
    background: var(--surf);
}
.connect-row .copied {
    color: var(--hud);
}

/* ---- Toast Notifications ---- */
#toast-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    z-index: 9999;
    display: flex;
    flex-direction: column;
    gap: 10px;
}
.toast {
    font-family: 'JetBrains Mono', monospace;
    font-size: 13px;
    background: var(--panel-a);
    border-left: 3px solid var(--hud);
    color: var(--ink-0);
    padding: 14px 18px;
    border-radius: var(--radius-sm);
    box-shadow: 0 12px 30px rgba(0, 0, 0, .5);
    transform: translateX(130%);
    transition: transform .35s cubic-bezier(.68, -.55, .265, 1.55);
    display: flex;
    align-items: center;
    max-width: 320px;
}
.toast.show {
    transform: translateX(0);
}

/* ---- Skeleton Loader ---- */
.skel {
    background: linear-gradient(90deg, rgba(255,255,255,.03) 25%, rgba(255,255,255,.07) 37%, rgba(255,255,255,.03) 63%);
    background-size: 400% 100%;
    animation: skel 1.4s ease infinite;
}
@keyframes skel {
    0% { background-position: 100% 50%; }
    100% { background-position: 0 50%; }
}

/* ---- Server Capacity Bar ---- */
#srv-bar {
    transition: width .7s cubic-bezier(.4, 0, .2, 1);
}
/* Pulse animation when server is nearly full */
@keyframes pulse-warning {
    0%, 100% { opacity: 1; }
    50% { opacity: .6; }
}
#srv-bar.warning {
    animation: pulse-warning 1.5s ease-in-out infinite;
}

/* ---- Player Count Animation ---- */
@keyframes count-up {
    from { opacity: .5; transform: translateY(4px); }
    to { opacity: 1; transform: translateY(0); }
}
.player-count-update {
    animation: count-up .3s ease-out;
}

/* ---- Server Status Dot Pulse (Live) ---- */
@keyframes dot-pulse {
    0%, 100% { box-shadow: 0 0 4px var(--on); }
    50% { box-shadow: 0 0 12px var(--on), 0 0 20px var(--on); }
}
.srv-dot-live {
    animation: dot-pulse 2s ease-in-out infinite;
}

/* ---- Connection Quality Indicator ---- */
.conn-quality {
    display: inline-block;
    width: 8px;
    height: 8px;
    border-radius: 50%;
    margin-right: 4px;
}
.conn-good { background: var(--on); }
.conn-medium { background: var(--hud); }
.conn-poor { background: var(--t); }

/* ==========================================================================
   VIEW TRANSITIONS
   ========================================================================== */
.page-view {
    opacity: 1;
    transition: opacity .25s ease, transform .25s ease;
}
.page-view.hidden {
    display: none !important;
}
.page-view.transitioning-out {
    opacity: 0;
    transform: translateY(8px);
}
.page-view.transitioning-in {
    opacity: 0;
    transform: translateY(8px);
}

/* ---- Server Offline Banner ---- */
.offline-banner {
    background: linear-gradient(135deg, rgba(217, 83, 79, .15), rgba(217, 83, 79, .05));
    border: 1px solid rgba(217, 83, 79, .25);
    border-radius: var(--radius-sm);
    padding: 12px 16px;
    text-align: center;
    font-family: 'JetBrains Mono', monospace;
    font-size: 11px;
    color: var(--t);
}
.offline-banner .last-seen {
    color: var(--ink-3);
    margin-top: 4px;
    font-size: 10px;
}

/* ---- Mobile Bottom Bar ---- */
@media (max-width: 1023px) {
    .mobile-bottom-bar {
        position: fixed;
        bottom: 0;
        left: 0;
        right: 0;
        z-index: 49;
        background: rgba(10, 12, 11, .95);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--line);
        display: flex;
        justify-content: space-around;
        padding: 6px 0 env(safe-area-inset-bottom, 8px) 0;
    }
    .mobile-bottom-bar button {
        display: flex;
        flex-direction: column;
        align-items: center;
        gap: 2px;
        padding: 6px 12px;
        min-width: 56px;
        min-height: 48px;
        color: var(--ink-3);
        font-size: 10px;
        font-family: 'JetBrains Mono', monospace;
        transition: color var(--transition-fast);
        background: none;
        border: none;
        cursor: pointer;
    }
    .mobile-bottom-bar button i {
        font-size: 18px;
    }
    .mobile-bottom-bar button.active {
        color: var(--hud);
    }
    /* Push main content above bottom bar */
    main {
        padding-bottom: 80px;
    }
}

/* ---- Mobile Menu Overlay ---- */
#mobile-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, .5);
    z-index: 48;
    opacity: 0;
    pointer-events: none;
    transition: opacity .25s ease;
}
#mobile-overlay.show {
    opacity: 1;
    pointer-events: auto;
}

/* ---- Admin Table Responsive ---- */
@media (max-width: 640px) {
    .admin-table-responsive {
        display: block;
        width: 100%;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .admin-table-responsive table {
        min-width: 500px;
    }
}

/* ---- Improved Touch Targets ---- */
button, 
a, 
input[type="submit"],
.nav-link {
    cursor: pointer;
}

/* ---- Image Preview (Admin Panel) ---- */
.img-preview {
    max-width: 200px;
    max-height: 120px;
    object-fit: cover;
    border-radius: var(--radius-sm);
    border: 1px solid var(--line);
    margin-top: 8px;
    display: none;
}
.img-preview.visible {
    display: block;
}
.img-preview-error {
    display: none;
    color: var(--t);
    font-size: 11px;
    font-family: 'JetBrains Mono', monospace;
    margin-top: 4px;
}

/* ---- Confirm Dialog (Custom) ---- */
.confirm-overlay {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0,0,0,.6);
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(2px);
}
.confirm-dialog {
    background: linear-gradient(180deg, var(--panel-a), var(--panel-b));
    border: 1px solid var(--line);
    border-radius: var(--radius);
    padding: 24px;
    max-width: 400px;
    width: 90%;
    box-shadow: 0 20px 50px rgba(0,0,0,.6);
}
.confirm-dialog h3 {
    font-family: 'Rajdhani', sans-serif;
    font-weight: 700;
    font-size: 18px;
    margin-bottom: 8px;
    color: #fff;
}
.confirm-dialog p {
    color: var(--ink-2);
    font-size: 14px;
    margin-bottom: 20px;
    line-height: 1.5;
}
.confirm-dialog .btn-row {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

/* ---- Live Region (Screen Reader) ---- */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border-width: 0;
}

/* ---- Reduced Motion ---- */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: .001ms !important;
        transition-duration: .001ms !important;
    }
}

/* ---- Visible Focus Ring ---- */
a:focus-visible,
button:focus-visible,
input:focus-visible,
[contenteditable]:focus-visible {
    outline: 2px solid var(--hud);
    outline-offset: 2px;
    border-radius: 4px;
}

/* ---- Print Styles ---- */
@media print {
    body {
        background: #fff !important;
        color: #000 !important;
    }
    header, footer, #toast-container, .mobile-bottom-bar, #mobile-overlay,
    .skip-link, .connect-row, #srv-connect {
        display: none !important;
    }
    .panel {
        border: 1px solid #ccc;
        background: #fff;
        box-shadow: none;
    }
    .page-view.hidden {
        display: block !important;
    }
    a { color: #000; text-decoration: underline; }
}

/* ==========================================================================
   THEME PICKER UI
   ========================================================================== */
.theme-picker-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    padding: 12px;
}
.theme-option {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 12px;
    min-height: 48px;
    border-radius: var(--radius-sm);
    background: var(--surf);
    border: 1px solid var(--line);
    color: var(--ink-1);
    font-family: 'JetBrains Mono', monospace;
    font-size: 12px;
    text-align: left;
    cursor: pointer;
    -webkit-tap-highlight-color: transparent;
    transition: border-color var(--transition-fast), color var(--transition-fast), background var(--transition-fast);
}
.theme-option:hover,
.theme-option:active {
    border-color: var(--hud-dim);
    color: var(--ink-0);
}
.theme-option.active {
    border-color: var(--hud);
    color: var(--hud);
    background: var(--hud-soft);
}
.theme-swatch {
    width: 22px;
    height: 22px;
    border-radius: 50%;
    flex-shrink: 0;
    border: 1px solid var(--line);
}
.theme-option-label {
    line-height: 1.2;
}

/* On phones, give the picker one column with comfortable tap targets */
@media (max-width: 1023px) {
    .theme-picker-grid {
        grid-template-columns: 1fr 1fr;
        gap: 10px;
        padding: 8px 4px 4px;
    }
    .theme-option {
        min-height: 52px;
    }
}
