/* ============================================================
   METAFRANC IBÉRICA — Stylesheet
   Tema dark com a paleta do logotipo (azul claro #4FB3E8 + branco)
   ============================================================ */

:root {
    --brand:           #4FB3E8;
    --brand-soft:      #6FC2EE;
    --brand-deep:      #2E8FC4;
    --brand-glow:      rgba(79, 179, 232, 0.25);

    --bg-0:            #0A0E14;
    --bg-1:            #0F141C;
    --bg-2:            #161D27;
    --bg-3:            #1E2733;
    --bg-elev:         #232D3A;

    --border:          #2A3441;
    --border-strong:   #3A4554;

    --text:            #E8EEF5;
    --text-soft:       #A4B0C0;
    --text-mute:       #6B7888;

    --ok:              #22C55E;
    --warn:            #F59E0B;
    --err:             #EF4444;
    --info:            var(--brand);

    --radius:          10px;
    --radius-lg:       14px;
    --radius-sm:       6px;

    --shadow-soft:     0 4px 12px rgba(0, 0, 0, 0.25);
    --shadow-elev:     0 12px 30px rgba(0, 0, 0, 0.35);
    --shadow-glow:     0 0 0 4px var(--brand-glow);

    --font:            'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    --font-mono:       ui-monospace, 'SF Mono', Menlo, Consolas, monospace;
}

* {
    box-sizing: border-box;
}

html, body {
    margin: 0;
    padding: 0;
    font-family: var(--font);
    background: var(--bg-0);
    color: var(--text);
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    line-height: 1.5;
}

body {
    min-height: 100vh;
    background-image:
        radial-gradient(1100px 600px at 88% -10%, rgba(79, 179, 232, 0.10), transparent 60%),
        radial-gradient(900px 500px at -10% 100%, rgba(79, 179, 232, 0.05), transparent 60%);
    background-attachment: fixed;
}

a {
    color: var(--brand);
    text-decoration: none;
    transition: color .15s ease;
}
a:hover { color: var(--brand-soft); }

h1, h2, h3, h4 { margin: 0 0 .6rem; letter-spacing: -.01em; }
h1 { font-size: 1.6rem; font-weight: 700; }
h2 { font-size: 1.25rem; font-weight: 600; }
h3 { font-size: 1.05rem; font-weight: 600; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: var(--bg-1); }
::-webkit-scrollbar-thumb {
    background: var(--bg-3);
    border-radius: 10px;
    border: 2px solid var(--bg-1);
}
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }

/* ============================================================
   LAYOUT — sidebar + main
   ============================================================ */
.app {
    display: grid;
    grid-template-columns: 250px 1fr;
    min-height: 100vh;
}

.sidebar {
    background: var(--bg-1);
    border-right: 1px solid var(--border);
    padding: 1.4rem 0 1rem;
    position: sticky;
    top: 0;
    height: 100vh;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.sidebar__logo {
    padding: 0 1.4rem 1.4rem;
    border-bottom: 1px solid var(--border);
    margin-bottom: 1rem;
}
.sidebar__logo img {
    width: 100%;
    max-width: 180px;
    height: auto;
    display: block;
}

.sidebar__nav {
    flex: 1;
    padding: 0 .6rem;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.sidebar__link {
    display: flex;
    align-items: center;
    gap: .7rem;
    padding: .65rem .8rem;
    border-radius: var(--radius-sm);
    color: var(--text-soft);
    font-size: .92rem;
    font-weight: 500;
    transition: all .15s ease;
}
.sidebar__link:hover {
    background: var(--bg-2);
    color: var(--text);
}
.sidebar__link--active {
    background: linear-gradient(90deg, var(--brand-glow), transparent);
    color: var(--brand);
    border-left: 3px solid var(--brand);
    padding-left: calc(.8rem - 3px);
}
.sidebar__link svg { flex-shrink: 0; }

.sidebar__section-title {
    font-size: .72rem;
    text-transform: uppercase;
    letter-spacing: .08em;
    color: var(--text-mute);
    padding: 1rem .8rem .4rem;
    font-weight: 600;
}

.sidebar__user {
    margin: 0 .6rem;
    padding: .8rem;
    border-radius: var(--radius);
    background: var(--bg-2);
    display: flex;
    align-items: center;
    gap: .7rem;
    border: 1px solid var(--border);
}
.sidebar__user-avatar {
    width: 36px; height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--brand), var(--brand-deep));
    display: grid; place-items: center;
    font-weight: 700; color: #fff;
    flex-shrink: 0;
}
.sidebar__user-info { min-width: 0; }
.sidebar__user-name {
    font-size: .85rem; font-weight: 600;
    white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}
