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

/* ── Base ───────────────────────────────────────────────────────────────── */
body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: #f4f5f9;
    color: #1e2d5a;
    min-height: 100vh;
}

/* ── Header Telecontrol ─────────────────────────────────────────────────── */
.tc-header {
    background: #1e2d5a;
    padding: 14px 20px;
    display: flex;
    align-items: center;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0,0,0,0.25);
}

.tc-logo-wrap {
    flex: 1;
    height: 36px;
}

.tc-logo-wrap img {
    height: 36px;
    width: auto;
}

/* ── Layout ─────────────────────────────────────────────────────────────── */
.container {
    max-width: 480px;
    margin: 0 auto;
    padding: 16px;
}

/* ── Cards genéricos ────────────────────────────────────────────────────── */
.tc-card {
    background: #fff;
    border-radius: 14px;
    padding: 18px 16px;
    margin-bottom: 16px;
    box-shadow: 0 2px 10px rgba(30,45,90,0.12);
}

.tc-card-title {
    font-size: 0.78rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.08em;
    color: #1e2d5a;
    margin-bottom: 14px;
}

/* ── Botões ─────────────────────────────────────────────────────────────── */
.btn {
    display: block;
    width: 100%;
    padding: 14px;
    margin-top: 12px;
    border: none;
    border-radius: 10px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}

.btn:active  { transform: scale(0.97); }
.btn:disabled { opacity: 0.4; cursor: not-allowed; }

.btn-primary   { background: #1e2d5a; color: #fff; }
.btn-success   { background: #16a34a; color: #fff; }
.btn-secondary { background: #e5e7eb; color: #333; }

.btn-scanner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 16px;
    background: #f5c518;
    color: #1e2d5a;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.btn-scanner:active { transform: scale(0.97); }

/* ── Divisor ────────────────────────────────────────────────────────────── */
.tc-divider {
    display: flex;
    align-items: center;
    text-align: center;
    font-size: 0.78rem;
    color: #9ca3af;
    margin: 14px 0;
    gap: 10px;
}
.tc-divider::before,
.tc-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

/* ── Busca manual ───────────────────────────────────────────────────────── */
.busca-manual {
    display: flex;
    gap: 8px;
    align-items: center;
}

.busca-manual input {
    flex: 1;
    padding: 13px 14px;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    font-size: 1rem;
    color: #1e2d5a;
    outline: none;
    transition: border-color 0.15s;
}
.busca-manual input:focus { border-color: #1e2d5a; }

.btn-buscar-icon {
    flex-shrink: 0;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #1e2d5a;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
}
.btn-buscar-icon:active { transform: scale(0.95); }

/* ── Card resultado de peça ─────────────────────────────────────────────── */
#peca-resultado {
    margin-top: 14px;
}

.peca-card {
    background: #f0f4ff;
    border-left: 4px solid #f5c518;
    border-radius: 10px;
    padding: 14px 16px;
}

.peca-card-header {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    font-weight: 700;
    color: #16a34a;
    margin-bottom: 10px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.peca-card-row {
    display: flex;
    flex-direction: column;
    margin-bottom: 8px;
}

.peca-card-row:last-child { margin-bottom: 0; }

.peca-label-catalogada {
    display: inline-block;
    background: #fef3c7;
    color: #92400e;
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 4px 10px;
    border-radius: 999px;
    margin-bottom: 10px;
}

.peca-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    margin-bottom: 2px;
}

.peca-valor {
    font-size: 0.95rem;
    font-weight: 600;
    color: #1e2d5a;
    word-break: break-word;
}

.peca-erro {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    border-radius: 10px;
    padding: 14px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #b91c1c;
}

/* ── Scanner (html5-qrcode) ─────────────────────────────────────────────── */
#scanner-reader {
    margin-top: 12px;
    border-radius: 12px;
    overflow: hidden;
}

#scanner-reader video {
    border-radius: 12px;
}

#scanner-reader img[alt="Info icon"],
#scanner-reader select {
    display: none !important;
}

/* ── Camera (fotos do produto) ──────────────────────────────────────────── */
#camera-section {
    background: #000;
    border-radius: 12px;
    overflow: hidden;
    position: relative;
    aspect-ratio: 4/3;
    display: flex;
    align-items: center;
    justify-content: center;
}

#video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: none;
}

#canvas-captura { display: none; }

#camera-placeholder {
    color: #888;
    text-align: center;
    padding: 20px;
    font-size: 0.9rem;
}

#preview-section {
    display: none;
    margin-top: 16px;
}

