/* testes-ml.css — Página "Testes ML" (Precificação Dinâmica e demais experimentos)
   Depende apenas de style.css (vars globais) e sidebar.css — sem acoplamento com Shopee. */

body {
    display: flex;
    min-height: 100vh;
}

.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: visible;
    min-width: 0;
}

/* ===================== TOPBAR ===================== */
.tml-topbar {
    background: var(--card-bg);
    border-bottom: 1px solid var(--border);
    padding: 0 28px;
    height: 58px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    flex-shrink: 0;
}

.tml-topbar-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.tml-page-icon {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background: #f1f5f9;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
}

.tml-page-title {
    font-size: 17px;
    font-weight: 800;
    display: flex;
    align-items: center;
    gap: 8px;
}

.tml-breadcrumb {
    font-size: 12px;
    color: var(--text-muted);
}

.tml-breadcrumb span {
    color: var(--text);
    font-weight: 600;
}

.beta-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 11px;
    font-weight: 700;
    padding: 2px 8px;
    border-radius: 999px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
}

.tml-topbar-right {
    display: flex;
    align-items: center;
    gap: 10px;
}

.loja-selector {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
}

.loja-selector label {
    font-size: 12px;
    color: var(--text-muted);
    font-weight: 600;
}

.loja-selector select {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
    cursor: pointer;
    outline: none;
}

/* ===================== CONTENT ===================== */
.tml-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 28px;
}

/* ===================== TABS ===================== */
.tml-tab-bar {
    display: flex;
    gap: 8px;
    margin-bottom: 20px;
    flex-wrap: wrap;
}

.tml-tab {
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text-muted);
    font-family: inherit;
    font-size: 13px;
    font-weight: 700;
    padding: 9px 16px;
    border-radius: 8px;
    cursor: pointer;
    transition: all .15s;
}

.tml-tab:hover {
    border-color: #94a3b8;
    color: var(--text);
}

.tml-tab.active {
    background: var(--primary);
    border-color: var(--primary);
    color: #fff;
}

.tml-tab-content {
    display: none;
}

.tml-tab-content.active {
    display: block;
}

/* ===================== CARDS / SECTIONS ===================== */
.tml-card {
    background: var(--card-bg);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 20px;
}

.tml-card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 16px;
    flex-wrap: wrap;
    gap: 10px;
}

.tml-card-title {
    font-size: 14px;
    font-weight: 800;
    color: var(--text);
    display: flex;
    align-items: center;
    gap: 8px;
}

.tml-card-title .material-symbols-rounded {
    font-size: 18px;
    color: var(--primary);
}

.tml-empty {
    text-align: center;
    color: var(--text-muted);
    font-size: 13px;
    padding: 40px 20px;
}

.tml-empty .material-symbols-rounded {
    font-size: 36px;
    display: block;
    margin: 0 auto 8px;
    color: var(--border);
}

/* ===================== BUTTONS ===================== */
.btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    border-radius: 8px;
    border: 1px solid var(--border);
    background: var(--card-bg);
    color: var(--text);
    font-family: inherit;
    font-size: 12px;
    font-weight: 600;
    cursor: pointer;
    transition: all .15s;
    white-space: nowrap;
}

.btn:hover {
    border-color: #94a3b8;
    background: #f8fafc;
}

.btn .material-symbols-rounded {
    font-size: 16px;
}

.btn-primary {
    background: var(--primary);
    color: #fff;
    border-color: var(--primary);
}

.btn-primary:hover {
    background: #243460;
}

.btn-success {
    background: var(--success);
    color: #fff;
    border-color: var(--success);
}

.btn-success:hover {
    background: #0ea975;
}

.btn-sm {
    padding: 4px 10px;
    font-size: 11px;
}

.btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ===================== TABELA ===================== */
.tml-table-wrap {
    overflow-x: auto;
}

.tml-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}

.tml-table th {
    text-align: left;
    padding: 10px 12px;
    background: var(--bg);
    color: var(--text-muted);
    font-weight: 700;
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: .03em;
    white-space: nowrap;
    border-bottom: 1px solid var(--border);
}

