/* Custom styles beyond Tailwind */

:root {
    --color-accent: 0 230 118;
    --color-surface: 22 33 62;
    --color-dark: 26 26 46;
    --color-muted: 158 158 158;
    --color-epl: 56 0 60;
    --theme-page-bg: linear-gradient(180deg, rgb(18 18 33) 0%, rgb(26 26 46) 100%);
    --theme-page-text: #f3f4f6;
    --theme-panel-text: #ffffff;
    --theme-border-strong: rgba(55, 65, 81, 1);
    --theme-border-soft: rgba(75, 85, 99, 1);
    --theme-hover-surface: rgba(26, 26, 46, 0.92);
    --theme-accent-soft: rgba(0, 230, 118, 0.1);
    --theme-shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.2);
    --theme-shadow-xl: 0 24px 60px rgba(0, 0, 0, 0.28);
}

[data-theme="light"] {
    --color-accent: 0 158 96;
    --color-surface: 255 255 255;
    --color-dark: 241 245 249;
    --color-muted: 100 116 139;
    --color-epl: 92 24 95;
    --theme-page-bg: linear-gradient(180deg, rgb(248 250 252) 0%, rgb(241 245 249) 100%);
    --theme-page-text: #0f172a;
    --theme-panel-text: #0f172a;
    --theme-border-strong: rgba(203, 213, 225, 1);
    --theme-border-soft: rgba(226, 232, 240, 1);
    --theme-hover-surface: rgba(226, 232, 240, 0.9);
    --theme-accent-soft: rgba(0, 230, 118, 0.14);
    --theme-shadow-lg: 0 16px 40px rgba(15, 23, 42, 0.08);
    --theme-shadow-xl: 0 24px 60px rgba(15, 23, 42, 0.1);
}

.theme-page {
    background: var(--theme-page-bg);
    color: var(--theme-page-text);
}

.site-nav,
.site-footer {
    background-color: rgb(var(--color-surface));
    border-color: var(--theme-border-strong);
}

.site-nav {
    border-bottom-width: 1px;
}

.site-footer {
    border-top-width: 1px;
    margin-top: auto;
}

.nav-link,
.nav-action-link,
.mobile-nav-link,
.theme-toggle-btn,
.mobile-menu-btn {
    transition:
        color 150ms ease,
        background-color 150ms ease,
        border-color 150ms ease;
}

.nav-link,
.nav-action-link,
.mobile-nav-link {
    border-radius: 0.375rem;
    color: rgb(var(--color-muted));
    font-weight: 500;
}

.nav-link {
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
}

.nav-action-link {
    padding: 0.375rem 0.75rem;
    font-size: 0.875rem;
}

.mobile-nav-link {
    display: block;
    padding: 0.5rem 0.75rem;
    font-size: 1rem;
}

.nav-link:hover,
.nav-action-link:hover,
.mobile-nav-link:hover,
.mobile-menu-btn:hover {
    color: var(--theme-page-text);
    background-color: var(--theme-hover-surface);
}

.nav-link-active {
    background-color: var(--theme-accent-soft);
    color: rgb(var(--color-accent));
}

.theme-toggle-btn {
    background: none;
    border: 0;
    padding: 0;
}

.theme-toggle-mobile {
    align-items: center;
    display: flex;
    justify-content: space-between;
    width: 100%;
}

.theme-toggle-track {
    align-items: center;
    background-color: rgb(var(--color-dark));
    border: 1px solid var(--theme-border-soft);
    border-radius: 9999px;
    color: rgb(var(--color-muted));
    display: inline-flex;
    gap: 0.3rem;
    height: 2.25rem;
    justify-content: space-between;
    padding: 0.22rem 0.3rem;
    position: relative;
    width: 4.9rem;
}

.theme-toggle-track:hover {
    background-color: var(--theme-hover-surface);
}

.theme-toggle-icon,
.theme-toggle-thumb {
    align-items: center;
    display: inline-flex;
    height: 1.55rem;
    justify-content: center;
    position: relative;
    width: 1.55rem;
    z-index: 1;
}

.theme-toggle-icon {
    z-index: 2;
}

.theme-toggle-icon svg,
.theme-toggle-thumb svg {
    height: 0.95rem;
    width: 0.95rem;
}

