/* ==========================================
   MOBILE-FIRST RESPONSIVE CSS
   Base styles for mobile, enhanced for desktop
   ========================================== */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #059669;
    --primary-dark: #047857;
    --primary-light: #10b981;
    --success-color: #10b981;
    --danger-color: #dc2626;
    --warning-color: #f59e0b;
    --gray-100: #f9fafb;
    --gray-200: #e5e7eb;
    --gray-300: #d1d5db;
    --gray-400: #9ca3af;
    --gray-600: #4b5563;
    --gray-700: #374151;
    --gray-800: #1f2937;
    --gray-900: #111827;

    /* Touch target size */
    --touch-target: 44px;

    /* Responsive spacing */
    --spacing-xs: 0.5rem;
    --spacing-sm: 0.75rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
}

/* ========== BASE STYLES (MOBILE) ========== */

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen', 'Ubuntu', 'Cantarell', sans-serif;
    background: var(--gray-100);
    color: var(--gray-900);
    line-height: 1.6;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
}

.container {
    width: 100%;
    padding: 0 var(--spacing-md);
    margin: 0 auto;
}

/* ========== MOBILE LAYOUT STRUCTURE ========== */

body {
    padding-bottom: 95px; /* Space for bottom navigation */
}

/* ========== HEADER (MOBILE-FIRST) ========== */

header {
    background: white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    z-index: 100;
    border-bottom: 1px solid var(--gray-200);
    min-height: 60px;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--spacing-md);
    position: relative;
}

/* Hamburger Menu Button */
.menu-toggle {
    display: flex;
    flex-direction: column;
    justify-content: space-around;
    width: var(--touch-target);
    height: var(--touch-target);
    background: transparent;
    border: none;
    cursor: pointer;
    padding: var(--spacing-sm);
    z-index: 200;
}

.menu-toggle span {
    width: 100%;
    height: 3px;
    background: var(--gray-800);
    border-radius: 2px;
    transition: all 0.3s ease;
}

.menu-toggle.active span:nth-child(1) {
    transform: rotate(45deg) translate(7px, 7px);
}

.menu-toggle.active span:nth-child(2) {
    opacity: 0;
}

.menu-toggle.active span:nth-child(3) {
    transform: rotate(-45deg) translate(7px, -7px);
}

.logo {
    font-size: clamp(1.25rem, 5vw, 1.5rem);
    font-weight: 700;
    color: var(--primary-color);
    letter-spacing: -0.5px;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.logo img {
    height: 32px;
    width: 32px;
    border-radius: 50%;
    object-fit: cover;
}

/* Navigation Drawer (Mobile) - Menu lateral hamburguer */
nav.side-drawer {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    height: 100vh;
    background: white;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.1);
    z-index: 150;
    transition: right 0.3s ease;
    overflow-y: auto;
    padding-top: 70px;
}

nav.side-drawer.active {
    right: 0;
}

/* Overlay */
.nav-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 140;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.nav-overlay.active {
    display: block;
    opacity: 1;
}

nav.side-drawer ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    padding: var(--spacing-md);
}

nav.side-drawer li {
    margin-bottom: var(--spacing-xs);
}

nav.side-drawer a {
    display: block;
    text-decoration: none;
    color: var(--gray-700);
    padding: var(--spacing-md);
    border-radius: 8px;
    transition: all 0.2s;
    font-weight: 500;
    min-height: var(--touch-target);
    display: flex;
    align-items: center;
}

nav.side-drawer a:hover,
nav.side-drawer a:active {
    background: var(--gray-100);
    color: var(--primary-color);
}

