:root {
    /* ============================================================ */
    /* 1. VARIÁVEIS DE TEMA (White Label)                           */
    /* ============================================================ */
    
    /* Cores Padrão (Baseado no Vermelho ARQMED Original) */
    --theme-primary: #dc2626;      /* Equivale ao red-600 */
    --theme-hover: #b91c1c;        /* Equivale ao red-700 */
    --theme-sidebar-top: #7f1d1d;  /* Gradiente Superior Sidebar */
    --theme-sidebar-bottom: #4c0f0f; /* Gradiente Inferior Sidebar */
    --theme-bg-light: #fef2f2;     /* Fundo Claro (red-50) */
    --theme-border: #fca5a5;       /* Bordas (red-300) */

    /* Variáveis Estruturais */
    --sidebar-bg: linear-gradient(180deg, var(--theme-sidebar-top) 0%, var(--theme-sidebar-bottom) 100%);
    --glass: rgba(255, 255, 255, 0.06);
}

/* ============================================================ */
/* 2. OVERRIDES DO TAILWIND (A Mágica do White Label)           */
/* ============================================================ */
/* Estas regras forçam o sistema a usar as variáveis acima 
   mesmo quando o HTML pede as classes vermelhas do Tailwind */

/* Cores de Texto */
.text-red-600 { color: var(--theme-primary) !important; }
.text-red-700 { color: var(--theme-hover) !important; }
.text-red-800 { color: var(--theme-sidebar-top) !important; }

/* Cores de Fundo */
.bg-red-50  { background-color: var(--theme-bg-light) !important; }
.bg-red-100 { background-color: var(--theme-bg-light) !important; filter: brightness(0.95); }
.bg-red-600 { background-color: var(--theme-primary) !important; }
.bg-red-700 { background-color: var(--theme-hover) !important; }

/* Bordas */
.border-red-600 { border-color: var(--theme-primary) !important; }
.border-red-300 { border-color: var(--theme-border) !important; }
.border-red-200 { border-color: var(--theme-border) !important; opacity: 0.5; }

/* Sidebar e Header */
#sidebar, .md\:bg-gradient-to-b {
    background: var(--sidebar-bg) !important;
}

header.border-red-600 {
    border-color: var(--theme-primary) !important;
}

/* Botões Customizados */
.btn-red {
    background-color: var(--theme-primary) !important;
    color: white !important;
}
.btn-red:hover {
    background-color: var(--theme-hover) !important;
}


/* ============================================================ */
/* 3. ESTILOS GERAIS DO SISTEMA (Mantidos do Original)          */
/* ============================================================ */

/* Sidebar container */
#sidebar {
    color: #fff;
    width: 18rem;
    padding: 0;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.45);
    display: flex;
    flex-direction: column;
}

#sidebar-header {
  background-color: #ffffff;
  width: 100%;
  height: 5rem;
  padding: 0 1.5rem;
  border-bottom: 4px solid var(--theme-primary); /* Usando variável */
  display: flex;
  align-items: center;
  box-sizing: border-box;
}

#sidebar nav {
    padding: 1.5rem;
    flex: 1;
    overflow-y: auto;
}

#sidebar .mt-8 {
    margin-top: auto;
    padding: 1.5rem;
}

/* Botões / itens da sidebar */
button.sidebar-hover {
    position: relative;
    display: flex;
    align-items: center;
    gap: .75rem;
    width: 100%;
    text-align: left;
    padding: .9rem 1rem;
    border-radius: .75rem;
    background: transparent;
    color: rgba(255, 255, 255, 0.95);
    border: 1px solid rgba(255, 255, 255, 0.04);
    cursor: pointer;
    transition: transform .22s cubic-bezier(.2, .9, .2, 1),
        box-shadow .22s ease,
        background-color .18s ease,
        color .18s ease;
    transform-origin: left center;
    outline: none;
}

/* Barra lateral de acento (pseudo-element) */
button.sidebar-hover::before {
    content: '';
    position: absolute;
    left: 0.25rem;
    top: 50%;
    transform: translateY(-50%) scaleY(1);
    height: 60%;
    width: 4px;
    border-radius: 4px;
    background: transparent;
    transition: background .18s ease, height .18s ease;
    box-shadow: 0 0 0 rgba(0, 0, 0, 0);
    opacity: 0.0;
}

