/* ===========================================================
   Tema — Escalas de Arbitragem
   Cor primária: #FA8F18 (sobrescreve variáveis do Bootstrap)
   =========================================================== */

:root {
    --bs-primary: #FA8F18;
    --bs-primary-rgb: 250, 143, 24;
    --brand: #FA8F18;
    --brand-dark: #d9760a;
    --brand-light: #ffb457;
    --brand-soft: #fff3e3;

    --sidebar-width: 250px;
    --sidebar-compact: 64px;
    --topbar-height: 60px;
    --sidebar-bg: #1f2430;
    --sidebar-fg: #c7ccd6;
    --sidebar-fg-active: #ffffff;
}

/* ---- Overrides de componentes primários ---- */
.btn-primary {
    --bs-btn-bg: var(--brand);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand-dark);
    --bs-btn-hover-border-color: var(--brand-dark);
    --bs-btn-active-bg: var(--brand-dark);
    --bs-btn-active-border-color: var(--brand-dark);
    --bs-btn-disabled-bg: var(--brand);
    --bs-btn-disabled-border-color: var(--brand);
    color: #fff;
}
.btn-outline-primary {
    --bs-btn-color: var(--brand-dark);
    --bs-btn-border-color: var(--brand);
    --bs-btn-hover-bg: var(--brand);
    --bs-btn-hover-border-color: var(--brand);
    --bs-btn-active-bg: var(--brand);
    --bs-btn-active-border-color: var(--brand);
}
a { color: var(--brand-dark); }
a:hover { color: var(--brand); }
.text-primary { color: var(--brand) !important; }
.bg-primary { background-color: var(--brand) !important; }
.link-primary { color: var(--brand) !important; }
.form-control:focus, .form-select:focus {
    border-color: var(--brand-light);
    box-shadow: 0 0 0 .2rem rgba(var(--bs-primary-rgb), .25);
}
.page-link { color: var(--brand-dark); }
.page-item.active .page-link { background-color: var(--brand); border-color: var(--brand); }
.nav-tabs .nav-link.active { color: var(--brand-dark); border-bottom-color: transparent; }
.badge.bg-primary { background-color: var(--brand) !important; }
.spinner-border.text-primary { color: var(--brand) !important; }

/* ===========================================================
   Layout base (app shell)
   =========================================================== */
body {
    background: #f4f5f7;
    min-height: 100vh;
}

.app-shell { display: flex; min-height: 100vh; }

