/* Variáveis CSS para cores do sidebar no modo light - serão sobrescritas por cada painel */
:root {
    --sidebar-bg-light: #2D3748;
    --sidebar-text-light: #F7FAFC;
    --sidebar-text-secondary-light: #CBD5E0;
    --sidebar-border-light: #4A5568;
    --sidebar-hover-light: #4A5568;
    --sidebar-active-light: #5a52c9;
}

/* Aplicar cores personalizadas do sidebar no modo light */
.sidebar-panel {
    background-color: var(--sidebar-bg-light) !important;
    border-color: var(--sidebar-border-light) !important;
}

/* No modo dark, usar as cores personalizadas de cada painel ou padrão */
.dark .sidebar-panel {
    background-color: var(--sidebar-bg-dark, #1E293B) !important;
    border-color: #334155 !important;
}

/* Cores dos textos e links no sidebar - modo light */
.sidebar-panel .sidebar-label p,
.sidebar-panel nav a:not(.bg-primary),
.sidebar-panel nav button {
    color: var(--sidebar-text-secondary-light) !important;
}

.sidebar-panel nav a:hover:not(.bg-primary),
.sidebar-panel nav button:hover {
    background-color: var(--sidebar-hover-light) !important;
}

.sidebar-panel .submenu {
    border-color: var(--sidebar-border-light) !important;
}

/* No modo dark, usar cores padrão */
.dark .sidebar-panel .sidebar-text,
.dark .sidebar-panel .sidebar-label,
.dark .sidebar-panel .sidebar-label p,
.dark .sidebar-panel nav a:not(.bg-primary),
.dark .sidebar-panel nav button {
    color: var(--sidebar-text-dark, #94A3B8) !important;
}

.dark .sidebar-panel nav a:hover:not(.bg-primary),
.dark .sidebar-panel nav button:hover {
    background-color: rgba(51, 65, 85, 0.5) !important;
}

.dark .sidebar-panel .submenu {
    border-color: #334155 !important;
}

.sidebar-scroll::-webkit-scrollbar {
    width: 5px;
}
.sidebar-scroll::-webkit-scrollbar-track {
    background: transparent;
}
.sidebar-scroll::-webkit-scrollbar-thumb {
    background: #64748B;
    border-radius: 4px;
}
.sidebar-scroll:hover::-webkit-scrollbar-thumb {
    background: #6B63DD;
}

/* ============================
 * Select2 - integração com tema claro/escuro
 * Deixa o Select2 visualmente igual aos inputs padrão do painel
 * ============================ */

/* Largura sempre 100% para seguir o campo original */
.select2-container {
    width: 100% !important;
}

/* Estado padrão (light) – usa o mesmo tom dos inputs do painel */
.select2-container--default .select2-selection--single {
    background-color: #EEF2FF; /* tom claro levemente arroxeado, combinando com o tema */
    border: 1px solid #E5E7EB; /* mesma borda dos inputs */
    border-radius: 0.375rem;   /* rounded-md */
    min-height: 2.5rem;        /* ~ py-2 + text-sm */
    padding: 0.5rem 0.75rem;
    display: flex;
    align-items: center;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #111827; /* text-text-main-light aproximado */
    padding-left: 0;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100%;
    right: 0.5rem;
}

/* Focus */
.select2-container--default.select2-container--focus .select2-selection--single {
    border-color: #6366F1; /* primary aproximado */
    box-shadow: 0 0 0 1px rgba(99, 102, 241, 0.3);
}

/* Modo dark – alinhado aos inputs em dark mode */
.dark .select2-container--default .select2-selection--single {
    background-color: #020617; /* mesmo fundo dos campos em dark */
    border-color: #111827;     /* borda levemente mais clara para destacar */
}

.dark .select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #F9FAFB; /* texto claro */
}

/* Dropdown */
.select2-container--default .select2-results__options {
    max-height: 260px;
}

.select2-container--default .select2-results > .select2-results__options {
    background-color: #EEF2FF; /* mesmo tom do campo no light */
    color: #111827;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #4F46E5; /* primary */
    color: #FFFFFF;
}

.dark .select2-container--default .select2-results > .select2-results__options {
    background-color: #020617; /* segue o fundo dos campos no dark */
    color: #E5E7EB;
}

.dark .select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #4F46E5;
    color: #FFFFFF;
}
@keyframes spin-slow {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}
.animate-spin-slow {
    animation: spin-slow 3s linear infinite;
}
.submenu {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, opacity 0.3s ease-out;
    opacity: 0;
}
.submenu:not(.hidden) {
    max-height: 500px;
    opacity: 1;
}
/* No modo mini, o submenu nunca deve aparecer */
aside.sidebar-mini .submenu:not(.hidden) {
    max-height: 0 !important;
    opacity: 0 !important;
    visibility: hidden !important;
    display: none !important;
}
.submenu-icon {
    transition: transform 0.3s ease;
}
/* Submenu Link Hover Effects */
.submenu a {
    transition: all 0.2s ease;
}
.submenu a:hover {
    transform: translateX(4px);
}
.submenu a:hover span:first-child {
    transform: scale(1.2);
    transition: transform 0.2s ease;
}
/* Mini Sidebar Styles */
aside.sidebar-mini {
    width: 80px !important;
}
aside.sidebar-mini .sidebar-text,
aside.sidebar-mini .sidebar-label,
aside.sidebar-mini .sidebar-badge,
aside.sidebar-mini .submenu-icon {
    display: none !important;
}
aside.sidebar-mini .sidebar-icon {
    margin-right: 0 !important;
}
aside.sidebar-mini nav a,
aside.sidebar-mini nav button {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}
aside.sidebar-mini .menu-item {
    position: relative;
}
/* No modo mini, o submenu antigo não deve aparecer - apenas o tooltip */
aside.sidebar-mini .menu-item .submenu {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}
/* Tooltip unificado para modo mini - todos os itens */
aside.sidebar-mini nav a,
aside.sidebar-mini nav button {
    position: relative;
}