.sidebar__user-role {
    font-size: .72rem; color: var(--text-mute);
    text-transform: capitalize;
}

.main {
    padding: 1.6rem 2rem 3rem;
    max-width: 1400px;
    width: 100%;
}

.page-header {
    display: flex;
    align-items: flex-end;
    justify-content: space-between;
    margin-bottom: 1.6rem;
    gap: 1rem;
    flex-wrap: wrap;
}
.page-header__title { font-size: 1.6rem; font-weight: 700; }
.page-header__subtitle { color: var(--text-mute); font-size: .9rem; margin-top: .15rem; }
.page-header__actions { display: flex; gap: .5rem; flex-wrap: wrap; }

/* ============================================================
   CARDS
   ============================================================ */
.card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.4rem;
    box-shadow: var(--shadow-soft);
}
.card--padded { padding: 1.6rem; }
.card__header {
    display: flex; align-items: center; justify-content: space-between;
    margin-bottom: 1rem; gap: 1rem; flex-wrap: wrap;
}
.card__title { font-size: 1.05rem; font-weight: 600; }

/* Estatísticas */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1rem;
    margin-bottom: 1.4rem;
}
.stat {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 1.2rem 1.3rem;
    position: relative;
    overflow: hidden;
}
.stat::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 3px;
    background: linear-gradient(90deg, var(--brand), transparent);
}
.stat__label {
    font-size: .78rem; text-transform: uppercase; letter-spacing: .06em;
    color: var(--text-mute); font-weight: 600;
}
.stat__value {
    font-size: 2rem; font-weight: 700;
    margin-top: .35rem; letter-spacing: -.02em;
}
.stat__hint { font-size: .8rem; color: var(--text-soft); margin-top: .25rem; }
.stat--ok::before  { background: linear-gradient(90deg, var(--ok), transparent); }
.stat--warn::before { background: linear-gradient(90deg, var(--warn), transparent); }
.stat--err::before  { background: linear-gradient(90deg, var(--err), transparent); }

/* ============================================================
   BOTÕES
   ============================================================ */
.btn {
    appearance: none;
    border: 1px solid var(--border-strong);
    background: var(--bg-2);
    color: var(--text);
    padding: .55rem 1rem;
    border-radius: var(--radius-sm);
    font: 500 .9rem/1 var(--font);
    cursor: pointer;
    display: inline-flex; align-items: center; gap: .5rem;
    transition: all .15s ease;
    text-decoration: none;
}
.btn:hover {
    background: var(--bg-3);
    border-color: var(--brand);
}
.btn:active { transform: translateY(1px); }
.btn:disabled { opacity: .5; cursor: not-allowed; }

.btn--primary {
    background: var(--brand);
    border-color: var(--brand);
    color: #061018;
    font-weight: 600;
}
.btn--primary:hover {
    background: var(--brand-soft);
    border-color: var(--brand-soft);
    box-shadow: var(--shadow-glow);
}
.btn--danger {
    background: transparent;
    border-color: var(--err);
    color: var(--err);
}
.btn--danger:hover {
    background: var(--err);
    color: #fff;
}
.btn--ghost {
    background: transparent;
    border-color: transparent;
}
.btn--ghost:hover {
    background: var(--bg-2);
    border-color: var(--border);
}
.btn--sm { padding: .35rem .65rem; font-size: .82rem; }
.btn--icon { padding: .45rem; }
.btn--full { width: 100%; justify-content: center; }

/* ============================================================
   FORMULÁRIOS
   ============================================================ */
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
    gap: 1rem;
}
.form-row { display: flex; flex-direction: column; gap: .35rem; }
.form-row--full { grid-column: 1 / -1; }
.form-row label {
    font-size: .82rem;
    color: var(--text-soft);
    font-weight: 500;
}
.form-row label .req { color: var(--err); margin-left: 2px; }

