/* ================================================================
   ESTOQUE TABOCA — CSS MODERNO v2.0
   ================================================================ */

/* ---------- VARIÁVEIS DE DESIGN ---------- */
:root {
    --brand: #0066FF;
    --brand-dark: #0050CC;
    --brand-glow: rgba(0, 102, 255, 0.15);
    --brand-subtle: rgba(0, 102, 255, 0.06);
    --surface: #ffffff;
    --surface-glass: rgba(255, 255, 255, 0.72);
    --bg: #f0f2f5;
    --bg-mesh: linear-gradient(135deg, #f0f2f5 0%, #e8ecf4 40%, #f0f2f5 60%, #edf0f7 100%);
    --text-primary: #111827;
    --text-secondary: #6b7280;
    --text-muted: #9ca3af;
    --border: #e5e7eb;
    --border-light: rgba(0,0,0,0.06);
    --shadow-sm: 0 1px 2px rgba(0,0,0,0.04);
    --shadow-md: 0 4px 16px rgba(0,0,0,0.06);
    --shadow-lg: 0 12px 40px rgba(0,0,0,0.08);
    --shadow-glow: 0 8px 32px rgba(0, 102, 255, 0.12);
    --radius-sm: 0.5rem;
    --radius-md: 0.75rem;
    --radius-lg: 1rem;
    --radius-xl: 1.25rem;
    --radius-2xl: 1.5rem;
    --green: #059669;
    --red: #dc2626;
    --yellow: #d97706;
    --transition-fast: 0.15s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-base: 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-spring: 0.35s cubic-bezier(0.34, 1.56, 0.64, 1);
}

/* ---------- BASE ---------- */
body { 
    font-family: 'Inter', sans-serif; 
    background: var(--bg-mesh);
    background-attachment: fixed;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 80px;
    color: var(--text-primary);
}
.material-symbols-outlined {
    font-variation-settings: 'FILL' 0, 'wght' 400, 'GRAD' 0, 'opsz' 24;
}

/* ---------- GLASSMORPHISM HELPERS ---------- */
.tonal-elevation {
    background: var(--surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-light);
    box-shadow: var(--shadow-md);
}
.glass-panel {
    background: var(--surface-glass);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid rgba(255,255,255,0.5);
    box-shadow: var(--shadow-md);
}

/* ---------- BOTÃO INSTALAR PWA ---------- */
.pwa-install-btn {
    background: linear-gradient(135deg, #0066FF, #4F46E5);
    color: #fff;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.35);
    animation: pwa-pulse 2.5s infinite;
}
.pwa-install-btn:hover {
    transform: scale(1.05);
    box-shadow: 0 6px 20px rgba(0, 102, 255, 0.5);
}
@keyframes pwa-pulse {
    0%, 100% { box-shadow: 0 4px 12px rgba(0,102,255,0.35); }
    50%       { box-shadow: 0 4px 20px rgba(0,102,255,0.6); }
}

/* ---------- FILTER TOOLTIP (desktop hover + mobile tap) ---------- */
.filter-tooltip-wrap {
    position: relative;
    display: inline-flex;
}
.filter-tooltip {
    visibility: hidden;
    opacity: 0;
    position: absolute;
    bottom: calc(100% + 8px);
    left: 50%;
    transform: translateX(-50%);
    background: #1f2937;
    color: #fff;
    font-size: 0.7rem;
    font-weight: 500;
    line-height: 1.35;
    padding: 6px 10px;
    border-radius: 8px;
    white-space: nowrap;
    max-width: 260px;
    white-space: normal;
    text-align: center;
    pointer-events: none;
    transition: opacity 0.2s, visibility 0.2s;
    z-index: 50;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}
.filter-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 5px solid transparent;
    border-top-color: #1f2937;
}
/* Desktop: hover */
.filter-tooltip-wrap:hover .filter-tooltip {
    visibility: visible;
    opacity: 1;
}
/* Mobile: tap/focus */
.filter-tooltip-wrap .compras-filter-btn:focus + .filter-tooltip,
.filter-tooltip-wrap .compras-filter-btn:active + .filter-tooltip {
    visibility: visible;
    opacity: 1;
}

/* ---------- SCROLLBAR ---------- */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #d1d5db; border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #9ca3af; }

/* ---------- MODAIS ---------- */
.modal-backdrop {
    display: none; opacity: 0; position: fixed; top: 0; left: 0;
    width: 100%; height: 100%;
    background-color: rgba(0,0,0,0.4); z-index: 40;
    transition: opacity 0.3s ease; backdrop-filter: blur(8px);
}
.modal {
    display: none;
    opacity: 0;
    position: fixed;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%) scale(0.92);
    z-index: 50;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    max-height: 90vh;
    overflow: hidden;
    flex-direction: column;
    border-radius: var(--radius-xl) !important;
    box-shadow: 0 24px 80px rgba(0,0,0,0.15) !important;
}
.modal.show { 
    transform: translate(-50%, -50%) scale(1); 
    display: flex;
    opacity: 1;
}
.modal-backdrop.show { display: block; opacity: 1; }
.modal > h2:first-of-type { flex: 0 0 auto; }
.modal > form,
.modal > div:nth-of-type(1) { flex: 1; overflow-y: auto; padding-right: 0.25rem; }
.modal > div:last-child { flex: 0 0 auto; margin-top: auto; padding-top: 1.5rem; }
.modal form > div.mt-8 {
    position: sticky; bottom: 0; background: #ffffff;
    padding-top: 0.75rem; margin-top: 1rem;
}
@media (max-width: 767px) {
    .modal { width: calc(100% - 1.5rem); max-height: calc(100vh - 1rem); }
    .modal > form, .modal > div:nth-of-type(1) { padding-bottom: 0.5rem; }
}

