/* ==========================================================================
   DESIGN SYSTEM - APPLE INSPIRED (FUTURISTIC & SOPHISTICATED)
   ========================================================================== */

/* Base & Typography */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #09090b; /* Space Gray/Metallic base */
    background-image: 
        radial-gradient(circle at 10% 20%, rgba(99, 102, 241, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 90% 80%, rgba(168, 85, 247, 0.08) 0%, transparent 40%),
        radial-gradient(circle at 50% 50%, rgba(0, 113, 227, 0.04) 0%, transparent 60%);
    background-attachment: fixed;
    min-height: 100vh;
    color: #f3f4f6;
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Glassmorphism Global Base */
.card, .card-dashboard, .modal-content, .dropdown-menu, .offcanvas, .toast {
    background: rgba(22, 22, 26, 0.7) !important;
    backdrop-filter: blur(24px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(24px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 20px !important;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3) !important;
    color: #e5e7eb !important;
}

/* Force bg-white containers inside content/modals to match Apple glassmorphism */
.content .bg-white, .modal-content .bg-white, .modal-body .bg-white {
    background-color: rgba(25, 25, 30, 0.65) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    color: #f3f4f6 !important;
}

.content .bg-white *, .modal-content .bg-white * {
    color: inherit;
}

/* SweetAlert Dark Glassmorphism style */
.swal2-popup {
    background: rgba(20, 20, 25, 0.85) !important;
    backdrop-filter: blur(35px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(35px) saturate(180%) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 24px !important;
    color: #ffffff !important;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.5) !important;
}

.swal2-title {
    color: #ffffff !important;
    font-weight: 700 !important;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
}

.swal2-html-container {
    color: rgba(255, 255, 255, 0.7) !important;
    font-family: -apple-system, BlinkMacSystemFont, sans-serif !important;
}

.swal2-confirm {
    background-color: #0071e3 !important;
    border-radius: 12px !important;
    padding: 0.65rem 2rem !important;
    font-weight: 600 !important;
}

.swal2-cancel {
    background-color: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border-radius: 12px !important;
    padding: 0.65rem 2rem !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
}

/* Splash Screen */
.splash-screen {
    position: fixed;
    inset: 0;
    background: #09090b;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.splash-screen img {
    width: 90px;
    animation: pulse 1.6s infinite cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes pulse {
    0%, 100% {
        transform: scale(0.95);
        opacity: 0.75;
        filter: drop-shadow(0 0 15px rgba(255,255,255,0.05));
    }
    50% {
        transform: scale(1.05);
        opacity: 1;
        filter: drop-shadow(0 0 30px rgba(0, 113, 227, 0.2));
    }
}

/* Login Container */
.login-container {
    min-height: 100vh;
    display: none;
    align-items: center;
    justify-content: center;
    background: transparent;
    padding: 20px;
    z-index: 1;
    position: relative;
}

.login-container.active {
    display: flex;
}

.login-box {
    background: rgba(20, 20, 25, 0.65) !important;
    backdrop-filter: blur(35px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(35px) saturate(190%) !important;
    padding: 3rem 2.5rem;
    border-radius: 24px;
    box-shadow: 0 30px 60px rgba(0, 0, 0, 0.4) !important;
    width: 100%;
    max-width: 440px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.login-box:hover {
    border-color: rgba(255, 255, 255, 0.12);
}

.logo-pequena {
    width: 80px;
    height: auto;
    margin-bottom: 1rem;
    filter: drop-shadow(0 8px 16px rgba(0, 0, 0, 0.2));
}

/* Sidebar - Sleek Glassmorphic macOS Sidebar */
.sidebar {
    position: fixed;
    top: 0;
    left: 0;
    height: 100vh;
    width: 275px;
    background: rgba(15, 15, 20, 0.7) !important;
    backdrop-filter: blur(30px) saturate(180%) !important;
    -webkit-backdrop-filter: blur(30px) saturate(180%) !important;
    border-right: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: none !important;
    z-index: 1040;
    transition: all 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    display: flex;
    flex-direction: column;
}

.sidebar-header {
    min-height: 80px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
}

.header-info h6 {
    color: #ffffff;
    letter-spacing: -0.01em;
    font-size: 1.1rem;
}

.logo-sidebar {
    width: 38px;
    border-radius: 9px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.sidebar-content {
    padding-top: 1.25rem;
}

.sidebar .nav-link {
    padding: 0.75rem 1.1rem;
    margin: 0.25rem 0.85rem;
    border-radius: 10px;
    color: #9ca3af !important;
    font-weight: 500;
    font-size: 0.92rem;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    position: relative;
    overflow: hidden;
}

.sidebar .nav-link::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    height: 100%;
    width: 0;
    background: rgba(255, 255, 255, 0.03);
    transition: width 0.25s ease;
    z-index: 0;
}

.sidebar .nav-link:hover::before {
    width: 100%;
}

.sidebar .nav-link span, .sidebar .nav-link i {
    position: relative;
    z-index: 1;
}

.sidebar .nav-link i {
    font-size: 1.15rem;
    color: #9ca3af;
    transition: color 0.2s ease;
}

.sidebar .nav-link:hover {
    color: #ffffff !important;
}

.sidebar .nav-link:hover i {
    color: #ffffff;
}

.sidebar .nav-link.active {
    background: rgba(255, 255, 255, 0.08) !important;
    color: #ffffff !important;
    border: 1px solid rgba(255, 255, 255, 0.08);
    font-weight: 600;
}

.sidebar .nav-link.active i {
    color: #0071e3; /* Apple Blue highlight for active icon */
}

.sidebar .nav-link.text-danger {
    color: #f87171 !important;
}

.sidebar .nav-link.text-danger:hover {
    background: rgba(239, 68, 68, 0.1) !important;
    color: #ef4444 !important;
}

.sidebar-footer {
    border-top: 1px solid rgba(255, 255, 255, 0.05) !important;
}

.user-profile-badge {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
}

/* Main Content Area */
.content {
    margin-left: 275px;
    padding: 2rem;
    min-height: 100vh;
    background: transparent;
    transition: margin-left 0.4s cubic-bezier(0.16, 1, 0.3, 1);
}

.main-header {
    border: none;
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05);
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
    border-radius: 16px;
    margin-bottom: 1.5rem;
}

/* Forms & Inputs */
.form-label {
    color: #ffffff;
    font-weight: 500;
    font-size: 0.85rem;
}

.modal .form-label, 
.modal label {
    color: #ffffff !important;
}

.form-control, .form-select {
    padding: 0.75rem 1rem;
    border-radius: 12px;
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    color: #ffffff !important;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
}

.form-control::placeholder {
    color: rgba(255, 255, 255, 0.35) !important;
}

.form-control:focus, .form-select:focus {
    background: rgba(255, 255, 255, 0.06) !important;
    border-color: #0071e3 !important;
    box-shadow: 0 0 0 4px rgba(0, 113, 227, 0.25) !important;
}

.toggle-password {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    cursor: pointer;
    color: rgba(255, 255, 255, 0.4);
    z-index: 10;
    transition: color 0.2s ease;
}

.toggle-password:hover {
    color: #ffffff;
}

/* Buttons */
.btn-primary {
    background: #0071e3 !important;
    border: none !important;
    color: #ffffff !important;
    border-radius: 12px !important;
    padding: 0.75rem 1.5rem;
    font-weight: 600;
    box-shadow: 0 4px 12px rgba(0, 113, 227, 0.3) !important;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1) !important;
}

.btn-primary:hover {
    background: #0077ed !important;
    transform: translateY(-1px);
    box-shadow: 0 8px 20px rgba(0, 113, 227, 0.45) !important;
}

.btn-primary:active {
    transform: translateY(0);
}

/* Animations */
.fade-in {
    animation: fadeIn 0.5s cubic-bezier(0.25, 1, 0.5, 1);
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Sidebar Overlay (Mobile) */
.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 1039;
}

.sidebar-overlay.active {
    display: block;
}

/* Responsive */
@media (max-width: 991px) {
    .sidebar {
        transform: translateX(-100%);
        width: 275px;
        z-index: 1040;
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .content {
        margin-left: 0;
        padding: 1.25rem;
    }
}

/* Mobile Header */
#mobile-header {
    background: rgba(15, 15, 20, 0.7) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border: 1px solid rgba(255, 255, 255, 0.06) !important;
    box-shadow: 0 8px 30px rgba(0, 0, 0, 0.2) !important;
}

#mobile-header .btn-light {
    background: rgba(255, 255, 255, 0.05) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    color: #ffffff;
}

/* Dashboard Welcome */
.dashboard-welcome {
    background: linear-gradient(135deg, rgba(99, 102, 241, 0.15) 0%, rgba(168, 85, 247, 0.15) 100%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 20px;
    padding: 2.5rem;
    color: white;
    margin-bottom: 2rem;
    position: relative;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15) !important;
}

.dashboard-welcome::after {
    content: '';
    position: absolute;
    top: -50%;
    right: -10%;
    width: 350px;
    height: 350px;
    background: radial-gradient(circle, rgba(255, 255, 255, 0.05) 0%, transparent 70%);
    border-radius: 50%;
}

.card-stats {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 18px;
    padding: 1.5rem;
    height: 100%;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    cursor: pointer;
}

.card-stats:hover {
    transform: translateY(-4px);
    background: rgba(255, 255, 255, 0.05) !important;
    border-color: rgba(255, 255, 255, 0.08) !important;
    box-shadow: 0 12px 30px rgba(0, 0, 0, 0.25) !important;
}

.icon-box {
    width: 48px;
    height: 48px;
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 1rem;
}

.icon-box.blue { background: rgba(0, 113, 227, 0.15); color: #0071e3; }
.icon-box.green { background: rgba(52, 199, 89, 0.15); color: #34c759; }
.icon-box.purple { background: rgba(168, 85, 247, 0.15); color: #a855f7; }
.icon-box.orange { background: rgba(255, 149, 0, 0.15); color: #ff9500; }

.quick-action-btn {
    background: rgba(255, 255, 255, 0.03) !important;
    border: 1px solid rgba(255, 255, 255, 0.05) !important;
    border-radius: 14px;
    padding: 1rem;
    display: flex;
    align-items: center;
    gap: 1rem;
    color: #d1d5db;
    text-decoration: none;
    transition: all 0.25s cubic-bezier(0.25, 1, 0.5, 1);
    font-weight: 500;
}

.quick-action-btn:hover {
    background: rgba(255, 255, 255, 0.06) !important;
    color: #ffffff;
    border-color: #0071e3 !important;
}

/* Modal Cadastro Empresa Apple Grouped Elements style */
#modalCadastroEmpresa .modal-content {
    background: rgba(18, 18, 22, 0.85) !important;
    backdrop-filter: blur(40px) saturate(190%) !important;
    -webkit-backdrop-filter: blur(40px) saturate(190%) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 24px !important;
}

#modalCadastroEmpresa .modal-header {
    border-bottom: none !important;
    padding: 2.25rem 2.25rem 0.5rem 2.25rem !important;
}

#modalCadastroEmpresa .modal-body {
    padding: 0 2.25rem 2.25rem 2.25rem !important;
}

#modalCadastroEmpresa .alert-info {
    background: rgba(0, 113, 227, 0.1) !important;
    border: 1px solid rgba(0, 113, 227, 0.25) !important;
    color: #70b5ff !important;
    border-radius: 12px;
}

#modalCadastroEmpresa h6 {
    color: #ffffff !important;
    font-weight: 600;
    margin-top: 1.5rem;
    font-size: 1rem;
}

#modalCadastroEmpresa hr {
    border-top: 1px solid rgba(255, 255, 255, 0.08) !important;
    opacity: 1;
}

#modalCadastroEmpresa .btn-close {
    background-color: rgba(255, 255, 255, 0.06);
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16' fill='%23fff'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586 14.293.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e");
    border-radius: 50%;
    opacity: 0.8;
    padding: 0.6rem;
    transition: all 0.2s ease;
}

