/* ═══════════════════════════════════════════════════════════════════════════
   Avartan Network Importer — Frontend Styles
   Designed to sit cleanly inside WooCommerce My Account layout.
   ═══════════════════════════════════════════════════════════════════════════ */

/* ── Root variables ──────────────────────────────────────────────────────── */
.avartan-importer {
    --ai-primary:      #a9cb52;   /* Avartan brand green */
    --ai-primary-dark: #8fb040;
    --ai-primary-text: #ffffff;   /* text on primary bg */
    --ai-success:      #5ea949;
    --ai-danger:       #c0392b;
    --ai-warning:      #f39c12;
    --ai-text:         #3d3d3d;
    --ai-text-muted:   #767676;
    --ai-border:       #e2e2e2;
    --ai-bg:           #ffffff;
    --ai-bg-alt:       #f8f7f7;
    --ai-radius:       6px;
    --ai-shadow:       0 2px 8px rgba(0,0,0,.08);
    --ai-step-size:    36px;
    font-family: inherit;
    color: var(--ai-text);
}

/* ── Steps indicator ─────────────────────────────────────────────────────── */
.ai-steps {
    display: flex;
    align-items: center;
    margin-bottom: 28px;
    overflow-x: auto;
    padding-bottom: 4px;
}

.ai-steps__item {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
    min-width: 80px;
    opacity: .45;
    transition: opacity .25s;
}
.ai-steps__item.active,
.ai-steps__item.completed { opacity: 1; }