.user-info {
    border-top: 1px solid var(--gray-200);
    padding-top: var(--spacing-md);
    margin-top: var(--spacing-md);
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.user-info span {
    padding: 0 var(--spacing-md);
    font-weight: 600;
    color: var(--gray-700);
}

.notification-badge {
    position: relative;
    cursor: pointer;
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.notification-badge:active {
    background: var(--gray-100);
}

.notification-count {
    position: absolute;
    top: 8px;
    right: 8px;
    background: var(--danger-color);
    color: white;
    border-radius: 50%;
    min-width: 20px;
    height: 20px;
    font-size: 0.75rem;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 4px;
    font-weight: 600;
}

/* ========== BUTTONS (TOUCH-FRIENDLY) ========== */

.btn {
    padding: var(--spacing-md) var(--spacing-lg);
    min-height: var(--touch-target);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    position: relative;
    overflow: hidden;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}

.btn:active {
    transform: scale(0.98);
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: white;
}

.btn-primary:active {
    background: linear-gradient(135deg, var(--primary-dark) 0%, #065f46 100%);
}

.btn-success {
    background: var(--success-color);
    color: white;
}

.btn-danger {
    background: var(--danger-color);
    color: white;
}

.btn-secondary {
    background: var(--gray-300);
    color: var(--gray-800);
}

.btn-small {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: 0.875rem;
    min-height: 36px;
}

/* ========== LOGIN PAGE (MOBILE) ========== */

.login-container {
    min-height: 100vh;
    min-height: 100dvh; /* Dynamic viewport height for mobile */
    max-height: 100vh;
    max-height: 100dvh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, #047857 0%, #059669 50%, #10b981 100%);
    padding: var(--spacing-lg);
    overflow: hidden; /* Remove scroll da tela de login */
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
}

.login-box {
    background: white;
    padding: clamp(1.5rem, 5vw, 2rem);
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    width: 100%;
    max-width: 420px;
    margin: auto;
}

.logo-container {
    text-align: center;
    margin-bottom: var(--spacing-xl);
}

.logo-image {
    width: clamp(80px, 20vw, 120px) !important;
    height: clamp(80px, 20vw, 120px) !important;
    border-radius: 50%;
    margin-bottom: 1rem;
    object-fit: cover;
}

.logo-icon {
    font-size: clamp(2.5rem, 10vw, 3.5rem);
    margin-bottom: var(--spacing-sm);
}

.login-box h1 {
    margin: 0;
    font-size: clamp(1.5rem, 6vw, 2rem);
    font-weight: 700;
    color: var(--gray-900);
}

.subtitle {
    color: var(--gray-600);
    font-size: clamp(0.875rem, 4vw, 0.95rem);
    margin-top: var(--spacing-sm);
}

/* Mobile-specific login adjustments */
@media (max-width: 768px) {
    .login-container {
        padding: var(--spacing-md);
        align-items: center;
        justify-content: center;
    }
    
    .login-box {
        margin: 0;
        max-height: 90vh;
        overflow-y: auto;
    }
}

/* Very small screens */
@media (max-width: 380px) {
    .login-container {
        padding: var(--spacing-sm);
    }
    
    .login-box {
        padding: 1.25rem;
        border-radius: 12px;
    }
}

/* Login button - full width */
.btn-login {
    width: 100%;
}

/* Login subtitle */
.login-subtitle {
    margin-top: 1rem;
    text-align: center;
    color: var(--gray-600);
    font-size: clamp(0.75rem, 3vw, 0.875rem);
    line-height: 1.4;
}

/* ========== FORMS (MOBILE-OPTIMIZED) ========== */

.form-group {
    margin-bottom: var(--spacing-md);
}

.form-group label {
    display: block;
    margin-bottom: var(--spacing-sm);
    color: var(--gray-700);
    font-weight: 500;
    font-size: 0.95rem;
}

.form-group input,
.form-group select,
.form-group textarea {
    width: 100%;
    padding: var(--spacing-md);
    min-height: var(--touch-target);
    border: 2px solid var(--gray-300);
    border-radius: 8px;
    font-size: 16px; /* Prevents zoom on iOS */
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(5, 150, 105, 0.1);
}

/* Specific input types for mobile keyboards */
input[type="email"] {
    text-transform: lowercase;
}

input[type="tel"] {
    font-variant-numeric: tabular-nums;
}

input[type="number"] {
    font-variant-numeric: tabular-nums;
}

/* ========== ALERTS ========== */

.alert {
    padding: var(--spacing-md);
    border-radius: 8px;
    margin-bottom: var(--spacing-md);
    font-size: 0.95rem;
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 10000;
    min-width: 300px;
    max-width: 500px;
    animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.alert-error {
    background: #fee2e2;
    color: var(--danger-color);
    border: 1px solid #fecaca;
}

.alert-success {
    background: #d1fae5;
    color: var(--success-color);
    border: 1px solid #a7f3d0;
}

.alert-warning {
    background: #fef3c7;
    color: #b45309;
    border: 1px solid #fcd34d;
}

/* ========== CARDS (RESPONSIVE) ========== */

.card {
    background: white;
    border-radius: 12px;
    padding: var(--spacing-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    margin-bottom: var(--spacing-md);
    border: 1px solid var(--gray-200);
}

.card-header {
    border-bottom: 1px solid var(--gray-200);
    padding-bottom: var(--spacing-md);
    margin-bottom: var(--spacing-md);
}

.card-title {
    font-size: clamp(1.125rem, 5vw, 1.25rem);
    font-weight: 600;
}

/* ========== STATS GRID (MOBILE-FIRST) ========== */

.stats-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
    margin-bottom: var(--spacing-lg);
}

.stat-card {
    background: white;
    padding: var(--spacing-lg);
    border-radius: 12px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--gray-200);
    transition: all 0.2s ease;
}

.stat-card:active {
    transform: scale(0.98);
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
}

.stat-label {
    color: var(--gray-600);
    font-size: 0.875rem;
    margin-bottom: var(--spacing-sm);
    font-weight: 500;
}

.stat-value {
    font-size: clamp(1.75rem, 8vw, 2rem);
    font-weight: bold;
    color: var(--gray-900);
}

/* ========== TABLES (MOBILE: CARD STACK) ========== */

.table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

table {
    width: 100%;
    border-collapse: collapse;
    min-width: 600px; /* Forces horizontal scroll on small screens */
}

table th,
table td {
    padding: var(--spacing-md);
    text-align: left;
    border-bottom: 1px solid var(--gray-200);
}

table th {
    background: var(--gray-100);
    font-weight: 600;
    color: var(--gray-700);
    position: sticky;
    top: 0;
    z-index: 10;
}

/* Mobile Card View for Tables */
.table-mobile {
    display: none;
}

.table-mobile-card {
    background: white;
    border-radius: 12px;
    padding: var(--spacing-md);
    margin-bottom: var(--spacing-md);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
    border: 1px solid var(--gray-200);
}

.table-mobile-card-row {
    display: flex;
    justify-content: space-between;
    padding: var(--spacing-sm) 0;
    border-bottom: 1px solid var(--gray-100);
}

.table-mobile-card-row:last-child {
    border-bottom: none;
}

.table-mobile-card-label {
    font-weight: 600;
    color: var(--gray-700);
    font-size: 0.875rem;
}

.table-mobile-card-value {
    color: var(--gray-900);
    font-size: 0.875rem;
    text-align: right;
}

.table-mobile-card-actions {
    margin-top: var(--spacing-md);
    padding-top: var(--spacing-md);
    border-top: 1px solid var(--gray-200);
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
}

/* ========== BADGES ========== */

.badge {
    padding: 0.375rem 0.75rem;
    border-radius: 12px;
    font-size: 0.875rem;
    font-weight: 500;
    display: inline-block;
}

.badge-pendente {
    background: #fef3c7;
    color: #92400e;
}

.badge-aprovado {
    background: #d1fae5;
    color: #065f46;
}

.badge-reprovado {
    background: #fee2e2;
    color: #991b1b;
}

/* ========== MODALS (MOBILE-FRIENDLY) ========== */

.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    overflow-y: auto;
}

.modal.active {
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: var(--spacing-md);
}

.modal-content {
    background: white;
    border-radius: 12px;
    padding: var(--spacing-lg);
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    margin: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.modal-header h2 {
    font-size: clamp(1.25rem, 5vw, 1.5rem);
}

.modal-close {
    background: none;
    border: none;
    font-size: 2rem;
    cursor: pointer;
    color: var(--gray-600);
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    transition: background 0.2s;
}

.modal-close:active {
    background: var(--gray-100);
}

/* ========== MAP ========== */

#map {
    height: 300px;
    border-radius: 8px;
    width: 100%;
}

/* ========== PWA INSTALL BANNER ========== */

.pwa-install-banner {
    display: none;
    position: fixed;
    bottom: max(env(safe-area-inset-bottom), var(--spacing-md));
    left: var(--spacing-md);
    right: var(--spacing-md);
    background: white;
    padding: var(--spacing-md);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    max-width: 100%;
}

.pwa-install-banner.show {
    display: flex;
    gap: var(--spacing-md);
    align-items: center;
    flex-wrap: wrap;
    justify-content: space-between;
}

@media (max-width: 480px) {
    .pwa-install-banner {
        flex-direction: column;
        align-items: stretch;
    }
    
    .pwa-install-banner button {
        width: 100%;
    }
}

/* ========== UTILITY CLASSES ========== */

.hidden {
    display: none !important;
}

.loading {
    text-align: center;
    padding: var(--spacing-xl);
    color: var(--gray-600);
}

.text-center {
    text-align: center;
}

.mt-1 { margin-top: var(--spacing-xs); }
.mt-2 { margin-top: var(--spacing-md); }
.mt-3 { margin-top: var(--spacing-lg); }
.mt-4 { margin-top: var(--spacing-xl); }

.mb-1 { margin-bottom: var(--spacing-xs); }
.mb-2 { margin-bottom: var(--spacing-md); }
.mb-3 { margin-bottom: var(--spacing-lg); }
.mb-4 { margin-bottom: var(--spacing-xl); }

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.items-center {
    align-items: center;
}

.justify-between {
    justify-content: space-between;
}

.gap-1 { gap: var(--spacing-xs); }
.gap-2 { gap: var(--spacing-md); }
.gap-3 { gap: var(--spacing-lg); }

.w-full {
    width: 100%;
}

/* ==========================================
   TABLET BREAKPOINT (768px+)
   ========================================== */

@media (min-width: 768px) {
    .container {
        max-width: 720px;
    }

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

    .card {
        padding: var(--spacing-lg);
    }

    #map {
        height: 400px;
    }

    .modal.active {
        align-items: center;
    }

    .pwa-install-banner {
        left: 50%;
        right: auto;
        transform: translateX(-50%);
        max-width: 500px;
    }
}

/* ==========================================
   DESKTOP BREAKPOINT (1024px+)
   ========================================== */

@media (min-width: 1024px) {
    .container {
        max-width: 1200px;
        padding: 0 var(--spacing-xl);
    }

    /* Hide mobile menu toggle */
    .menu-toggle {
        display: none;
    }

    /* Desktop navigation */
    nav {
        position: static;
        width: auto;
        height: auto;
        box-shadow: none;
        padding-top: 0;
        overflow: visible;
    }

    nav ul {
        flex-direction: row;
        gap: var(--spacing-lg);
        padding: 0;
    }

    nav li {
        margin-bottom: 0;
    }

    nav a {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .user-info {
        flex-direction: row;
        border-top: none;
        padding-top: 0;
        margin-top: 0;
        align-items: center;
        gap: var(--spacing-md);
    }

    .user-info span {
        padding: 0;
    }

    .nav-overlay {
        display: none !important;
    }

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

    .stat-card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
        transform: translateY(-2px);
    }

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

    .btn-primary:hover {
        box-shadow: 0 4px 12px rgba(5, 150, 105, 0.3);
    }

    .card:hover {
        box-shadow: 0 4px 16px rgba(0, 0, 0, 0.1);
    }

    #map {
        height: 500px;
    }

    .logo img {
        height: 40px;
        width: 40px;
    }
}

