/* ============================================
   DRIVERUB - ESTILOS PRINCIPAIS (MODERN LAYOUT)
   ============================================ */

/* Importação de Fonte Moderna */
/* Importação de Fonte - Resetando para garantir leitura limpa */
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700;800;900&display=swap');

/* Variáveis CSS para cores e tokens de design */
:root {
    /* Corporate Light Palette */
    --color-dark-blue: #142553;
    /* Main Brand Blue */
    --color-gold: #f3b41c;
    /* Brand Yellow */
    --color-gold-hover: #e0a81b;
    --color-white: #ffffff;

    /* Text Colors for Light Mode */
    --color-text-main: #334155;
    /* Slate 700 */
    --color-text-muted: #64748b;
    /* Slate 500 */
    --color-text-light: #ffffff;

    /* Backgrounds */
    --bg-color: #ffffff;
    /* Pure White */
    --card-bg: #ffffff;

    --color-gray-text: #525252;
    --color-blue-light: #e0f2fe;
    --color-red-light: #fef2f2;
    --color-green-light: #e0ffe0;
    --color-green-highlight: #bbf7d0;
    --color-red-highlight: #fca5a5;

    /* Design Tokens para Layout Moderno (Light) */
    --glass-bg: rgba(255, 255, 255, 1);
    --glass-border: rgba(0, 0, 0, 0.05);
    /* Subtle border for white cards */
    --glass-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -1px rgba(0, 0, 0, 0.03);
    --glass-blur: none;
    /* Removed blur for clean corporate look */

    --card-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
    --premium-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

    --font-main: 'Poppins', system-ui, -apple-system, sans-serif;

    /* Gray Scale - Adjusted for "No Grey" rule triggers */
    --color-gray-50: #ffffff;
    --color-gray-100: #f1f5f9;
    --color-gray-200: #e2e8f0;
    --color-gray-400: #94a3b8;
    --color-gray-600: #475569;
    --color-gray-700: #334155;
    --color-gray-900: #0f172a;
}

* {
    font-family: var(--font-main);
}

/* CSS Crítico para garantir que botões sejam visíveis mesmo sem Tailwind */
button {
    border: none !important;
    padding: 0.75rem 1.5rem !important;
    border-radius: 0.5rem !important;
    font-weight: 600 !important;
    cursor: pointer !important;
    transition: all 0.2s !important;
    display: inline-flex !important;
    align-items: center !important;
    justify-content: center !important;
    min-height: 2.5rem !important;
}

button:hover {
    opacity: 0.9 !important;
    transform: translateY(-1px) !important;
}

button:active {
    transform: translateY(0) !important;
}

/* Aplicar cores apenas quando classes específicas estão presentes */
.bg-dark-blue,
[class*="bg-dark-blue"] {
    background-color: var(--color-dark-blue) !important;
    color: var(--color-white) !important;
}

.text-white,
[class*="text-white"] {
    color: var(--color-white) !important;
}

.bg-blue-500,
[class*="bg-blue-500"],
[class*="bg-blue-600"],
[class*="bg-blue-700"] {
    background-color: #3b82f6 !important;
    color: var(--color-white) !important;
}

.bg-green-500,
[class*="bg-green-500"],
[class*="bg-green-600"],
[class*="bg-green-700"] {
    background-color: #10b981 !important;
    color: var(--color-white) !important;
}

.bg-red-500,
[class*="bg-red-500"],
[class*="bg-red-600"],
[class*="bg-red-700"] {
    background-color: #ef4444 !important;
    color: var(--color-white) !important;
}

.bg-yellow-500,
[class*="bg-yellow-500"],
[class*="bg-yellow-400"] {
    background-color: #eab308 !important;
    color: #000000 !important;
}

.bg-gold,
[class*="bg-gold"] {
    background-color: var(--color-gold) !important;
    color: var(--color-dark-blue) !important;
}

.bg-purple-500,
[class*="bg-purple-500"],
[class*="bg-purple-600"],
[class*="bg-purple-700"] {
    background-color: #a855f7 !important;
    color: var(--color-white) !important;
}

.bg-gray-100,
[class*="bg-gray-100"],
[class*="bg-gray-200"] {
    background-color: var(--color-gray-100) !important;
    color: #000000 !important;
}

/* Removing Gradients for Minimalism (DISABLED: This was hiding the login hero image)
[class*="bg-gradient-to-r"] {
    background-image: none !important;
    background-color: var(--color-dark-blue) !important;
}
*/

/* Specific overrides for gradients to Flat Colors */
.bg-gold,
[class*="bg-gold"] {
    background: var(--color-gold) !important;
    color: #000000 !important;
    border: none !important;
}

/* Glassmorphism utility */
/* Minimalist Card - Flat, White, bordered */
.glass-card,
.card-minimal {
    background: #ffffff !important;
    border: 1px solid #e2e8f0 !important;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05) !important;
    border-radius: 12px !important;
    /* Reduced radius from modern 24px */
    backdrop-filter: none !important;
}

.glass-card:hover {
    border-color: var(--color-dark-blue) !important;
    transform: none !important;
    /* Stop floating */
}

/* Remove dark background force override */
.bg-dark-blue:has(.glass-card) {
    background: var(--color-dark-blue) !important;
}

/* Custom Select Styling */
.custom-select::after {
    content: '';
    position: absolute;
    right: 1.25rem;
    top: 50%;
    transform: translateY(-50%);
    width: 0.75rem;
    height: 0.75rem;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 24 24' stroke='%23ffb300' stroke-width='3'%3E%3Cpath stroke-linecap='round' stroke-linejoin='round' d='M19.5 8.25l-7.5 7.5-7.5-7.5' /%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: center;
    pointer-events: none;
    transition: transform 0.3s ease;
}

.custom-select:focus-within::after {
    transform: translateY(-50%) rotate(180deg);
}

/* Animations */
@keyframes fade-in {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.animate-fade-in {
    animation: fade-in 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

@keyframes loading-bar {
    0% {
        transform: translateX(-100%);
    }

    50% {
        transform: translateX(0);
    }

    100% {
        transform: translateX(100%);
    }
}

.animate-loading-bar {
    animation: loading-bar 2s cubic-bezier(0.65, 0, 0.35, 1) infinite;
}

@keyframes float {

    0%,
    100% {
        transform: translateY(0);
    }

    50% {
        transform: translateY(-15px);
    }
}

.animate-float {
    animation: float 4s ease-in-out infinite;
}

/* Custom Scrollbar */
.custom-scrollbar::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.02);
    border-radius: 10px;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
    background: rgba(255, 179, 0, 0.2);
    border-radius: 10px;
    transition: background 0.3s ease;
}

.custom-scrollbar::-webkit-scrollbar-thumb:hover {
    background: rgba(255, 179, 0, 0.4);
}

/* Typography Refinements */
.font-black {
    font-weight: 900;
}

.tracking-tighter {
    letter-spacing: -0.05em;
}

.tracking-tight {
    letter-spacing: -0.025em;
}

.tracking-widest {
    letter-spacing: 0.1em;
}

/* Base modernizations */
body {
    background-color: var(--bg-color) !important;
    color: var(--color-text-main);
    min-height: 100vh;
}

/* Modernize Buttons Global */
/* MINIMALIST BUTTONS */
button:not(.close-modal) {
    border-radius: 8px !important;
    /* Standard radius */
    font-weight: 600 !important;
    text-transform: none !important;
    /* Remove excessive uppercase */
    letter-spacing: normal !important;
    font-size: 0.9rem !important;
    box-shadow: none !important;
    /* Flat buttons */
    border: 1px solid transparent !important;
}