/* ---------- ABAS DE NAVEGAÇÃO (TABS ANTIGOS) ---------- */
.top-tab-btn {
    @apply flex items-center gap-2 px-3 py-2 md:px-4 md:py-3 text-base font-medium text-slate-500 border-b-2 border-transparent hover:bg-slate-100 hover:text-slate-800 transition-all duration-200 whitespace-nowrap mr-2 rounded-t-lg;
}
.top-tab-btn.active {
    @apply text-indigo-600 border-indigo-600 bg-indigo-50;
}

/* ---------- SIDEBAR NAVIGATION ---------- */
.tab-btn {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 9px 12px;
    font-size: 0.8125rem;
    font-weight: 500;
    color: var(--text-secondary);
    border-radius: var(--radius-md);
    cursor: pointer;
    transition: all var(--transition-fast);
    white-space: nowrap;
    letter-spacing: 0.01em;
    position: relative;
}
.tab-btn:hover {
    background-color: var(--brand-subtle);
    color: var(--brand);
}
.tab-btn:hover .nav-icon {
    background-color: var(--brand-glow);
    color: var(--brand);
}
.tab-btn.active {
    background: linear-gradient(135deg, var(--brand-glow), rgba(0, 102, 255, 0.08));
    color: var(--brand);
    font-weight: 700;
    box-shadow: inset 3px 0 0 var(--brand);
}
.tab-btn.active .nav-icon {
    background: var(--brand);
    color: #ffffff;
    box-shadow: 0 4px 12px rgba(0, 102, 255, 0.3);
}
.tab-btn .nav-icon {
    width: 34px;
    height: 34px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: var(--radius-sm);
    background-color: rgba(107, 114, 128, 0.08);
    color: var(--text-secondary);
    flex-shrink: 0;
    transition: all var(--transition-base);
}
.nav-section-label {
    font-size: 0.625rem;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    padding: 18px 12px 4px;
    user-select: none;
}

/* ---------- TOAST ---------- */
#toast {
    position: fixed;
    bottom: -100px; left: 50%;
    transform: translateX(-50%);
    padding: 14px 24px;
    border-radius: var(--radius-lg);
    font-weight: 600;
    font-size: 0.875rem;
    transition: bottom 0.4s cubic-bezier(0.34, 1.56, 0.64, 1), background-color var(--transition-fast);
    z-index: 100;
    box-shadow: 0 12px 40px rgba(0,0,0,0.15);
    backdrop-filter: blur(12px);
}
#toast.show { bottom: 30px; }