/* ==========================================
   LARGE DESKTOP (1280px+)
   ========================================== */

@media (min-width: 1280px) {
    .container {
        max-width: 1280px;
    }
}

/* ==========================================
   ACCESSIBILITY & TOUCH IMPROVEMENTS
   ========================================== */

/* Focus styles for keyboard navigation */
a:focus-visible,
button:focus-visible,
input:focus-visible,
select:focus-visible,
textarea:focus-visible {
    outline: 2px solid var(--primary-color);
    outline-offset: 2px;
}

/* Reduce motion for users who prefer it */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .btn {
        border: 2px solid currentColor;
    }

    .card {
        border-width: 2px;
    }
}

/* Dark mode support (future enhancement) */
@media (prefers-color-scheme: dark) {
    /* Can be implemented later */
}

/* ==========================================
   BOTTOMNAVIGATION (MOBILE)
   ========================================== */

.bottom-nav {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
    display: flex;
    justify-content: space-around;
    align-items: center;
    height: 85px;
    z-index: 99;
    padding: 0 4px;
}

.bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    text-decoration: none;
    color: var(--gray-600);
    font-size: 0.75rem;
    padding: 6px 2px;
    transition: color 0.3s ease;
    min-height: var(--touch-target);
    gap: 0.35rem;
    max-width: 95px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.bottom-nav-item:active {
    transform: scale(0.95);
}