button:not(.close-modal):hover {
    transform: none !important;
    opacity: 0.9 !important;
    box-shadow: none !important;
}

button:not(.close-modal):active {
    opacity: 0.8 !important;
}

/* Modernize Inputs Global */
input,
select,
textarea {
    border-radius: 12px !important;
    border: 1.5px solid #e5e7eb !important;
    padding: 0.75rem 1rem !important;
    transition: all 0.2s ease !important;
    background-color: #f9fafb !important;
}

input:focus,
select:focus,
textarea:focus {
    border-color: var(--color-gold) !important;
    background-color: #ffffff !important;
    box-shadow: 0 0 0 4px rgba(255, 179, 0, 0.1) !important;
    outline: none !important;
}

/* Special classes */
.bg-gold {
    background: linear-gradient(135deg, #ffb300 0%, #ffca28 100%) !important;
    color: var(--color-dark-blue) !important;
}

.bg-gold:hover {
    background: linear-gradient(135deg, #ffca28 0%, #ffb300 100%) !important;
}

/* Se Tailwind não carregar, aplicar cor padrão apenas em botões sem classe específica */
body:not(.tailwind-loaded) button:not([class*="bg-"]):not([class*="text-"]) {
    background-color: #3b82f6 !important;
    color: var(--color-white) !important;
}

/* Card e botão de código de vinculação - fundo branco */
#admin-company-code-card {
    background-color: var(--color-white) !important;
    border-color: #d1d5db !important;
}

#admin-copy-code-button {
    background-color: var(--color-white) !important;
    color: var(--color-dark-blue) !important;
    border: 2px solid var(--color-dark-blue) !important;
}

#admin-copy-code-button:hover {
    background-color: var(--color-gray-100) !important;
}

#admin-company-code-display {
    color: var(--color-dark-blue) !important;
}

/* ============================================
   LAYOUT PROFISSIONAL ADMIN COM SIDEBAR
   ============================================ */

.admin-layout-container {
    display: flex !important;
    min-height: 100vh !important;
    background-color: var(--bg-color) !important;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

#admin-view.admin-layout-container {
    display: flex !important;
    flex-direction: row !important;
    align-items: stretch !important;
    background: transparent !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    padding: 0 !important;
    margin: 0 !important;
    background-color: var(--color-dark-blue) !important;
    /* Admin Background */
}

/* Global Styles for Admin Sidebar Overlay (Hidden on PC by default) */
.admin-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: 10000;
    backdrop-filter: blur(4px);
}

.admin-sidebar {
    width: 260px !important;
    background: var(--color-dark-blue) !important;
    color: white !important;
    display: flex !important;
    flex-direction: column !important;
    position: fixed !important;
    left: 0 !important;
    top: 0 !important;
    bottom: 0 !important;
    height: 100vh !important;
    z-index: 1000 !important;
    box-shadow: none !important;
    border-radius: 0 !important;
    border-right: 1px solid rgba(255, 255, 255, 0.1) !important;
    transform: none !important;
    /* Ensure it's never hidden on desktop */
    visibility: visible !important;
}

.admin-sidebar-header {
    padding: 1.5rem 1.25rem;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.75rem;
    flex-shrink: 0;
    flex-direction: column;
}

.admin-sidebar-logo {
    width: auto !important;
    max-width: 100% !important;
    height: auto !important;
    max-height: 132px !important;
    /* 40% reduced from 220px */
    object-fit: contain;
    filter: drop-shadow(0 0 8px rgba(255, 179, 0, 0.3));
    transform: scale(1.1);
}

.admin-sidebar-title {
    font-size: 1.25rem;
    font-weight: 800;
    color: var(--color-gold);
    margin: 0;
    letter-spacing: -0.025em;
}

.admin-sidebar-nav {
    flex: 1;
    padding: 1rem 0.75rem;
    overflow-y: auto;
    overflow-x: hidden;
}

.admin-menu-item {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem !important;
    /* Reduced gap */
    padding: 0.4rem 0.75rem !important;
    /* Drastically reduced padding */
    background: transparent;
    border: none;
    color: rgba(255, 255, 255, 0.7);
    font-size: 0.75rem !important;
    /* Smaller font */
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: left;
    justify-content: flex-start !important;
    /* Left justify */
    border-radius: 8px;
    margin-bottom: 1px !important;
    /* Minimal margin */
    border-left: 3px solid transparent !important;
    /* Prevent layout shift */
    outline: none !important;
    /* Remove focus ring (raio) */
}

.admin-menu-item:hover {
    background: rgba(255, 255, 255, 0.2) !important;
    color: var(--color-gold) !important;
    transform: translateX(6px) !important;
    border-left: 3px solid var(--color-gold) !important;
    /* padding-left unchanged because border takes space now */
}

.admin-menu-item.active {
    background-color: #FFFF00 !important;
    /* Pure Yellow */
    color: #000000 !important;
    border: none !important;
    border-left: 3px solid #FFFF00 !important;
    /* Keep structural stability */
    font-weight: 800 !important;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1) !important;
}

.admin-menu-item svg {
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
}

.admin-menu-item:hover svg {
    transform: scale(1.1);
}

.admin-menu-item-secondary {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
}

.admin-sidebar-footer {
    padding: 0.75rem 1.25rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    flex-shrink: 0;
}

.admin-code-card {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 0.5rem;
    padding: 0.5rem;
    backdrop-filter: blur(10px);
}

.admin-code-label {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.7);
    margin-bottom: 0.375rem;
    font-weight: 500;
}

.admin-code-display-wrapper {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 0.375rem;
}

.admin-code-display {
    font-size: 0.8125rem;
    font-weight: 700;
    font-family: monospace;
    color: #d4a94d;
    letter-spacing: 0.05em;
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
}

.admin-code-copy-btn {
    background: rgba(212, 169, 77, 0.2);
    border: 1px solid rgba(212, 169, 77, 0.3);
    border-radius: 0.375rem;
    padding: 0.375rem;
    color: #d4a94d;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
}

.admin-code-copy-btn:hover {
    background: rgba(212, 169, 77, 0.3);
    border-color: #d4a94d;
}

.admin-link-company-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem;
    background: rgba(59, 130, 246, 0.2);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: 0.5rem;
    color: white;
    font-size: 0.875rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-link-company-btn:hover {
    background: rgba(59, 130, 246, 0.3);
    border-color: #3b82f6;
}

.admin-user-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.5rem;
    background: rgba(255, 255, 255, 0.05);
    border-radius: 0.5rem;
    margin-bottom: 0.5rem !important;
}

.admin-user-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background: rgba(212, 169, 77, 0.2);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #d4a94d;
    flex-shrink: 0;
}

.admin-user-avatar svg {
    width: 18px;
    height: 18px;
}

.admin-user-details {
    flex: 1;
    min-width: 0;
}

.admin-user-name {
    font-size: 0.8125rem;
    font-weight: 600;
    color: white;
    margin: 0;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    line-height: 1.2;
}

.admin-user-role {
    font-size: 0.6875rem;
    color: rgba(255, 255, 255, 0.6);
    margin: 0;
    line-height: 1.2;
}