/* ---------- LOADER ---------- */
#loader-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: var(--bg-mesh);
    z-index: 9999; display: flex; justify-content: center; align-items: center;
    transition: opacity 0.3s ease;
}
.spinner {
    border: 3px solid rgba(0, 102, 255, 0.15); width: 40px; height: 40px;
    border-radius: 50%; border-top-color: var(--brand);
    animation: spin 0.8s linear infinite;
}
.spinner-small {
    border: 2px solid rgba(255, 255, 255, 0.3); width: 16px; height: 16px;
    border-radius: 50%; border-left-color: #ffffff;
    animation: spin 0.8s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }
#app-logo img {
    width: auto; height: auto; max-width: 120px; max-height: 48px;
    border-radius: var(--radius-sm); object-fit: contain;
}
.mic-btn.is-listening { animation: mic-pulse 1.5s infinite; }
@keyframes mic-pulse {
    0% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0.7); }
    70% { box-shadow: 0 0 0 10px rgba(239, 68, 68, 0); }
    100% { box-shadow: 0 0 0 0 rgba(239, 68, 68, 0); }
}

/* ---------- SKELETON LOADER ---------- */
.skeleton {
    background: linear-gradient(90deg, #f1f5f9 25%, #e2e8f0 50%, #f1f5f9 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s ease-in-out infinite;
    border-radius: 0.375rem;
}
@keyframes shimmer { 0% { background-position: 200% 0; } 100% { background-position: -200% 0; } }
.skeleton-text { height: 1rem; margin-bottom: 0.5rem; }
.skeleton-title { height: 1.5rem; width: 60%; margin-bottom: 0.75rem; }

/* ---------- DASHBOARD CARDS ---------- */
.dashboard-reveal {
    opacity: 0;
    transform: translateY(12px);
    animation: dashboardFadeUp 0.5s ease forwards;
}
@keyframes dashboardFadeUp { to { opacity: 1; transform: translateY(0); } }
.dashboard-chart-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    padding: 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: box-shadow var(--transition-base);
}
.dashboard-chart-card:hover { box-shadow: var(--shadow-md); }
.dashboard-top-pill {
    display: inline-flex; align-items: center; gap: 0.35rem;
    padding: 0.25rem 0.65rem; border-radius: 9999px;
    font-size: 0.72rem; font-weight: 700;
    background: var(--brand-glow); color: var(--brand);
}
#dashboard-stats > div {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    transition: transform var(--transition-spring), box-shadow var(--transition-base);
    position: relative;
    overflow: hidden;
}
#dashboard-stats > div:hover {
    transform: translateY(-4px);
    box-shadow: var(--shadow-glow);
}

/* ---------- VIEW TRANSITIONS ---------- */
.view-content:not(.hidden) {
    animation: viewFadeIn 0.35s ease-out forwards;
}
@keyframes viewFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---------- TABLES ---------- */
#app-container table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
}
#app-container thead th {
    position: sticky;
    top: 0;
    z-index: 10;
    background: rgba(249, 250, 251, 0.92);
    backdrop-filter: blur(8px);
    border-bottom: 1px solid var(--border);
    font-size: 0.6875rem;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: var(--text-muted);
    font-weight: 700;
}
#app-container tbody tr {
    transition: background-color var(--transition-fast);
}
#app-container tbody tr:hover {
    background-color: rgba(0, 102, 255, 0.03);
}
.overflow-x-auto {
    border-radius: var(--radius-lg); 
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
    background: var(--surface);
}

/* ---------- BUTTONS ---------- */
button {
    transition: all var(--transition-fast);
}
button:active:not(:disabled) {
    transform: scale(0.97);
}

/* ---------- INPUTS ---------- */
input[type="text"], input[type="number"], input[type="password"], 
input[type="date"], input[type="email"], select, textarea {
    transition: border-color var(--transition-fast), box-shadow var(--transition-fast);
}
input:focus, select:focus, textarea:focus {
    border-color: var(--brand) !important;
    box-shadow: 0 0 0 3px var(--brand-glow) !important;
}

