/* Caravana Futsal — Preto · Branco · Vermelho · Cinza */

:root {
    --sidebar-width: 260px;
    --sidebar-collapsed-width: 80px;
    --navbar-height: 64px;

    --color-bg: #050505;
    --color-surface: #111111;
    --color-surface-2: #1a1a1a;
    --color-surface-3: #242424;
    --color-text: #ffffff;
    --color-text-muted: #a3a3a3;
    --color-text-dim: #737373;
    --color-border: #2e2e2e;
    --color-border-soft: #222222;

    --color-red: #e11d2e;
    --color-red-hover: #c41020;
    --color-red-soft: rgba(225, 29, 46, 0.16);
    --color-red-glow: rgba(225, 29, 46, 0.35);

    --color-white: #ffffff;
    --color-gray: #8a8a8a;
    --touch-min: 44px;
}

html {
    scroll-behavior: smooth;
    color-scheme: dark;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Inter', system-ui, -apple-system, sans-serif;
    background-color: var(--color-bg);
    color: var(--color-text);
    overflow-x: hidden;
}

body.sidebar-mobile-open {
    overflow: hidden;
}

.safe-area-top {
    padding-top: env(safe-area-inset-top, 0);
}

.safe-area-bottom {
    padding-bottom: env(safe-area-inset-bottom, 0);
}

/* Layout — mobile-first (igual ao CSS crítico; evita salto ao carregar este arquivo) */
#sidebar-wrapper {
    position: fixed;
    left: -100%;
    top: 0;
    bottom: 0;
    z-index: 50;
    width: min(var(--sidebar-width), 86vw);
    max-width: 320px;
    transition: width 0.3s ease, left 0.3s ease;
    background-color: var(--color-surface);
    border-color: var(--color-border);
    padding-bottom: env(safe-area-inset-bottom, 0);
}

#sidebar-wrapper.sidebar-open {
    left: 0;
    box-shadow: 8px 0 40px rgba(0, 0, 0, 0.55);
}

#sidebar-wrapper.sidebar-collapsed {
    width: var(--sidebar-collapsed-width);
}

#main-content {
    margin-left: 0;
    width: 100%;
    transition: margin-left 0.3s ease;
    background-color: var(--color-bg);
    min-height: 100dvh;
    min-height: 100vh;
}

#main-content > main {
    padding-bottom: calc(1rem + env(safe-area-inset-bottom, 0px));
}

@media (min-width: 1024px) {
    #sidebar-wrapper {
        left: 0 !important;
        width: var(--sidebar-width);
        max-width: none;
    }

    #main-content {
        margin-left: var(--sidebar-width);
        width: auto;
    }

    #sidebar-wrapper.sidebar-collapsed ~ #main-content {
        margin-left: var(--sidebar-collapsed-width);
    }
}

#sidebar-overlay {
    transition: opacity 0.3s ease;
    backdrop-filter: blur(2px);
}

/* Nav ativo */
.sidebar-link.is-active,
a.sidebar-link.bg-brand-red {
    background: var(--color-red) !important;
    color: var(--color-white) !important;
    box-shadow: 0 8px 24px var(--color-red-glow);
}

/* Botão primário utilitário */
.btn-primary,
button.btn-primary {
    background: var(--color-red);
    color: #fff;
    border: none;
    box-shadow: 0 8px 20px var(--color-red-glow);
}

.btn-primary:hover,
button.btn-primary:hover {
    background: var(--color-red-hover);
}

/* Cards de superfície com contraste real */
.surface-card {
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: 1rem;
}

.surface-card:hover {
    border-color: #3f3f3f;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

.animate-fade-in {
    animation: none;
}

::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #404040;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--color-red);
}

.app-logo-wrap {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

.app-logo {
    object-fit: contain;
    display: block;
}

/* Inputs dark */
html.dark .hover\:bg-red-50:hover {
    background-color: var(--color-red-soft) !important;
}

html.dark .divide-y > :not([hidden]) ~ :not([hidden]) {
    border-color: var(--color-border);
}

html.dark input:not([type="checkbox"]):not([type="radio"]):not([type="submit"]):not([type="button"]),
html.dark textarea,
html.dark select {
    background-color: var(--color-surface-2);
    color: var(--color-text);
    border-color: var(--color-border);
    min-height: var(--touch-min);
    font-size: 16px; /* evita zoom iOS */
}

html.dark input::placeholder,
html.dark textarea::placeholder {
    color: var(--color-text-dim);
}

html.dark button:not(:disabled),
html.dark a.inline-flex {
    min-height: var(--touch-min);
}

/* (spinner removido — painel carrega direto via PHP) */

/* Empty state */
.empty-state {
    padding: 2.5rem 1.25rem;
    text-align: center;
    color: var(--color-text-muted);
    border: 1px dashed var(--color-border);
    border-radius: 1rem;
    background: var(--color-surface);
}

.empty-state__icon {
    width: 3rem;
    height: 3rem;
    margin: 0 auto 0.75rem;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--color-red-soft);
    color: var(--color-red);
}

