:root {
    --primary-bg: #0f172a;
    --secondary-bg: #1e293b;
    --accent-blue: #3b82f6;
    --accent-blue-hover: #2563eb;
    --accent-red: #ef4444;
    --accent-green: #10b981;
    --accent-yellow: #f59e0b;
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --sidebar-width: 260px;
    --glass: rgba(255, 255, 255, 0.08);
    --ui-border: rgba(255, 255, 255, 0.08);
    --ui-bg: rgba(15, 23, 42, 0.6);
    --card-radius: 16px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

/* Scrollbar moderno */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}
::-webkit-scrollbar-track {
    background: #090d16;
}
::-webkit-scrollbar-thumb {
    background: #334155;
    border-radius: 4px;
}
::-webkit-scrollbar-thumb:hover {
    background: #475569;
}

html {
    overflow-x: hidden;
    overflow-y: auto;
    font-size: 16px;
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    background: radial-gradient(circle at top right, #1e293b, #0f172a);
    background-attachment: fixed;
    color: var(--text-primary);
    display: flex;
    min-height: 100vh;
    min-height: -webkit-fill-available;
    overflow-x: hidden;
    overflow-y: auto;
}

/* ==========================================================================
   Sidebar / Drawer Lateral
   ========================================================================== */
.sidebar {
    width: var(--sidebar-width);
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    height: 100vh;
    position: fixed;
    top: 0;
    left: 0;
    display: flex;
    flex-direction: column;
    padding: 1.5rem 1rem;
    border-right: 1px solid var(--glass);
    z-index: 100;
    overflow-y: auto;
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    z-index: 95;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.sidebar-overlay.open {
    display: block;
    opacity: 1;
}

.sidebar-header {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-size: 1.35rem;
    font-weight: 600;
    margin-bottom: 2rem;
    position: relative;
}

.sidebar-close-btn {
    display: none;
    position: absolute;
    right: 0;
    top: 0;
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-secondary);
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
}

.sidebar-close-btn:active {
    background: rgba(239, 68, 68, 0.2);
    color: white;
}

.nav-links {
    list-style: none;
    flex-grow: 1;
}

.nav-links li {
    margin-bottom: 0.4rem;
}

.nav-links a {
    color: var(--text-secondary);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.85rem;
    padding: 0.75rem 1rem;
    border-radius: 12px;
    font-size: 0.95rem;
    font-weight: 500;
    min-height: 44px;
    transition: all 0.25s ease;
}

.nav-links a:hover, .nav-links a.active {
    background-color: var(--glass);
    color: var(--text-primary);
    transform: translateX(4px);
}

.nav-links i {
    width: 22px;
    font-size: 1.1rem;
    text-align: center;
}

.nav-submenu {
    list-style: none;
    padding-left: 1.75rem;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease-out, margin 0.3s ease;
    margin-top: 0;
}

.nav-submenu.show {
    max-height: 250px;
    margin-top: 0.4rem;
    margin-bottom: 0.4rem;
}

.nav-submenu a {
    padding: 0.55rem 0.85rem;
    font-size: 0.88rem;
    color: var(--text-secondary);
    min-height: 38px;
}

.nav-submenu a:hover {
    color: var(--accent-blue);
    transform: translateX(4px);
    background-color: transparent;
}

.sidebar-footer {
    border-top: 1px solid var(--glass);
    padding-top: 1.25rem;
    margin-top: auto;
}

.logout-btn {
    color: var(--accent-red);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    font-weight: 600;
    min-height: 44px;
}

/* ==========================================================================
   Content Area & Topbar
   ========================================================================== */
.content {
    margin-left: var(--sidebar-width);
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    min-height: 100vh;
    width: calc(100% - var(--sidebar-width));
    max-width: 100%;
}

.top-bar {
    min-height: 64px;
    padding: 0.75rem 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(30, 41, 59, 0.7);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-bottom: 1px solid var(--glass);
    position: sticky;
    top: 0;
    z-index: 40;
    gap: 0.75rem;
}

.mobile-menu-btn {
    display: none;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid var(--glass);
    color: var(--text-primary);
    font-size: 1.2rem;
    width: 42px;
    height: 42px;
    border-radius: 10px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: background 0.2s;
}

.mobile-menu-btn:active {
    background: rgba(255, 255, 255, 0.15);
}

.main-body {
    padding: 1.5rem;
    flex-grow: 1;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
}

/* ==========================================================================
   Grids e Cards Responsivos
   ========================================================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.stat-card {
    background-color: var(--secondary-bg);
    padding: 1.25rem 1.5rem;
    border-radius: var(--card-radius);
    border: 1px solid var(--glass);
    display: flex;
    align-items: center;
    gap: 1.25rem;
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.stat-card:hover {
    transform: translateY(-4px);
    box-shadow: 0 12px 28px -6px rgba(0, 0, 0, 0.35);
}

.stat-icon {
    width: 54px;
    height: 54px;
    border-radius: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    flex-shrink: 0;
}

.stat-info h3 {
    font-size: 1.75rem;
    font-weight: 700;
    margin-bottom: 0.2rem;
    line-height: 1.1;
}

.stat-info p {
    color: var(--text-secondary);
    font-size: 0.85rem;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    font-weight: 600;
}

/* ==========================================================================
   Tabelas e Containers de Dados Responsivos
   ========================================================================== */
.data-section,
.data-table-container {
    background-color: var(--secondary-bg);
    border-radius: var(--card-radius);
    border: 1px solid var(--glass);
    overflow: hidden;
    margin-bottom: 1.5rem;
    width: 100%;
}

.data-section-table-wrapper,
.data-table-responsive {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table, .modern-table {
    width: 100%;
    border-collapse: collapse;
}

th {
    text-align: left;
    padding: 0.9rem 1.25rem;
    background-color: rgba(0, 0, 0, 0.25);
    color: var(--text-secondary);
    font-size: 0.78rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
    white-space: nowrap;
    border-bottom: 1px solid var(--glass);
}

td {
    padding: 1rem 1.25rem;
    border-bottom: 1px solid var(--glass);
    vertical-align: middle;
}

/* ==========================================================================
   Modais Responsivos
   ========================================================================== */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    padding: 1rem;
}

.modal-content {
    background-color: #1e293b;
    border: 1px solid var(--ui-border);
    border-radius: 18px;
    width: 100%;
    max-width: 480px;
    padding: 1.75rem;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.5);
    animation: modalFadeIn 0.25s cubic-bezier(0.16, 1, 0.3, 1);
    max-height: 90vh;
    overflow-y: auto;
}