input[type="text"], input[type="password"], input[type="email"],
input[type="number"], input[type="search"], select, textarea {
    background: var(--bg-0);
    border: 1px solid var(--border);
    color: var(--text);
    padding: .6rem .8rem;
    border-radius: var(--radius-sm);
    font: 400 .92rem/1.4 var(--font);
    transition: border-color .15s ease, box-shadow .15s ease;
    width: 100%;
}
input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--brand);
    box-shadow: var(--shadow-glow);
}
textarea { resize: vertical; min-height: 80px; }
select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%236B7888' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .8rem center;
    padding-right: 2rem;
}
input[readonly] { background: var(--bg-1); color: var(--text-soft); }

.form-actions {
    display: flex; gap: .6rem; justify-content: flex-end;
    margin-top: 1rem; padding-top: 1rem;
    border-top: 1px solid var(--border);
    flex-wrap: wrap;
}

/* ============================================================
   TABELAS
   ============================================================ */
.table-wrap {
    overflow-x: auto;
    border-radius: var(--radius);
    border: 1px solid var(--border);
}
table.data {
    width: 100%;
    border-collapse: collapse;
    font-size: .9rem;
    background: var(--bg-1);
}
table.data thead th {
    text-align: left;
    background: var(--bg-2);
    color: var(--text-soft);
    font-size: .78rem;
    text-transform: uppercase;
    letter-spacing: .06em;
    padding: .8rem 1rem;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    white-space: nowrap;
}
table.data tbody td {
    padding: .85rem 1rem;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}
table.data tbody tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: var(--bg-2); }

td.col-acoes {
    width: 1%;
    white-space: nowrap;
    text-align: right;
}
td.col-acoes .btn { margin-left: .25rem; }

.empty-state {
    padding: 3rem 1rem;
    text-align: center;
    color: var(--text-mute);
}
.empty-state__icon { font-size: 2.2rem; margin-bottom: .4rem; opacity: .5; }

/* ============================================================
   BADGES
   ============================================================ */
.badge {
    display: inline-flex;
    align-items: center;
    padding: .2rem .6rem;
    font-size: .75rem;
    font-weight: 600;
    border-radius: 20px;
    background: var(--bg-3);
    color: var(--text-soft);
    border: 1px solid var(--border-strong);
    white-space: nowrap;
}
.badge--ok    { background: rgba(34,197,94,.12); color: var(--ok); border-color: rgba(34,197,94,.3); }
.badge--warn  { background: rgba(245,158,11,.12); color: var(--warn); border-color: rgba(245,158,11,.3); }
.badge--err   { background: rgba(239,68,68,.12); color: var(--err); border-color: rgba(239,68,68,.3); }
.badge--info  { background: rgba(79,179,232,.12); color: var(--brand); border-color: rgba(79,179,232,.3); }

/* ============================================================
   ALERTAS / FLASH
   ============================================================ */