.theme-toggle-sun {
    color: #f59e0b;
}

[data-theme="dark"] .theme-toggle-sun {
    color: #fbbf24;
    filter: drop-shadow(0 0 6px rgba(251, 191, 36, 0.35));
}

[data-theme="light"] .theme-toggle-sun {
    color: #f59e0b !important;
}

.theme-toggle-moon {
    color: rgb(var(--color-accent));
}

.theme-toggle-thumb {
    background: linear-gradient(180deg, rgb(var(--color-surface)), rgb(var(--color-dark)));
    border: 1px solid var(--theme-border-soft);
    border-radius: 9999px;
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.18);
    color: var(--theme-page-text);
    left: 0.22rem;
    position: absolute;
    top: 0.28rem;
    transition:
        left 180ms ease,
        background 180ms ease,
        border-color 180ms ease,
        box-shadow 180ms ease;
}

.theme-toggle-thumb.is-dark {
    left: calc(100% - 1.77rem);
}

[data-theme="light"] .theme-toggle-track {
    background-color: rgba(255, 255, 255, 0.92);
}

[data-theme="light"] .theme-toggle-thumb {
    background: linear-gradient(180deg, #ffffff, #f8fafc);
    box-shadow: 0 6px 16px rgba(15, 23, 42, 0.12);
}

.mobile-menu-btn {
    color: rgb(var(--color-muted));
    padding: 0.5rem;
}

.mobile-menu-shell {
    border-top: 1px solid var(--theme-border-strong);
}

.themed-panel {
    background-color: rgb(var(--color-surface));
    border: 1px solid var(--theme-border-strong);
    border-radius: 0.5rem;
}

.themed-title {
    color: var(--theme-panel-text);
    font-weight: 700;
}

.themed-label {
    color: color-mix(in srgb, var(--theme-page-text) 72%, transparent);
    display: block;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.25rem;
}

.themed-input {
    appearance: none;
    background-color: rgb(var(--color-dark));
    border: 1px solid var(--theme-border-soft);
    border-radius: 0.375rem;
    color: var(--theme-page-text);
    display: block;
    font-size: 1rem;
    line-height: 1.5rem;
    padding: 0.5rem 0.75rem;
    width: 100%;
}

.themed-input::placeholder {
    color: rgb(var(--color-muted));
}

.themed-input:focus {
    border-color: rgb(var(--color-accent));
    outline: none;
}

.themed-input-mono {
    font-family: "Roboto Mono", "Courier New", monospace;
}

.themed-input-right {
    text-align: right;
}

.themed-input-sm {
    font-size: 0.875rem;
}

.toast-shell {
    align-items: flex-start;
    background-color: rgb(var(--color-surface));
    border: 1px solid var(--theme-border-soft);
    border-radius: 0.5rem;
    box-shadow: var(--theme-shadow-lg);
    display: flex;
    gap: 0.75rem;
    padding: 1rem;
}

.toast-message {
    color: var(--theme-panel-text);
    flex: 1;
    font-size: 0.875rem;
}

.toast-dismiss {
    color: rgb(var(--color-muted));
    flex-shrink: 0;
}

.toast-dismiss:hover {
    color: var(--theme-page-text);
}

/* ================================================
   Tailwind utility overrides for light mode
   ================================================ */
[data-theme="light"] .bg-surface {
    background-color: rgb(var(--color-surface)) !important;
}

[data-theme="light"] .bg-surface\/50 {
    background-color: rgba(255, 255, 255, 0.5) !important;
}

[data-theme="light"] .bg-dark {
    background-color: rgb(var(--color-dark)) !important;
}

[data-theme="light"] .bg-dark\/40 {
    background-color: rgba(241, 245, 249, 0.72) !important;
}

[data-theme="light"] .bg-dark\/60 {
    background-color: rgba(241, 245, 249, 0.82) !important;
}

[data-theme="light"] .bg-dark\/70 {
    background-color: rgba(226, 232, 240, 0.92) !important;
}

[data-theme="light"] .from-surface {
    --tw-gradient-from: rgb(255 255 255) var(--tw-gradient-from-position) !important;
    --tw-gradient-to: rgb(255 255 255 / 0) var(--tw-gradient-to-position) !important;
    --tw-gradient-stops: var(--tw-gradient-from), var(--tw-gradient-to) !important;
}

[data-theme="light"] .to-dark {
    --tw-gradient-to: rgb(241 245 249) var(--tw-gradient-to-position) !important;
}

[data-theme="light"] .border-gray-700,
[data-theme="light"] .border-gray-700\/50,
[data-theme="light"] .border-gray-700\/60,
[data-theme="light"] .border-gray-700\/70,
[data-theme="light"] .border-gray-700\/80,
[data-theme="light"] .border-gray-600 {
    border-color: var(--theme-border-strong) !important;
}

[data-theme="light"] .text-gray-100,
[data-theme="light"] .text-white {
    color: var(--theme-panel-text) !important;
}

[data-theme="light"] .text-gray-300,
[data-theme="light"] .text-gray-400 {
    color: rgb(var(--color-muted)) !important;
}

[data-theme="light"] .hover\:text-white:hover {
    color: var(--theme-panel-text) !important;
}

[data-theme="light"] .hover\:bg-dark:hover {
    background-color: var(--theme-hover-surface) !important;
}

[data-theme="light"] .shadow-\[0_16px_40px_rgba\(0\,0\,0\,0\.2\)\] {
    box-shadow: var(--theme-shadow-lg) !important;
}

[data-theme="light"] .shadow-\[0_18px_45px_rgba\(0\,0\,0\,0\.22\)\],
[data-theme="light"] .shadow-\[0_24px_60px_rgba\(0\,0\,0\,0\.28\)\] {
    box-shadow: var(--theme-shadow-xl) !important;
}

/* ================================================
   HTMX Loading Indicators
   ================================================ */
.htmx-indicator {
    opacity: 0;
    transition: opacity 200ms ease-in;
}

.htmx-request .htmx-indicator,
.htmx-request.htmx-indicator {
    opacity: 1;
}

/* Smooth HTMX swap transitions */
.htmx-swapping {
    opacity: 0;
    transition: opacity 100ms ease-out;
}

.htmx-settling {
    opacity: 1;
    transition: opacity 200ms ease-in;
}

/* ================================================
   Spinner
   ================================================ */
@keyframes spin {
    to { transform: rotate(360deg); }
}

.spinner {
    display: inline-block;
    width: 1em;
    height: 1em;
    border: 2px solid currentColor;
    border-right-color: transparent;
    border-radius: 50%;
    animation: spin 600ms linear infinite;
    vertical-align: middle;
}

.spinner-sm {
    width: 0.875em;
    height: 0.875em;
    border-width: 1.5px;
}

/* ================================================
   Odds Flash (on polling refresh)
   ================================================ */
@keyframes odds-flash {
    0% { background-color: rgba(0, 230, 118, 0.2); }
    100% { background-color: transparent; }
}

.htmx-settling .odds-value {
    animation: odds-flash 800ms ease-out;
}

/* ================================================
   Mobile Menu
   ================================================ */
.mobile-menu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 300ms ease-out;
}

.mobile-menu.open {
    max-height: 500px;
    transition: max-height 300ms ease-in;
}

/* ================================================
   WebSocket Connection Status
   ================================================ */
@keyframes pulse-dot {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.4; }
}

.ws-status {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    display: inline-block;
}

.ws-status.connected {
    background-color: rgb(var(--color-accent));
}

.ws-status.disconnected {
    background-color: #9e9e9e;
    animation: pulse-dot 2s ease-in-out infinite;
}

/* ================================================
   Toast Notifications
   ================================================ */
@keyframes slide-in {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes slide-out {
    from { transform: translateX(0); opacity: 1; }
    to { transform: translateX(100%); opacity: 0; }
}

.animate-slide-in {
    animation: slide-in 300ms ease-out;
}

.animate-slide-out {
    animation: slide-out 300ms ease-in forwards;
}

/* ================================================
   Form Error Shake
   ================================================ */
@keyframes shake {
    0%, 100% { transform: translateX(0); }
    20%, 60% { transform: translateX(-4px); }
    40%, 80% { transform: translateX(4px); }
}

.shake {
    animation: shake 400ms ease-in-out;
}