/* Tooltip container que será criado via JavaScript */
.mini-tooltip {
    position: fixed;
    left: 80px;
    background: #ffffff;
    color: #1E293B;
    border-radius: 0.5rem;
    padding: 0.75rem;
    min-width: 200px;
    z-index: 1002;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    border: 1px solid #E2E8F0;
    pointer-events: none;
    opacity: 0;
    visibility: hidden;
    transform: translateX(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}
.mini-tooltip.show {
    opacity: 1;
    visibility: visible;
    transform: translateX(0);
    pointer-events: auto;
}
.dark .mini-tooltip {
    background: #1E293B;
    color: #F8FAFC;
    border-color: #334155;
}
.mini-tooltip-title {
    font-weight: 600;
    font-size: 0.875rem;
    margin-bottom: 0.5rem;
    padding-bottom: 0.5rem;
    border-bottom: 1px solid #E2E8F0;
    color: #1E293B;
}
.dark .mini-tooltip-title {
    border-bottom-color: #334155;
    color: #F8FAFC;
}
.mini-tooltip-items {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}
.mini-tooltip-item {
    font-size: 0.8125rem;
    padding: 0.375rem 0.5rem;
    border-radius: 0.375rem;
    transition: background-color 0.2s;
    color: #64748B;
    cursor: pointer;
}
.dark .mini-tooltip-item {
    color: #94A3B8;
}
.mini-tooltip-item:hover {
    background-color: #F1F5F9;
    color: #6B63DD;
}
.dark .mini-tooltip-item:hover {
    background-color: #334155;
    color: #6B63DD;
}
/* Dropdown Menus */
.dropdown-menu {
    position: absolute;
    top: calc(100% + 0.75rem);
    right: 0;
    background: #ffffff;
    border-radius: 0.5rem;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
    min-width: 320px;
    max-width: 380px;
    z-index: 1050;
    opacity: 0;
    visibility: hidden;
    transform: translateY(-10px);
    transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
    border: 1px solid #E2E8F0;
}
#user-dropdown {
    min-width: 240px;
}
/* Ajustes para telas menores - dropdown responsivo (exceto user-dropdown) */
@media (max-width: 640px) {
    header {
        overflow: visible !important;
    }
    header > div {
        overflow: visible !important;
    }
    /* Garantir que o container relativo não corte o dropdown */
    header .relative {
        overflow: visible !important;
    }
}
@media (min-width: 641px) and (max-width: 768px) {
    header {
        overflow: visible !important;
    }
    header > div {
        overflow: visible !important;
    }
    /* Garantir que o container relativo não corte o dropdown */
    header .relative {
        overflow: visible !important;
    }
}
.dropdown-menu.show {
    opacity: 1;
    visibility: visible;
    transform: translateY(0);
}
.dark .dropdown-menu {
    background: #1E293B;
    border-color: #334155;
}
.dropdown-header {
    padding: 1rem;
    border-bottom: 1px solid #E2E8F0;
}
.dark .dropdown-header {
    border-bottom-color: #334155;
}
/* Corrigir quadrado azul no avatar do usuário */
.dropdown-header .rounded-full {
    background: transparent !important;
}
.dropdown-header .rounded-full img {
    background: transparent !important;
    display: block;
}
#user-toggle {
    background: transparent !important;
    border: none !important;
    padding: 0 !important;
    overflow: visible !important;
    border-radius: 50%;
}
#user-toggle img {
    background: transparent !important;
    display: block;
    border-radius: 50%;
}
/* Ajustar indicador de status online para não ser cortado */
#user-toggle > span {
    bottom: -2px !important;
    right: -2px !important;
}
/* Esconder título no header e mostrar abaixo em telas menores que 376px */
@media (max-width: 375px) {
    .page-title-header {
        display: none !important;
    }
    .page-title-below {
        display: block !important;
    }
    /* Ajustar padding do conteúdo quando título aparece abaixo */
    .page-title-below ~ div {
        padding-top: 0.5rem !important;
    }
}
@media (min-width: 376px) {
    .page-title-below {
        display: none !important;
    }
}
.dropdown-item {
    padding: 0.75rem 1rem;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    cursor: pointer;
    transition: background-color 0.2s;
    border-bottom: 1px solid #F1F5F9;
}
.dark .dropdown-item {
    border-bottom-color: #334155;
}
.dropdown-item:last-child {
    border-bottom: none;
}
.dropdown-item:hover {
    background-color: #F8FAFC;
}
.dark .dropdown-item:hover {
    background-color: #334155;
}
/* Estilos para o toggle switch no menu do usuário */
.dropdown-item label {
    margin: 0;
}
.dropdown-item input[type="checkbox"]:checked + div {
    background-color: #6B63DD;
}
.dropdown-item input[type="checkbox"]:checked + div:after {
    background-color: #ffffff;
}
.dropdown-footer {
    padding: 0.75rem 1rem;
    border-top: 1px solid #E2E8F0;
    text-align: center;
}
.dark .dropdown-footer {
    border-top-color: #334155;
}
/* Sidebar Toggle Button Visibility */
.sidebar-toggle-btn {
    display: none;
}
@media (min-width: 1000px) {
    .sidebar-toggle-btn {
        display: flex;
    }
}
/* Sticky Footer */
body {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}
#app-container {
    display: flex;
    flex: 1;
    min-height: 0;
}
/* Mobile Sidebar Overlay */
.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 40;
    transition: opacity 0.3s ease;
}
.sidebar-overlay.active {
    display: block;
    opacity: 1;
}
/* Desktop Sidebar - Fixed */
@media (min-width: 1024px) {
    aside#sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100vh;
        overflow-y: auto;
        overflow-x: hidden;
        z-index: 30;
    }
    aside#sidebar.sidebar-mini {
        width: 80px !important;
    }
    /* Ajustar margin do main para compensar o sidebar fixo */
    main {
        transition: margin-left 0.3s ease;
    }
    /* Ajustar header fixo baseado no sidebar */
    header {
        transition: left 0.3s ease, right 0.3s ease;
    }
    body:not(.sidebar-mini-active) header {
        left: 256px;
    }
    body.sidebar-mini-active header {
        left: 80px;
    }
    /* Barra de ações fixa inferior (mesma lógica do header) */
    #painel-fixed-footer {
        transition: left 0.3s ease, right 0.3s ease;
    }
    body:not(.sidebar-mini-active) #painel-fixed-footer {
        left: 256px;
    }
    body.sidebar-mini-active #painel-fixed-footer {
        left: 80px;
    }
}
/* Mobile - Header full width */
@media (max-width: 1023px) {
    header {
        left: 0 !important;
        right: 0 !important;
        top: 0 !important;
        margin: 0 !important;
        border-radius: 0 !important;
        border-left: none !important;
        border-right: none !important;
        border-top: none !important;
        overflow: visible !important;
    }
    #painel-fixed-footer {
        left: 0 !important;
        right: 0 !important;
    }
    header > div:last-child {
        gap: 1rem !important;
        flex-wrap: nowrap;
    }
    header > div:last-child > button,
    header > div:last-child > div {
        flex-shrink: 0;
    }
}
/* Mobile Sidebar */
@media (max-width: 1023px) {
    aside {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        z-index: 50;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
    }
    aside.mobile-open {
        transform: translateX(0);
    }
}
/* Notifications Sidebar Right */
#notifications-sidebar {
    position: fixed;
    top: 0;
    right: 0;
    width: 400px;
    max-width: 90vw;
    height: 100vh;
    background: #ffffff;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 60;
    transform: translateX(100%);
    transition: transform 0.3s ease;
    display: flex;
    flex-direction: column;
    border-left: 1px solid #E2E8F0;
}
#notifications-sidebar.open {
    transform: translateX(0);
}
.dark #notifications-sidebar {
    background: #1E293B;
    border-left-color: #334155;
}
#notifications-sidebar .sidebar-header {
    padding: 1.5rem;
    border-bottom: 1px solid #E2E8F0;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-shrink: 0;
}
.dark #notifications-sidebar .sidebar-header {
    border-bottom-color: #334155;
}
#notifications-sidebar .sidebar-header h2 {
    font-size: 1.125rem;
    font-weight: 700;
    color: #1E293B;
    margin: 0;
}
.dark #notifications-sidebar .sidebar-header h2 {
    color: #F8FAFC;
}
#notifications-sidebar .sidebar-header p {
    font-size: 0.75rem;
    color: #64748B;
    margin: 0.25rem 0 0 0;
}
.dark #notifications-sidebar .sidebar-header p {
    color: #94A3B8;
}
#notifications-sidebar .sidebar-close {
    background: transparent;
    border: none;
    color: #64748B;
    cursor: pointer;
    padding: 0.5rem;
    border-radius: 0.375rem;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}
