/* ==============================================================================
   Arr Public Hub - Minimal Services Dashboard
   Seamless Auto Light/Dark Theme & Full Viewport Presence
   ============================================================================== */

/* ------------------------------------------------------------------------------
   1. Theme Variables: Dark & Light Adaptation
   ------------------------------------------------------------------------------ */

/* Default / Dark Theme Tokens */
:root,
:root[data-theme="dark"] {
    --bg-canvas: #06090f;
    --bg-canvas-subtle: #0c121e;
    --bg-card: rgba(15, 23, 42, 0.72);
    --bg-card-hover: rgba(22, 33, 58, 0.9);
    --bg-card-elevated: #111a2c;
    --bg-pill: rgba(30, 41, 59, 0.75);
    --bg-pill-hover: rgba(51, 65, 85, 0.85);

    --border-card: rgba(255, 255, 255, 0.09);
    --border-card-hover: rgba(56, 189, 248, 0.5);
    --border-subtle: rgba(255, 255, 255, 0.09);

    --text-primary: #f8fafc;
    --text-secondary: #cbd5e1;
    --text-muted: #94a3b8;
    --text-dim: #64748b;

    --title-gradient: linear-gradient(180deg, #ffffff 40%, #cbd5e1 100%);

    --accent-cyan: #38bdf8;
    --accent-cyan-light: rgba(56, 189, 248, 0.15);
    --accent-cyan-glow: rgba(56, 189, 248, 0.28);

    --status-online: #34d399;
    --status-online-bg: rgba(52, 211, 153, 0.14);
    --status-offline: #f87171;
    --status-offline-bg: rgba(248, 113, 113, 0.14);
    --status-warn: #fbbf24;

    --card-shadow: 0 8px 32px -4px rgba(0, 0, 0, 0.5);
    --card-shadow-hover: 0 24px 56px -6px rgba(0, 0, 0, 0.75), 0 0 36px -2px rgba(56, 189, 248, 0.2);

    --ambient-1: rgba(14, 165, 233, 0.14);
    --ambient-2: rgba(147, 51, 234, 0.12);
}

/* Light Theme Tokens */
:root[data-theme="light"] {
    --bg-canvas: #f6f8fb;
    --bg-canvas-subtle: #edf2f7;
    --bg-card: rgba(255, 255, 255, 0.85);
    --bg-card-hover: rgba(255, 255, 255, 0.98);
    --bg-card-elevated: #ffffff;
    --bg-pill: #eef2f6;
    --bg-pill-hover: #e2e8f0;

    --border-card: rgba(226, 232, 240, 0.9);
    --border-card-hover: rgba(14, 165, 233, 0.5);
    --border-subtle: rgba(226, 232, 240, 0.75);

    --text-primary: #0f172a;
    --text-secondary: #475569;
    --text-muted: #64748b;
    --text-dim: #94a3b8;

    --title-gradient: linear-gradient(180deg, #0f172a 30%, #334155 100%);

    --accent-cyan: #0284c7;
    --accent-cyan-light: #e0f2fe;
    --accent-cyan-glow: rgba(2, 132, 199, 0.15);

    --status-online: #10b981;
    --status-online-bg: rgba(16, 185, 129, 0.12);
    --status-offline: #ef4444;
    --status-offline-bg: rgba(239, 68, 68, 0.12);
    --status-warn: #f59e0b;

    --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
    --card-shadow-hover: 0 16px 36px -4px rgba(14, 165, 233, 0.16);

    --ambient-1: rgba(2, 132, 199, 0.08);
    --ambient-2: rgba(168, 85, 247, 0.06);
}

/* Automatic CSS Fallback when no explicit data-theme attribute is set */
@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) {
        --bg-canvas: #f6f8fb;
        --bg-canvas-subtle: #edf2f7;
        --bg-card: rgba(255, 255, 255, 0.85);
        --bg-card-hover: rgba(255, 255, 255, 0.98);
        --bg-card-elevated: #ffffff;
        --bg-pill: #eef2f6;
        --bg-pill-hover: #e2e8f0;

        --border-card: rgba(226, 232, 240, 0.9);
        --border-card-hover: rgba(14, 165, 233, 0.5);
        --border-subtle: rgba(226, 232, 240, 0.75);

        --text-primary: #0f172a;
        --text-secondary: #475569;
        --text-muted: #64748b;
        --text-dim: #94a3b8;

        --title-gradient: linear-gradient(180deg, #0f172a 30%, #334155 100%);

        --accent-cyan: #0284c7;
        --accent-cyan-light: #e0f2fe;
        --accent-cyan-glow: rgba(2, 132, 199, 0.15);

        --status-online: #10b981;
        --status-online-bg: rgba(16, 185, 129, 0.12);
        --status-offline: #ef4444;
        --status-offline-bg: rgba(239, 68, 68, 0.12);
        --status-warn: #f59e0b;

        --card-shadow: 0 4px 20px -2px rgba(15, 23, 42, 0.06), 0 2px 6px -1px rgba(15, 23, 42, 0.04);
        --card-shadow-hover: 0 16px 36px -4px rgba(14, 165, 233, 0.16);

        --ambient-1: rgba(2, 132, 199, 0.08);
        --ambient-2: rgba(168, 85, 247, 0.06);
    }
}

/* ------------------------------------------------------------------------------
   2. Reset & Full-Height Viewport Foundation
   ------------------------------------------------------------------------------ */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    height: 100%;
}