#preview-section img {
    width: 100%;
    border-radius: 12px;
    border: 2px solid #d1d5db;
}

/* ── Status ─────────────────────────────────────────────────────────────── */
#status, #status-medir {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
    display: none;
}

#status.info, #status-medir.info { background: #dbeafe; color: #1e40af; }
#status.erro, #status-medir.erro { background: #fee2e2; color: #b91c1c; }
#status.ok                        { background: #dcfce7; color: #15803d; }

/* ── Imagens resultado ──────────────────────────────────────────────────── */
.imagens-resultado {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
    margin-bottom: 16px;
}

.imagens-resultado figure { margin: 0; }

.imagens-resultado figcaption {
    font-size: 0.75rem;
    color: #6b7280;
    text-align: center;
    margin-top: 4px;
}

.imagens-resultado img {
    width: 100%;
    border-radius: 8px;
    border: 1px solid #d1d5db;
}

/* ── Fotos grid ─────────────────────────────────────────────────────────── */
.fotos-grid-3 {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 8px;
    margin-bottom: 4px;
}

.foto-card {
    background: #fff;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    transition: border-color 0.2s;
    box-shadow: 0 1px 4px rgba(30,45,90,0.08);
}

.foto-card.card-ativo  { border-color: #1e2d5a; box-shadow: 0 0 0 3px rgba(30,45,90,0.15); }
.foto-card.card-pronto { border-color: #16a34a; }

.foto-card-preview {
    position: relative;
    aspect-ratio: 4/3;
    background: #f3f4f6;
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden;
}

.foto-card-preview img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.foto-card-vazia {
    text-align: center;
    color: #9ca3af;
    padding: 8px;
}

.foto-card-vazia span  { display: block; font-weight: 700; font-size: 0.9rem; color: #6b7280; }
.foto-card-vazia small { font-size: 0.72rem; }

.foto-card-ok {
    position: absolute;
    top: 6px;
    right: 6px;
    background: #16a34a;
    color: #fff;
    width: 22px;
    height: 22px;
    border-radius: 50%;
    font-size: 0.75rem;
    font-weight: 700;
    display: none;
    align-items: center;
    justify-content: center;
}

.btn-foto {
    display: block;
    width: 100%;
    padding: 8px;
    border: none;
    border-top: 1px solid #e5e7eb;
    background: #f9fafb;
    font-size: 0.8rem;
    font-weight: 600;
    color: #1e2d5a;
    cursor: pointer;
}
.btn-foto:active { background: #eef2ff; }

/* ── Camera wrap ────────────────────────────────────────────────────────── */
#camera-wrap {
    margin-top: 14px;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 12px;
    overflow: hidden;
    padding-bottom: 12px;
    box-shadow: 0 2px 8px rgba(30,45,90,0.1);
}

.camera-label {
    background: #1e2d5a;
    color: #fff;
    text-align: center;
    font-size: 0.82rem;
    font-weight: 600;
    padding: 7px 12px;
}

#camera-wrap #camera-section { border-radius: 0; margin: 0; }
#camera-wrap .btn             { margin-left: 12px; margin-right: 12px; width: calc(100% - 24px); }
#camera-wrap #preview-section { padding: 0 12px; }

.preview-acoes {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 8px;
    margin-top: 10px;
}
.preview-acoes .btn { margin: 0; width: 100%; }

/* ── Campo código produto ───────────────────────────────────────────────── */
.campo-codigo {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 14px;
    background: #fff;
    border-radius: 12px;
    padding: 12px 14px;
    box-shadow: 0 1px 4px rgba(30,45,90,0.08);
}

.campo-codigo label {
    font-size: 0.85rem;
    font-weight: 600;
    color: #6b7280;
    white-space: nowrap;
}

.campo-codigo input {
    flex: 1;
    padding: 8px 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 8px;
    font-size: 1rem;
    color: #1e2d5a;
    background: #fff;
    outline: none;
}

.campo-codigo input:focus { border-color: #1e2d5a; }

/* ── Medidas editáveis ──────────────────────────────────────────────────── */
.medidas-form {
    margin-top: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.medida-campo label {
    display: block;
    font-size: 0.78rem;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 4px;
}

.medida-input-wrap {
    display: flex;
    align-items: center;
    background: #fff;
    border: 1.5px solid #d1d5db;
    border-radius: 10px;
    overflow: hidden;
    transition: border-color 0.15s;
}

.medida-input-wrap:focus-within { border-color: #1e2d5a; }

.medida-input-wrap input {
    flex: 1;
    border: none;
    outline: none;
    padding: 12px 14px;
    font-size: 1.2rem;
    font-weight: 700;
    color: #1e2d5a;
    background: transparent;
    -moz-appearance: textfield;
}

.medida-input-wrap input::-webkit-outer-spin-button,
.medida-input-wrap input::-webkit-inner-spin-button { -webkit-appearance: none; }

.medida-unidade {
    padding: 0 14px;
    font-size: 0.95rem;
    font-weight: 600;
    color: #9ca3af;
    background: #f9fafb;
    border-left: 1px solid #e5e7eb;
    height: 100%;
    display: flex;
    align-items: center;
    min-height: 48px;
}

/* ── Progress bar ───────────────────────────────────────────────────────── */
.progress-bar {
    background: #e5e7eb;
    border-radius: 8px;
    height: 18px;
    overflow: hidden;
    margin-top: 14px;
}

.progress-fill {
    background: #f5c518;
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 8px;
}

.progress-texto {
    text-align: center;
    font-size: 0.85rem;
    color: #6b7280;
    margin-top: 6px;
}

/* ── Status envio ───────────────────────────────────────────────────────── */
#status-envio {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
}

#status-envio.ok   { background: #dcfce7; color: #15803d; }
#status-envio.erro { background: #fee2e2; color: #b91c1c; }

.status-msg {
    margin-top: 14px;
    padding: 12px 16px;
    border-radius: 8px;
    font-size: 0.9rem;
}
.status-msg.ok   { background: #dcfce7; color: #15803d; }
.status-msg.erro { background: #fee2e2; color: #b91c1c; }

/* ── Home (menu principal) ─────────────────────────────────────────────── */
.home-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.btn-home {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    padding: 18px 16px;
    background: #fff;
    border: none;
    border-radius: 14px;
    box-shadow: 0 2px 10px rgba(30,45,90,0.12);
    font-size: 1rem;
    font-weight: 700;
    color: #1e2d5a;
    text-decoration: none;
    cursor: pointer;
    transition: transform 0.1s;
}
.btn-home:active { transform: scale(0.98); }

.btn-home .btn-home-icon {
    flex-shrink: 0;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    background: #f0f4ff;
    color: #1e2d5a;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* ── Voltar / fila de sincronização ────────────────────────────────────── */
.btn-voltar {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: none;
    border: none;
    color: #1e2d5a;
    font-size: 0.9rem;
    font-weight: 600;
    padding: 8px 0;
    margin-bottom: 12px;
    cursor: pointer;
    text-decoration: none;
}

/* ── Relatório ──────────────────────────────────────────────────────────── */
.relatorio-item {
    padding: 12px 0;
    border-bottom: 1px solid #eef0f4;
}
.relatorio-item:last-child { border-bottom: none; }

.relatorio-item-header {
    display: flex;
    justify-content: flex-end;
    margin-bottom: 6px;
}

.relatorio-data {
    font-size: 0.75rem;
    color: #9ca3af;
    font-weight: 600;
}

.relatorio-paginacao {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-top: 16px;
    gap: 10px;
}
.relatorio-paginacao .btn {
    display: inline-block;
    width: auto;
    margin-top: 0;
    padding: 10px 16px;
}

.relatorio-pagina-info {
    font-size: 0.82rem;
    color: #6b7280;
    text-align: center;
    flex: 1;
}

.fila-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 1px solid #eef0f4;
    font-size: 0.88rem;
}
.fila-item:last-child { border-bottom: none; }

.fila-status {
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.04em;
    padding: 3px 8px;
    border-radius: 999px;
}
.fila-status-pendente { background: #e5e7eb; color: #374151; }
.fila-status-enviando { background: #dbeafe; color: #1d4ed8; }
.fila-status-enviado  { background: #dcfce7; color: #15803d; }
.fila-status-erro     { background: #fee2e2; color: #b91c1c; }

/* ── Spinner ────────────────────────────────────────────────────────────── */
.spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid currentColor;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 0.7s linear infinite;
    margin-right: 8px;
    vertical-align: middle;
}

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

/* ── Tabela (legado) ────────────────────────────────────────────────────── */
table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
    border-radius: 10px;
    overflow: hidden;
    box-shadow: 0 1px 4px rgba(0,0,0,0.08);
}

th, td {
    padding: 12px 16px;
    text-align: left;
    border-bottom: 1px solid #f3f4f6;
    font-size: 0.95rem;
}

th {
    background: #f9fafb;
    color: #6b7280;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

td:last-child {
    font-weight: 700;
    color: #1e2d5a;
}