#notifications-sidebar .sidebar-close:hover {
    background: #F1F5F9;
    color: #1E293B;
}
.dark #notifications-sidebar .sidebar-close:hover {
    background: #334155;
    color: #F8FAFC;
}
#notifications-sidebar .sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
}
#notifications-sidebar .notification-item {
    padding: 1rem;
    border-bottom: 1px solid #F1F5F9;
    display: flex;
    gap: 0.75rem;
    transition: background-color 0.2s;
    cursor: pointer;
}
#notifications-sidebar .notification-item:hover {
    background: #F8FAFC;
}
.dark #notifications-sidebar .notification-item {
    border-bottom-color: #334155;
}
.dark #notifications-sidebar .notification-item:hover {
    background: #334155;
}
#notifications-sidebar .notification-item:last-child {
    border-bottom: none;
}
#notifications-sidebar .notification-icon {
    width: 2.5rem;
    height: 2.5rem;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}
#notifications-sidebar .notification-content {
    flex: 1;
    min-width: 0;
}
#notifications-sidebar .notification-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1E293B;
    margin: 0 0 0.25rem 0;
}
.dark #notifications-sidebar .notification-title {
    color: #F8FAFC;
}
#notifications-sidebar .notification-text {
    font-size: 0.8125rem;
    color: #64748B;
    margin: 0 0 0.25rem 0;
    line-height: 1.4;
}
.dark #notifications-sidebar .notification-text {
    color: #94A3B8;
}
#notifications-sidebar .notification-time {
    font-size: 0.75rem;
    color: #94A3B8;
    margin: 0;
}
.dark #notifications-sidebar .notification-time {
    color: #64748B;
}
#notifications-sidebar .sidebar-footer {
    padding: 1rem 1.5rem;
    border-top: 1px solid #E2E8F0;
    text-align: center;
    flex-shrink: 0;
}
.dark #notifications-sidebar .sidebar-footer {
    border-top-color: #334155;
}
#notifications-sidebar .sidebar-footer a {
    color: #6B63DD;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    transition: color 0.2s;
}
#notifications-sidebar .sidebar-footer a:hover {
    color: #5a52c9;
    text-decoration: underline;
}
/* Overlay para sidebar de notificações */
#notifications-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 59;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}
#notifications-overlay.active {
    opacity: 1;
    visibility: visible;
}
/* Responsivo - sidebar de notificações */
@media (min-width: 1024px) and (max-width: 1280px) {
    #notifications-sidebar {
        width: 380px;
    }
}
@media (max-width: 1023px) {
    #notifications-sidebar {
        width: 100vw;
        max-width: 100vw;
    }
}