/* Ícone dentro do botão */
button.sidebar-hover i {
    min-width: 1.4rem;
    text-align: center;
    font-size: 1.05rem;
    transition: transform .22s cubic-bezier(.2, .9, .2, 1), color .18s ease;
    transform-origin: center;
}

/* Hover — visível e forte */
button.sidebar-hover:hover {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.03));
    transform: translateX(6px) scale(1.03);
    box-shadow: 0 8px 28px rgba(0, 0, 0, 0.35), 0 1px 0 rgba(255, 255, 255, 0.02) inset;
    color: #fff;
}

/* Atualizado para usar as variáveis de tema no gradiente do hover */
button.sidebar-hover:hover::before {
    background: linear-gradient(180deg, var(--theme-primary), var(--theme-sidebar-top));
    opacity: 1;
    height: 75%;
}

button.sidebar-hover:hover i {
    transform: translateX(3px) rotate(8deg) scale(1.15);
    color: #fff;
}

/* Estado ativo (visível e distinto) */
.sidebar-active {
    background: linear-gradient(90deg, rgba(255, 255, 255, 0.06), rgba(255, 255, 255, 0.02));
    color: #fff;
    transform: translateX(6px) scale(1.03);
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.24), 0 1px 0 rgba(255, 255, 255, 0.02) inset;
}

/* Atualizado para usar as variáveis de tema */
.sidebar-active::before {
    background: linear-gradient(180deg, var(--theme-primary), var(--theme-hover));
    opacity: 1;
    height: 85%;
}

.sidebar-active i {
    transform: translateX(3px) scale(1.12);
}

/* Foco por teclado (acessibilidade) */
button.sidebar-hover:focus-visible {
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.18), 0 8px 30px rgba(0, 0, 0, 0.35);
}

/* Submenu itens */
#submenu-config .sidebar-hover {
    padding-left: 1.5rem;
    font-size: 0.95rem;
    background: transparent;
    border: none;
}

#submenu-config .sidebar-hover:hover {
    background: rgba(255, 255, 255, 0.04);
    transform: translateX(4px);
}

/* Scrollbar Customizada */
.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
.custom-scrollbar::-webkit-scrollbar-track {
  background: #f1f1f1;
}
.custom-scrollbar::-webkit-scrollbar-thumb {
  background: #d1d5db; /* gray-300 */
  border-radius: 10px;
}
.custom-scrollbar::-webkit-scrollbar-thumb:hover {
  background: #9ca3af; /* gray-400 */
}

/* Sessão ativa (rodapé) */
.session-box {
    margin-top: 1.25rem;
    padding: 0.9rem;
    background: var(--glass);
    border-radius: 0.7rem;
    border: 1px solid rgba(255, 255, 255, 0.06);
    box-shadow: 0 6px 18px rgba(0, 0, 0, 0.35);
    color: rgba(255, 255, 255, 0.95);
}

/* Botão sair destacado */
.logout-btn {
    margin-top: 1rem;
    width: 100%;
    padding: .9rem;
    border-radius: .75rem;
    background: linear-gradient(90deg, var(--theme-sidebar-top), var(--theme-sidebar-bottom));
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.18);
    border: none;
    color: #fff;
    font-weight: 600;
    cursor: pointer;
    transition: transform .18s ease, box-shadow .18s ease, filter .18s ease;
}

.logout-btn:hover {
    transform: translateY(-2px);
    filter: brightness(1.03);
    box-shadow: 0 16px 36px rgba(0, 0, 0, 0.24);
}

/* Responsividade */
@media (max-width: 768px) {
    #sidebar {
        width: 100%;
        padding: 1rem;
    }

    button.sidebar-hover {
        padding: .75rem;
        border-radius: .6rem;
    }
}

@keyframes slideInRight {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

@keyframes fadeOut {
    from { opacity: 1; }
    to { opacity: 0; }
}

.toast-enter {
    animation: slideInRight 0.3s ease-out forwards;
}

.toast-exit {
    animation: fadeOut 0.3s ease-in forwards;
}

.modal-confirm-overlay {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    animation: fadeIn 0.2s forwards;
    backdrop-filter: blur(2px);
}

.modal-confirm-box {
    background: white;
    border-radius: 0.75rem;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);
    width: 90%;
    max-width: 400px;
    padding: 1.5rem;
    transform: scale(0.95);
    animation: scaleUp 0.2s forwards;
    border-top: 4px solid var(--theme-primary);
}

@keyframes fadeIn { to { opacity: 1; } }
@keyframes scaleUp { to { transform: scale(1); } }