:root {
    --color-primary: #7B6CF6;
    --color-primary-hover: #6A5CE8;
    --color-primary-soft: rgba(123, 108, 246, 0.12);
    --color-bg: #F5F6FA;
    --color-card: #ffffff;
    --color-text: #2D2B3A;
    --color-text-muted: #8B87A0;
    --color-border: #E8E6F0;
    --shadow-soft: 0 4px 24px -4px rgba(45, 43, 58, 0.06);
    --shadow-soft-lg: 0 10px 40px -8px rgba(45, 43, 58, 0.08);
}

/* Cards com sombra suave */
.shadow-card,
.rounded-xl.bg-white,
.rounded-2xl.bg-white,
.rounded-xl.bg-card-light,
.rounded-2xl.bg-card-light {
    box-shadow: var(--shadow-soft);
}

.shadow-card-lg {
    box-shadow: var(--shadow-soft-lg);
}

/* Sidebar */
#sidebar {
    box-shadow: 4px 0 24px -4px rgba(123, 108, 246, 0.15);
}

#sidebar nav a,
#sidebar > .flex.flex-col.gap-4 > a:not(.text-red-300) {
    color: rgba(255, 255, 255, 0.88) !important;
}

#sidebar nav a .material-symbols-outlined,
#sidebar > .flex.flex-col.gap-4 > a .material-symbols-outlined {
    color: #ffffff !important;
}

#sidebar nav a:hover,
#sidebar > .flex.flex-col.gap-4 > a:not(.text-red-300):hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

#sidebar nav a.sidebar-link-active {
    background: rgba(255, 255, 255, 0.22) !important;
    color: #ffffff !important;
}

#sidebar .text-red-300 {
    color: #FCA5A5 !important;
}

#sidebar .text-red-300:hover {
    background: rgba(239, 68, 68, 0.15) !important;
}

#sidebar #sidebar-toggle {
    color: rgba(255, 255, 255, 0.85) !important;
}

#sidebar #sidebar-toggle:hover {
    background: rgba(255, 255, 255, 0.12) !important;
}

#sidebar .sidebar-logo-wrap {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 1.25rem 1rem 1rem;
    overflow: visible;
}

#sidebar .sidebar-logo-link {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 4.5rem;
    height: 4.5rem;
    flex-shrink: 0;
}

#sidebar .sidebar-app-icon {
    width: 3.5rem;
    height: 3.5rem;
    object-fit: contain;
    object-position: center;
    display: block;
}

#sidebar .sidebar-toggle-wrap {
    margin-top: auto;
    padding: 0.75rem 1rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.12);
}

#sidebar .sidebar-toggle-btn {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    width: 100%;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    color: rgba(255, 255, 255, 0.88);
    transition: background-color 0.2s ease;
}

#sidebar .sidebar-toggle-btn:hover {
    background: rgba(255, 255, 255, 0.12);
}

/* Sidebar retraído */
#sidebar.sidebar-collapsed {
    width: 5rem;
}

#sidebar.sidebar-collapsed .sidebar-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

#sidebar.sidebar-collapsed .sidebar-logo-link {
    width: 3.25rem;
    height: 3.25rem;
}

#sidebar.sidebar-collapsed .sidebar-app-icon {
    width: 2.75rem;
    height: 2.75rem;
}

#sidebar.sidebar-collapsed nav a {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

#sidebar.sidebar-collapsed .sidebar-toggle-btn {
    justify-content: center;
    padding-left: 0.75rem;
    padding-right: 0.75rem;
}

#sidebar.sidebar-collapsed #sidebar-toggle .material-symbols-outlined {
    transform: rotate(180deg);
}

/* Scrollbar suave */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

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

::-webkit-scrollbar-thumb {
    background: #D1CFE0;
    border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
    background: #B8B4CC;
}

.dark ::-webkit-scrollbar-thumb {
    background: #3D3A55;
}

.dark ::-webkit-scrollbar-thumb:hover {
    background: #4F4B6B;
}