#modalCadastroEmpresa .btn-close:hover {
    background-color: rgba(255, 255, 255, 0.15);
    opacity: 1;
}

/* Select2 overrides */
.select2-container--default .select2-selection--single {
    background: rgba(255, 255, 255, 0.04) !important;
    border: 1px solid rgba(255, 255, 255, 0.1) !important;
    border-radius: 12px !important;
    height: auto !important;
    padding: 0.45rem 0.6rem !important;
    color: #ffffff !important;
}

.select2-container--default .select2-selection--single .select2-selection__rendered {
    color: #ffffff !important;
}

.select2-container--default .select2-selection--single .select2-selection__arrow {
    height: 100% !important;
    top: 0 !important;
}

.select2-dropdown {
    background: rgba(20, 20, 25, 0.95) !important;
    backdrop-filter: blur(25px) !important;
    border: 1px solid rgba(255, 255, 255, 0.08) !important;
    border-radius: 12px !important;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5) !important;
}

.select2-results__option {
    color: rgba(255, 255, 255, 0.8) !important;
    padding: 0.6rem 1rem !important;
}

.select2-container--default .select2-results__option--highlighted[aria-selected] {
    background-color: #0071e3 !important;
    color: #ffffff !important;
}

.select2-container--default .select2-results__option[aria-selected=true] {
    background-color: rgba(255, 255, 255, 0.08) !important;
}