/* ---------- EMPTY STATES ---------- */
#no-products-message, #no-requisitions-message, #no-exits-message, #no-rm-message, #no-locations-message {
    position: relative;
    padding: 4rem 2rem;
    color: var(--text-secondary);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: linear-gradient(135deg, rgba(249, 250, 251, 0.6), rgba(243, 244, 246, 0.3));
    border-radius: var(--radius-xl);
    overflow: hidden;
    text-align: center;
    border: 2px dashed var(--border);
}
#no-products-message p, #no-requisitions-message p, #no-exits-message p, #no-rm-message p, #no-locations-message p {
    font-weight: 600; color: var(--text-secondary); z-index: 1;
}
#no-products-message button { z-index: 1; margin-top: 1rem; }
#no-products-message::after, #no-requisitions-message::after, #no-exits-message::after,
#no-rm-message::after, #no-locations-message::after {
    font-family: 'Material Symbols Outlined';
    font-variation-settings: 'FILL' 0, 'wght' 200;
    font-size: 8rem;
    position: absolute;
    color: var(--text-muted);
    opacity: 0.08;
    top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    z-index: 0;
    pointer-events: none;
}
#no-products-message::after { content: 'inventory_2'; }
#no-requisitions-message::after { content: 'list_alt'; }
#no-exits-message::after { content: 'outbox'; }
#no-rm-message::after { content: 'assignment'; }
#no-locations-message::after { content: 'map'; }

/* ---------- PRINT ---------- */
@media print {
    body * { visibility: hidden; }
    #print-area, #print-area * { visibility: visible; }
    #print-area { position: absolute; left: 0; top: 0; width: 100%; }
}

/* ---------- ESTRELA MODULE ---------- */
.estrela-tab-btn { cursor: pointer; border: none; outline: none; }
.estrela-tab-btn:not(.active):hover {
    background: var(--brand-subtle) !important;
    color: var(--brand) !important;
}
.estrela-summary-card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1rem 1.25rem;
    box-shadow: var(--shadow-sm);
    transition: transform var(--transition-spring), box-shadow var(--transition-base);
}
.estrela-summary-card:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.estrela-summary-card .value {
    font-size: 1.75rem; font-weight: 800; letter-spacing: -0.025em; color: var(--text-primary);
}
.estrela-summary-card .label {
    font-size: 0.75rem; font-weight: 600; color: var(--text-secondary); margin-top: 0.15rem;
}
.estrela-status-ok {
    background: rgba(5, 150, 105, 0.1); color: var(--green);
    font-weight: 700; font-size: 0.7rem; padding: 0.2rem 0.6rem;
    border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.04em;
}
.estrela-status-low {
    background: rgba(220, 38, 38, 0.1); color: var(--red);
    font-weight: 700; font-size: 0.7rem; padding: 0.2rem 0.6rem;
    border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.04em;
}
.estrela-status-warn {
    background: rgba(217, 119, 6, 0.1); color: var(--yellow);
    font-weight: 700; font-size: 0.7rem; padding: 0.2rem 0.6rem;
    border-radius: 9999px; text-transform: uppercase; letter-spacing: 0.04em;
}

/* ---------- BOTTOM NAV (MOBILE) ---------- */
#bottom-nav {
    background: var(--surface-glass) !important;
    backdrop-filter: blur(20px) !important;
    -webkit-backdrop-filter: blur(20px) !important;
    border-top: 1px solid var(--border-light) !important;
    box-shadow: 0 -4px 24px rgba(0,0,0,0.06) !important;
}

/* ---------- DRAWER ---------- */
#bottom-drawer {
    background: var(--surface) !important;
    box-shadow: 0 -12px 48px rgba(0,0,0,0.12) !important;
    border-radius: 1.5rem 1.5rem 0 0 !important;
}
#bottom-drawer .drawer-btn {
    transition: all var(--transition-fast);
    border: 1px solid var(--border);
}
#bottom-drawer .drawer-btn:hover {
    background: var(--brand-subtle) !important;
    border-color: var(--brand) !important;
}
#bottom-drawer .drawer-btn:active {
    transform: scale(0.95);
}

/* ---------- FORMS VISUAL ---------- */
#add-product-form, #add-location-form {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-sm);
}

/* ---------- REPORT CARDS ---------- */
#reports-view .bg-slate-50 {
    background: var(--surface) !important;
    border: 1px solid var(--border) !important;
    border-radius: var(--radius-xl) !important;
    box-shadow: var(--shadow-sm);
    transition: all var(--transition-base);
}
#reports-view .bg-slate-50:hover {
    box-shadow: var(--shadow-md);
    transform: translateY(-2px);
}

/* ---------- MOBILE MENU ---------- */
#mobile-menu-btn svg { transition: transform 0.2s ease-in-out; }
#mobile-menu-btn.open svg { transform: rotate(90deg); }