body {
    min-height: 100%;
    min-height: 100vh;
    min-height: 100dvh;
    background-color: var(--bg-canvas);
    color: var(--text-primary);
    font-family: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
    overflow-x: hidden;
    position: relative;
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Ambient Radial Glows */
.ambient-glow {
    position: fixed;
    border-radius: 50%;
    pointer-events: none;
    z-index: 0;
    filter: blur(140px);
}
.glow-1 {
    width: 650px;
    height: 550px;
    background: var(--ambient-1);
    top: -150px;
    left: -100px;
}
.glow-2 {
    width: 700px;
    height: 600px;
    background: var(--ambient-2);
    bottom: -150px;
    right: -100px;
}

/* ------------------------------------------------------------------------------
   3. Discreet Floating Theme Switcher
   ------------------------------------------------------------------------------ */
.theme-switch-btn {
    position: fixed;
    top: 1.5rem;
    right: 1.5rem;
    z-index: 100;
    background: var(--bg-card);
    border: 1px solid var(--border-card);
    color: var(--text-muted);
    border-radius: 50%;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: var(--card-shadow);
    transition: all 0.25s ease;
}

.theme-switch-btn:hover {
    color: var(--text-primary);
    border-color: var(--border-card-hover);
    transform: scale(1.08);
}

.theme-switch-btn svg {
    width: 18px;
    height: 18px;
}

/* Icon visibility depending on current applied theme */
:root[data-theme="dark"] .icon-moon,
:root:not([data-theme="light"]) .icon-moon {
    display: block;
}
:root[data-theme="dark"] .icon-sun,
:root:not([data-theme="light"]) .icon-sun {
    display: none;
}

:root[data-theme="light"] .icon-moon {
    display: none;
}
:root[data-theme="light"] .icon-sun {
    display: block;
}

@media (prefers-color-scheme: light) {
    :root:not([data-theme="dark"]) .icon-moon {
        display: none;
    }
    :root:not([data-theme="dark"]) .icon-sun {
        display: block;
    }
}

/* ------------------------------------------------------------------------------
   4. Centered Layout Container
   ------------------------------------------------------------------------------ */
.hub-wrapper {
    width: 100%;
    max-width: 960px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 3rem;
    margin: auto 0;
    position: relative;
    z-index: 1;
}

/* ------------------------------------------------------------------------------
   5. Text Header
   ------------------------------------------------------------------------------ */
.hub-header {
    text-align: center;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    padding: 0 1rem;
}

.host-badge {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.35rem 0.95rem;
    border-radius: 9999px;
    background: var(--bg-pill);
    border: 1px solid var(--border-subtle);
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: -0.01em;
    backdrop-filter: blur(8px);
}

.host-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--status-online);
    box-shadow: 0 0 8px var(--status-online);
}

.hub-title {
    font-size: 2.75rem;
    font-weight: 800;
    letter-spacing: -0.035em;
    color: var(--text-primary);
    line-height: 1.15;
    background: var(--title-gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.hub-subtitle {
    font-size: 1.05rem;
    font-weight: 400;
    color: var(--text-muted);
    letter-spacing: -0.01em;
    line-height: 1.5;
}

/* ------------------------------------------------------------------------------
   6. Services Grid & Service Cards
   ------------------------------------------------------------------------------ */
.services-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 2rem;
    width: 100%;
}

.service-card {
    position: relative;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    min-height: 250px;
    padding: 2rem 2.2rem;
    background: var(--bg-card);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-card);
    border-radius: 22px;
    text-decoration: none;
    color: inherit;
    box-shadow: var(--card-shadow);
    transition: all 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    overflow: hidden;
}