.bottom-nav-item.active {
    color: var(--primary-color);
}

.bottom-nav-item .icon {
    font-size: 1.5rem;
    transition: transform 0.3s ease;
}

.bottom-nav-item.active .icon {
    transform: scale(1.1);
}

.bottom-nav-item span:not(.icon) {
    display: block;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    text-align: center;
}

/* FAB Button (Central Scanner) */
.fab-container {
    position: relative;
    flex: 0 0 auto;
    margin: 0 2px;
    overflow: visible;
}

.fab-button {
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: var(--primary-color);
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    border: none;
    box-shadow: 0 2px 8px rgba(5, 150, 105, 0.25);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    bottom: 12px;
}

.fab-button:hover {
    box-shadow: 0 4px 12px rgba(5, 150, 105, 0.35);
}

.fab-button:active {
    transform: scale(0.95);
    box-shadow: 0 2px 6px rgba(5, 150, 105, 0.25);
}

.fab-button .icon {
    font-size: 1.5rem;
    color: white;
}

/* Main content adjustment */
main {
    min-height: calc(100vh - 150px);
    padding-top: 75px; /* Espaço para header fixo */
    padding-bottom: 100px; /* Espaço para bottom nav */
}

/* Ajustes específicos para mobile */
@media (max-width: 767px) {
    main {
        padding-top: 80px;
        padding-bottom: 110px;
    }
}

