/* =================================================================
   WMS MOBILE — Worker tiles + Admin mobile + Dark mode consistency
   ================================================================= */

/* ─── WORKER SCREEN (MOBILE-FIRST) ─────────────────────────────── */

.worker-screen {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    padding: 0;
    background: transparent;
}

/* Top bar */
.worker-topbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px;
    background: var(--sidebar-bg);
    border-bottom: 1px solid rgba(255,255,255,0.06);
    position: sticky;
    top: 0;
    z-index: 100;
}

.worker-topbar-brand {
    display: flex;
    align-items: center;
    gap: 10px;
}

.worker-topbar-brand .brand-icon {
    width: 34px;
    height: 34px;
    border-radius: 10px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
}

.worker-topbar-brand .brand-name {
    font-weight: 800;
    font-size: 0.95rem;
    color: #e2e8f0;
    letter-spacing: 0.3px;
}

.worker-topbar-actions {
    display: flex;
    align-items: center;
    gap: 8px;
}

.worker-topbar-btn {
    width: 36px;
    height: 36px;
    border-radius: 10px;
    border: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.07);
    color: #94a3b8;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9rem;
    transition: 0.2s;
    text-decoration: none;
}

.worker-topbar-btn:hover {
    background: rgba(255,255,255,0.12);
    color: #e2e8f0;
}

/* Worker greeting */
.worker-greeting {
    padding: 24px 20px 16px;
    background: linear-gradient(135deg, var(--sidebar-bg) 0%, transparent 100%);
}

.worker-greeting .greet-label {
    font-size: 0.78rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 600;
}

.worker-greeting .greet-name {
    font-size: 1.6rem;
    font-weight: 800;
    color: var(--text-main);
    margin: 4px 0 6px;
}

.worker-greeting .greet-sub {
    font-size: 0.82rem;
    color: var(--text-muted);
}

.worker-greeting .live-badge {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.7rem;
    font-weight: 700;
    color: #10b981;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-top: 6px;
}

.live-badge .live-dot {
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: #10b981;
    animation: livePulse 2s ease-in-out infinite;
}

@keyframes livePulse {
    0%, 100% { opacity: 1; transform: scale(1); }
    50%       { opacity: 0.5; transform: scale(0.7); }
}

/* Quick stats row */
.worker-quick-stats {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    padding: 0 20px 20px;
}

.wqs-card {
    background: var(--bg-card);
    border: 1px solid rgba(148,163,184,0.15);
    border-radius: 12px;
    padding: 12px;
    text-align: center;
    backdrop-filter: blur(8px);
}

.wqs-card .wqs-value {
    font-size: 1.4rem;
    font-weight: 800;
    color: var(--text-main);
    display: block;
}

.wqs-card .wqs-label {
    font-size: 0.65rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.06em;
    font-weight: 600;
    margin-top: 2px;
}

/* Tile grid */
.worker-section-title {
    padding: 0 20px 10px;
    font-size: 0.72rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.1em;
    font-weight: 700;
}

.worker-tiles {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
    padding: 0 20px 24px;
}

.worker-tile {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 28px 16px 24px;
    border-radius: 18px;
    text-decoration: none;
    border: 1px solid rgba(148,163,184,0.15);
    background: var(--bg-card);
    backdrop-filter: blur(10px);
    transition: transform 0.22s cubic-bezier(0.34, 1.56, 0.64, 1),
                box-shadow 0.22s ease,
                border-color 0.22s ease;
    overflow: hidden;
    text-align: center;
    animation: tileReveal 0.4s ease both;
}

@keyframes tileReveal {
    from { opacity: 0; transform: translateY(16px) scale(0.96); }
    to   { opacity: 1; transform: translateY(0) scale(1); }
}

.worker-tile:nth-child(1) { animation-delay: 0.05s; }
.worker-tile:nth-child(2) { animation-delay: 0.10s; }
.worker-tile:nth-child(3) { animation-delay: 0.15s; }
.worker-tile:nth-child(4) { animation-delay: 0.20s; }
.worker-tile:nth-child(5) { animation-delay: 0.25s; }
.worker-tile:nth-child(6) { animation-delay: 0.30s; }
.worker-tile:nth-child(7) { animation-delay: 0.35s; }
.worker-tile:nth-child(8) { animation-delay: 0.40s; }

