/* Global Main CSS - Variables & Resets */

:root {
    /* App Standard Variables (from Lobby) */
    --tabbar-h: 80px;
    /* Increased for floating look */
    --header-h: 60px;

    /* Color Palette - Dark Mode */
    --app-bg: #0B1016;
    /* Deep dark blue/black */
    --app-surface: #151b26;
    /* Slightly lighter for cards */
    --app-text-main: #ffffff;
    --app-text-muted: #94a3b8;
    --app-primary: #3b82f6;
    --app-primary-hover: #2563eb;

    /* Variables for compatibility */
    --border: rgba(255, 255, 255, 0.08);
    /* Updated to match --app-border */
    --bg: var(--app-bg);
    --muted: var(--app-text-muted);

    --loader-art: url('../icons/Launchscreen_RallyeApp_Desktop.png');
    --map-control-size: 48px;
    --map-control-icon-size: 20px;

    /* Tabbar specific */
    --app-tabbar-bg: rgba(21, 27, 38, 0.65);
    --app-tabbar-border: rgba(255, 255, 255, 0.05);
    --app-tabbar-item: #94a3b8;
    --app-tabbar-item-active: #3b82f6;

    --safe-area-top: env(safe-area-inset-top, 0px);
    --safe-area-right: env(safe-area-inset-right, 0px);
    --safe-area-bottom: env(safe-area-inset-bottom, 0px);
    --safe-area-left: env(safe-area-inset-left, 0px);

    --radius-md: 14px;
    --radius-lg: 24px;
    --radius-full: 9999px;
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.4);

    /* Station Card Variables */
    --station-primary: #1d4ed8;
    --station-primary-dark: #1e3a8a;
    --station-accent: #f97316;
    --station-accent-strong: #9a3412;
    --station-text: #1f2937;
    --station-muted: #6b7280;
    --station-bg: #f9fafb;
    --station-card-bg: #ffffff;
    --station-shadow: 0 4px 20px rgba(0, 0, 0, 0.06);
    --station-radius: 16px;
}

/* Global Box Sizing */
*,
*::before,
*::after {
    box-sizing: border-box;
}

/* Base Body Styles */
html,
body {
    margin: 0;
    padding: 0;
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    min-height: 100%;
    font-family: 'Inter', system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    -webkit-text-size-adjust: 100%;
    color: var(--bg);
    overscroll-behavior: none;
    /* iOS Rubber-band fix */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
}

/* Image Resets */
img,
video,
canvas,
svg {
    max-width: 100%;
    height: auto;
    display: block;
    -webkit-touch-callout: none;
    -webkit-user-drag: none;
}

/* Text Selection (App Feel) */
body {
    -webkit-user-select: none;
    user-select: none;
    -webkit-touch-callout: none;
}

input,
textarea,
[contenteditable="true"] {
    -webkit-user-select: text;
    user-select: text;
    -webkit-touch-callout: default;
    cursor: auto;
}

/* Base App Layout */
.app {
    min-height: 100svh;
    min-height: 100dvh;
    min-height: calc(var(--vh, 1vh) * 100);
    width: 100%;
    display: flex;
    flex-direction: column;
    background: inherit;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0 0 0 0);
    white-space: nowrap;
    border: 0;
}

/* Inputs & Buttons Overrides */
input,
select,
textarea,
button {
    font-size: 18px;
    line-height: 1.2;
    scroll-margin-top: 32px;
    scroll-margin-bottom: 40px;
    font-family: inherit;
}

/* Button System */
.btn {
    padding: 14px 16px;
    border-radius: 12px;
    border: none;
    cursor: pointer;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
    transition: transform .16s ease, background-color .18s ease, box-shadow .18s ease, color .18s ease;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    text-decoration: none;
}

.btn:active {
    transform: scale(.98);
}

.btn:disabled {
    opacity: .55;
    cursor: not-allowed;
    pointer-events: none;
}

.btn:focus-visible {
    outline: 3px solid rgba(59, 130, 246, .45);
    outline-offset: 2px;
}

.btn-prim,
.btn-primary {
    background: #2563eb;
    color: #fff;
}

.btn-prim:hover,
.btn-primary:hover {
    background: #1d4ed8;
}

.btn-flat,
.btn-light {
    background: #f1f5f9;
    color: #475569;
    border: 1px solid #e2e8f0;
}

.btn-flat:hover,
.btn-light:hover {
    background: #e2e8f0;
}

.btn-warn {
    background: #dc2626;
    color: #fff;
}

.btn-ghost {
    background: transparent;
    color: #0f172a;
}

.btn-link {
    background: transparent;
    color: #64748b;
    padding: 8px;
    font-weight: 500;
    text-decoration: none;
    font-size: 14px;
}

/* === App Shell (Shared) === */
.app-shell {
    height: 100dvh;
    display: flex;
    flex-direction: column;
    background: var(--app-bg);
}

/* Header */
.app-header {
    position: sticky;
    top: 0;
    height: calc(var(--header-h) + var(--safe-area-top));
    padding-top: var(--safe-area-top);
    padding-inline: 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    background: transparent;
    z-index: 900;
}

.app-header__titles {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.app-header__title {
    font-size: 1.75rem;
    font-weight: 700;
    letter-spacing: -0.02em;
    color: var(--app-text-main);
    margin: 0;
}

/* Floating Tab Bar */
.app-tabbar {
    position: fixed;
    bottom: 24px;
    left: 20px;
    right: 20px;
    height: 72px;
    padding: 0 12px;
    background: var(--app-tabbar-bg);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--app-tabbar-border);
    border-radius: 40px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    z-index: 1000;
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.4);
    max-width: 500px;
    margin: 0 auto;
}

.app-tab {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 4px;
    background: transparent;
    border: none;
    padding: 8px 0;
    color: var(--app-tabbar-item);
    cursor: pointer;
    transition: all 0.2s ease;
    position: relative;
}

.app-tab__icon {
    width: 24px;
    height: 24px;
    transition: transform 0.2s ease, color 0.2s ease;
}

.app-tab__icon svg {
    width: 100%;
    height: 100%;
    fill: none;
    stroke: currentColor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.app-tab__label {
    font-size: 0.7rem;
    font-weight: 500;
    letter-spacing: 0.02em;
    opacity: 0;
    transform: translateY(4px);
    transition: all 0.2s ease;
    position: absolute;
    bottom: 2px;
}

.app-tab[aria-selected="true"] {
    color: var(--app-tabbar-item-active);
}

.app-tab[aria-selected="true"] .app-tab__icon {
    transform: translateY(-8px);
    color: var(--app-primary);
    filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
}

.app-tab[aria-selected="true"] .app-tab__label {
    opacity: 1;
    transform: translateY(0);
}

/* Drawer / Accordion */
.drawer-accordion {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.drawer-accordion__trigger {
    width: 100%;
    background: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    cursor: pointer;
    text-align: left;
    transition: all 0.2s ease;
    color: var(--app-text-main);
}

.drawer-accordion__trigger:hover {
    background: rgba(255, 255, 255, 0.06);
}

.drawer-accordion__title {
    font-weight: 600;
    font-size: 1rem;
    color: var(--app-text-main);
}

.drawer-accordion__panel {
    display: none;
    padding: 16px;
    background: rgba(0, 0, 0, 0.2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
    margin-top: 4px;
}

.drawer-accordion__panel--open {
    display: block;
}