.tml-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border);
    vertical-align: middle;
}

.tml-table tbody tr:hover {
    background: #f8fafc;
}

.tml-prod-cell {
    display: flex;
    align-items: center;
    gap: 10px;
}

.tml-prod-cell img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 6px;
    border: 1px solid var(--border);
    background: #f1f5f9;
    flex-shrink: 0;
}

.tml-prod-nome {
    font-weight: 600;
    color: var(--text);
    max-width: 280px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.tml-prod-id {
    font-size: 11px;
    color: var(--text-muted);
}

/* ===================== BADGES DE STATUS ===================== */
.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 9px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
    white-space: nowrap;
}

.badge-ok {
    background: #d1fae5;
    color: #065f46;
}

.badge-warn {
    background: #fef3c7;
    color: #92400e;
}

.badge-danger {
    background: #fee2e2;
    color: #991b1b;
}

.badge-neutral {
    background: #f1f5f9;
    color: var(--text-muted);
}

/* ===================== REGRAS / FORM ===================== */
.tml-form-row {
    display: flex;
    align-items: flex-end;
    gap: 16px;
    flex-wrap: wrap;
}

.tml-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.tml-field label {
    font-size: 11px;
    font-weight: 700;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .03em;
}

.tml-field select,
.tml-field input {
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    background: var(--card-bg);
    min-width: 160px;
}

.tml-field select:focus,
.tml-field input:focus {
    outline: 2px solid #c7d2fe;
    border-color: var(--primary);
}

.tml-toggle-ativo {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    font-weight: 700;
    color: var(--text);
}

/* ===================== MODAL ===================== */
.tml-modal-overlay {
    display: none;
    position: fixed;
    inset: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, .5);
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.tml-modal-overlay.show {
    display: flex;
}

.tml-modal-box {
    background: #fff;
    width: 560px;
    max-width: 95vw;
    max-height: 85vh;
    border-radius: 10px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, .25);
    overflow: hidden;
    display: flex;
    flex-direction: column;
}

.tml-modal-header {
    padding: 15px 20px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border);
    font-weight: 700;
    font-size: 15px;
}

.tml-modal-body {
    padding: 16px 20px;
    overflow-y: auto;
}

.tml-close-btn {
    background: none;
    border: none;
    color: #999;
    cursor: pointer;
    padding: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: color .2s;
}

.tml-close-btn:hover {
    color: #666;
}

.tml-close-btn .material-symbols-rounded {
    font-size: 20px;
}

/* ===================== TOAST (feedback / modo seguro) ===================== */
#mlToastContainer {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 2000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.ml-toast {
    padding: 12px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    box-shadow: 0 4px 16px rgba(0, 0, 0, .15);
    max-width: 360px;
    animation: ml-toast-in .25s ease-out;
}

@keyframes ml-toast-in {
    from { opacity: 0; transform: translateY(12px); }
    to   { opacity: 1; transform: translateY(0); }
}

.ml-toast-warn {
    background: #fef3c7;
    border-left: 4px solid #f59e0b;
    color: #92400e;
}

.ml-toast-error {
    background: #fee2e2;
    border-left: 4px solid #ef4444;
    color: #991b1b;
}

.ml-toast-success {
    background: #dcfce7;
    border-left: 4px solid #22c55e;
    color: #166534;
}

.ml-toast-info {
    background: #e0f2fe;
    border-left: 4px solid #0ea5e9;
    color: #075985;
}

/* ===================== SPINNER ===================== */
.tml-spinner {
    width: 28px;
    height: 28px;
    border: 3px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    margin: 24px auto;
    animation: tml-spin .8s linear infinite;
}

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

/* ===================== UTIL ===================== */
.tml-muted {
    color: var(--text-muted);
    font-size: 12px;
}

.tml-row-self {
    background: #eff6ff !important;
    font-weight: 700;
}

/* ===================== AVISO (banner informativo) ===================== */
.tml-aviso {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fef3c7;
    color: #92400e;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    margin-bottom: 16px;
}

.tml-aviso .material-symbols-rounded {
    font-size: 18px;
    flex-shrink: 0;
}