.admin-logout-btn {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.625rem;
    background: #ef4444;
    border: 1px solid #dc2626;
    border-radius: 0.5rem;
    color: white;
    font-size: 0.8125rem;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
}

.admin-logout-btn:hover {
    background: #dc2626;
    border-color: #b91c1c;
}

.admin-logout-btn svg {
    width: 16px;
    height: 16px;
}

.admin-main-content {
    flex: 1 !important;
    margin-left: 260px !important;
    display: flex !important;
    flex-direction: column !important;
    min-height: 100vh !important;
    width: calc(100% - 260px) !important;
    max-width: calc(100% - 260px) !important;
    padding: 2rem !important;
    box-sizing: border-box !important;
}

/* Bento Grid Layout System */
.bento-grid {
    display: grid;
    grid-template-columns: repeat(12, 1fr);
    grid-auto-rows: minmax(160px, auto);
    gap: 1.5rem;
    padding-bottom: 2rem;
}

.bento-item {
    background: var(--card-bg);
    border-radius: 20px;
    padding: 1.5rem;
    box-shadow: var(--glass-shadow);
    border: 1px solid var(--glass-border);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
    display: flex;
    flex-direction: column;
}

.bento-item:hover {
    transform: translateY(-2px);
    box-shadow: var(--card-shadow);
    border-color: rgba(23, 53, 107, 0.1);
}

.col-span-12 {
    grid-column: span 12;
}

.col-span-8 {
    grid-column: span 8;
}

.col-span-6 {
    grid-column: span 6;
}

.col-span-4 {
    grid-column: span 4;
}

.col-span-3 {
    grid-column: span 3;
}

.row-span-2 {
    grid-row: span 2;
}

@media (max-width: 1024px) {
    .bento-grid {
        grid-template-columns: 1fr;
        grid-auto-rows: auto;
    }

    .col-span-12,
    .col-span-8,
    .col-span-6,
    .col-span-4,
    .col-span-3 {
        grid-column: span 1;
    }
}

.admin-header {
    background: rgba(255, 255, 255, 0.8) !important;
    backdrop-filter: blur(10px) !important;
    border-bottom: 1px solid var(--color-gray-200);
    padding: 1rem 2rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 1rem;
    z-index: 100;
    border-radius: 20px;
    margin-bottom: 1rem;
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

.admin-header-left {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-sidebar-toggle {
    display: none;
    background: transparent;
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-dark-blue);
    border-radius: 0.375rem;
    transition: background 0.2s ease;
}

.admin-sidebar-toggle:hover {
    background: var(--color-gray-100);
}

.admin-header-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--color-dark-blue);
    margin: 0;
}

.admin-header-subtitle {
    font-size: 0.875rem;
    color: var(--color-gray-600);
    margin: 0;
}

.admin-header-right {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.admin-code-card-header {
    display: block;
}

/* Strict Mobile/Desktop Toggle */
#admin-company-code-card-header {
    display: none !important;
    /* Hide Mobile Version on Desktop */
}

#admin-company-code-card-header-desktop {
    display: block !important;
    /* Show Desktop Version on Desktop */
}

.admin-code-header-content {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    background: var(--color-gray-50);
    border: 1px solid var(--color-gray-200);
    border-radius: 0.5rem;
    padding: 0.5rem 0.75rem;
}

.admin-code-header-label {
    font-size: 0.75rem;
    color: var(--color-gray-600);
    font-weight: 500;
    margin: 0;
}

.admin-code-header-display {
    font-size: 0.875rem;
    font-weight: 700;
    font-family: monospace;
    color: var(--color-dark-blue);
    letter-spacing: 0.05em;
    margin: 0;
}

.admin-code-header-copy {
    background: var(--color-gray-700);
    border: none;
    padding: 0.5rem;
    cursor: pointer;
    color: var(--color-white);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 0.375rem;
}

.admin-code-header-copy:hover {
    background: #1f2937;
    color: var(--color-white);
}

.admin-content-area {
    flex: 1;
    padding: 2rem;
    overflow-y: auto;
    background: #f5f7fa;
}

@media (max-width: 1024px) {
    .admin-sidebar {
        transform: translateX(-100%) !important;
        width: 280px !important;
        max-width: 85vw !important;
        transition: transform 0.3s ease !important;
    }

    .admin-sidebar:not(.open) {
        transform: translateX(-100%) !important;
    }

    .admin-sidebar.open {
        transform: translateX(0) !important;
    }

    .admin-main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding-left: 0 !important;
        padding-right: 0 !important;
    }

    .admin-sidebar-toggle {
        display: block !important;
        min-width: 44px !important;
        min-height: 44px !important;
    }

    .admin-code-card-header {
        display: block;
    }

    .admin-code-card {
        display: none;
    }

    .admin-content-area {
        padding: 1rem !important;
        width: 100% !important;
        max-width: 100% !important;
        overflow-x: hidden !important;
    }

    .admin-header {
        padding: 0.75rem 1rem !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .admin-sidebar-overlay {
        display: none;
        position: fixed;
        inset: 0;
        background: rgba(0, 0, 0, 0.5);
        z-index: 999;
        /* backdrop-filter: blur(2px); - REMOVIDO: Causava efeito 'fosco' indesejado em iOS mesmo quando oculto ou em transição */
        -webkit-backdrop-filter: none;
        backdrop-filter: none;
    }

    .admin-sidebar-overlay.active {
        display: block;
        /* Re-ativar blur apenas quando ativo e se necessário, mas seguro remover para garantir lisura */
        -webkit-backdrop-filter: blur(2px);
        backdrop-filter: blur(2px);
    }

    /* Garantir que o container admin não tenha limitações */
    #admin-view.admin-layout-container {
        width: 100% !important;
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
        overflow-x: hidden !important;
        position: relative !important;
    }

    /* Garantir que app-container não limite no mobile */
    #app-container.user-logged:has(#admin-view:not(.hidden)) {
        max-width: 100vw !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
        overflow-x: hidden !important;
    }

    /* Garantir que body não tenha overflow horizontal */
    body:has(#admin-view:not(.hidden)) {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
}