/* Toast mobile */
#toast-container {
    left: 0.75rem;
    right: 0.75rem;
    top: calc(0.75rem + env(safe-area-inset-top, 0px));
    max-width: 100%;
}

@media (min-width: 640px) {
    #toast-container {
        left: auto;
        right: 1rem;
        width: auto;
        max-width: 24rem;
    }
}

/* Toolbar mobile */
.toolbar-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    justify-content: space-between;
    gap: 0.75rem;
}

.toolbar-row .toolbar-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    width: 100%;
}

@media (min-width: 640px) {
    .toolbar-row .toolbar-actions {
        width: auto;
    }
}

.toolbar-row .toolbar-actions > * {
    flex: 1 1 auto;
}

@media (min-width: 640px) {
    .toolbar-row .toolbar-actions > * {
        flex: 0 0 auto;
    }
}

/* Ranking */
@keyframes sorteioPopIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

@keyframes sorteioSlideIn {
    from { opacity: 0; transform: translateX(-12px); }
    to { opacity: 1; transform: translateX(0); }
}

.sorteio-pop-in {
    animation: sorteioPopIn 0.4s ease forwards;
}

.sorteio-slide-in {
    animation: sorteioSlideIn 0.35s ease forwards;
}

.ranking-premio {
    position: relative;
    border-radius: 1.25rem;
    overflow: hidden;
}

.ranking-premio--light,
.ranking-premio--dark {
    background: linear-gradient(135deg, #1a1a1a 0%, #111111 45%, #0a0a0a 100%);
    border: 1px solid #333;
    box-shadow: 0 8px 40px rgba(0, 0, 0, 0.5), inset 0 1px 0 rgba(225, 29, 46, 0.15);
}

.ranking-premio__glow {
    position: absolute;
    top: -40%;
    right: -10%;
    width: 50%;
    height: 80%;
    background: radial-gradient(circle, var(--color-red-glow) 0%, transparent 70%);
    pointer-events: none;
}

.ranking-premio__inner {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
    padding: 1.25rem;
}

@media (min-width: 640px) {
    .ranking-premio__inner {
        flex-direction: row;
        padding: 2rem;
        gap: 2rem;
    }
}

.ranking-premio__image-wrap {
    flex-shrink: 0;
    width: 100%;
    max-width: 260px;
}

.ranking-premio__image {
    width: 100%;
    height: auto;
    border-radius: 0.75rem;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.55);
    transform: rotate(-2deg);
    transition: transform 0.3s ease;
}

.ranking-premio__image:hover {
    transform: rotate(0deg) scale(1.02);
}

.ranking-premio__text {
    flex: 1;
    text-align: center;
}

@media (min-width: 640px) {
    .ranking-premio__text {
        text-align: left;
    }
}

.ranking-premio__badge {
    display: inline-block;
    font-size: 0.75rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 0.35rem 0.75rem;
    border-radius: 9999px;
    background: var(--color-red-soft);
    color: #fecaca;
    border: 1px solid rgba(225, 29, 46, 0.45);
    margin-bottom: 0.75rem;
}

.ranking-premio__title {
    font-size: 1.15rem;
    font-weight: 800;
    line-height: 1.3;
    margin-bottom: 0.5rem;
    color: #ffffff;
}

@media (min-width: 640px) {
    .ranking-premio__title {
        font-size: 1.35rem;
    }
}

.ranking-premio__desc {
    font-size: 0.9rem;
    line-height: 1.5;
    margin-bottom: 0.5rem;
    color: var(--color-text-muted);
}

.ranking-premio__note {
    font-size: 0.8rem;
    font-weight: 600;
    color: #d4d4d4;
}

.ranking-barra {
    padding: 0.75rem 0;
}

.ranking-barra__header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    margin-bottom: 0.5rem;
}

.ranking-barra__pos {
    flex-shrink: 0;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 3rem;
    min-height: 1.75rem;
    padding: 0.25rem 0.5rem;
    border-radius: 9999px;
    font-size: 0.7rem;
    font-weight: 700;
    line-height: 1.2;
    text-align: center;
}

.ranking-barra__nome {
    font-weight: 700;
    font-size: 0.95rem;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.ranking-barra__stats {
    font-size: 0.75rem;
    margin-top: 0.125rem;
}

.ranking-barra__pts {
    flex-shrink: 0;
    font-size: 1.25rem;
    line-height: 1;
    color: var(--color-red);
}

.ranking-barra__track {
    height: 0.75rem;
    border-radius: 9999px;
    overflow: hidden;
    background: #262626;
}

.ranking-barra__fill {
    height: 100%;
    border-radius: 9999px;
    transition: width 0.4s ease;
    min-width: 4px;
}

@media (max-width: 639px) {
    .ranking-barra__pos {
        min-width: 2.5rem;
        font-size: 0.65rem;
    }

    .ranking-barra__pts {
        font-size: 1rem;
    }

    /* Evita overflow em listas densas */
    .ranking-barra__nome {
        max-width: 42vw;
    }
}

/* Tabelas / listas em mobile */
.table-scroll {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}