/* Tables refinement - Dark Apple Glassmorphism */
.table, .table-hover, .table-light, .table-striped {
    color: #ffffff !important;
    margin-bottom: 0;
    background-color: transparent !important;
    --bs-table-bg: transparent !important;
    --bs-table-color: #ffffff !important;
}

.table *, .table tbody, .table thead, .table tr, .table td, .table th {
    background-color: transparent !important;
    color: #ffffff !important;
}

.table thead th, .table-light th, .table thead.table-light th {
    background-color: rgba(0, 0, 0, 0.4) !important; /* Dark header instead of white */
    border-bottom: 2px solid rgba(255, 255, 255, 0.1) !important;
    font-weight: 600;
}

.table-hover tbody tr:hover, .table-hover tbody tr:hover td, .table-hover tbody tr:hover th {
    background-color: rgba(255, 255, 255, 0.08) !important;
    cursor: pointer;
}

.table td, .table th {
    border-bottom: 1px solid rgba(255, 255, 255, 0.06) !important;
    padding: 1.1rem 0.85rem !important;
}

/* ==========================================================================
   MELHORIAS DE RESPONSIVIDADE (MOBILE & TABLET) - SISTEMA PRINCIPAL
   ========================================================================== */

/* Touch Scroll e Responsividade de Tabelas */
.table-responsive {
    -webkit-overflow-scrolling: touch;
    scrollbar-width: thin;
    scrollbar-color: rgba(255, 255, 255, 0.15) transparent;
    border-radius: 16px;
}