/* Botões primários com texto claro */
.btn-primary-soft {
    background-color: var(--color-primary);
    color: #ffffff;
}

.btn-primary-soft:hover {
    background-color: var(--color-primary-hover);
}

/* Página de Perfil */
.profile-nav-link {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.75rem 1rem;
    border-radius: 0.75rem;
    font-size: 0.875rem;
    font-weight: 500;
    color: #6b7280;
    transition: all 0.2s ease;
    border-left: 3px solid transparent;
}

.profile-nav-link:hover {
    background: #F5F6FA;
    color: #2D2B3A;
}

.dark .profile-nav-link {
    color: #A8A3C4;
}

.dark .profile-nav-link:hover {
    background: rgba(255, 255, 255, 0.05);
    color: #ffffff;
}

.profile-nav-link.active {
    background: rgba(123, 108, 246, 0.1);
    color: #7B6CF6;
    border-left-color: #7B6CF6;
    font-weight: 600;
}

.dark .profile-nav-link.active {
    background: rgba(123, 108, 246, 0.15);
    color: #A89FF8;
    border-left-color: #A89FF8;
}

.profile-toggle {
    position: relative;
    width: 2.75rem;
    height: 1.5rem;
    flex-shrink: 0;
}

.profile-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
    position: absolute;
}

.profile-toggle-slider {
    position: absolute;
    cursor: pointer;
    inset: 0;
    background: #D1D5DB;
    border-radius: 9999px;
    transition: 0.2s;
}

.profile-toggle-slider::before {
    content: "";
    position: absolute;
    height: 1.125rem;
    width: 1.125rem;
    left: 3px;
    bottom: 3px;
    background: white;
    border-radius: 50%;
    transition: 0.2s;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.15);
}

.profile-toggle input:checked + .profile-toggle-slider {
    background: #7B6CF6;
}

.profile-toggle input:checked + .profile-toggle-slider::before {
    transform: translateX(1.25rem);
}

/* ——— Mobile & iPad ——— */
.safe-top {
    padding-top: env(safe-area-inset-top, 0px);
}

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

@media (max-width: 1023px) {
    .lg-sticky-only {
        position: static !important;
        top: auto !important;
    }
}

@media (min-width: 1024px) {
    .lg-sticky-only {
        position: sticky;
    }
}

/* Tabelas: cards em mobile */
@media (max-width: 767px) {
    .responsive-table-cards thead {
        display: none;
    }

    .responsive-table-cards tbody tr {
        display: block;
        padding: 1rem;
        border-bottom: 1px solid var(--color-border);
    }

    .dark .responsive-table-cards tbody tr {
        border-bottom-color: #E8E6F0;
    }

    .responsive-table-cards tbody td {
        display: flex;
        justify-content: space-between;
        align-items: flex-start;
        gap: 0.75rem;
        padding: 0.35rem 0;
        border: none;
        text-align: right;
    }

    .responsive-table-cards tbody td::before {
        content: attr(data-label);
        font-size: 0.75rem;
        font-weight: 600;
        text-transform: uppercase;
        letter-spacing: 0.05em;
        color: var(--color-text-muted);
        text-align: left;
        flex-shrink: 0;
    }

    .responsive-table-cards tbody td:first-child {
        display: block;
        text-align: left;
        padding-bottom: 0.5rem;
    }

    .responsive-table-cards tbody td:first-child::before {
        display: none;
    }

    .responsive-table-cards .td-actions {
        justify-content: flex-end;
        padding-top: 0.5rem;
    }

    .responsive-table-cards .td-actions::before {
        display: none;
    }
}

/* Área de toque mínima em dispositivos touch */
@media (hover: none) and (pointer: coarse) {
    .touch-target {
        min-height: 44px;
        min-width: 44px;
    }

    .group-hover\:opacity-100 {
        opacity: 1 !important;
    }
}

/* Busca colapsável no header */
#app-search-wrap.collapsed {
    display: none;
}

@media (min-width: 768px) {
    #app-search-wrap.collapsed {
        display: flex;
    }
}