.modal-content.large-modal {
    max-width: 900px;
}

@keyframes modalFadeIn {
    from { opacity: 0; transform: translateY(12px) scale(0.97); }
    to { opacity: 1; transform: translateY(0) scale(1); }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.25rem;
}

.modal-header h3 {
    font-size: 1.15rem;
    margin: 0;
    color: #f1f5f9;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.close-modal-btn {
    background: rgba(255, 255, 255, 0.08);
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    width: 36px;
    height: 36px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.close-modal-btn:hover {
    color: white;
    background: rgba(239, 68, 68, 0.2);
}

/* ==========================================================================
   Ajustes Mobile / Responsividade Geral
   ========================================================================== */
@media (max-width: 1024px) {
    :root {
        --sidebar-width: 240px;
    }
}

@media (max-width: 900px) {
    .shifts-layout-grid,
    .migration-grid,
    .user-dashboard-grid {
        grid-template-columns: 1fr !important;
        gap: 1.25rem !important;
    }
}

@media (max-width: 768px) {
    body {
        flex-direction: column;
        overflow-x: hidden;
    }

    /* Sidebar Drawer */
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        width: min(85vw, 300px);
        height: 100vh;
        height: -webkit-fill-available;
        z-index: 100;
        background: rgba(15, 23, 42, 0.96);
        backdrop-filter: blur(24px);
        -webkit-backdrop-filter: blur(24px);
        transform: translateX(-100%);
        padding: 1.5rem 1.25rem;
        box-shadow: 4px 0 25px rgba(0, 0, 0, 0.6);
    }

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

    .sidebar-close-btn {
        display: flex;
    }

    .content {
        margin-left: 0;
        width: 100%;
    }

    .top-bar {
        height: auto;
        min-height: 60px;
        padding: 0.6rem 1rem;
    }

    .mobile-menu-btn {
        display: flex;
    }

    .top-bar h1 {
        font-size: 1.05rem !important;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 55vw;
    }

    .main-body {
        padding: 1rem 0.85rem;
    }

    /* Grids e Cabeçalhos */
    .stats-grid {
        grid-template-columns: 1fr;
        gap: 0.85rem;
    }

    .profile-header {
        flex-direction: column !important;
        align-items: flex-start !important;
        padding: 1.25rem 1rem !important;
        gap: 1rem !important;
    }

    .profile-header .search-wrapper,
    .profile-header .input-search {
        width: 100% !important;
    }

    .profile-avatar {
        width: 76px !important;
        height: 76px !important;
        font-size: 2.2rem !important;
        border-radius: 20px !important;
    }

    .profile-info {
        width: 100% !important;
    }

    .profile-badges {
        justify-content: flex-start !important;
    }

    .actions-grid {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    .action-card {
        padding: 1.25rem !important;
    }

    /* Barra de Ações em Lote */
    .bulk-action-bar {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.85rem !important;
        padding: 1rem !important;
    }

    .bulk-action-bar > div {
        width: 100% !important;
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 0.75rem !important;
    }

    .custom-dropdown {
        width: 100% !important;
    }

    #bulk_password_fields {
        flex-direction: column !important;
        align-items: stretch !important;
        width: 100% !important;
    }

    #bulk_new_password {
        width: 100% !important;
    }

    #submitBulkBtn {
        width: 100% !important;
        justify-content: center !important;
    }

    /* Tabelas sempre roláveis horizontalmente sem quebrar layout */
    .data-section,
    .data-table-container,
    .data-section-table-wrapper {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    table, .modern-table {
        min-width: 560px;
    }

    /* Modais */
    .modal-content {
        padding: 1.25rem;
        width: 95%;
        border-radius: 14px;
    }

    /* Evitar auto-zoom do Safari no iOS em campos de formulário */
    input[type="text"],
    input[type="email"],
    input[type="password"],
    input[type="date"],
    input[type="time"],
    select,
    textarea {
        font-size: 16px !important;
    }
}

@media (max-width: 480px) {
    .main-body {
        padding: 0.75rem 0.5rem;
    }

    .stat-card {
        padding: 1rem;
        gap: 1rem;
    }

    .stat-icon {
        width: 46px;
        height: 46px;
        font-size: 1.25rem;
    }

    .stat-info h3 {
        font-size: 1.45rem;
    }

    .days-grid {
        grid-template-columns: repeat(4, 1fr) !important;
        gap: 0.35rem !important;
    }

    .day-label {
        padding: 0.4rem 0.2rem !important;
        font-size: 0.75rem !important;
    }
}