/* ===================== GRID DE PRODUTOS (A/B Test) ===================== */
.tml-prod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
    gap: 14px;
}

.tml-prod-grid-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tml-prod-grid-card img {
    width: 100%;
    height: 120px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

/* ===================== GRID DE FOTOS (Sync Fotos) ===================== */
.tml-fotos-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 16px;
}

.tml-fotos-card {
    border: 1px solid var(--border);
    border-radius: 10px;
    padding: 12px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.tml-foto-principal {
    width: 100%;
    height: 160px;
    object-fit: contain;
    border-radius: 6px;
    background: #f8fafc;
    border: 1px solid var(--border);
}

.tml-fotos-thumbs {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.tml-fotos-thumbs img {
    width: 36px;
    height: 36px;
    object-fit: cover;
    border-radius: 4px;
    border: 1px solid var(--border);
    background: #f1f5f9;
}

.tml-foto-thumb-wrap {
    position: relative;
    cursor: grab;
}

.tml-foto-remover {
    position: absolute;
    top: -6px;
    right: -6px;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    border: none;
    background: #ef4444;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    padding: 0;
    line-height: 1;
}

.tml-foto-remover:hover {
    background: #dc2626;
}

.tml-foto-remover:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* ===================== ABA: DADOS FISCAIS ===================== */
.mlf-search-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
    background: var(--bg);
    border: 1px solid var(--border);
    border-radius: 8px;
    padding: 6px 10px;
}

.mlf-search-wrap input {
    border: none;
    background: transparent;
    font-family: inherit;
    font-size: 12px;
    color: var(--text);
    outline: none;
    width: 200px;
}

.mlf-xml-aviso {
    background: #d1fae5;
    border-color: #6ee7b7;
    color: #065f46;
}

/* ===================== MODAL DADOS FISCAIS ===================== */
.mlf-modal {
    width: 620px;
    max-width: 96vw;
    max-height: 90vh;
}

.mlf-modal-footer {
    padding: 14px 20px;
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    background: var(--card-bg);
    flex-shrink: 0;
}

.mlf-row {
    display: flex;
    gap: 14px;
    margin-bottom: 16px;
    flex-wrap: wrap;
    align-items: flex-start;
}

.mlf-field-half  { flex: 1; min-width: 180px; }
.mlf-field-third { flex: 1; min-width: 120px; }

.mlf-prefix-input,
.mlf-suffix-input {
    display: flex;
    align-items: center;
    border: 1px solid var(--border);
    border-radius: 8px;
    overflow: hidden;
    background: var(--card-bg);
    width: 100%;
}

.mlf-prefix-input span,
.mlf-suffix-input span {
    padding: 8px 10px;
    background: var(--bg);
    font-size: 12px;
    font-weight: 700;
    color: var(--text-muted);
    white-space: nowrap;
    border-right: 1px solid var(--border);
}

.mlf-suffix-input span {
    border-right: none;
    border-left: 1px solid var(--border);
}

.mlf-prefix-input input,
.mlf-suffix-input input {
    border: none;
    flex: 1;
    padding: 8px 10px;
    font-family: inherit;
    font-size: 13px;
    color: var(--text);
    outline: none;
    background: transparent;
    min-width: 0;
}

.mlf-readonly {
    background: var(--bg) !important;
    color: var(--text-muted) !important;
    cursor: not-allowed;
}

.mlf-section-sep {
    font-size: 11px;
    font-weight: 800;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: .05em;
    border-top: 1px solid var(--border);
    padding-top: 14px;
    margin-bottom: 16px;
}

.mlf-ncm-desc {
    font-size: 10px;
    font-weight: 600;
    color: #3483fa;
    margin-left: 6px;
    cursor: pointer;
    text-decoration: underline;
    text-transform: none;
    letter-spacing: 0;
}

.mlf-aviso-full {
    display: flex;
    align-items: center;
    gap: 8px;
    background: #fef3c7;
    border: 1px solid #fde68a;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 12px;
    font-weight: 600;
    color: #92400e;
    margin-bottom: 16px;
}
