/* ============================================================================
   Design tokens
   ----------------------------------------------------------------------------
   Os valores abaixo são exatamente os que o sistema já usava — esta camada
   só dá nome a eles. Um tema alternativo redefine apenas estas variáveis.

   --accent / --accent-rgb são sobrescritos em tempo de execução pelo bloco
   <style> do header.php, a partir da cor configurada em Configurações.
   ========================================================================== */
:root {
    /* ── Destaque ── */
    --accent:         #ff6600;
    --accent-rgb:     255, 102, 0;
    --orange:         var(--accent);            /* alias legado */
    --accent-soft:    rgba(var(--accent-rgb), .12);
    --accent-softer:  rgba(var(--accent-rgb), .06);
    --on-accent:      #ffffff;

    /* ── Superfícies ── */
    --bg:             #080808;   /* fundo da página        */
    --bg-deep:        #000000;   /* sidebar, navbar mobile */
    --surface:        #121212;   /* cards, tabelas         */
    --surface-2:      #1a1a1a;   /* inputs, painéis        */
    --surface-3:      #202020;   /* foco / hover           */

    /* ── Bordas ── */
    --border:         #2a2a2a;
    --border-soft:    #1a1a1a;
    --border-strong:  #444444;   /* campos de formulário   */

    /* ── Texto (do mais claro ao mais apagado) ── */
    --text-strong:    #ffffff;
    --text:           #f5f5f5;
    --text-soft:      #cccccc;
    --text-muted:     #aaaaaa;
    --text-dim:       #888888;
    --text-faint:     #666666;

    /* ── Sobreposições neutras ── */
    --overlay-1:      rgba(255, 255, 255, .02);
    --overlay-2:      rgba(255, 255, 255, .06);
    --overlay-3:      rgba(255, 255, 255, .12);

    /* ── Status (idênticos em todos os temas — significam estado, não estilo) ── */
    --success:        #27ae60;   --success-rgb: 39, 174, 96;
    --warning:        #f1c40f;   --warning-rgb: 241, 196, 15;
    --danger:         #e74c3c;   --danger-rgb:  231, 76, 60;
    --neutral:        #95a5a6;   --neutral-rgb: 127, 140, 141;
    --go:             #4cd137;   /* verde do "Revisar Pedidos" */

    /* ── Geometria ── */
    --radius-card:    16px;
    --radius-nav:     12px;
    --radius-sm:      10px;
    --radius-pill:    999px;
    --sidebar-w:      280px;   /* gaveta do mobile; no desktop vira a trilha */
    --sidebar-w-mob:  300px;
    --sidebar-expanded-w: 280px;  /* largura da trilha aberta no hover */
    --rail-item:      48px;       /* botão quadrado de cada página na trilha */
    --navbar-h-mob:   60px;
    --content-pad:    30px;
    --card-gap:       2rem;

    /* ── Profundidade ── */
    --shadow-card:    0 10px 30px rgba(0, 0, 0, .5);
    --shadow-nav:     0 4px 15px rgba(var(--accent-rgb), .08);
    --shadow-sm:      0 4px 14px rgba(0, 0, 0, .35);

    /* Tom mais escuro do destaque, para o hover de botões preenchidos. */
    --accent-hover:   color-mix(in srgb, var(--accent) 84%, #000);
}

body {
    background-color: #080808 !important;
    color: #f5f5f5 !important;
    font-family: 'Inter', sans-serif;
    margin: 0;
    overflow-x: hidden;
}

/* Sidebar & Layout */
.sidebar {
    width: 280px;
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    background-color: #000;
    border-right: 1px solid #2a2a2a;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    transition: all 0.4s ease;
}

/* Sidebar Nav Items */
.nav-item-custom {
    display: flex;
    align-items: center;
    padding: 12px 20px;
    margin-bottom: 4px;
    color: #888888;
    text-decoration: none !important;
    border-radius: 12px;
    border-left: 4px solid transparent;
    font-weight: 500;
    transition: all 0.3s ease;
}

.nav-item-custom i {
    font-size: 1.2rem;
    margin-right: 15px;
    color: #666666;
    transition: color 0.3s ease;
}

/* Hover state */
.nav-item-custom:hover {
    background: rgba(var(--accent-rgb), 0.06) !important;
    color: #cccccc !important;
    text-decoration: none !important;
}

.nav-item-custom:hover i {
    color: var(--accent) !important;
}

/* Active (current page) state */
.nav-item-custom.active {
    background: rgba(var(--accent-rgb), 0.12) !important;
    color: #ffffff !important;
    border-left: 4px solid var(--accent) !important;
    border-radius: 0 12px 12px 0;
    box-shadow: 0 4px 15px rgba(var(--accent-rgb), 0.08);
    text-decoration: none !important;
}

.nav-item-custom.active i {
    color: var(--accent) !important;
}

/* Cores semânticas dos itens do menu (antes eram style="" inline).
   O :not(.active) preserva o comportamento anterior: quando o item é o da
   página atual, o !important de .active vencia o style="" inline e o texto
   ficava branco. Sem essa exclusão, a cor semântica passaria a vencer. */
.nav-item-custom.nav-warn:not(.active) {
    color: var(--warning) !important;
}

.nav-item-custom.nav-go:not(.active) {
    color: var(--go) !important;
}

/* Item com contador: o número vai para a ponta direita.
   Isto era inline, e inline vence folha de estilo — por isso a trilha de
   ícones não conseguia centralizar justamente estes itens. */
.nav-item-custom.has-badge {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

/* Ensure modal always appears above sidebar */
.modal-backdrop {
    z-index: 1040 !important;
}

.modal {
    z-index: 1050 !important;
}


.main-content {
    margin-left: 280px;
    min-height: 100vh;
    padding: 30px;
    background-color: #080808;
}

/* Typography & Colors */
.text-orange {
    color: var(--accent) !important;
}

.bg-orange {
    background-color: var(--accent) !important;
}

.text-muted {
    color: #aaaaaa !important;
}

.fw-800 {
    font-weight: 800;
}

.x-small {
    font-size: 0.65rem;
}

/* Status Badges */
.badge-pendente {
    background: rgba(231, 76, 60, 0.15) !important;
    color: #e74c3c !important;
    border: 1px solid rgba(231, 76, 60, 0.4);
}

.badge-parcial {
    background: rgba(241, 196, 15, 0.15) !important;
    color: #f1c40f !important;
    border: 1px solid rgba(241, 196, 15, 0.4);
}

.badge-pago {
    background: rgba(39, 174, 96, 0.15) !important;
    color: #27ae60 !important;
    border: 1px solid rgba(39, 174, 96, 0.4);
}

.badge-aguardando {
    background: rgba(127, 140, 141, 0.15) !important;
    color: #95a5a6 !important;
    border: 1px solid rgba(127, 140, 141, 0.4);
}

.badge-em_producao {
    background: rgba(var(--accent-rgb), 0.15) !important;
    color: var(--accent) !important;
    border: 1px solid rgba(var(--accent-rgb), 0.4);
}

.badge-finalizado {
    background: rgba(39, 174, 96, 0.15) !important;
    color: #27ae60 !important;
    border: 1px solid rgba(39, 174, 96, 0.4);
}

/* Cards & Containers */
.card {
    background-color: #121212 !important;
    border: 1px solid #2a2a2a !important;
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    margin-bottom: 2rem;
}

/* Tables */
.table-dark {
    --bs-table-bg: #121212;
    --bs-table-border-color: #2a2a2a;
    color: #f5f5f5;
}

.table-hover tbody tr:hover {
    background-color: rgba(var(--accent-rgb), 0.05) !important;
}

/* Forms */
.form-control,
.form-select {
    background-color: #1a1a1a !important;
    border: 1px solid #444 !important;
    color: #fff !important;
}

/* Placeholder visível */
.form-control::placeholder,
textarea::placeholder {
    color: #888 !important;
    opacity: 1 !important;
}

.form-select option {
    background: #1a1a1a;
    color: #fff;
}

.form-control:focus,
.form-select:focus {
    border-color: var(--accent) !important;
    box-shadow: 0 0 0 0.2rem rgba(var(--accent-rgb), 0.2) !important;
    background-color: #202020 !important;
    color: #fff !important;
}

/* Labels mais claras */
label.x-small,
.text-muted.text-uppercase {
    color: #cccccc !important;
}

.input-group-text {
    background-color: #1a1a1a !important;
    border-color: #444 !important;
    color: #aaa !important;
}

/* Buttons */
.btn-primary {
    background: linear-gradient(135deg, var(--accent) 0%, color-mix(in srgb, var(--accent) 80%, #000) 100%) !important;
    border: none !important;
    color: #fff !important;
    font-weight: 700;
    padding: 10px 20px;
    border-radius: 10px;
}

.btn-outline-orange {
    border: 1px solid var(--accent) !important;
    color: var(--accent) !important;
    background: transparent !important;
    transition: all 0.3s ease;
}

.btn-outline-orange:hover {
    background: var(--accent) !important;
    color: #fff !important;
}

/* Responsive */
@media (max-width: 992px) {
    .sidebar {
        left: -100%;
        top: 60px;
        height: calc(100vh - 60px);
        width: 100%;
        max-width: 300px;
    }

    .sidebar.active {
        left: 0;
    }

    .main-content {
        margin-left: 0;
        padding: 80px 20px 20px 20px !important;
    }

    .mobile-navbar {
        display: flex !important;
        position: fixed;
        top: 0;
        width: 100%;
        height: 60px;
        background: #000;
        z-index: 1001;
        border-bottom: 1px solid #2a2a2a;
        padding: 0 20px;
        align-items: center;
        justify-content: space-between;
    }
}

.mobile-navbar {
    display: none;
}

.toggle-sidebar {
    background: none;
    border: none;
    color: var(--accent);
    font-size: 1.8rem;
    cursor: pointer;
}


/* ============================================================================
   Menu lateral em trilha de ícones (somente desktop)
   ----------------------------------------------------------------------------
   A barra fica com 72px mostrando só os ícones e cresce para 280px quando o
   mouse entra nela. A expansão é por cima do conteúdo: a página não é
   empurrada e não há reflow ao passar o mouse.

   Abaixo de 993px nada disso vale — o menu volta a ser a gaveta de sempre,
   com .mobile-navbar e o botão #toggleSidebar intactos.

   Os seletores começam com :root de propósito. O <style> do header.php carrega
   DEPOIS deste arquivo, então uma regra de especificidade igual perderia por
   ordem. :root soma (0,1,0) e faz estas regras vencerem.
   ========================================================================== */
@media (min-width: 993px) {
    :root {
        --sidebar-w: 72px;
    }

    :root .sidebar {
        align-items: center;
    }

    /* Cabeçalho: só o logo, centralizado */
    :root .sidebar-header {
        justify-content: center !important;
        padding: 18px 0;
        width: 100%;
    }
    :root .sidebar-header img {
        height: 34px;
        margin: 0 !important;
    }
    :root .sidebar-header span,
    :root .sidebar-header .btn-link {
        display: none;
    }

    :root .sidebar-menu {
        width: 100%;
        overflow-x: hidden;
    }

    /* Cada página vira um quadrado arredondado com o ícone no centro */
    :root .sidebar .nav-item-custom {
        position: relative;
        width: var(--rail-item);
        height: var(--rail-item);
        margin: 6px auto !important;
        padding: 0;
        justify-content: center;
        border-left: none !important;
        border-radius: var(--radius-nav) !important;
    }
    :root .sidebar .nav-item-custom i {
        margin-right: 0;
        font-size: 1.25rem;
    }
    /* Alguns links aninham <div><i><span></div>; display:contents dissolve o
       wrapper e centraliza o ícone sem precisar mexer no HTML. */
    :root .sidebar .nav-item-custom > div {
        display: contents;
    }

    :root .sidebar .nav-item-custom.active {
        background: var(--accent) !important;
        color: var(--on-accent) !important;
        box-shadow: 0 6px 18px rgba(var(--accent-rgb), .35);
    }
    :root .sidebar .nav-item-custom.active i {
        color: var(--on-accent) !important;
    }

    /* Some o rótulo, nunca o contador */
    :root .sidebar .nav-item-custom span:not(.badge) {
        display: none;
    }
    :root .sidebar .nav-item-custom .badge {
        position: absolute;
        top: 1px;
        right: 1px;
        min-width: 15px;
        padding: 1px 4px !important;
        font-size: .55rem !important;
        line-height: 1.2;
    }

    /* Títulos de seção viram divisores: rótulo não cabe a 72px, e recolher não
       faz sentido quando não há o que recolher. pointer-events:none neutraliza
       o onclick sem tocar no JS. */
    :root .sidebar .nav-section-header {
        height: 1px;
        min-height: 1px;
        padding: 0;
        margin: 12px 16px;
        background: var(--border-soft);
        overflow: hidden;
        pointer-events: none;
    }
    :root .sidebar .nav-section-header * {
        display: none;
    }
    :root .sidebar .nav-section-content {
        display: block !important;
        border-left: none;
        margin-left: 0;
        padding-bottom: 0;
    }

    /* Rodapé: só o avatar na trilha; perfil e números abrem num painel ao lado.
       Esconder tudo tiraria o botão de som, que é preferência de verdade. */
    :root .sidebar-bottom {
        position: relative;
        padding: 8px 0 14px;
        width: 100%;
        text-align: center;
    }
    :root .sidebar-bottom .sidebar-card-header {
        display: none;
    }
    :root .sb-rail-avatar {
        display: flex;
        align-items: center;
        justify-content: center;
        margin: 0 auto 10px;
        width: 38px;
        height: 38px;
        border-radius: 50%;
        background: var(--accent-soft);
        color: var(--accent);
        font-size: .78rem;
        font-weight: 700;
        cursor: default;
    }
    /* Perfil e estatísticas saem juntos num painel só, senão os dois se
       sobrepõem no mesmo canto. */
    :root .sb-flyout {
        display: none;
        position: absolute;
        bottom: 8px;
        left: calc(var(--sidebar-w) + 8px);
        width: 264px;
        padding: 12px;
        text-align: left;
        background: var(--surface);
        border: 1px solid var(--border);
        border-radius: var(--radius-card);
        box-shadow: var(--shadow-card);
        z-index: 1100;
    }
    :root .sidebar-bottom:hover .sb-flyout {
        display: block;
    }
    :root .sb-flyout .sidebar-card-content {
        display: block !important;
    }

    /* ── Expansão temporária ────────────────────────────────────────────────
       O conteúdo da página continua ancorado nos 72px: a barra cresce por
       cima, então passar o mouse não empurra nada. */
    :root .sidebar:is(:hover, :focus-within) {
        width: var(--sidebar-expanded-w);
        align-items: stretch;
        box-shadow: 18px 0 36px rgba(0, 0, 0, .45);
    }
    :root .sidebar:is(:hover, :focus-within) .sidebar-header {
        justify-content: flex-start !important;
        padding: 16px;
    }
    :root .sidebar:is(:hover, :focus-within) .sidebar-header img {
        height: 38px;
        margin-right: 10px !important;
    }
    :root .sidebar:is(:hover, :focus-within) .sidebar-header span {
        display: inline;
        white-space: nowrap;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-item-custom {
        width: auto;
        height: 42px;
        margin: 4px 10px !important;
        padding: 0 12px;
        justify-content: flex-start;
        border-radius: 8px !important;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-item-custom > i,
    :root .sidebar:is(:hover, :focus-within) .nav-item-custom > div > i {
        flex-shrink: 0;
        margin-right: 12px;
        font-size: 1.05rem;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-item-custom span:not(.badge) {
        display: inline;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-item-custom .badge {
        position: static;
        margin-left: auto;
        min-width: 18px;
        font-size: .58rem !important;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-section-header {
        height: auto;
        min-height: 0;
        margin: 10px 14px 4px;
        padding: 5px 0;
        background: transparent;
        overflow: visible;
        pointer-events: auto;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-section-header * {
        display: inline;
    }
    /* Na trilha recolhida, os ícones de todas as seções continuam visíveis.
       Quando o menu abre, porém, o estado controlado pela seta volta a valer. */
    :root .sidebar:is(:hover, :focus-within) .nav-section-content {
        display: none !important;
    }
    :root .sidebar:is(:hover, :focus-within) .nav-section-content.expanded {
        display: block !important;
    }
    :root .sidebar:is(:hover, :focus-within) .sidebar-bottom {
        padding: 8px 14px 14px;
        text-align: left;
    }
    :root .sidebar:is(:hover, :focus-within) .sb-rail-avatar {
        display: none;
    }
    :root .sidebar:is(:hover, :focus-within) .sb-flyout {
        display: block;
        position: static;
        width: auto;
        padding: 0;
        background: transparent;
        border: 0;
        border-radius: 0;
        box-shadow: none;
    }
    :root .sidebar:is(:hover, :focus-within) .sidebar-card-header {
        display: flex;
    }
    /* Com a barra aberta, Perfil e Hoje respeitam suas próprias setas. */
    :root .sidebar:is(:hover, :focus-within) .sb-flyout .sidebar-card-content {
        display: none !important;
    }
    :root .sidebar:is(:hover, :focus-within) .sb-flyout .sidebar-card-content.expanded {
        display: block !important;
    }
}