/* Ajustes para desktop */
@media (min-width: 768px) {
    main {
        padding-top: 80px;
        padding-bottom: 110px;
    }
}

main.container > *:first-child {
    margin-top: 0;
    padding-top: 0;
}

/* Adjust for desktop */
@media (min-width: 768px) {
    .bottom-nav {
        display: flex; /* Mantém visível em desktop também */
        justify-content: center;
        gap: var(--spacing-md);
        padding: 0 var(--spacing-xl);
    }

    .bottom-nav-item {
        max-width: 120px;
    }

    body {
        padding-bottom: 95px; /* Mantém espaço para barra */
    }

    main {
        padding-top: 0; /* Remove padding-top em desktop */
    }
}

/* ==========================================
   SCANNER MODAL
   ========================================== */

.scanner-modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 200;
    align-items: center;
    justify-content: center;
}

.scanner-modal.active {
    display: flex;
}

.scanner-modal-content {
    background: white;
    border-radius: 16px;
    padding: var(--spacing-xl);
    width: 90%;
    max-width: 500px;
    max-height: 80vh;
    overflow-y: auto;
}

.scanner-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: var(--spacing-lg);
}

.scanner-modal-header h2 {
    font-size: 1.25rem;
    color: var(--gray-900);
}

.scanner-close {
    background: none;
    border: none;
    font-size: 1.5rem;
    color: var(--gray-600);
    cursor: pointer;
    padding: 0;
    width: var(--touch-target);
    height: var(--touch-target);
    display: flex;
    align-items: center;
    justify-content: center;
}

.upload-area {
    border: 2px dashed var(--gray-300);
    border-radius: 12px;
    padding: var(--spacing-xl);
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: var(--spacing-md);
}

.upload-area:hover {
    border-color: var(--primary-color);
    background: var(--gray-100);
}

.upload-area .icon {
    font-size: 3rem;
    color: var(--gray-400);
    margin-bottom: var(--spacing-sm);
}

.upload-area p {
    color: var(--gray-600);
    font-size: 0.875rem;
}

.image-preview {
    margin-top: var(--spacing-md);
    border-radius: 8px;
    overflow: hidden;
    display: none;
}

.image-preview.active {
    display: block;
}

.image-preview img {
    width: 100%;
    height: auto;
}

/* ========== WMS FULL MRX - AJUSTE MOBILE ========== */
/* Corrige o título WMS Full MRX que fica atrás da navbar no mobile */
@media (max-width: 768px) {
    main.container h1 {
        margin-top: 25px !important; /* Adiciona 25px de margem extra no mobile */
        padding-top: 0;
    }
}
/* ========== CHAT WIDGET FLUTUANTE ========== */