@media (max-width: 768px) {
    .admin-sidebar {
        width: 280px !important;
        max-width: 85vw !important;
        transform: translateX(-100%) !important;
    }

    .admin-sidebar:not(.open) {
        transform: translateX(-100%) !important;
    }

    .admin-sidebar.open {
        transform: translateX(0) !important;
    }

    .admin-main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 0 !important;
    }

    .admin-header {
        padding: 0.75rem 1rem !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        width: 100% !important;
        max-width: 100% !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        background: white !important;
    }

    .admin-header-left {
        flex: 1 !important;
        min-width: 0 !important;
        display: flex !important;
        align-items: center !important;
        gap: 0.75rem !important;
    }

    .admin-header-right {
        flex-shrink: 0 !important;
    }

    .admin-header-title {
        font-size: 0.875rem !important;
        line-height: 1.2 !important;
        overflow: visible !important;
        text-overflow: clip !important;
        white-space: normal !important;
        word-break: break-word !important;
    }

    .admin-header-subtitle {
        font-size: 0.625rem !important;
        display: none !important;
    }

    /* Ajustar código da empresa no header para mobile */
    .admin-code-card-header {
        display: block !important;
        width: 100% !important;
        margin-top: 0.5rem !important;
    }

    .admin-code-header-content {
        font-size: 0.7rem !important;
        padding: 0.4rem 0.5rem !important;
        flex-wrap: wrap !important;
        gap: 0.35rem !important;
    }

    .admin-code-header-label {
        font-size: 0.65rem !important;
    }

    .admin-code-header-display {
        font-size: 0.8rem !important;
        font-weight: 700 !important;
        word-break: break-all !important;
    }

    .admin-code-header-copy {
        padding: 0.25rem !important;
        min-width: auto !important;
    }

    .admin-code-header-copy svg {
        width: 12px !important;
        height: 12px !important;
    }

    /* Esconder código no header-right no mobile (ele aparece dentro do header-left) */
    .admin-header-right .admin-code-card-header {
        display: none !important;
    }

    /* Mostrar código dentro do header-left no mobile */
    .admin-header-left .admin-code-card-header,
    #admin-company-code-card-header {
        display: block !important;
        width: 100% !important;
        margin-top: 0.5rem !important;
    }

    /* Ocultar Desktop ID explicitamente */
    #admin-company-code-card-header-desktop {
        display: none !important;
    }

    .admin-content-area {
        padding: 0.75rem !important;
        width: 100% !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }

    /* Ajustar código no header para mobile */
    .admin-code-card-header {
        display: none !important;
    }

    /* Garantir que cards não ultrapassem a largura */
    .admin-sub-view .bg-white,
    .admin-sub-view .bg-gray-50 {
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Garantir que o container admin não ultrapasse a largura */
    #admin-view.admin-layout-container {
        width: 100vw !important;
        max-width: 100vw !important;
        overflow-x: hidden !important;
    }
}

/* Padronização profissional das sub-views do admin */
.admin-sub-view {
    background: transparent;
}

.admin-sub-view h3 {
    color: var(--color-dark-blue);
    font-weight: 700;
    margin-bottom: 1.5rem;
}

.admin-sub-view h4 {
    color: var(--color-dark-blue);
    font-weight: 600;
}

/* Cards padronizados - branco com borda cinza */
.admin-sub-view .bg-white,
.admin-sub-view .bg-gray-50 {
    background: var(--color-white) !important;
    border: 1px solid var(--color-gray-200) !important;
    border-radius: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* Remover cores vibrantes das seções */
.admin-sub-view .bg-red-light,
.admin-sub-view .bg-green-light,
.admin-sub-view .bg-blue-light,
.admin-sub-view .bg-yellow-50,
.admin-sub-view .bg-orange-50 {
    background: var(--color-white) !important;
    border-color: var(--color-gray-200) !important;
}

/* Botões de filtro padronizados */
.admin-sub-view button[data-period],
.admin-sub-view button[data-period-conductor] {
    background: var(--color-gray-100) !important;
    color: var(--color-gray-700) !important;
    border: 1px solid var(--color-gray-200) !important;
}

.admin-sub-view button[data-period].active,
.admin-sub-view button[data-period-conductor].active {
    background: var(--color-dark-blue) !important;
    color: var(--color-white) !important;
    border-color: var(--color-dark-blue) !important;
}

/* Inputs e selects padronizados */
.admin-sub-view input,
.admin-sub-view select,
.admin-sub-view textarea {
    background: var(--color-white) !important;
    border: 1px solid #d1d5db !important;
    color: #1f2937 !important;
}

.admin-sub-view input:focus,
.admin-sub-view select:focus,
.admin-sub-view textarea:focus {
    border-color: var(--color-dark-blue) !important;
}

/* ============================================
   ESTILOS GERAIS
   ============================================ */

body {
    font-family: 'Poppins', sans-serif;
    color: var(--color-text-main);
    background-color: var(--color-dark-blue) !important;
    /* Force Blue Background Global */
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

.container {
    max-width: 600px;
}

#auth-card.hidden,
#auth-view.hidden,
#admin-view.hidden,
#conductor-view.hidden,
#master-view.hidden {
    display: none !important;
}

.view-content {
    width: 100%;
    max-width: 100%;
}

/* Garantir que apenas uma view seja visível por vez */
.view-content:not(.hidden)~.view-content:not(.hidden) {
    display: none !important;
}

/* Garantir que auth-view esteja oculta quando user está logado */
#app-container.user-logged #auth-view,
#app-container.user-logged #auth-card,
#app-container.user-logged #auth-split-layout {
    display: none !important;
}

/* Garantir que views de admin/conductor estejam ocultas quando não logado */
#app-container:not(.user-logged) #admin-view,
#app-container:not(.user-logged) #conductor-view,
#app-container:not(.user-logged) #master-view {
    display: none !important;
}

/* Login: ocupar 100% da viewport — sem max-width/padding global que criam faixa azul */
#app-container:not(.user-logged) {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
}

/* Painel do formulário: rolagem interna (login + cadastro longo) */
#login-form-panel {
    min-height: 0;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
}

/* Hero: fundo no HTML + <img>; regra global img{height:auto} não pode esmagar o hero */
#login-hero-panel .login-hero-img {
    max-width: none !important;
    width: 100% !important;
    height: 100% !important;
    min-height: 100%;
    object-fit: cover;
}

#login-hero-panel {
    background-color: #0f1d3a;
    background-image: url('../assets/log.png?v=55');
    background-size: cover;
    background-position: center right;
    background-repeat: no-repeat;
}

/* Cadastro: card mais compacto para caber na altura da tela */
#auth-card:has(#register-form-container:not(.hidden)) {
    padding-top: 0.875rem;
    padding-bottom: 0.875rem;
}

#auth-card:has(#register-form-container:not(.hidden)) .auth-logo-img {
    height: 3.25rem;
}

@media (min-width: 640px) {
    #auth-card:has(#register-form-container:not(.hidden)) .auth-logo-img {
        height: 3.75rem;
    }
}

#auth-card:has(#register-form-container:not(.hidden)) .auth-subtitle {
    margin-bottom: 0.5rem;
}

/* Login em desktop: altura fixa, sem rolagem na página */
@media (min-width: 1024px) {
    #auth-split-layout {
        height: 100dvh;
        max-height: 100dvh;
        min-height: 0;
        overflow: hidden;
    }

    #login-hero-panel {
        min-height: 0;
    }

    html:has(#app-container:not(.user-logged):not(.hidden)),
    body:has(#app-container:not(.user-logged):not(.hidden)) {
        overflow: hidden;
        height: 100%;
        max-height: 100dvh;
    }
}

#app-container.user-logged {
    max-width: 100%;
}

/* Forçar layout admin quando admin-view está visível */
#app-container.user-logged:has(#admin-view:not(.hidden)) {
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    width: 100% !important;
}

/* Mobile: garantir que app-container não limite */
@media (max-width: 1024px) {
    #app-container.user-logged:has(#admin-view:not(.hidden)) {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
        width: 100% !important;
    }

    body:has(#admin-view:not(.hidden)) {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }
}

body:has(#admin-view:not(.hidden)) {
    background: #f5f7fa !important;
    overflow-x: hidden;
}