.worker-tile::before {
    content: '';
    position: absolute;
    inset: 0;
    border-radius: inherit;
    opacity: 0.12;
    transition: opacity 0.3s;
    background: var(--tile-gradient, linear-gradient(135deg, #4f46e5, #7c3aed));
}

.worker-tile:hover {
    transform: translateY(-4px) scale(1.02);
    border-color: var(--tile-color, #4f46e5);
    box-shadow: 0 12px 28px rgba(0,0,0,0.12), 0 0 0 1px var(--tile-color, #4f46e5) inset;
}

.worker-tile:hover::before { opacity: 0.18; }

.worker-tile:active {
    transform: translateY(0) scale(0.98);
}

.worker-tile .tile-icon {
    width: 52px;
    height: 52px;
    border-radius: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    color: #fff;
    background: var(--tile-gradient, linear-gradient(135deg, #4f46e5, #7c3aed));
    box-shadow: 0 6px 16px rgba(0,0,0,0.18);
}

.worker-tile .tile-label {
    font-size: 0.82rem;
    font-weight: 800;
    color: var(--text-main);
    text-transform: uppercase;
    letter-spacing: 0.04em;
    line-height: 1.2;
}

.worker-tile .tile-desc {
    font-size: 0.68rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Tile color variants */
.tile-picking    { --tile-gradient: linear-gradient(135deg,#f59e0b,#d97706); --tile-color: #f59e0b; }
.tile-conferencia{ --tile-gradient: linear-gradient(135deg,#8b5cf6,#6d28d9); --tile-color: #8b5cf6; }
.tile-expedicao  { --tile-gradient: linear-gradient(135deg,#10b981,#059669); --tile-color: #10b981; }
.tile-recebimento{ --tile-gradient: linear-gradient(135deg,#0ea5e9,#0284c7); --tile-color: #0ea5e9; }
.tile-devolucao  { --tile-gradient: linear-gradient(135deg,#ef4444,#dc2626); --tile-color: #ef4444; }
.tile-estoque    { --tile-gradient: linear-gradient(135deg,#06b6d4,#0891b2); --tile-color: #06b6d4; }
.tile-pedidos    { --tile-gradient: linear-gradient(135deg,#6366f1,#4f46e5); --tile-color: #6366f1; }
.tile-admin      { --tile-gradient: linear-gradient(135deg,#1e293b,#334155); --tile-color: #475569; }

/* Full-width tile */
.worker-tile.tile-full {
    grid-column: 1 / -1;
    flex-direction: row;
    justify-content: flex-start;
    padding: 18px 20px;
    gap: 14px;
}

.worker-tile.tile-full .tile-icon {
    width: 44px;
    height: 44px;
    font-size: 1.2rem;
    border-radius: 12px;
    flex-shrink: 0;
}

.worker-tile.tile-full .tile-text {
    text-align: left;
}

/* Bottom safe area */
.worker-footer {
    padding: 16px 20px calc(16px + env(safe-area-inset-bottom));
    display: flex;
    justify-content: center;
    gap: 20px;
    border-top: 1px solid rgba(148,163,184,0.12);
}

.worker-footer a {
    font-size: 0.78rem;
    font-weight: 700;
    color: var(--text-muted);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 6px 10px;
    border-radius: 8px;
    transition: 0.2s;
}

.worker-footer a:hover { color: var(--text-main); background: rgba(148,163,184,0.1); }

/* ─── ADMIN MOBILE SWITCHER ─────────────────────────────────────── */

.fab-admin-switch {
    position: fixed;
    bottom: calc(20px + env(safe-area-inset-bottom));
    right: 20px;
    z-index: 1100;
    display: none; /* shown by JS when admin on mobile */
    align-items: center;
    gap: 8px;
    background: linear-gradient(135deg, var(--primary), #7c3aed);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 12px 18px 12px 14px;
    font-size: 0.82rem;
    font-weight: 700;
    cursor: pointer;
    box-shadow: 0 8px 24px rgba(99,102,241,0.45);
    transition: 0.25s;
    text-decoration: none;
}

.fab-admin-switch i { font-size: 1rem; }

.fab-admin-switch:hover {
    transform: translateY(-2px);
    box-shadow: 0 12px 32px rgba(99,102,241,0.55);
}

/* ─── GLOBAL MODAL FIXES ────────────────────────────────────────── */

.modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 9000;
    background: rgba(2,6,23,0.75);
    backdrop-filter: blur(6px);
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: modalOverlayIn 0.2s ease;
}

.modal-overlay.is-open {
    display: flex;
}

@keyframes modalOverlayIn {
    from { opacity: 0; }
    to   { opacity: 1; }
}

.modal-box {
    background: var(--bg-card);
    border: 1px solid rgba(148,163,184,0.2);
    border-radius: 20px;
    padding: 28px;
    width: 100%;
    max-width: 520px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 24px 48px rgba(2,6,23,0.35);
    animation: modalBoxIn 0.28s cubic-bezier(0.34, 1.56, 0.64, 1);
    color: var(--text-main);
}

.modal-box.modal-wide { max-width: 860px; }

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

.modal-box h2, .modal-box h3 {
    color: var(--text-main);
    margin-bottom: 16px;
    font-size: 1.2rem;
    font-weight: 800;
}

.modal-close {
    position: absolute;
    top: 16px;
    right: 18px;
    background: none;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    line-height: 1;
    transition: color 0.2s;
    padding: 4px;
}

.modal-close:hover { color: var(--text-main); }

/* Dark mode modal */
body.theme-dark .modal-box {
    background: #0f172a;
    border-color: #334155;
}

body.theme-dark .modal-content {
    background: #0f172a !important;
    border-color: #334155 !important;
    color: #e2e8f0 !important;
}

/* ─── DARK MODE COMPREHENSIVE FIXES ─────────────────────────────── */

body.theme-dark {
    --bg-card: rgba(15,23,42,0.95);
    --glass-border: rgba(51,65,85,0.6);
}

/* dash.css component overrides for dark */
body.theme-dark .card-operacao {
    background: rgba(15,23,42,0.92);
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .card-operacao:hover {
    background: rgba(30,41,59,0.95);
    border-color: var(--primary);
}

body.theme-dark .card-stat {
    background: rgba(15,23,42,0.92);
    border-color: #334155;
}

body.theme-dark .card-stat h4 { color: #94a3b8; }
body.theme-dark .card-stat .value { color: #e2e8f0; }

body.theme-dark .dash-tab {
    background: rgba(15,23,42,0.8);
    border-color: #334155;
    color: #94a3b8;
}

body.theme-dark .dash-tab:hover { color: #e2e8f0; border-color: #6366f1; }
body.theme-dark .dash-tab.active { background: #4f46e5; border-color: #4f46e5; color: #fff; }

body.theme-dark .kanban-col {
    background: rgba(15,23,42,0.7);
    border-color: #334155;
}

body.theme-dark .kanban-card {
    background: rgba(30,41,59,0.8);
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark .kanban-card .kc-nome { color: #e2e8f0; }
body.theme-dark .kanban-card .kc-id   { color: #64748b; }
body.theme-dark .kanban-card .kc-footer{ color: #64748b; }

body.theme-dark .rv-card {
    background: rgba(15,23,42,0.9);
    border-color: #334155;
}

body.theme-dark .rv-card .rv-label { color: #64748b; }
body.theme-dark .rv-card .rv-val   { color: #e2e8f0; }

body.theme-dark .filtro-bar input,
body.theme-dark .filtro-bar select {
    background: #0f172a;
    border-color: #334155;
    color: #e2e8f0;
}

body.theme-dark tr:hover td { background: rgba(99,102,241,0.06); }

body.theme-dark .worker-tile {
    background: rgba(15,23,42,0.9);
    border-color: #334155;
}

body.theme-dark .wqs-card {
    background: rgba(15,23,42,0.9);
    border-color: #334155;
}

body.theme-dark .wqs-card .wqs-value { color: #e2e8f0; }
body.theme-dark .wqs-card .wqs-label { color: #64748b; }

/* scrollbar dark */
body.theme-dark ::-webkit-scrollbar-thumb { background: #334155; }
body.theme-dark ::-webkit-scrollbar-track { background: #0f172a; }

/* ─── KPI CARD LIVE ANIMATIONS ──────────────────────────────────── */

.card-stat {
    overflow: hidden;
}

.card-stat::after {
    content: '';
    position: absolute;
    inset: 0;
    background: linear-gradient(135deg, transparent 60%, rgba(99,102,241,0.06));
    pointer-events: none;
    border-radius: inherit;
}

.card-stat .kpi-shimmer {
    display: inline-block;
    background: linear-gradient(90deg, transparent 30%, rgba(255,255,255,0.15) 50%, transparent 70%);
    background-size: 200% 100%;
    border-radius: 4px;
    animation: kpiShimmer 2s ease infinite;
}

@keyframes kpiShimmer {
    from { background-position: 200% center; }
    to   { background-position: -200% center; }
}

/* Counting-up animation target */
.kpi-animate {
    transition: color 0.3s ease;
}

.kpi-animate.updating {
    color: var(--primary) !important;
}

/* Live dot on dashboard header */
.live-indicator {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    font-size: 0.72rem;
    font-weight: 700;
    color: #10b981;
    text-transform: uppercase;
    letter-spacing: 0.07em;
    padding: 4px 10px;
    background: rgba(16,185,129,0.1);
    border: 1px solid rgba(16,185,129,0.25);
    border-radius: 999px;
}

.live-indicator .live-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: #10b981;
    animation: livePulse 2s ease-in-out infinite;
}

#area-admin {
    position: relative;
    z-index: 1;
}

.admin-neural-bg {
    position: fixed;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
    opacity: 0.95;
}

.admin-neural-bg canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* ─── GLOBE CANVAS CONTAINER ────────────────────────────────────── */

.globe-container {
    position: absolute;
    inset: 0;
    overflow: hidden;
    pointer-events: none;
    z-index: 0;
    border-radius: inherit;
}

.globe-container canvas {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
}

/* Admin dashboard header with globe */
.dash-hero {
    position: relative;
    z-index: 1;
    border-radius: var(--radius);
    overflow: hidden;
    background: var(--sidebar-bg);
    padding: 28px 32px;
    margin-bottom: 24px;
    min-height: 200px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 20px;
}

.dash-hero-content {
    position: relative;
    z-index: 1;
}

.dash-hero h1 {
    font-size: clamp(1.4rem, 3vw, 2rem);
    font-weight: 900;
    color: #e2e8f0;
    line-height: 1.2;
    margin-bottom: 8px;
}

.dash-hero p {
    color: #94a3b8;
    font-size: 0.9rem;
}

.dash-hero-kpis {
    position: relative;
    z-index: 1;
    display: flex;
    gap: 16px;
    flex-wrap: wrap;
}

.dash-tabs,
.dash-section {
    position: relative;
    z-index: 1;
}

.dash-hero-kpi {
    background: rgba(255,255,255,0.07);
    border: 1px solid rgba(255,255,255,0.1);
    border-radius: 14px;
    padding: 14px 18px;
    text-align: center;
    min-width: 100px;
    backdrop-filter: blur(4px);
}

.dash-hero-kpi .hk-val {
    display: block;
    font-size: 1.6rem;
    font-weight: 800;
    color: #e2e8f0;
}

.dash-hero-kpi .hk-label {
    font-size: 0.65rem;
    color: #64748b;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    font-weight: 700;
    margin-top: 2px;
}

/* ─── RESPONSIVE BREAKPOINTS ────────────────────────────────────── */

@media (max-width: 1024px) {
    .dash-hero { min-height: 160px; padding: 22px 24px; }
    .dash-hero h1 { font-size: 1.4rem; }

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

@media (max-width: 768px) {
    /* Worker screen full width */
    .worker-screen {
        padding-bottom: env(safe-area-inset-bottom);
    }

    .worker-tiles { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .worker-greeting .greet-name { font-size: 1.3rem; }

    .dash-hero { flex-direction: column; align-items: flex-start; min-height: auto; }
    .dash-hero-kpis { width: 100%; }
    .dash-hero-kpi { flex: 1; min-width: 80px; }

    /* Modal full screen on mobile */
    .modal-overlay { padding: 0; align-items: flex-end; }
    .modal-box {
        border-radius: 20px 20px 0 0;
        max-height: 85vh;
        padding: 24px 20px;
    }

    /* Show admin FAB on mobile for admin users */
    .fab-admin-switch { display: flex; }

    .worker-quick-stats { gap: 8px; }
}

@media (max-width: 480px) {
    .worker-tiles { grid-template-columns: repeat(2, 1fr); }
    .worker-quick-stats { grid-template-columns: repeat(3, 1fr); }

    .fab-admin-switch span { display: none; }
    .fab-admin-switch { padding: 12px 14px; }
}

/* ─── SPINNER / LOADING ─────────────────────────────────────────── */

@keyframes spin { to { transform: rotate(360deg); } }

.spinner {
    display: inline-block;
    width: 14px;
    height: 14px;
    border: 2px solid rgba(99,102,241,0.25);
    border-top-color: #6366f1;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    vertical-align: middle;
    margin-right: 4px;
}

/* ─── ANIMATIONS FOR PAGE SECTIONS ─────────────────────────────── */

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

.anim-in {
    animation: fadeSlideUp 0.4s ease both;
}

/* Stagger children */
.anim-stagger > *:nth-child(1) { animation: fadeSlideUp 0.35s 0.05s ease both; }
.anim-stagger > *:nth-child(2) { animation: fadeSlideUp 0.35s 0.10s ease both; }
.anim-stagger > *:nth-child(3) { animation: fadeSlideUp 0.35s 0.15s ease both; }
.anim-stagger > *:nth-child(4) { animation: fadeSlideUp 0.35s 0.20s ease both; }
.anim-stagger > *:nth-child(5) { animation: fadeSlideUp 0.35s 0.25s ease both; }
.anim-stagger > *:nth-child(6) { animation: fadeSlideUp 0.35s 0.30s ease both; }