.chat-widget-container {
    position: fixed;
    bottom: 100px;
    right: 20px;
    z-index: 9999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', sans-serif;
}

.chat-widget-bubble {
    width: 60px;
    height: 60px;
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(99, 102, 241, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.chat-widget-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 6px 25px rgba(99, 102, 241, 0.5);
}

.chat-widget-bubble.active {
    transform: scale(0.9);
}

.chat-widget-bubble i {
    font-size: 24px;
    color: white;
}

.chat-widget-badge {
    position: absolute;
    top: -2px;
    right: -2px;
    width: 18px;
    height: 18px;
    background: #ef4444;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    color: white;
    font-weight: bold;
    animation: pulse 2s infinite;
}

@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

.chat-widget-popup {
    position: absolute;
    bottom: 75px;
    right: 0;
    width: 380px;
    max-width: calc(100vw - 40px);
    height: 520px;
    max-height: calc(100vh - 200px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    display: none;
    flex-direction: column;
    overflow: hidden;
    animation: slideUp 0.3s ease;
}

.chat-widget-popup.active {
    display: flex;
}

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

.chat-widget-header {
    background: linear-gradient(135deg, #6366f1, #8b5cf6);
    color: white;
    padding: 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-widget-header-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.chat-widget-header-info i {
    font-size: 24px;
}

.chat-widget-title {
    display: block;
    font-weight: 600;
    font-size: 16px;
}

.chat-widget-status {
    display: block;
    font-size: 12px;
    opacity: 0.9;
}

.chat-widget-header-actions {
    display: flex;
    gap: 8px;
}

.chat-widget-header-actions button {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.chat-widget-header-actions button:hover {
    background: rgba(255, 255, 255, 0.3);
}

.chat-widget-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    background: #f8fafc;
}

.chat-widget-welcome {
    text-align: center;
    padding: 24px 16px;
    color: #6b7280;
}

.chat-widget-welcome i {
    font-size: 40px;
    color: #6366f1;
    margin-bottom: 12px;
}

.chat-widget-welcome p {
    font-size: 14px;
    line-height: 1.5;
}

.chat-widget-message {
    max-width: 85%;
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    animation: fadeIn 0.3s ease;
}

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

.chat-widget-message.user {
    align-self: flex-end;
    background: #eef2ff;
    border-bottom-right-radius: 4px;
}

.chat-widget-message.assistant {
    align-self: flex-start;
    background: white;
    border: 1px solid #e5e7eb;
    border-bottom-left-radius: 4px;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.chat-widget-message-content {
    word-break: break-word;
}

.chat-widget-message-content strong {
    font-weight: 600;
    color: #1f2937;
}

.chat-widget-message-fonte {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid #f3f4f6;
    font-size: 11px;
    color: #9ca3af;
    display: flex;
    align-items: center;
    gap: 4px;
}

.chat-widget-typing {
    display: flex;
    gap: 4px;
    padding: 12px 16px;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 16px;
    border-bottom-left-radius: 4px;
    align-self: flex-start;
    width: fit-content;
}

.chat-widget-typing span {
    width: 8px;
    height: 8px;
    background: #9ca3af;
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out both;
}

.chat-widget-typing span:nth-child(1) { animation-delay: -0.32s; }
.chat-widget-typing span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typingBounce {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}

.chat-widget-suggestions {
    display: flex;
    gap: 8px;
    padding: 8px 16px;
    overflow-x: auto;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-widget-suggestions button {
    flex-shrink: 0;
    padding: 8px 12px;
    background: #f3f4f6;
    border: 1px solid #e5e7eb;
    border-radius: 999px;
    font-size: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: all 0.2s;
    white-space: nowrap;
}

.chat-widget-suggestions button:hover {
    background: #eef2ff;
    border-color: #6366f1;
    color: #6366f1;
}

.chat-widget-suggestions button i {
    font-size: 12px;
    color: #6b7280;
}

.chat-widget-suggestions button:hover i {
    color: #6366f1;
}

.chat-widget-input-container {
    display: flex;
    gap: 8px;
    padding: 12px 16px;
    background: white;
    border-top: 1px solid #e5e7eb;
}

.chat-widget-input-container textarea {
    flex: 1;
    padding: 10px 14px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 14px;
    resize: none;
    min-height: 44px;
    max-height: 80px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.chat-widget-input-container textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.chat-widget-input-container button {
    width: 44px;
    height: 44px;
    background: #6366f1;
    color: white;
    border: none;
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    transition: all 0.2s;
}

.chat-widget-input-container button:hover {
    background: #4f46e5;
    transform: scale(1.05);
}

@media (max-width: 480px) {
    .chat-widget-container {
        bottom: 90px;
        right: 16px;
    }
    
    .chat-widget-popup {
        width: calc(100vw - 32px);
        height: calc(100vh - 180px);
        right: -8px;
    }
    
    .chat-widget-bubble {
        width: 54px;
        height: 54px;
    }
    
    .chat-widget-bubble i {
        font-size: 22px;
    }
}

/* ========== PCB SCANNER WIDGET ========== */

.scanner-widget-container {
    position: fixed;
    bottom: 100px;
    left: 24px;
    z-index: 9998;
}

.scanner-widget-bubble {
    width: 56px;
    height: 56px;
    background: linear-gradient(135deg, #10b981, #059669);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    box-shadow: 0 6px 20px rgba(5, 150, 105, 0.4);
    transition: all 0.3s ease;
    position: relative;
}

.scanner-widget-bubble:hover {
    transform: scale(1.1);
    box-shadow: 0 8px 28px rgba(5, 150, 105, 0.5);
}

.scanner-widget-bubble.active {
    transform: scale(0.95);
}

.scanner-widget-bubble i {
    color: white;
    font-size: 24px;
}

.scanner-widget-popup {
    position: absolute;
    bottom: 70px;
    left: 0;
    width: 320px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    overflow: hidden;
    opacity: 0;
    visibility: hidden;
    transform: translateY(20px) scale(0.95);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.scanner-widget-popup.active {
    opacity: 1;
    visibility: visible;
    transform: translateY(0) scale(1);
}

.scanner-widget-header {
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    padding: 14px 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.scanner-widget-header-info {
    display: flex;
    align-items: center;
    gap: 10px;
}

.scanner-widget-header-info i {
    font-size: 24px;
}

.scanner-widget-title {
    font-weight: 600;
    font-size: 15px;
    display: block;
}

.scanner-widget-status {
    font-size: 11px;
    opacity: 0.85;
}

.scanner-widget-header-actions {
    display: flex;
    gap: 8px;
}

.scanner-widget-header-actions button,
.scanner-widget-header-actions a {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 14px;
    transition: background 0.2s;
    text-decoration: none;
}

.scanner-widget-header-actions button:hover,
.scanner-widget-header-actions a:hover {
    background: rgba(255, 255, 255, 0.3);
}

.scanner-widget-body {
    padding: 16px;
}

.scanner-upload-area {
    border: 2px dashed #d1d5db;
    border-radius: 12px;
    padding: 24px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    background: #fafafa;
    min-height: 120px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.scanner-upload-area:hover,
.scanner-upload-area.dragover {
    border-color: #10b981;
    background: #ecfdf5;
}

.scanner-preview {
    max-width: 100%;
    max-height: 120px;
    border-radius: 8px;
    object-fit: contain;
}

.scanner-widget-result {
    padding: 16px;
}

.scanner-result-grade {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
    font-size: 1rem;
    font-weight: bold;
    color: white;
}

.scanner-result-grade.low { background: linear-gradient(135deg, #6c757d, #495057); }
.scanner-result-grade.medium { background: linear-gradient(135deg, #ffc107, #e0a800); color: #000; }
.scanner-result-grade.high { background: linear-gradient(135deg, #28a745, #1e7e34); }

.scanner-result-info {
    text-align: center;
    margin-bottom: 12px;
}

.scanner-price-info {
    text-align: center;
    padding: 8px;
    background: #ecfdf5;
    border-radius: 8px;
}

@media (max-width: 480px) {
    .scanner-widget-container {
        bottom: 90px;
        left: 16px;
    }
    
    .scanner-widget-popup {
        width: calc(100vw - 32px);
        left: 0;
    }
    
    .scanner-widget-bubble {
        width: 54px;
        height: 54px;
    }
}
