/* ── wott.css v3.6 ─────────────────────────────────────────────────────────── */

/* ── Tokens partilhados ─────────────────────────────────────────────────── */
.wott-badge {
    display: inline-block; padding: 2px 7px; border-radius: 4px; border: 1px solid;
    font-size: 10px; font-weight: 700; letter-spacing: .5px; flex-shrink: 0;
}
.wott-code {
    font-family: ui-monospace, Menlo, monospace; font-size: 12px;
    background: #f8fafc; border: 1px solid #e2e8f0; border-radius: 4px;
    padding: 2px 8px; color: #1e293b;
}
.wott-status-chip {
    display: inline-flex; align-items: center; gap: 5px;
    padding: 3px 9px; border-radius: 20px; border: 1px solid;
    font-size: 11px; font-weight: 600;
}
.wott-chip-dot { width: 6px; height: 6px; border-radius: 50%; flex-shrink: 0; }

/* ── Botões ──────────────────────────────────────────────────────────────── */
.wott-icon-btn {
    display: inline-flex; align-items: center; justify-content: center;
    width: 28px; height: 28px; border-radius: 6px; border: 1px solid #e2e8f0;
    background: none; cursor: pointer; color: #94a3b8;
    text-decoration: none; transition: .15s; flex-shrink: 0;
}
.wott-icon-btn:hover { background: #f1f5f9; color: #475569; border-color: #cbd5e1; text-decoration: none; }
.wott-icon-btn.wott-btn-danger:hover { background: #fef2f2; color: #ef4444; border-color: #fecaca; }
.wott-text-btn {
    background: none; border: none; cursor: pointer; font-size: 12px; color: #3b82f6;
    padding: 4px 8px; border-radius: 5px; transition: .15s;
    display: inline-flex; align-items: center; gap: 4px;
}
.wott-text-btn:hover { background: #eff6ff; }

/* ── Card ────────────────────────────────────────────────────────────────── */
.wott-card, .wott-fc {
    border: 1px solid #e5e7eb; border-radius: 10px;
    margin-bottom: 8px; overflow: hidden; background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

.wott-card-head {
    display: flex; align-items: center; justify-content: space-between;
    padding: 10px 14px; gap: 8px; flex-wrap: wrap;
}
.wott-card-head-left  { display: flex; align-items: center; gap: 7px; flex-wrap: wrap; min-width: 0; }
.wott-card-head-right { display: flex; align-items: center; gap: 4px; flex-shrink: 0; }

/* ── Evento actual ───────────────────────────────────────────────────────── */
.wott-current-event {
    display: flex; align-items: flex-start; gap: 0;
    padding: 10px 14px 10px;
    border-top: 1px solid #f1f5f9;
}

/* ── Timeline (linha + pontos) ───────────────────────────────────────────── */
.wott-tl-line-wrap {
    display: flex; flex-direction: column; align-items: center;
    width: 22px; flex-shrink: 0; margin-right: 10px;
}
.wott-tl-dot {
    width: 12px; height: 12px; border-radius: 50%;
    border: 2px solid; flex-shrink: 0;
}
.wott-tl-dot-sm { width: 9px; height: 9px; }

.wott-dot-transit   { background: #dbeafe; border-color: #3b82f6; }
.wott-dot-completed { background: #dcfce7; border-color: #16a34a; }
.wott-dot-delay     { background: #fee2e2; border-color: #dc2626; }
.wott-dot-pending   { background: #f1f5f9; border-color: #94a3b8; }

/* Ponto actual com pulso */
.wott-dot-pulse.wott-dot-transit {
    box-shadow: 0 0 0 3px #dbeafe;
    animation: wott-pulse 2s ease-in-out infinite;
}
.wott-dot-pulse.wott-dot-completed { box-shadow: 0 0 0 3px #dcfce7; }
@keyframes wott-pulse {
    0%,100% { box-shadow: 0 0 0 3px #dbeafe; }
    50%      { box-shadow: 0 0 0 5px #bfdbfe; }
}

.wott-tl-line {
    width: 2px; background: #e2e8f0; flex: 1; min-height: 14px; margin-top: 2px;
}
.wott-tl-line-sm { min-height: 10px; }

.wott-event-body { min-width: 0; }
.wott-event-status {
    display: block; font-size: 13px; font-weight: 600; color: #1e293b;
}
.wott-event-meta {
    display: block; font-size: 11px; color: #94a3b8;
    font-family: ui-monospace, monospace; margin-top: 2px;
}

/* ── Histórico ───────────────────────────────────────────────────────────── */
.wott-hist-toggle {
    display: flex; align-items: center; gap: 6px;
    width: 100%; padding: 7px 14px 7px 46px;
    border: none; border-top: 1px solid #f8fafc;
    background: none; cursor: pointer;
    font-size: 11px; color: #94a3b8; text-align: left;
    transition: background .15s, color .15s;
}
.wott-hist-toggle:hover { background: #fafafa; color: #64748b; }
.wott-hist-toggle .wott-chevron { transition: transform .2s; }
.wott-hist-toggle.open .wott-chevron { transform: rotate(180deg); }

.wott-history {
    border-top: 1px solid #f8fafc; padding: 8px 14px 12px;
}
.wott-history[hidden] { display: none !important; }

.wott-hist-item {
    display: flex; align-items: flex-start; gap: 0;
    padding: 5px 0;
}
.wott-hist-item .wott-tl-line-wrap { margin-right: 10px; }

/* ── Timestamp ───────────────────────────────────────────────────────────── */
.wott-fetched-row {
    display: flex; align-items: center; gap: 4px;
    padding: 5px 14px 8px;
    font-size: 10px; color: #d1d5db;
    font-family: ui-monospace, monospace; border-top: 1px solid #f8fafc;
}

/* ── Formulário de edição ────────────────────────────────────────────────── */
.wott-card-form {
    padding: 12px 14px; border-top: 1px dashed #e5e7eb; background: #fafafa;
}
.wott-fields-grid {
    display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 10px; margin-bottom: 8px;
}
@media (max-width: 800px) { .wott-fields-grid { grid-template-columns: 1fr 1fr; } }
.wott-fg    { display: flex; flex-direction: column; gap: 4px; }
.wott-label { font-size: 10px; font-weight: 600; color: #6b7280; text-transform: uppercase; letter-spacing: .06em; }
.wott-select, .wott-input {
    border-radius: 6px; border: 1px solid #d1d5db;
    padding: 6px 8px; font-size: 12px; background: #fff; width: 100%; box-sizing: border-box;
}
.wott-multiselect { min-height: 64px; }
.wott-mono  { font-family: ui-monospace, monospace; }
.wott-ctt-extra { display: flex; gap: 14px; margin: 8px 0 4px; }
.wott-radio { display: flex; align-items: center; gap: 5px; font-size: 12px; cursor: pointer; }
.wott-items-extra { margin: 8px 0 4px; }
.wott-form-actions { display: flex; gap: 8px; align-items: center; margin-top: 10px; }
.wott-btn-cancel { background: none; border: none; color: #9ca3af; font-size: 12px; cursor: pointer; padding: 0; }
.wott-btn-cancel:hover { color: #6b7280; }

/* ── Novo card ───────────────────────────────────────────────────────────── */
.wott-new-card {
    background: #f8fafc; border: 2px dashed #cbd5e1;
    border-radius: 10px; padding: 14px; margin-bottom: 8px;
}
.wott-new-card-title {
    font-size: 11px; font-weight: 700; color: #64748b;
    text-transform: uppercase; letter-spacing: .08em; margin-bottom: 10px;
}

/* ── Admin geral ─────────────────────────────────────────────────────────── */
.wott-admin { font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif; }
.wott-box-footer {
    display: flex; align-items: center; justify-content: space-between; padding-top: 6px;
}
.wott-api-warning {
    padding: 7px 12px; background: #fffbeb; border: 1px solid #fde68a;
    border-radius: 6px; font-size: 12px; color: #92400e; margin-bottom: 10px;
}
.wott-api-warning a { color: #b45309; font-weight: 600; }
.wott-msg { padding: 7px 12px; border-radius: 6px; font-size: 12px; margin-bottom: 8px; animation: wottFadeUp .2s ease; }
.wott-msg-success { background: #f0fdf4; border: 1px solid #bbf7d0; color: #166534; }
.wott-msg-warning { background: #fffbeb; border: 1px solid #fde68a; color: #92400e; }
.wott-msg-error   { background: #fef2f2; border: 1px solid #fecaca; color: #991b1b; }

/* ── Frontend ────────────────────────────────────────────────────────────── */
.wott-frontend-section { margin-top: 24px; }
.wott-frontend-section h2 { font-size: 16px; margin-bottom: 12px; }

/* Link "Seguir ↗" no frontend */
.wott-link-btn {
    display: inline-flex; align-items: center; justify-content: center;
}
/* Versão texto para o frontend */
.wott-fc .wott-icon-btn.wott-link-btn {
    width: auto; padding: 0 10px; gap: 4px; font-size: 11px; font-weight: 600;
    color: #475569;
}
.wott-fc .wott-icon-btn.wott-link-btn::after { content: " Seguir"; }

/* Overrides frontend */
.wott-fc .wott-card-head { padding: 12px 16px; }
.wott-fc .wott-current-event { padding: 12px 16px; }
.wott-fc .wott-hist-toggle { padding-left: 48px; }
.wott-fc .wott-history { padding: 10px 16px 14px; }
.wott-fc .wott-fetched-row { padding: 5px 16px 8px; }
.wott-fc .wott-event-status { font-size: 14px; }

@keyframes wottFadeUp { from { opacity:0; transform: translateY(3px); } to { opacity:1; transform: none; } }

/* ── Campo código postal ─────────────────────────────────────────────────── */
.wott-postcode-row {
    margin-bottom: 8px;
}
.wott-postcode-required {
    color: #ef4444;
    margin-left: 2px;
}
.wott-postcode-hint {
    font-size: 11px;
    color: #f97316;
    margin-top: 4px;
    display: block;
    background: #fff7ed;
    border: 1px solid #fed7aa;
    border-radius: 5px;
    padding: 4px 8px;
}

/* ── Tracking badge na tabela de artigos ─────────────────────────────────── */
.wott-item-tracking {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-top: 5px;
    flex-wrap: wrap;
}
.wott-item-carrier {
    display: inline-block;
    padding: 1px 6px;
    border-radius: 3px;
    border: 1px solid;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .4px;
}
.wott-item-code {
    font-family: ui-monospace, monospace;
    font-size: 11px;
    background: #f8fafc;
    border: 1px solid #e2e8f0;
    border-radius: 3px;
    padding: 1px 6px;
    color: #475569;
}
.wott-item-scope-tag {
    font-size: 10px;
    color: #94a3b8;
    font-style: italic;
}

/* Hint abaixo do multiselect */
.wott-field-hint {
    font-size: 11px;
    color: #94a3b8;
    margin: 4px 0 0;
    font-style: italic;
}

/* ── Portal de tracking (Ontime e similares) ─────────────────────────────── */
.wott-portal-instructions {
    margin: 0 14px 12px;
    border: 1px solid #fed7aa;
    border-radius: 8px;
    background: #fff7ed;
    overflow: hidden;
}
.wott-portal-row {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 9px 12px 6px;
    font-size: 12px;
    color: #9a3412;
    font-weight: 500;
}
.wott-portal-row svg { color: #f97316; flex-shrink: 0; }

.wott-portal-fields {
    display: flex;
    gap: 10px;
    padding: 0 12px 8px;
    flex-wrap: wrap;
}
.wott-portal-field {
    display: flex;
    align-items: center;
    gap: 6px;
    background: #fff;
    border: 1px solid #fed7aa;
    border-radius: 6px;
    padding: 5px 8px;
}
.wott-portal-field-label {
    font-size: 10px;
    font-weight: 600;
    color: #c2410c;
    text-transform: uppercase;
    letter-spacing: .05em;
    white-space: nowrap;
}
.wott-portal-field-value {
    font-family: ui-monospace, monospace;
    font-size: 12px;
    font-weight: 600;
    color: #1e293b;
    background: none;
    border: none;
    padding: 0;
}
.wott-portal-copy {
    background: none;
    border: none;
    color: #f97316;
    cursor: pointer;
    padding: 0 2px;
    font-size: 12px;
    line-height: 1;
    transition: .15s;
}
.wott-portal-copy:hover { color: #ea580c; }

.wott-portal-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: calc(100% - 24px);
    margin: 0 12px 10px;
    padding: 8px;
    background: #f97316;
    color: #fff;
    border-radius: 6px;
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: background .15s;
}
.wott-portal-open-btn:hover { background: #ea580c; color: #fff; text-decoration: none; }

.wott-portal-btn { color: #f97316 !important; border-color: #fed7aa !important; }
.wott-portal-btn:hover { background: #fff7ed !important; border-color: #f97316 !important; }

/* Frontend: instruções mais visíveis */
.wott-fc .wott-portal-instructions {
    margin: 0 0 0;
    border-radius: 0 0 10px 10px;
    border-top: 1px solid #fed7aa;
    border-left: none; border-right: none; border-bottom: none;
}

/* ── Produtos associados ao tracking (admin) ─────────────────────────────── */
.wott-card-products {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    padding: 6px 14px 7px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
}
.wott-prod-scope-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    letter-spacing: .3px;
    white-space: nowrap;
    flex-shrink: 0;
}
.wott-prod-scope-full    { background:#eff6ff; color:#1d4ed8; border:1px solid #bfdbfe; }
.wott-prod-scope-partial { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.wott-prod-list {
    font-size: 11px;
    color: #475569;
    min-width: 0;
}
.wott-prod-name { font-weight: 500; color: #374151; }
.wott-prod-qty  { color: #94a3b8; font-weight: 400; }
.wott-prod-sep  { color: #d1d5db; margin: 0 2px; }

/* ── Produtos no popup da tabela de encomendas ───────────────────────────── */
.wott-col-products {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    padding: 7px 12px;
    border-bottom: 1px solid #f1f5f9;
    background: #f8fafc;
}
.wott-col-scope-tag {
    display: inline-block;
    padding: 2px 7px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
    white-space: nowrap;
    flex-shrink: 0;
}
.wott-col-scope-full    { background:#eff6ff; color:#1d4ed8; border:1px solid #bfdbfe; }
.wott-col-scope-partial { background:#fef3c7; color:#92400e; border:1px solid #fde68a; }
.wott-col-prod-list {
    font-size: 11px;
    color: #475569;
    min-width: 0;
}

/* ── Scope tag no card frontend ─────────────────────────────────────────── */
.wott-fc-scope {
    display: flex;
    align-items: center;
    gap: 7px;
    flex-wrap: wrap;
    padding: 6px 16px 7px;
    border-top: 1px solid #f1f5f9;
    background: #fafafa;
    font-size: 11px;
}

/* ── Itens agrupados por envio (frontend) ────────────────────────────────── */
.wott-items-by-shipment {
    margin: 0 0 24px;
}
.wott-items-by-shipment h2 {
    font-size: 16px;
    margin: 0 0 14px;
}
.wott-shipment-group {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}
.wott-shipment-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    gap: 8px;
}
.wott-shipment-head-left {
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}
.wott-shipment-scope-tag {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 4px;
    font-size: 10px;
    font-weight: 700;
}
.wott-shipment-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.wott-shipment-table thead tr {
    border-bottom: 1px solid #f1f5f9;
}
.wott-shipment-table th {
    padding: 8px 16px;
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .06em;
    color: #94a3b8;
    text-align: left;
    background: #fafafa;
}
.wott-shipment-table td {
    padding: 10px 16px;
    border-bottom: 1px solid #f8fafc;
    vertical-align: middle;
}
.wott-shipment-table tr:last-child td { border-bottom: none; }
.wott-shipment-table .wott-col-qty    { text-align: center; color: #64748b; width: 60px; }
.wott-shipment-table .wott-col-total  { text-align: right; font-weight: 600; width: 90px; }
.wott-item-img {
    display: inline-block;
    vertical-align: middle;
    margin-right: 10px;
}
.wott-item-img img {
    width: 32px;
    height: 32px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid #e2e8f0;
}
.wott-item-name { vertical-align: middle; color: #1e293b; }

/* ── Vista unificada (frontend) ──────────────────────────────────────────── */
.wott-unified-view { margin-bottom: 0; }

.wott-unified-card {
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    overflow: hidden;
    margin-bottom: 12px;
    background: #fff;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
}

/* Cabeçalho */
.wott-uc-head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e5e7eb;
    gap: 8px; flex-wrap: wrap;
}
.wott-uc-head-left  { display:flex; align-items:center; gap:8px; flex-wrap:wrap; }
.wott-uc-head-right { display:flex; align-items:center; gap:6px; flex-shrink:0; }

/* Tabela de artigos */
.wott-uc-items {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.wott-uc-items thead tr { border-bottom: 1px solid #f1f5f9; }
.wott-uc-items th {
    padding: 7px 16px;
    font-size: 10px; font-weight: 700;
    text-transform: uppercase; letter-spacing: .06em;
    color: #94a3b8; text-align: left; background: #fafafa;
}
.wott-uc-items td {
    padding: 10px 16px;
    border-bottom: 1px solid #f8fafc;
    vertical-align: middle;
}
.wott-uc-items tr:last-child td { border-bottom: none; }
.wott-uc-qty   { text-align:center; color:#64748b; width:55px; }
.wott-uc-total { text-align:right; font-weight:600; width:80px; }

/* Tracking inline */
.wott-uc-tracking {
    display: flex;
    align-items: flex-start;
    gap: 0;
    padding: 10px 16px 6px;
    border-top: 1px solid #f1f5f9;
}

/* Portal inline */
.wott-uc-portal {
    padding: 10px 16px 12px;
    background: #fff7ed;
    border-top: 1px solid #fed7aa;
    font-size: 12px; color: #9a3412;
}
.wott-uc-portal p { margin: 0 0 8px; font-weight: 500; }

/* Pending */
.wott-uc-pending {
    padding: 10px 16px;
    font-size: 12px; color: #94a3b8;
    border-top: 1px solid #f1f5f9;
}

/* Divider antes dos totais */
.wott-unified-divider { margin: 0 0 0; border: none; border-top: 1px solid #e5e7eb; }

/* Esconder a thead da tabela WC quando está vazia de items */
.woocommerce-table--order-details:not(:has(tbody tr:not(.wott-hidden))) thead { display:none; }