.table-responsive::-webkit-scrollbar {
    height: 6px;
    width: 6px;
}

.table-responsive::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Dispositivos Móveis e Tablets (< 992px) */
@media (max-width: 991.98px) {
    .content {
        margin-left: 0 !important;
        padding: 0.75rem !important;
    }

    #conteudoPrincipal {
        padding-left: 0.25rem !important;
        padding-right: 0.25rem !important;
    }

    /* Ajuste de Modais no Mobile */
    .modal-dialog {
        margin: 0.5rem auto !important;
        max-width: calc(100% - 1rem) !important;
    }

    .modal-content {
        border-radius: 18px !important;
    }

    .modal-header, .modal-body, .modal-footer {
        padding: 1.25rem !important;
    }
}

/* Dispositivos Pequenos (< 768px) */
@media (max-width: 767.98px) {
    .login-box {
        padding: 2rem 1.5rem !important;
        border-radius: 20px !important;
    }

    .dashboard-welcome {
        padding: 1.5rem !important;
        border-radius: 16px !important;
    }

    .card-stats {
        padding: 1rem !important;
    }

    /* Tabelas compactas no mobile */
    .table td, .table th {
        padding: 0.75rem 0.5rem !important;
        font-size: 0.85rem !important;
        white-space: nowrap;
    }

    .table td.text-wrap, .table th.text-wrap {
        white-space: normal !important;
    }

    /* Botões e grupos no mobile */
    .btn-group, .d-flex.gap-2, .d-flex.gap-3 {
        flex-wrap: wrap;
    }

    /* Form-select e Form-control compactos no mobile */
    .form-control, .form-select {
        font-size: 0.9rem;
        padding: 0.6rem 0.85rem;
    }
}

/* Dispositivos Extra Pequenos (< 576px) */
@media (max-width: 575.98px) {
    #mobile-header {
        padding: 0.75rem 1rem !important;
        border-radius: 14px !important;
    }

    .login-container {
        padding: 10px !important;
    }
}