.service-card:hover {
    transform: translateY(-6px);
    background: var(--bg-card-hover);
    border-color: var(--border-card-hover);
    box-shadow: var(--card-shadow-hover);
}

/* Ambient Accent Glow Layer */
.card-glow-layer {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 4px;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.service-card[data-container="jellyfin"] .card-glow-layer {
    background: linear-gradient(90deg, #aa5cc3, #00a4dc);
}

.service-card[data-container="seerr"] .card-glow-layer {
    background: linear-gradient(90deg, #a855f7, #6366f1);
}

.service-card:hover .card-glow-layer {
    opacity: 1;
}

/* Card Top: Icon & Metadata */
.card-top {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 1.5rem;
}

.service-icon-box {
    width: 54px;
    height: 54px;
    border-radius: 16px;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    transition: transform 0.25s ease;
}

.service-card:hover .service-icon-box {
    transform: scale(1.08);
}

.service-img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.glow-fuchsia {
    background: rgba(217, 70, 239, 0.14);
    border: 1px solid rgba(217, 70, 239, 0.28);
    box-shadow: 0 0 20px rgba(217, 70, 239, 0.18);
}

.glow-purple {
    background: rgba(168, 85, 247, 0.14);
    border: 1px solid rgba(168, 85, 247, 0.28);
    box-shadow: 0 0 20px rgba(168, 85, 247, 0.18);
}

.card-header-meta {
    display: flex;
    align-items: center;
}

.status-indicator {
    display: inline-flex;
    align-items: center;
    gap: 0.35rem;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.22rem 0.65rem;
    border-radius: 9999px;
    background: var(--bg-pill);
    color: var(--text-muted);
    border: 1px solid var(--border-subtle);
}

.status-indicator .dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: currentColor;
}

.status-indicator.online {
    background: var(--status-online-bg);
    color: var(--status-online);
    border-color: rgba(16, 185, 129, 0.25);
}

.status-indicator.online .dot {
    box-shadow: 0 0 8px currentColor;
    animation: pulseDot 2s infinite ease-in-out;
}

.status-indicator.offline {
    background: var(--status-offline-bg);
    color: var(--status-offline);
    border-color: rgba(239, 68, 68, 0.25);
}

@keyframes pulseDot {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.4; transform: scale(0.85); }
}

/* Card Body */
.card-body {
    margin-bottom: 1.6rem;
}

.service-name {
    font-size: 1.4rem;
    font-weight: 700;
    color: var(--text-primary);
    letter-spacing: -0.02em;
    margin-bottom: 0.45rem;
    line-height: 1.2;
}

.service-summary {
    font-size: 0.9rem;
    font-weight: 400;
    color: var(--text-muted);
    line-height: 1.55;
}

/* Card Footer */
.card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding-top: 1.15rem;
    border-top: 1px solid var(--border-subtle);
}

.service-domain {
    font-family: 'JetBrains Mono', monospace;
    font-size: 0.78rem;
    font-weight: 500;
    color: var(--text-dim);
    letter-spacing: -0.01em;
    transition: color 0.2s ease;
}

.service-card:hover .service-domain {
    color: var(--accent-cyan);
}

.action-arrow {
    width: 30px;
    height: 30px;
    border-radius: 9px;
    background: var(--bg-pill);
    color: var(--text-secondary);
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    border: 1px solid var(--border-subtle);
    transition: all 0.25s ease;
}

.action-arrow svg {
    width: 14px;
    height: 14px;
    transition: transform 0.25s ease;
}

.service-card:hover .action-arrow {
    background: var(--accent-cyan);
    color: #ffffff;
    border-color: var(--accent-cyan);
    box-shadow: 0 4px 14px var(--accent-cyan-glow);
}

.service-card:hover .action-arrow svg {
    transform: translate(2px, -2px);
}

/* ------------------------------------------------------------------------------
   7. Responsive Layout
   ------------------------------------------------------------------------------ */
@media (max-width: 768px) {
    body {
        padding: 2rem 1.25rem;
    }

    .theme-switch-btn {
        top: 1rem;
        right: 1rem;
        width: 34px;
        height: 34px;
    }

    .hub-title {
        font-size: 2.1rem;
    }

    .hub-wrapper {
        gap: 2rem;
    }

    .services-grid {
        grid-template-columns: 1fr;
        max-width: 440px;
        gap: 1.35rem;
    }

    .service-card {
        min-height: auto;
        padding: 1.75rem 1.75rem;
    }
}