/* ── Barra de navegação inferior (somente app mobile) ─────────────────── */
body.app-mode main {
    padding-bottom: calc(4.75rem + env(safe-area-inset-bottom, 0px));
}

body.app-mode .painel-default-footer {
    display: none;
}

.app-bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 50;
    display: flex;
    justify-content: space-around;
    align-items: stretch;
    background: #0f172a;
    border-top: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: 0 -4px 16px rgba(0, 0, 0, 0.35);
    padding: 0.35rem 0 calc(0.35rem + env(safe-area-inset-bottom, 0px));
}

.dark .app-bottom-nav {
    background: #0b0f14;
}

.app-bottom-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 0.15rem;
    padding: 0.45rem 0.25rem;
    text-decoration: none;
    color: #94a3b8;
    font-size: 0.65rem;
    font-weight: 500;
    line-height: 1.1;
    transition: color 0.15s ease;
}

.app-bottom-nav a .material-symbols-outlined {
    font-size: 1.35rem;
    line-height: 1;
}

.app-bottom-nav a.active,
.app-bottom-nav a:hover {
    color: #6B63DD;
}

.app-bottom-nav a.active .material-symbols-outlined {
    font-variation-settings: 'FILL' 1;
}

/* Fallback WebView: só modais fixos no app — NÃO usar .hidden global (quebra hidden lg:flex no site) */
body.app-mode .fixed.inset-0.hidden,
body.app-mode [id*="modal"].hidden {
    display: none !important;
}