/* Layout de card centralizado em desktop quando logado */
@media (min-width: 1025px) {
    #app-container.user-logged:has(#admin-view:not(.hidden)) {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 0 !important;
    }

    #app-container.user-logged:not(:has(#admin-view:not(.hidden))):not(:has(#master-view:not(.hidden))) {
        max-width: 600px;
        margin: 2rem auto;
        padding: 0;
    }

    body:has(#app-container.user-logged:not(:has(#admin-view:not(.hidden)))) {
        background: linear-gradient(135deg, var(--color-dark-blue) 0%, #003a52 100%);
    }

    body:has(#admin-view:not(.hidden)) {
        background: #f5f7fa !important;
    }

    #conductor-view:not(.hidden) {
        background: #e5e5e5;
        border-radius: 1rem;
        box-shadow: 0 20px 50px rgba(0, 0, 0, 0.2);
        padding: 2.5rem;
        margin: 0 auto;
        max-width: 100%;
        min-height: calc(100vh - 4rem);
        display: flex;
        flex-direction: column;
        align-items: center;
    }

    #admin-view:not(.hidden).admin-layout-container {
        background: transparent !important;
        border-radius: 0 !important;
        box-shadow: none !important;
        padding: 0 !important;
        margin: 0 !important;
        max-width: 100% !important;
        width: 100% !important;
        min-height: 100vh;
        display: flex !important;
        flex-direction: row !important;
        align-items: stretch;
        position: relative;
    }

    #master-view:not(.hidden) {
        background: transparent;
        padding: 2rem;
        margin: 0;
        max-width: 100%;
        width: 100%;
    }

    #conductor-view:not(.hidden)>* {
        max-width: 100%;
        width: 100%;
    }

    #admin-view:not(.hidden).admin-layout-container>* {
        max-width: 100%;
        width: 100%;
    }

    #master-view:not(.hidden)>* {
        max-width: 1400px;
        margin: 0 auto;
    }

    #conductor-nav,
    .grid.grid-cols-2 {
        max-width: 100%;
        margin: 0 auto;
    }

    body:has(#master-view:not(.hidden)) #app-container.user-logged {
        max-width: 100%;
        margin: 0;
        padding: 0;
    }
}

#conductor-view:not(.hidden) {
    background: #e5e5e5;
    border-radius: 1rem;
    padding: 1rem;
}

#admin-view:not(.hidden).admin-layout-container {
    background: transparent;
    border-radius: 0;
    padding: 0;
}

#master-view:not(.hidden) {
    background: transparent;
    padding: 1rem;
}

/* Mobile: garantir fundo branco nas views internas */
@media (max-width: 640px) {
    body {
        background-color: var(--color-dark-blue) !important;
    }

    #conductor-view:not(.hidden) {
        background: #e5e5e5 !important;
    }

    #admin-view:not(.hidden).admin-layout-container {
        background: transparent !important;
    }
}

/* Melhorias gerais de design profissional */
.bg-white {
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.bg-gray-50 {
    border: 1px solid rgba(0, 0, 0, 0.05);
}

/* Botões com design mais profissional */
button {
    transition: all 0.2s ease;
}

button:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

button:active {
    transform: translateY(0);
}

/* Cards com sombras mais suaves */
.rounded-lg,
.rounded-xl {
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.08);
}

/* Inputs com melhor design */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="datetime-local"],
select,
textarea {
    transition: all 0.2s ease;
    border: 2px solid var(--color-gray-200);
}

input[type="text"]:focus,
input[type="email"]:focus,
input[type="password"]:focus,
input[type="number"]:focus,
input[type="datetime-local"]:focus,
select:focus,
textarea:focus {
    border-color: var(--color-dark-blue);
    box-shadow: 0 0 0 3px rgba(0, 28, 40, 0.1);
}

/* Melhorar espaçamento e hierarquia visual */
h1,
h2,
h3 {
    letter-spacing: -0.02em;
}

/* Bordas mais suaves */
.border {
    border-color: rgba(0, 0, 0, 0.08);
}

/* Cards de listagem mais refinados */
.bg-gray-50,
.bg-white {
    transition: all 0.2s ease;
}

.bg-gray-50:hover,
.bg-white:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
}

/* Sistema de Toast Notifications Moderno e Profissional */
.toast-container {
    position: fixed;
    top: 24px;
    right: 24px;
    z-index: 10000;
    display: flex;
    flex-direction: column;
    gap: 16px;
    max-width: 420px;
    width: calc(100% - 48px);
}

@media (max-width: 640px) {
    .toast-container {
        top: 16px;
        right: 16px;
        left: 16px;
        max-width: 100%;
        width: auto;
    }
}

.toast {
    background: var(--color-white);
    border-radius: 16px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15), 0 1px 3px rgba(0, 0, 0, 0.1);
    padding: 18px 22px;
    display: flex;
    align-items: flex-start;
    gap: 14px;
    animation: slideInRight 0.4s cubic-bezier(0.16, 1, 0.3, 1);
    position: relative;
    overflow: hidden;
    border: 1px solid rgba(0, 0, 0, 0.05);
    backdrop-filter: blur(10px);
}

.toast::before {
    content: '';
    position: absolute;
    left: 0;
    top: 0;
    bottom: 0;
    width: 5px;
    border-radius: 16px 0 0 16px;
}