.alert {
    padding: .9rem 1.1rem;
    border-radius: var(--radius);
    border-left: 3px solid;
    background: var(--bg-2);
    margin-bottom: 1rem;
    font-size: .9rem;
    display: flex; align-items: flex-start; gap: .6rem;
}
.alert--success { border-color: var(--ok); color: #B7F0C8; }
.alert--error   { border-color: var(--err); color: #FCC; }
.alert--warning { border-color: var(--warn); color: #FED7AA; }
.alert--info    { border-color: var(--brand); color: #C9E6F8; }

/* ============================================================
   FILTROS / TOOLBAR
   ============================================================ */
.toolbar {
    display: flex;
    gap: .6rem;
    flex-wrap: wrap;
    align-items: center;
    margin-bottom: 1rem;
}
.toolbar__search { flex: 1; min-width: 240px; position: relative; }
.toolbar__search input { padding-left: 2.3rem; }
.toolbar__search svg {
    position: absolute; left: .7rem; top: 50%;
    transform: translateY(-50%); color: var(--text-mute);
    pointer-events: none;
}

/* ============================================================
   MODAL
   ============================================================ */
.modal-backdrop {
    position: fixed; inset: 0;
    background: rgba(5, 8, 14, .75);
    backdrop-filter: blur(4px);
    z-index: 1000;
    display: none;
    align-items: flex-start;
    justify-content: center;
    padding: 4rem 1rem 2rem;
    overflow-y: auto;
}
.modal-backdrop.open { display: flex; animation: fadeIn .15s ease; }
@keyframes fadeIn { from { opacity: 0; } to { opacity: 1; } }

.modal {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-elev);
    max-width: 640px; width: 100%;
    animation: slideUp .2s ease;
}
@keyframes slideUp {
    from { opacity: 0; transform: translateY(20px); }
    to   { opacity: 1; transform: translateY(0); }
}
.modal__header {
    padding: 1.2rem 1.4rem;
    border-bottom: 1px solid var(--border);
    display: flex; align-items: center; justify-content: space-between;
}
.modal__title { font-size: 1.05rem; font-weight: 600; }
.modal__close {
    background: none; border: none; color: var(--text-mute);
    cursor: pointer; padding: .25rem; font-size: 1.5rem;
    line-height: 1; border-radius: var(--radius-sm);
}
.modal__close:hover { background: var(--bg-2); color: var(--text); }
.modal__body { padding: 1.4rem; }
.modal__footer {
    padding: 1rem 1.4rem;
    border-top: 1px solid var(--border);
    display: flex; justify-content: flex-end; gap: .6rem;
}

/* ============================================================
   LOGIN
   ============================================================ */
.auth-wrap {
    min-height: 100vh;
    display: grid;
    place-items: center;
    padding: 2rem 1rem;
    background:
        radial-gradient(900px 500px at 50% -10%, rgba(79,179,232,.18), transparent 60%),
        radial-gradient(900px 500px at 50% 110%, rgba(79,179,232,.08), transparent 60%),
        var(--bg-0);
}
.auth-card {
    background: var(--bg-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg);
    padding: 2.4rem 2rem;
    width: 100%;
    max-width: 400px;
    box-shadow: var(--shadow-elev);
    position: relative;
}
.auth-card::before {
    content: '';
    position: absolute; top: 0; left: 0; right: 0; height: 4px;
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
}
.auth-logo {
    text-align: center;
    margin-bottom: 1.6rem;
}
.auth-logo img {
    width: 100%; max-width: 230px;
    height: auto; display: inline-block;
}
.auth-title {
    text-align: center;
    font-size: 1rem;
    color: var(--text-soft);
    font-weight: 500;
    margin-bottom: 1.8rem;
}
.auth-form .form-row { margin-bottom: 1rem; }
.auth-form .btn { margin-top: .4rem; }
.auth-footer {
    text-align: center;
    margin-top: 1.4rem;
    font-size: .8rem;
    color: var(--text-mute);
}

/* ============================================================
   ESCANEAMENTO EAN (câmara)
   ============================================================ */
.scanner-wrap {
    position: relative;
    background: #000;
    border-radius: var(--radius);
    overflow: hidden;
    aspect-ratio: 4 / 3;
    max-width: 480px;
    margin: 0 auto;
}
.scanner-wrap video,
.scanner-wrap canvas {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}
.scanner-overlay {
    position: absolute; inset: 0;
    pointer-events: none;
    display: grid; place-items: center;
}
.scanner-box {
    width: 70%; height: 35%;
    border: 2px solid var(--brand);
    border-radius: 8px;
    box-shadow: 0 0 0 9999px rgba(0,0,0,.45);
}
.scanner-line {
    position: absolute;
    left: 15%; right: 15%;
    top: 50%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--brand), transparent);
    animation: scan 2s ease-in-out infinite;
}
@keyframes scan {
    0%, 100% { top: 32.5%; }
    50%      { top: 67.5%; }
}

/* ============================================================
   MOBILE
   ============================================================ */
.mobile-toggle {
    display: none;
    position: fixed;
    top: 1rem; left: 1rem;
    z-index: 200;
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    width: 40px; height: 40px;
    align-items: center; justify-content: center;
    cursor: pointer;
    color: var(--text);
}

@media (max-width: 880px) {
    .app { grid-template-columns: 1fr; }
    .sidebar {
        position: fixed; left: 0; top: 0;
        height: 100vh; width: 80%; max-width: 280px;
        z-index: 150;
        transform: translateX(-100%);
        transition: transform .2s ease;
    }
    .sidebar.open { transform: translateX(0); }
    .mobile-toggle { display: flex; }
    .main { padding: 4.5rem 1rem 2rem; }
    .page-header { flex-direction: column; align-items: flex-start; }
}

.sidebar-backdrop {
    display: none;
    position: fixed; inset: 0;
    background: rgba(0,0,0,.5);
    z-index: 140;
}
.sidebar-backdrop.open { display: block; }

/* Utilitários */
.flex { display: flex; }
.gap-1 { gap: .5rem; }
.gap-2 { gap: 1rem; }
.mt-1 { margin-top: .5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: .5rem; }
.mb-2 { margin-bottom: 1rem; }
.text-mute { color: var(--text-mute); }
.text-soft { color: var(--text-soft); }
.text-center { text-align: center; }
.text-right { text-align: right; }
.font-mono { font-family: var(--font-mono); }
.hidden { display: none !important; }

/* ============================================================
   TOAST DE SCAN (notificação flutuante)
   ============================================================ */
.scan-toast {
    position: fixed;
    bottom: 2rem;
    left: 50%;
    transform: translateX(-50%) translateY(120%);
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .9rem 1.4rem;
    display: flex;
    align-items: center;
    gap: .8rem;
    box-shadow: 0 12px 32px rgba(0,0,0,.5);
    z-index: 1000;
    transition: transform .25s ease, opacity .25s ease;
    opacity: 0;
    pointer-events: none;
    min-width: 240px;
    max-width: 90vw;
}
.scan-toast--visible {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}
.scan-toast__icon {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: grid; place-items: center;
    font-size: 1.15rem;
    font-weight: 700;
    flex-shrink: 0;
}
.scan-toast__text {
    font-weight: 600;
    font-size: .95rem;
}
.scan-toast--ok {
    border-left: 4px solid var(--ok);
}
.scan-toast--ok .scan-toast__icon {
    background: rgba(34,197,94,.18);
    color: var(--ok);
}
.scan-toast--info {
    border-left: 4px solid var(--brand);
}
.scan-toast--info .scan-toast__icon {
    background: var(--brand-glow);
    color: var(--brand);
}
.scan-toast--err {
    border-left: 4px solid var(--err);
}
.scan-toast--err .scan-toast__icon {
    background: rgba(239,68,68,.18);
    color: var(--err);
}

/* ============================================================
   PRODUTOS PENDENTES (de revisão)
   ============================================================ */
.row-pendente {
    background: rgba(245,158,11,.05);
}
.row-pendente td:first-child {
    border-left: 3px solid var(--warn);
}
.badge--pendente {
    background: rgba(245,158,11,.15);
    color: var(--warn);
    border-color: rgba(245,158,11,.35);
}

/* ============================================================
   IMPORTAÇÃO — preview da tabela
   ============================================================ */
.import-dropzone {
    border: 2px dashed var(--border);
    border-radius: var(--radius);
    padding: 2rem 1.4rem;
    text-align: center;
    background: var(--bg-1);
    transition: border-color .15s ease, background .15s ease;
    cursor: pointer;
}
.import-dropzone:hover,
.import-dropzone.dragover {
    border-color: var(--brand);
    background: var(--brand-glow);
}
.import-dropzone__icon {
    font-size: 2.2rem;
    margin-bottom: .6rem;
    opacity: .7;
}
.import-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(120px, 1fr));
    gap: .8rem;
    margin: 1rem 0;
}
.import-stat {
    background: var(--bg-2);
    border: 1px solid var(--border);
    border-radius: var(--radius);
    padding: .8rem 1rem;
    text-align: center;
}
.import-stat__num {
    font-size: 1.5rem;
    font-weight: 700;
    line-height: 1;
}
.import-stat__lbl {
    font-size: .75rem;
    color: var(--text-mute);
    text-transform: uppercase;
    letter-spacing: .04em;
    margin-top: .25rem;
}
.import-stat--ok .import-stat__num   { color: var(--ok); }
.import-stat--warn .import-stat__num { color: var(--warn); }
.import-stat--err .import-stat__num  { color: var(--err); }