/* ---- Sidebar ---- */
.app-sidebar {
    width: var(--sidebar-width);
    background: var(--sidebar-bg);
    color: var(--sidebar-fg);
    flex-shrink: 0;
    display: flex;
    flex-direction: column;
    position: fixed;
    top: 0; left: 0; bottom: 0;
    z-index: 1030;
    transition: width .2s ease;
    overflow-x: hidden;
}
.app-sidebar .sidebar-brand {
    height: var(--topbar-height);
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: 0 1rem;
    color: #fff;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid rgba(255,255,255,.06);
}
.app-sidebar .sidebar-brand img { max-height: 32px; }
.app-sidebar .nav { flex-direction: column; padding: .5rem 0; overflow-y: auto; }
.app-sidebar .nav-link {
    color: var(--sidebar-fg);
    display: flex;
    align-items: center;
    gap: .75rem;
    padding: .6rem 1rem;
    white-space: nowrap;
    border-left: 3px solid transparent;
}
.app-sidebar .nav-link i { font-size: 1.15rem; min-width: 1.15rem; text-align: center; }
.app-sidebar .nav-link:hover { color: #fff; background: rgba(255,255,255,.05); }
.app-sidebar .nav-link.active {
    color: var(--sidebar-fg-active);
    background: rgba(var(--bs-primary-rgb), .18);
    border-left-color: var(--brand);
}
.app-sidebar .nav-section {
    text-transform: uppercase;
    font-size: .7rem;
    letter-spacing: .05em;
    color: #6b7280;
    padding: 1rem 1rem .35rem;
    white-space: nowrap;
}

/* ---- Conteúdo ---- */
.app-main {
    flex: 1;
    margin-left: var(--sidebar-width);
    display: flex;
    flex-direction: column;
    min-width: 0;
    transition: margin-left .2s ease;
}
.app-topbar {
    height: var(--topbar-height);
    background: #fff;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0 1.25rem;
    position: sticky;
    top: 0;
    z-index: 1020;
}
.app-topbar .page-title { font-size: 1.1rem; font-weight: 600; margin: 0; }
.app-content { padding: 1.25rem; flex: 1; }

/* ===========================================================
   Modo: Lateral compacto (só ícones; expande no hover)
   =========================================================== */
body.menu-compacto .app-sidebar { width: var(--sidebar-compact); }
body.menu-compacto .app-main { margin-left: var(--sidebar-compact); }
body.menu-compacto .app-sidebar .link-text,
body.menu-compacto .app-sidebar .nav-section,
body.menu-compacto .app-sidebar .brand-text { display: none; }
body.menu-compacto .app-sidebar:hover { width: var(--sidebar-width); box-shadow: 4px 0 12px rgba(0,0,0,.15); }
body.menu-compacto .app-sidebar:hover .link-text,
body.menu-compacto .app-sidebar:hover .nav-section,
body.menu-compacto .app-sidebar:hover .brand-text { display: inline; }

/* ===========================================================
   Modo: Topo (menu horizontal com dropdowns)
   =========================================================== */
body.menu-topo .app-sidebar { display: none; }
body.menu-topo .app-main { margin-left: 0; }
/* Sem sidebar: esconde o hamburger da topbar (o menu do topo tem o seu próprio no mobile) */
body.menu-topo .menu-toggle { display: none !important; }
.app-navbar-top { display: none; }
body.menu-topo .app-navbar-top {
    display: flex;
    align-items: center;
    background: var(--sidebar-bg);
    padding: 0 1rem;
    min-height: var(--topbar-height);
    position: sticky;          /* fica logo abaixo da topbar (título/usuário) ao rolar */
    top: var(--topbar-height);
    z-index: 1019;             /* acima do conteúdo, abaixo da topbar (1020) */
}
body.menu-topo .app-navbar-top .navbar-brand,
body.menu-topo .app-navbar-top .nav-link { color: #e5e7eb; }
body.menu-topo .app-navbar-top .nav-link { padding: .5rem .85rem; border-radius: .4rem; }
body.menu-topo .app-navbar-top .nav-link:hover { color: #fff; background: rgba(255,255,255,.08); }
body.menu-topo .app-navbar-top .nav-link.active { color: #fff; background: rgba(var(--bs-primary-rgb), .22); }
body.menu-topo .app-navbar-top .dropdown-toggle::after { margin-left: .4rem; vertical-align: .15em; }
body.menu-topo .app-navbar-top .dropdown-menu {
    --bs-dropdown-link-active-bg: var(--brand);
    border: none;
    box-shadow: 0 6px 20px rgba(0,0,0,.18);
    border-radius: .5rem;
    margin-top: .35rem;
}
body.menu-topo .app-navbar-top .dropdown-item.active,
body.menu-topo .app-navbar-top .dropdown-item:active { color: #fff; }

/* ===========================================================
   Responsivo (mobile: sidebar vira off-canvas simples)
   =========================================================== */
.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.4);
    z-index: 1029;
}
@media (max-width: 992px) {
    .app-sidebar { transform: translateX(-100%); }
    .app-main { margin-left: 0 !important; }
    body.sidebar-open .app-sidebar { transform: translateX(0); width: var(--sidebar-width); }
    body.sidebar-open .app-sidebar .link-text,
    body.sidebar-open .app-sidebar .nav-section,
    body.sidebar-open .app-sidebar .brand-text { display: inline; }
    body.sidebar-open .sidebar-backdrop { display: block; }
    .menu-toggle { display: inline-flex !important; }
}
.menu-toggle { display: none; }

/* ===========================================================
   Utilidades / cards / dashboard
   =========================================================== */
.stat-card { border: none; border-radius: .75rem; box-shadow: 0 1px 3px rgba(0,0,0,.08); }
.stat-card .stat-icon {
    width: 48px; height: 48px; border-radius: .6rem;
    display: flex; align-items: center; justify-content: center;
    font-size: 1.4rem; color: #fff; background: var(--brand);
}
.stat-card .stat-value { font-size: 1.6rem; font-weight: 700; line-height: 1; }
.stat-card .stat-label { color: #6b7280; font-size: .85rem; }

.card { border: none; border-radius: .75rem; box-shadow: 0 1px 3px rgba(0,0,0,.06); }
.card-header { background: #fff; border-bottom: 1px solid #eef0f2; font-weight: 600; }

.table thead th { font-size: .78rem; text-transform: uppercase; letter-spacing: .02em; color: #6b7280; }
.avatar-sm { width: 34px; height: 34px; border-radius: 50%; object-fit: cover; }

/* ===========================================================
   Seletor de cor por grade (ex.: Cor da sigla das Equipes)
   =========================================================== */
.cor-sigla-picker { display: flex; flex-wrap: wrap; gap: .4rem; padding-top: .25rem; }
.cor-swatch {
    width: 28px; height: 28px; border-radius: 50%;
    border: 2px solid #fff;
    box-shadow: 0 0 0 1px rgba(0,0,0,.12);
    cursor: pointer;
    padding: 0;
    transition: transform .1s ease, box-shadow .1s ease;
}
.cor-swatch:hover { transform: scale(1.1); }
.cor-swatch.selecionada { box-shadow: 0 0 0 2px #fff, 0 0 0 4px var(--brand); }
.cor-swatch-mais {
    display: flex; align-items: center; justify-content: center;
    color: #6b7280; font-size: .85rem; background: #f3f4f6;
    border-style: dashed; border-color: #c9ccd1;
}
.cor-swatch-mais.selecionada { color: #fff; border-style: solid; }
/* Input nativo mantido no DOM (acionado pelo botão "mais cores"), sem exibição própria */
.cor-sigla-native {
    position: absolute; width: 1px; height: 1px;
    padding: 0; margin: -1px; overflow: hidden;
    clip: rect(0,0,0,0); white-space: nowrap; border: 0;
}

/* ===========================================================
   Componente de Disponibilidade (calendário)
   =========================================================== */
.disp-bar {
    background: #fff;
    border: 1px solid #eef0f2;
    border-radius: .5rem;
    padding: .6rem .9rem;
    font-size: .88rem;
}
.disp-bar input.disp-hora { width: 7.5rem !important; }

.disp-grid {
    display: grid;
    grid-template-columns: repeat(7, 1fr);
    gap: 4px;
}
.disp-head {
    text-align: center;
    font-size: .72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .03em;
    color: #6b7280;
    padding: .25rem 0;
}
.disp-cell {
    position: relative;
    min-height: 74px;
    border-radius: .4rem;
    padding: .5rem .4rem;
    cursor: pointer;
    text-align: center;
    transition: filter .1s ease, transform .1s ease;
}
.disp-cell:not(.disp-cell-blank):not(.bloqueada):hover { filter: brightness(1.05); transform: translateY(-1px); }
.disp-grid-semana .disp-cell { min-height: 96px; }

.disp-cell-blank { background: transparent; cursor: default; }

.disp-cell.disponivel { background: #16a34a; color: #fff; }            /* INTEGRAL (dia todo) */
.disp-cell.disponivel-horario { background: #2563eb; color: #fff; }   /* disponível com faixa de horário */
.disp-cell.indisponivel { background: #fde2e1; color: #9f1c1c; }
.disp-cell.bloqueada { background: #e5e7eb; color: #6b7280; cursor: not-allowed; }

.disp-cell.hoje { outline: 2px solid var(--brand); outline-offset: -2px; }

.disp-daynum { font-size: .95rem; font-weight: 700; display: block; line-height: 1.3; }
.disp-label {
    display: block;
    font-size: .66rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .02em;
    margin-top: .2rem;
}
.disp-cell.disponivel .disp-label,
.disp-cell.disponivel-horario .disp-label,
.disp-cell.indisponivel .disp-label { opacity: .92; }
.disp-lock { position: absolute; top: .3rem; right: .35rem; font-size: .7rem; }

/* Ícone de observação por dia (discreto; destaca quando há nota) */
.disp-obs-icon {
    position: absolute; top: .3rem; left: .35rem;
    font-size: .72rem; cursor: pointer; opacity: .45;
    transition: opacity .1s ease, transform .1s ease;
}
.disp-obs-icon:hover { opacity: 1; transform: scale(1.15); }
.disp-obs-icon.tem { opacity: 1; color: #fbbf24; }  /* nota existente = amarelo, visível sobre qualquer fundo */
.disp-cell.indisponivel .disp-obs-icon.tem { color: #d97706; }

.disp-legenda { display: flex; flex-wrap: wrap; gap: 1rem; font-size: .8rem; color: #4b5563; }
.disp-legenda-item { display: inline-flex; align-items: center; gap: .4rem; }
.disp-swatch { width: 14px; height: 14px; border-radius: 3px; display: inline-block; }
.disp-swatch-disp { background: #16a34a; }
.disp-swatch-horario { background: #2563eb; }
.disp-swatch-indisp { background: #fde2e1; border: 1px solid #f3b4b2; }
.disp-swatch-hoje { background: #fff; outline: 2px solid var(--brand); outline-offset: -2px; }
.disp-swatch-bloq { background: #e5e7eb; }

@media (max-width: 576px) {
    .disp-cell { min-height: 52px; padding: .3rem .2rem; }
    .disp-daynum { font-size: .78rem; }
    .disp-label { font-size: .58rem; }
    .disp-bar input.disp-hora { width: 6rem !important; }
}

/* Impressão (relatórios/PDF) */
@media print {
    .app-sidebar, .app-topbar, .app-navbar-top, .no-print { display: none !important; }
    .app-main { margin-left: 0 !important; }
    .app-content { padding: 0 !important; }
    body { background: #fff; }
}