.toast.success::before {
    background: linear-gradient(180deg, #10b981 0%, #059669 100%);
}

.toast.error::before {
    background: linear-gradient(180deg, #ef4444 0%, #dc2626 100%);
}

.toast.warning::before {
    background: linear-gradient(180deg, #f59e0b 0%, #d97706 100%);
}

.toast.info::before {
    background: linear-gradient(180deg, #3b82f6 0%, #2563eb 100%);
}

.toast-icon {
    flex-shrink: 0;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 16px;
    font-weight: 600;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toast.success .toast-icon {
    background: linear-gradient(135deg, #d1fae5 0%, #a7f3d0 100%);
    color: #059669;
}

.toast.error .toast-icon {
    background: linear-gradient(135deg, #fee2e2 0%, #fecaca 100%);
    color: #dc2626;
}

.toast.warning .toast-icon {
    background: linear-gradient(135deg, #fef3c7 0%, #fde68a 100%);
    color: #d97706;
}

.toast.info .toast-icon {
    background: linear-gradient(135deg, #dbeafe 0%, #bfdbfe 100%);
    color: #2563eb;
}

.toast-content {
    flex: 1;
    min-width: 0;
    padding-top: 2px;
}

.toast-title {
    font-weight: 700;
    font-size: 15px;
    color: #111827;
    margin-bottom: 6px;
    letter-spacing: -0.01em;
}

.toast-message {
    font-size: 14px;
    color: var(--color-gray-600);
    line-height: 1.6;
    font-weight: 400;
}

.toast-close {
    flex-shrink: 0;
    background: rgba(0, 0, 0, 0.03);
    border: none;
    color: var(--color-gray-600);
    cursor: pointer;
    padding: 6px;
    border-radius: 8px;
    transition: all 0.2s ease;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.toast-close:hover {
    background: rgba(0, 0, 0, 0.08);
    color: var(--color-gray-700);
    transform: scale(1.1);
}

.toast-close:active {
    transform: scale(0.95);
}

.toast-progress {
    position: absolute;
    bottom: 0;
    left: 0;
    height: 4px;
    background: rgba(0, 0, 0, 0.08);
    animation: progressBar 5s linear;
    border-radius: 0 0 16px 16px;
}

.toast.success .toast-progress {
    background: linear-gradient(90deg, #10b981 0%, #34d399 100%);
}

.toast.error .toast-progress {
    background: linear-gradient(90deg, #ef4444 0%, #f87171 100%);
}

.toast.warning .toast-progress {
    background: linear-gradient(90deg, #f59e0b 0%, #fbbf24 100%);
}

.toast.info .toast-progress {
    background: linear-gradient(90deg, #3b82f6 0%, #60a5fa 100%);
}

@keyframes slideInRight {
    from {
        transform: translateX(100%);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

@keyframes slideOutRight {
    from {
        transform: translateX(0);
        opacity: 1;
    }

    to {
        transform: translateX(100%);
        opacity: 0;
    }
}

@keyframes progressBar {
    from {
        width: 100%;
    }

    to {
        width: 0%;
    }
}

.toast.hiding {
    animation: slideOutRight 0.3s ease-out forwards;
}

/* Transição suave para painel de detalhes da empresa */
[id^="tenant-details-"] {
    transition: all 0.3s ease-in-out;
    overflow: hidden;
}

[id^="tenant-details-"].hidden {
    max-height: 0;
    padding-top: 0;
    padding-bottom: 0;
    margin-top: 0;
    border-top: none;
}

/* Garantir que textos em cards brancos sejam visíveis */
.bg-white .text-gray-900,
.bg-white .text-gray-700,
.bg-white .text-gray-600,
.bg-white p,
.bg-white span:not(.text-dark-blue):not(.text-gold):not(.text-yellow-400):not(.text-white):not(.text-red-500):not(.text-green-500),
.bg-white strong:not(.text-dark-blue):not(.text-gold):not(.text-yellow-400):not(.text-white),
.bg-white div:not(.text-dark-blue):not(.text-gold):not(.text-yellow-400):not(.text-white),
.bg-gray-50 .text-gray-700,
.bg-gray-50 .text-gray-600,
.bg-gray-50 p,
.bg-gray-50 span:not(.text-dark-blue):not(.text-gold):not(.text-yellow-400):not(.text-white):not(.text-red-500):not(.text-green-500),
.bg-gray-50 strong:not(.text-dark-blue):not(.text-gold):not(.text-yellow-400):not(.text-white),
.bg-gray-50 div:not(.text-dark-blue):not(.text-gold):not(.text-yellow-400):not(.text-white) {
    color: #1f2937 !important;
}

/* Garantir que labels sejam visíveis */
label.text-gray-700,
label.text-gray-600 {
    color: var(--color-gray-700) !important;
}

/* Garantir contraste em elementos de lista */
.bg-gray-50 span,
.bg-white span,
.bg-gray-50 p,
.bg-white p,
li.bg-gray-50 span,
li.bg-gray-50 p,
div.bg-gray-50 span,
div.bg-gray-50 p,
div.bg-white span,
div.bg-white p {
    color: #1f2937 !important;
}

/* Forçar cor em todos os textos dentro de listas */
li p,
li span,
div.bg-white p,
div.bg-white span,
div.bg-gray-50 p,
div.bg-gray-50 span {
    color: #1f2937 !important;
}

/* Estilo customizado para o <select> */
.custom-select {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23525252%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E');
    background-repeat: no-repeat;
    background-position: right 1rem center;
    background-size: 0.65em auto;
    padding-right: 2.5rem;
}

/* Responsividade completa - Mobile First */
@media (max-width: 640px) {
    #app-container.user-logged {
        padding: 0.5rem;
    }

    .bg-white {
        padding: 1rem !important;
        margin: 0.5rem;
        border-radius: 0.75rem;
    }

    button {
        padding: 0.5rem 1rem;
        font-size: 0.875rem;
        min-height: 44px;
    }

    ul li,
    .bg-gray-50,
    .bg-white {
        padding: 0.75rem !important;
        margin-bottom: 0.5rem;
        font-size: 0.875rem;
    }

    h1 {
        font-size: 1.5rem;
        padding: 0.5rem;
    }

    h2 {
        font-size: 1.25rem;
    }

    h3 {
        font-size: 1.125rem;
    }

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

    input,
    select,
    textarea {
        font-size: 16px !important;
        padding: 0.75rem;
        width: 100%;
    }

    .fixed.inset-0 {
        padding: 1rem;
    }

    .fixed.inset-0>div {
        max-width: 100% !important;
        margin: 0;
    }

    .flex.gap-2,
    .flex.space-x-2,
    .flex.space-x-4 {
        flex-direction: column;
        gap: 0.5rem;
    }

    .bg-gradient-to-r {
        padding: 0.75rem !important;
    }

    table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
}

/* Tablets */
@media (min-width: 641px) and (max-width: 1024px) {
    #app-container.user-logged {
        padding: 1rem;
    }

    .bg-white {
        padding: 1.5rem;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr);
    }

    button {
        padding: 0.625rem 1.25rem;
        min-height: 40px;
    }
}

/* Desktop */
@media (min-width: 1025px) {
    #app-container.user-logged {
        max-width: 1400px;
        margin: 0 auto;
        padding: 2rem;
    }

    .grid {
        grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    }
}

/* Ajustes gerais para todos os dispositivos */
* {
    box-sizing: border-box;
}

img {
    max-width: 100%;
    height: auto;
}

/* Scroll suave */
html {
    scroll-behavior: smooth;
}

/* Melhorar legibilidade em todos os tamanhos */
body {
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

/* Garantir que inputs e selects sejam legíveis */
input,
select,
textarea {
    color: #1f2937 !important;
    background-color: var(--color-white) !important;
}

/* ============================================
   RESPONSIVIDADE COMPLETA - MOBILE & TABLET
   ============================================ */

/* Suporte para Safe Areas do iOS (notch, etc) */
@supports (padding: max(0px)) {
    body {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }

    .admin-sidebar {
        padding-top: env(safe-area-inset-top);
        padding-bottom: env(safe-area-inset-bottom);
    }

    .admin-main-content {
        padding-left: env(safe-area-inset-left);
        padding-right: env(safe-area-inset-right);
    }
}

/* Melhorias gerais para touch devices */
* {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
}

button,
a,
[role="button"] {
    -webkit-tap-highlight-color: rgba(0, 0, 0, 0.1);
    touch-action: manipulation;
    cursor: pointer;
}

/* Prevenir zoom em inputs no iOS (font-size mínimo 16px) */
input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="datetime-local"],
input[type="time"],
select,
textarea {
    font-size: 16px !important;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

/* Melhorias para telas muito pequenas (menos de 360px) */
@media (max-width: 360px) {
    #app-container.user-logged {
        padding: 0.25rem !important;
    }

    .bg-white,
    .bg-gray-50 {
        padding: 0.75rem !important;
        margin: 0.25rem !important;
    }

    h1 {
        font-size: 1.25rem !important;
    }

    h2 {
        font-size: 1.125rem !important;
    }

    h3 {
        font-size: 1rem !important;
    }

    button {
        padding: 0.625rem 0.875rem !important;
        font-size: 0.8125rem !important;
    }
}

/* Melhorias para mobile landscape */
@media (max-width: 896px) and (orientation: landscape) {
    .admin-sidebar {
        width: 240px !important;
    }

    .admin-main-content {
        margin-left: 240px !important;
        width: calc(100% - 240px) !important;
    }

    .admin-header {
        padding: 0.75rem 1rem !important;
    }

    .admin-content-area {
        padding: 1rem !important;
    }
}

/* Otimizações para tablets em modo retrato */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: portrait) {
    .admin-sidebar {
        width: 260px !important;
    }

    .admin-main-content {
        margin-left: 260px !important;
        width: calc(100% - 260px) !important;
    }

    .grid {
        grid-template-columns: repeat(2, 1fr) !important;
    }
}

/* Otimizações para tablets em modo paisagem */
@media (min-width: 641px) and (max-width: 1024px) and (orientation: landscape) {
    .admin-sidebar {
        width: 240px !important;
    }

    .admin-main-content {
        margin-left: 240px !important;
        width: calc(100% - 240px) !important;
    }

    .grid {
        grid-template-columns: repeat(3, 1fr) !important;
    }
}

/* Melhorias para modais em mobile */
@media (max-width: 640px) {

    /* Modais devem ocupar quase toda a tela em mobile */
    .fixed.inset-0>div {
        max-width: calc(100% - 2rem) !important;
        max-height: calc(100vh - 2rem) !important;
        margin: 1rem !important;
        overflow-y: auto !important;
        -webkit-overflow-scrolling: touch !important;
    }

    /* Modal de revisão específico */
    #maintenance-config-modal>div {
        max-width: calc(100% - 1rem) !important;
        padding: 1.5rem !important;
        max-height: 90vh !important;
        overflow-y: auto !important;
    }

    /* Garantir que modais não sejam cortados */
    .fixed.inset-0 {
        padding: 0.5rem !important;
        align-items: flex-start !important;
        padding-top: env(safe-area-inset-top, 0.5rem) !important;
    }
}

/* Melhorias para cards em mobile */
@media (max-width: 640px) {

    .bg-white,
    .bg-gray-50 {
        border-radius: 0.75rem !important;
        box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1) !important;
        width: 100% !important;
        max-width: 100% !important;
        margin-left: 0 !important;
        margin-right: 0 !important;
    }

    /* Cards de lista mais compactos */
    .space-y-2>*+* {
        margin-top: 0.5rem !important;
    }

    .space-y-3>*+* {
        margin-top: 0.75rem !important;
    }

    .space-y-4>*+* {
        margin-top: 1rem !important;
    }

    /* KPI Cards do dashboard */
    .admin-sub-view .bg-gradient-to-br {
        width: 100% !important;
        max-width: 100% !important;
        padding: 1rem !important;
        box-sizing: border-box !important;
    }

    /* Garantir que grids sejam de 1 coluna */
    .admin-sub-view .grid,
    .admin-sub-view [class*="grid"] {
        grid-template-columns: 1fr !important;
        gap: 1rem !important;
    }

    /* Botões de filtro em coluna */
    .admin-sub-view .flex.flex-wrap {
        flex-direction: column !important;
        gap: 0.5rem !important;
    }

    .admin-sub-view .flex.flex-wrap>button {
        width: 100% !important;
        margin-bottom: 0 !important;
    }

    /* Ajustar tamanhos de fonte em mobile */
    .admin-sub-view h3 {
        font-size: 1.125rem !important;
    }

    .admin-sub-view h4 {
        font-size: 1rem !important;
    }

    /* Garantir que tabelas sejam scrolláveis */
    .admin-sub-view table {
        display: block !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        width: 100% !important;
    }
}

/* Melhorias para sidebar admin em mobile - já aplicado acima */

/* Melhorias para botões em mobile - garantir tamanho mínimo para touch */
@media (max-width: 640px) {

    button,
    .admin-menu-item,
    .admin-logout-btn {
        min-height: 44px !important;
        min-width: 44px !important;
        padding: 0.75rem 1rem !important;
    }

    /* Botões pequenos também devem ter tamanho mínimo */
    button.text-xs,
    button.text-sm {
        min-height: 44px !important;
        padding: 0.625rem 1rem !important;
    }
}

/* Melhorias para formulários em mobile */
@media (max-width: 640px) {
    form {
        width: 100% !important;
    }

    form>* {
        width: 100% !important;
    }

    /* Espaçamento entre campos */
    .space-y-4>*+* {
        margin-top: 1rem !important;
    }

    /* Labels mais legíveis */
    label {
        font-size: 0.875rem !important;
        margin-bottom: 0.5rem !important;
        display: block !important;
    }
}

/* Melhorias para tabelas em mobile */
@media (max-width: 640px) {
    table {
        display: block !important;
        width: 100% !important;
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch !important;
        white-space: nowrap !important;
    }

    thead {
        display: none !important;
    }

    tbody {
        display: block !important;
    }

    tr {
        display: block !important;
        margin-bottom: 1rem !important;
        border: 1px solid #e5e7eb !important;
        border-radius: 0.5rem !important;
        padding: 0.75rem !important;
    }

    td {
        display: block !important;
        text-align: right !important;
        padding: 0.5rem 0 !important;
        border: none !important;
    }

    td::before {
        content: attr(data-label) ": ";
        font-weight: 600;
        float: left;
        text-align: left;
    }
}

/* Melhorias para listas em mobile */
@media (max-width: 640px) {

    ul,
    ol {
        padding-left: 1rem !important;
    }

    li {
        margin-bottom: 0.5rem !important;
        padding: 0.75rem !important;
    }
}

/* Melhorias para gráficos e visualizações em mobile */
@media (max-width: 640px) {
    .min-h-\[200px\] {
        min-height: 150px !important;
    }

    canvas,
    svg {
        max-width: 100% !important;
        height: auto !important;
    }
}

/* Melhorias para header admin em mobile */
@media (max-width: 640px) {
    .admin-header {
        padding: 0.75rem 1rem !important;
        flex-wrap: wrap !important;
        gap: 0.5rem !important;
        position: sticky !important;
        top: 0 !important;
        z-index: 100 !important;
        background: white !important;
    }

    .admin-header-left {
        flex: 1 1 auto !important;
        min-width: 0 !important;
    }

    .admin-header-right {
        flex: 0 0 auto !important;
    }

    .admin-header-title {
        font-size: 1.125rem !important;
        word-wrap: break-word !important;
        overflow-wrap: break-word !important;
    }

    .admin-header-subtitle {
        font-size: 0.75rem !important;
    }

    /* Esconder código no header em telas muito pequenas */
    .admin-code-card-header {
        display: none !important;
    }

    /* Ajustar botão toggle */
    .admin-sidebar-toggle {
        min-width: 44px !important;
        min-height: 44px !important;
        padding: 0.5rem !important;
        flex-shrink: 0 !important;
    }
}

/* Melhorias para conductor view em mobile */
@media (max-width: 640px) {
    #conductor-view {
        padding: 0.5rem !important;
        margin-top: 0 !important;
        padding-top: 0.5rem !important;
        min-height: auto !important;
    }

    #conductor-nav {
        gap: 0.5rem !important;
    }

    #conductor-nav button {
        padding: 1rem 0.75rem !important;
        min-height: 60px !important;
    }

    #conductor-header-section img {
        height: 100px !important;
        width: auto !important;
    }

    /* Forçar topo no admin mobile */
    .admin-main-content {
        padding-top: 0.5rem !important;
        margin-top: 0 !important;
    }

    .admin-sidebar-header {
        padding-top: env(safe-area-inset-top, 0.5rem) !important;
    }
}

/* Prevenir scroll horizontal indesejado */
html,
body {
    overflow-x: hidden !important;
    max-width: 100vw !important;
}

/* Mobile: garantir que admin-view não cause overflow */
@media (max-width: 1024px) {

    #admin-view.admin-layout-container,
    .admin-layout-container {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100vw !important;
    }

    .admin-sidebar {
        position: fixed !important;
        left: 0 !important;
        top: 0 !important;
        bottom: 0 !important;
        width: 280px !important;
        transform: translateX(-100%) !important;
        transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1) !important;
        z-index: 10001 !important;
        box-shadow: 10px 0 15px -3px rgba(0, 0, 0, 0.1) !important;
        background-color: var(--color-dark-blue) !important;
    }

    .admin-sidebar.open {
        transform: translateX(0) !important;
    }

    .admin-sidebar-overlay {
        position: fixed !important;
        inset: 0 !important;
        background-color: rgba(0, 0, 0, 0.5) !important;
        backdrop-filter: blur(4px) !important;
        z-index: 10000 !important;
        opacity: 0 !important;
        visibility: hidden !important;
        transition: opacity 0.3s ease, visibility 0.3s ease !important;
    }

    .admin-sidebar-overlay.active {
        opacity: 1 !important;
        visibility: visible !important;
    }

    .admin-main-content {
        margin-left: 0 !important;
        width: 100% !important;
        max-width: 100vw !important;
        padding: 1rem !important;
    }

    .admin-main-content,
    .admin-content-area {
        overflow-x: hidden !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    /* Garantir que grids sejam responsivos */
    .grid {
        grid-template-columns: 1fr !important;
    }

    /* Forçar todas as variações de grid para 1 coluna no mobile */
    .grid.grid-cols-1,
    .grid.grid-cols-2,
    .grid.grid-cols-3,
    .grid.grid-cols-4,
    .grid[class*="grid-cols"] {
        grid-template-columns: 1fr !important;
    }
}

/* Mobile pequeno: garantir que tudo seja de 1 coluna */
@media (max-width: 640px) {

    /* Forçar todos os grids para 1 coluna */
    .grid,
    [class*="grid-cols"] {
        grid-template-columns: 1fr !important;
    }

    /* Garantir que elementos não ultrapassem a largura */
    .admin-sub-view>* {
        width: 100% !important;
        max-width: 100% !important;
        box-sizing: border-box !important;
    }

    /* Ajustar espaçamentos */
    .gap-4,
    .gap-6,
    .gap-8 {
        gap: 0.75rem !important;
    }

    /* Reduzir padding dos cards de métricas do dashboard */
    .bg-gradient-to-br.rounded-xl {
        padding: 0.75rem !important;
    }

    /* Reduzir tamanho de fonte dos números grandes nos cards */
    .text-2xl,
    .text-3xl {
        font-size: 1.5rem !important;
        line-height: 1.2 !important;
    }

    /* Reduzir tamanho de fonte dos títulos dos cards */
    .text-xs.uppercase {
        font-size: 0.65rem !important;
    }

    /* Reduzir padding dos cards de condutores/administradores */
    .bg-white.rounded-lg {
        padding: 0.75rem !important;
    }

    /* Reduzir tamanho de fonte nos cards de condutores */
    .bg-white.rounded-lg h5,
    .bg-white.rounded-lg .font-bold {
        font-size: 0.875rem !important;
    }

    .bg-white.rounded-lg p {
        font-size: 0.75rem !important;
    }

    /* Reduzir espaçamentos entre elementos */
    .mb-4,
    .mb-6,
    .mb-8 {
        margin-bottom: 0.75rem !important;
    }

    .mt-4,
    .mt-6,
    .mt-8 {
        margin-top: 0.75rem !important;
    }

    /* Reduzir altura mínima dos gráficos */
    .min-h-\[150px\],
    .min-h-\[200px\] {
        min-height: 120px !important;
    }

    /* Reduzir tamanho dos botões nos cards de condutores */
    .bg-white.rounded-lg button {
        padding: 0.5rem 0.75rem !important;
        font-size: 0.75rem !important;
    }

    /* Reduzir tamanho dos títulos de seção */
    h3,
    h4 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Reduzir espaçamento entre cards de métricas */
    .grid.grid-cols-1.sm\\:grid-cols-2.lg\\:grid-cols-4 {
        gap: 0.5rem !important;
    }

    /* Reduzir tamanho dos títulos principais */
    .admin-sub-view h3 {
        font-size: 1rem !important;
        margin-bottom: 0.75rem !important;
    }

    /* Reduzir padding do conteúdo */
    .admin-content-area {
        padding: 0.5rem !important;
    }

    /* Ajustar padding de cards */
    .p-4,
    .p-5,
    .p-6 {
        padding: 1rem !important;
    }
}

/* Melhorias para scroll suave em mobile */
@media (max-width: 640px) {
    * {
        -webkit-overflow-scrolling: touch;
    }

    .overflow-y-auto,
    .overflow-auto {
        -webkit-overflow-scrolling: touch;
    }
}

/* Melhorias para texto em mobile - garantir legibilidade */
@media (max-width: 640px) {
    body {
        font-size: 14px !important;
        line-height: 1.6 !important;
    }

    p,
    span,
    div {
        font-size: 0.875rem !important;
        line-height: 1.6 !important;
    }

    .text-xs {
        font-size: 0.75rem !important;
    }

    .text-sm {
        font-size: 0.875rem !important;
    }

    .text-base {
        font-size: 1rem !important;
    }
}

/* Melhorias para espaçamento em mobile */
@media (max-width: 640px) {

    .p-4,
    .p-6,
    .p-8 {
        padding: 1rem !important;
    }

    .px-4,
    .px-6,
    .px-8 {
        padding-left: 1rem !important;
        padding-right: 1rem !important;
    }

    .py-4,
    .py-6,
    .py-8 {
        padding-top: 1rem !important;
        padding-bottom: 1rem !important;
    }

    .mb-4,
    .mb-6,
    .mb-8 {
        margin-bottom: 1rem !important;
    }

    .mt-4,
    .mt-6,
    .mt-8 {
        margin-top: 1rem !important;
    }
}

/* Garantir que elementos fixos respeitem safe areas */
.fixed {
    padding-left: env(safe-area-inset-left, 0);
    padding-right: env(safe-area-inset-right, 0);
}

/* Melhorias para performance em mobile */
@media (max-width: 640px) {
    * {
        will-change: auto;
    }

    /* Reduzir animações em mobile para melhor performance */
    @media (prefers-reduced-motion: reduce) {

        *,
        *::before,
        *::after {
            animation-duration: 0.01ms !important;
            animation-iteration-count: 1 !important;
            transition-duration: 0.01ms !important;
        }
    }
}

/* ============================================
   CAR LOADING ANIMATION
   ============================================ */

@keyframes drive-car {
    0% {
        left: -10%;
        transform: translateY(0) rotate(0deg);
    }

    10% {
        transform: translateY(-1px) rotate(-1deg);
    }

    20% {
        transform: translateY(0) rotate(0deg);
    }

    30% {
        transform: translateY(-1px) rotate(1deg);
    }

    40% {
        transform: translateY(0) rotate(0deg);
    }

    100% {
        left: 110%;
        transform: translateY(0) rotate(0deg);
    }
}

.animate-drive-car {
    animation: drive-car 2.5s linear infinite;
    position: absolute;
    bottom: 8px;
    /* Ajuste para ficar em cima da barra */
    z-index: 10;
}

@keyframes progress-fill {
    0% {
        width: 0%;
    }

    100% {
        width: 100%;
    }
}

.animate-progress-bar {
    animation: progress-fill 2.5s linear infinite;
    background-color: var(--color-gold);
    height: 100%;
    width: 0%;
}

/* Utility Classes for Gold Color */
.bg-gold {
    background-color: var(--color-gold) !important;
}

.text-gold {
    color: var(--color-gold) !important;
}

.border-gold {
    border-color: var(--color-gold) !important;
}