/* Bloqueia troca de aba antes de CSS/JS terminarem (WebView Android) */
body.app-mode:not(.horad-page-ready) .app-bottom-nav {
    pointer-events: none;
    opacity: 0.55;
}

/* ── Overlay de carregamento (navegação no painel) ─────────────────────── */
.horad-app-preloader {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    background-color: #0f172a;
    padding: 1.5rem;
    text-align: center;
}

.horad-app-preloader__icon {
    width: 6rem;
    height: 6rem;
    object-fit: contain;
    border-radius: 1.125rem;
    margin-bottom: 1.25rem;
    box-shadow: 0 10px 32px rgba(107, 99, 221, 0.35);
    animation: horad-preloader-icon-pulse 1.8s ease-in-out infinite;
}

@keyframes horad-preloader-icon-pulse {
    0%, 100% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.04);
    }
}

.horad-app-preloader__spinner {
    color: #6B63DD;
    font-size: 2.25rem;
    line-height: 1;
    margin-bottom: 0.5rem;
}

.horad-app-preloader__message {
    color: #e2e8f0;
    font-size: 0.95rem;
    line-height: 1.45;
    max-width: 18rem;
    margin: 0;
}

.horad-app-preloader__actions {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 0.75rem;
    margin-top: 1.25rem;
}

.horad-app-preloader--hidden {
    display: none !important;
    opacity: 0;
    pointer-events: none;
}

.horad-app-preloader__btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 2.5rem;
    padding: 0.5rem 1rem;
    border-radius: 0.5rem;
    border: 0;
    font-size: 0.875rem;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    transition: background-color 0.15s ease, color 0.15s ease;
}

.horad-app-preloader__btn--primary {
    background: #6B63DD;
    color: #fff;
}

.horad-app-preloader__btn--primary:hover {
    background: #5a52c4;
}

.horad-app-preloader__btn--secondary {
    background: rgba(255, 255, 255, 0.08);
    color: #e2e8f0;
}

.horad-app-preloader__btn--secondary:hover {
    background: rgba(255, 255, 255, 0.14);
}