.ai-steps__num {
    width: var(--ai-step-size);
    height: var(--ai-step-size);
    border-radius: 50%;
    background: var(--ai-bg-alt);
    border: 2px solid var(--ai-border);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 14px;
    transition: background .25s, border-color .25s, color .25s;
}
.ai-steps__item.active    .ai-steps__num { background: var(--ai-primary); border-color: var(--ai-primary); color: #fff; }
.ai-steps__item.completed .ai-steps__num { background: var(--ai-success); border-color: var(--ai-success); color: #fff; }

.ai-steps__label {
    font-size: 11px;
    font-weight: 600;
    text-align: center;
    white-space: nowrap;
    color: var(--ai-text-muted);
}
.ai-steps__item.active    .ai-steps__label,
.ai-steps__item.completed .ai-steps__label { color: var(--ai-text); }

.ai-steps__connector {
    flex: 1;
    height: 2px;
    background: var(--ai-border);
    min-width: 20px;
    margin-bottom: 20px;
}

/* ── Panel (each step's card) ────────────────────────────────────────────── */
.ai-panel {
    background: var(--ai-bg);
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    padding: 28px;
    margin-bottom: 20px;
    box-shadow: var(--ai-shadow);
    position: relative;
}
.ai-panel__title {
    margin: 0 0 6px;
    font-size: 18px;
    font-weight: 700;
    color: var(--ai-text);
}
.ai-panel__desc {
    color: var(--ai-text-muted);
    margin-bottom: 20px;
    font-size: 14px;
}

/* ── Numbered sections (Step 1) ──────────────────────────────────────────── */
.ai-sections {
    display: flex;
    flex-direction: column;
    gap: 0;
}

/* Each section: full width, bordered bottom separator */
.ai-section {
    padding: 20px 0;
    border-bottom: 1px solid var(--ai-border);
}
.ai-section--last { border-bottom: none; }

/* Header row: circle number + optional tick + title + border line */
.ai-section__head {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 16px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--ai-border);
}

.ai-section__num {
    width: 30px;
    height: 30px;
    border-radius: 50%;
    background: var(--ai-primary);
    color: #2d3a00;
    font-weight: 800;
    font-size: 13px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.ai-section__check {
    color: var(--ai-primary);
    flex-shrink: 0;
}

.ai-section__title {
    font-size: 15px;
    font-weight: 700;
    color: var(--ai-text);
    margin: 0;
    flex: 1;
}

/* Body: full width, no left indent */
.ai-section__body {
    width: 100%;
}

/* Select row: select fills available width, info chip on right */
.ai-section__row {
    display: flex;
    align-items: center;
    gap: 12px;
    width: 100%;
    flex-wrap: wrap;
}
.ai-section__row-main {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
}
.ai-section__row-main .ai-select {
    width: 100%;
    max-width: 100%;
}

.ai-info-chip {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: rgba(169,203,82,.1);
    border: 1px solid rgba(169,203,82,.35);
    border-radius: 20px;
    font-size: 13px;
    color: #5a7a00;
    white-space: nowrap;
    flex-shrink: 0;
    align-self: flex-start;
    margin-top: 0;
}
.ai-info-chip svg { color: var(--ai-primary); }

/* ── Upload row: drop zone 75% + tips 25% ────────────────────────────────── */
.ai-upload-row {
    display: flex;
    gap: 16px;
    align-items: flex-start;
    width: 100%;
}
.ai-upload-row .ai-file-drop { flex: 3; min-width: 0; }
.ai-upload-row .ai-tips      { flex: 1; min-width: 0; }

@media (max-width: 680px) {
    .ai-upload-row { flex-direction: column; }
}

/* File drop zone */
.ai-file-drop {
    border: 2px dashed #d0d5d0;
    border-radius: var(--ai-radius);
    padding: 36px 20px;
    text-align: center;
    background: #f8fdf2;
    cursor: pointer;
    transition: border-color .2s, background .2s;
    box-sizing: border-box;
}
.ai-file-drop:hover,
.ai-file-drop.drag-over { border-color: var(--ai-primary); background: rgba(169,203,82,.07); }

.ai-drop__main  { font-size: 15px; font-weight: 600; color: var(--ai-text); margin: 10px 0 4px; }
.ai-drop__or    { font-size: 14px; color: var(--ai-text-muted); margin: 0 0 12px; }
.ai-drop__browse { color: var(--ai-primary); font-weight: 700; cursor: pointer; text-decoration: underline; }
.ai-drop__hint  { font-size: 11px; color: var(--ai-text-muted); margin: 10px 0 0; line-height: 1.5; }

/* File type badges */
.ai-file-badges { display: flex; justify-content: center; gap: 6px; flex-wrap: wrap; margin-bottom: 8px; }
.ai-file-badge  { padding: 3px 10px; border-radius: 4px; font-size: 12px; font-weight: 700; }
.ai-file-badge--xlsx { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.ai-file-badge--xls  { background: #e8f5e9; color: #2e7d32; border: 1px solid #a5d6a7; }
.ai-file-badge--csv  { background: #fff8e1; color: #f57f17; border: 1px solid #ffe082; }
.ai-file-badge--ods  { background: #e3f2fd; color: #1565c0; border: 1px solid #90caf9; }

/* Tips panel */
.ai-tips { background: #fafff0; border: 1px solid #daeea0; border-radius: var(--ai-radius); padding: 16px; box-sizing: border-box; }
.ai-tips__title { font-weight: 700; font-size: 14px; color: var(--ai-text); margin: 0 0 10px; display: flex; align-items: center; gap: 6px; }
.ai-tips ul { margin: 0; padding-left: 16px; font-size: 13px; color: var(--ai-text-muted); line-height: 2; }

/* Text link */
.ai-btn--text-link { display: block; font-size: 13px; color: var(--ai-text-muted); text-decoration: none; margin-top: 10px; }
.ai-btn--text-link:hover { color: var(--ai-text); text-decoration: underline; }

/* ── Field groups ────────────────────────────────────────────────────────── */
.ai-field-group {
    margin-bottom: 24px;
}
.ai-label {
    display: block;
    font-weight: 700;
    margin-bottom: 8px;
    font-size: 14px;
    color: var(--ai-text);
}
.ai-label .required { color: var(--ai-danger); margin-left: 2px; }

.ai-select {
    width: 100%;
    max-width: 100%;
    padding: 10px 14px;
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    font-size: 14px;
    background: var(--ai-bg);
    color: var(--ai-text);
    transition: border-color .2s;
}
.ai-select:focus { outline: none; border-color: var(--ai-primary); box-shadow: 0 0 0 3px rgba(169,203,82,.2); }

.ai-field-hint {
    display: block;
    font-size: 12px;
    color: var(--ai-text-muted);
    margin-top: 6px;
}

/* ── File drop zone ──────────────────────────────────────────────────────── */
.ai-file-drop {
    border: 2px dashed var(--ai-border);
    border-radius: var(--ai-radius);
    padding: 40px 24px;
    text-align: center;
    background: var(--ai-bg-alt);
    cursor: pointer;
    transition: border-color .2s, background .2s;
    max-width: 480px;
}
.ai-file-drop:hover,
.ai-file-drop.drag-over { border-color: var(--ai-primary); background: rgba(169,203,82,.06); }
.ai-file-drop svg { color: var(--ai-text-muted); margin-bottom: 10px; }
.ai-file-drop p { margin: 0 0 12px; color: var(--ai-text-muted); font-size: 14px; }
.ai-file-hint { font-size: 11px !important; color: var(--ai-text-muted) !important; margin-top: 10px !important; }

.ai-file-input {
    position: absolute;
    width: 1px;
    height: 1px;
    opacity: 0;
    overflow: hidden;
    clip: rect(0,0,0,0);
}

.ai-file-chosen {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
    padding: 10px 14px;
    background: rgba(169,203,82,.08);
    border: 1px solid rgba(169,203,82,.3);
    border-radius: var(--ai-radius);
    font-size: 13px;
    max-width: 480px;
}
.ai-file-chosen::before { content: "📄"; }

/* ── Sample download ─────────────────────────────────────────────────────── */
.ai-sample-wrap { margin-top: 4px; margin-bottom: 16px; }

/* ── Buttons ─────────────────────────────────────────────────────────────── */
.ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 10px 22px;
    border-radius: var(--ai-radius);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    border: none;
    text-decoration: none;
    transition: background .2s, box-shadow .2s, opacity .2s;
    line-height: 1.4;
}
.ai-btn:hover { text-decoration: none; }
.ai-btn:disabled { opacity: .55; cursor: not-allowed; }

.ai-btn--primary  { background: var(--ai-primary); color: #2d3a00; font-weight: 700; }
.ai-btn--primary:hover { background: var(--ai-primary-dark); color: #2d3a00; }
.ai-btn--primary:focus { outline: none; box-shadow: 0 0 0 3px rgba(169,203,82,.35); }

.ai-btn--outline  { background: transparent; color: #5a7a00; border: 2px solid var(--ai-primary); }
.ai-btn--outline:hover { background: rgba(169,203,82,.08); color: #5a7a00; }

.ai-btn--ghost    { background: transparent; color: var(--ai-text-muted); border: 1px solid var(--ai-border); }
.ai-btn--ghost:hover { background: var(--ai-bg-alt); color: var(--ai-text); }

.ai-btn--confirm  { background: var(--ai-success); color: #fff; }
.ai-btn--confirm:hover { background: #4e9940; color: #fff; }

.ai-btn--sm { padding: 6px 14px; font-size: 13px; }

.ai-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 24px;
    padding-top: 20px;
    border-top: 1px solid var(--ai-border);
}

/* ── Tables ──────────────────────────────────────────────────────────────── */
.ai-table-scroll { overflow-x: auto; margin-bottom: 16px; }
.ai-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 13px;
}
.ai-table th,
.ai-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--ai-border);
    text-align: left;
    vertical-align: middle;
}
.ai-table thead th {
    background: var(--ai-bg-alt);
    font-weight: 700;
    font-size: 12px;
    text-transform: uppercase;
    letter-spacing: .5px;
    color: var(--ai-text-muted);
}
.ai-table tbody tr:last-child td { border-bottom: none; }
.ai-table tbody tr:hover { background: rgba(0,0,0,.015); }

/* Preview table */
.ai-table--preview th,
.ai-table--preview td { white-space: nowrap; max-width: 180px; overflow: hidden; text-overflow: ellipsis; }

/* Mapping table selects */
.ai-mapping-table .ai-map-select {
    width: 100%;
    min-width: 180px;
    padding: 7px 10px;
    border: 1px solid var(--ai-border);
    border-radius: 4px;
    font-size: 13px;
    background: var(--ai-bg);
}
.ai-mapping-table tr.ai-suggested .ai-map-select {
    border-color: var(--ai-primary);
    box-shadow: 0 0 0 2px rgba(169,203,82,.2);
}
.ai-sample-val { color: var(--ai-text-muted); font-size: 12px; font-style: italic; }

/* ── Badges ──────────────────────────────────────────────────────────────── */
.ai-badge {
    display: inline-flex;
    align-items: center;
    padding: 2px 9px;
    border-radius: 20px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: .4px;
    white-space: nowrap;
}
.ai-badge--core       { background: #e8f0fe; color: #1a56db; }
.ai-badge--meta       { background: #fef3c7; color: #92400e; }
.ai-badge--woo        { background: #ede9fe; color: #5b21b6; }
.ai-badge--ignore     { background: #f3f4f6; color: #9ca3af; }
.ai-badge--suggested  { background: rgba(169,203,82,.15); color: #5a7a00; }
.ai-badge--completed  { background: #edfaef; color: var(--ai-success); }
.ai-badge--running    { background: #fef3c7; color: var(--ai-warning); }
.ai-badge--pending    { background: #e8f0fe; color: #1a56db; }

/* ── Review summary ──────────────────────────────────────────────────────── */
.ai-review-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    padding: 20px;
    background: var(--ai-bg-alt);
    border-radius: var(--ai-radius);
    margin-bottom: 24px;
    border: 1px solid var(--ai-border);
}
.ai-review-stat { text-align: center; flex: 1; min-width: 100px; }
.ai-review-stat__num   { font-size: 32px; font-weight: 800; color: #5a7a00; line-height: 1; }
.ai-review-stat__label { font-size: 12px; color: var(--ai-text-muted); margin-top: 4px; }

/* ── Options grid (Step 3) ────────────────────────────────────────────────── */
.ai-options-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; }
@media (max-width: 600px) { .ai-options-grid { grid-template-columns: 1fr; } }

/* ── Toggle switch ───────────────────────────────────────────────────────── */
.ai-toggle { display: flex; align-items: center; gap: 10px; cursor: pointer; user-select: none; }
.ai-toggle input { position: absolute; opacity: 0; width: 0; height: 0; }
.ai-toggle__slider {
    position: relative;
    display: inline-block;
    width: 42px;
    height: 24px;
    background: var(--ai-border);
    border-radius: 12px;
    transition: background .2s;
    flex-shrink: 0;
}
.ai-toggle__slider::after {
    content: '';
    position: absolute;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: #fff;
    top: 3px;
    left: 3px;
    transition: transform .2s;
    box-shadow: 0 1px 3px rgba(0,0,0,.3);
}
.ai-toggle input:checked ~ .ai-toggle__slider { background: var(--ai-primary); }
.ai-toggle input:checked ~ .ai-toggle__slider::after { transform: translateX(18px); }
.ai-toggle__label { font-size: 14px; color: var(--ai-text); }

/* ── Results summary ─────────────────────────────────────────────────────── */
.ai-results-summary {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    margin-bottom: 24px;
}
.ai-result-card {
    flex: 1;
    min-width: 120px;
    padding: 18px 16px;
    border-radius: var(--ai-radius);
    text-align: center;
    border: 1px solid var(--ai-border);
}
.ai-result-card__num   { font-size: 38px; font-weight: 800; line-height: 1; }
.ai-result-card__label { font-size: 12px; color: var(--ai-text-muted); margin-top: 4px; }
.ai-result-card--total   { background: #f4f9e8; border-color: #d4e899; }
.ai-result-card--total   .ai-result-card__num { color: #5a7a00; }
.ai-result-card--success { background: #edfaef; }
.ai-result-card--success .ai-result-card__num { color: var(--ai-success); }
.ai-result-card--failed  { background: #fef0f0; }
.ai-result-card--failed  .ai-result-card__num { color: var(--ai-danger); }

.ai-success { color: var(--ai-success); font-weight: 600; }
.ai-failed  { color: var(--ai-danger);  font-weight: 600; }

/* ── Collapsible (details/summary) ──────────────────────────────────────── */
.ai-collapsible {
    border: 1px solid var(--ai-border);
    border-radius: var(--ai-radius);
    margin-bottom: 20px;
    overflow: hidden;
}
.ai-collapsible__trigger {
    padding: 12px 16px;
    background: var(--ai-bg-alt);
    cursor: pointer;
    font-weight: 600;
    font-size: 14px;
    user-select: none;
    list-style: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
}
.ai-collapsible__trigger::after { content: '▾'; font-size: 12px; }
.ai-collapsible[open] .ai-collapsible__trigger::after { content: '▴'; }
.ai-collapsible > *:not(summary) { padding: 16px; }

/* ── Section title ───────────────────────────────────────────────────────── */
.ai-section-title { font-size: 15px; font-weight: 700; margin: 0 0 8px; }
.ai-hint { font-size: 13px; color: var(--ai-text-muted); margin-bottom: 12px; display: flex; align-items: center; gap: 6px; flex-wrap: wrap; }

/* ── Loading overlay ─────────────────────────────────────────────────────── */
.ai-loading-overlay {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.85);
    border-radius: var(--ai-radius);
    z-index: 100;
    display: flex;
    align-items: center;
    justify-content: center;
}
.ai-loading-inner { text-align: center; }
.ai-spinner {
    width: 40px;
    height: 40px;
    border: 3px solid var(--ai-border);
    border-top-color: var(--ai-primary);
    border-radius: 50%;
    animation: ai-spin .7s linear infinite;
    margin: 0 auto 12px;
}
@keyframes ai-spin { to { transform: rotate(360deg); } }
.ai-loading-inner p { font-size: 14px; color: var(--ai-text-muted); font-weight: 600; margin: 0; }

/* ── Notices ─────────────────────────────────────────────────────────────── */
#aiNotices { margin-bottom: 16px; }
.ai-notice {
    padding: 12px 16px;
    border-radius: var(--ai-radius);
    font-size: 14px;
    margin-bottom: 10px;
    border-left: 4px solid;
}
.ai-notice--error   { background: #fef0f0; border-color: var(--ai-danger);  color: #c0392b; }
.ai-notice--success { background: #edfaef; border-color: var(--ai-success); color: #3a7d2e; }
.ai-notice--info    { background: #f4f9e8; border-color: var(--ai-primary); color: #5a7a00; }

/* ── History page header ─────────────────────────────────────────────────── */
.ai-history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    flex-wrap: wrap;
    gap: 10px;
}

/* ── Modal ───────────────────────────────────────────────────────────────── */
.ai-modal {
    position: fixed;
    inset: 0;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
}
.ai-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0,0,0,.5);
    backdrop-filter: blur(2px);
}
.ai-modal__dialog {
    position: relative;
    background: var(--ai-bg);
    border-radius: var(--ai-radius);
    width: 100%;
    max-width: 860px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0,0,0,.25);
    overflow: hidden;
}
.ai-modal__header {
    display: flex;
    align-items: center;
    padding: 16px 20px;
    border-bottom: 1px solid var(--ai-border);
    background: var(--ai-bg-alt);
}
.ai-modal__title { margin: 0; flex: 1; font-size: 16px; font-weight: 700; }
.ai-modal__close {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: var(--ai-text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    transition: color .2s;
}
.ai-modal__close:hover { color: var(--ai-danger); }
.ai-modal__body { padding: 20px; overflow-y: auto; }

/* ── Responsive ──────────────────────────────────────────────────────────── */
@media (max-width: 480px) {
    .ai-panel { padding: 18px; }
    .ai-steps__label { display: none; }
    .ai-steps__connector { min-width: 10px; }
    .ai-review-summary { flex-direction: column; }
    .ai-results-summary { flex-direction: column; }
    .ai-actions { flex-direction: column; }
    .ai-btn { width: 100%; justify-content: center; }
}