/* ============================================================
   WC eMAG Sync – Admin Styles
   ============================================================ */

/* ── 3.8.0 Async sync modal (Products page bulk Sync now) ───── */
body.skyemag-sync-modal-open { overflow: hidden; }
.skyemag-sync-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(20, 22, 26, 0.55);
    backdrop-filter: blur(4px);
    -webkit-backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
}
.skyemag-sync-modal {
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 18px 50px rgba(0, 0, 0, 0.35);
    width: min(560px, 92vw);
    padding: 24px;
    box-sizing: border-box;
}
.skyemag-sync-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    margin-bottom: 16px;
}
.skyemag-sync-modal-title {
    margin: 0;
    font-size: 18px;
    line-height: 1.3;
}
.skyemag-sync-modal-eta {
    color: #646970;
    font-size: 13px;
    white-space: nowrap;
}
.skyemag-sync-modal-bar-wrap {
    position: relative;
    background: #e5e5e5;
    border-radius: 4px;
    overflow: hidden;
    height: 28px;
}
.skyemag-sync-modal-bar {
    background: linear-gradient(90deg, #2271b1, #135e96);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
}
.skyemag-sync-modal-bar-text {
    position: absolute;
    inset: 0;
    text-align: center;
    line-height: 28px;
    font-size: 13px;
    font-weight: 600;
    color: #1d2327;
}
.skyemag-sync-modal-counters {
    margin: 12px 0 0;
    color: #50575e;
    font-size: 13px;
}
.skyemag-sync-modal-log {
    margin-top: 12px;
    max-height: 180px;
    overflow-y: auto;
    background: #1d2327;
    color: #a7aaad;
    font-family: ui-monospace, SFMono-Regular, monospace;
    font-size: 11px;
    line-height: 1.5;
    padding: 10px 12px;
    border-radius: 4px;
    white-space: pre-wrap;
    word-break: break-word;
}
.skyemag-sync-modal-log:empty {
    display: none;
}
.skyemag-sync-modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
    margin-top: 18px;
}


/* ── Settings page ─────────────────────────────────────────── */
.skyemag-settings .form-table th {
    width: 220px;
}
.skyemag-settings h2.title {
    border-bottom: 1px solid #dcdcde;
    padding-bottom: 8px;
    margin-top: 32px;
}

/* ── Status badges ─────────────────────────────────────────── */
.skyemag-badge {
    display: inline-block;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: .5px;
    white-space: nowrap;
}
.skyemag-badge--success { background:#d4edda; color:#155724; }
.skyemag-badge--error   { background:#f8d7da; color:#721c24; cursor:help; }
.skyemag-badge--pending { background:#fff3cd; color:#856404; }
.skyemag-badge--ready     { background:#d1ecf1; color:#0c5460; }
.skyemag-badge--not-ready { background:#e2e3e5; color:#383d41; cursor:help; }
.skyemag-badge--inactive  { background:#f8d7da; color:#721c24; }

/* ── Products table ────────────────────────────────────────── */
.skyemag-products-wrap .wp-list-table th,
.skyemag-products-wrap .wp-list-table td {
    vertical-align: middle;
}

/* Column widths */
.column-sync_enabled { width: 50px; text-align: center !important; }
.column-sku          { width: 110px; }
.column-type         { width: 80px; }
.column-stock        { width: 60px; text-align: right !important; }
.column-woo_price    { width: 100px; text-align: right !important; }
.column-margin       { width: 130px; }
.column-emag_price   { width: 100px; text-align: right !important; }
.column-last_sync    { width: 110px; }
.column-status       { width: 80px; }

/* Toggle switch */
.skyemag-toggle {
    position: relative;
    display: inline-block;
    width: 36px;
    height: 20px;
    cursor: pointer;
}
.skyemag-toggle input {
    opacity: 0;
    width: 0;
    height: 0;
}
.skyemag-toggle-slider {
    position: absolute;
    inset: 0;
    background: #ccc;
    border-radius: 20px;
    transition: .2s;
}
.skyemag-toggle-slider::before {
    content: '';
    position: absolute;
    height: 14px;
    width: 14px;
    left: 3px;
    bottom: 3px;
    background: #fff;
    border-radius: 50%;
    transition: .2s;
}
.skyemag-toggle input:checked + .skyemag-toggle-slider {
    background: #2271b1;
}
.skyemag-toggle input:checked + .skyemag-toggle-slider::before {
    transform: translateX(16px);
}
.skyemag-toggle.is-saving .skyemag-toggle-slider {
    opacity: .5;
}

/* Margin input */
/* All margin/stock inputs — consistent sizing */
.skyemag-col-input {
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 2px;
    position: relative;
}
.skyemag-margin-input,
.skyemag-min-margin-input,
.skyemag-max-margin-input,
.skyemag-stock-pct-input {
    width: 58px;
    min-width: 58px;
    box-sizing: border-box;
    text-align: right;
    border: 1px solid #8c8f94;
    border-radius: 3px;
    padding: 3px 4px;
    font-size: 13px;
}
.skyemag-margin-input:focus,
.skyemag-min-margin-input:focus,
.skyemag-max-margin-input:focus,
.skyemag-stock-pct-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}
.skyemag-margin-input.is-error,
.skyemag-min-margin-input.is-error,
.skyemag-max-margin-input.is-error,
.skyemag-stock-pct-input.is-error {
    border-color: #d63638;
    box-shadow: 0 0 0 1px #d63638;
}
.skyemag-margin-suffix {
    color: #50575e;
    flex-shrink: 0;
}
.skyemag-margin-saving,
.skyemag-min-margin-saving,
.skyemag-max-margin-saving,
.skyemag-stock-pct-saving {
    color: #2271b1;
    font-style: italic;
    font-size: 11px;
    position: absolute;
    left: 0;
    top: 100%;
    white-space: nowrap;
}
.skyemag-min-margin-warn {
    color: #d63638;
    font-size: 14px;
    cursor: help;
    vertical-align: middle;
    flex-shrink: 0;
}

/* Prices — red = ex. VAT, green = inc. VAT */
.skyemag-price-preview {
    font-weight: 600;
    color: #d63638;
}
.skyemag-woo-price {
    font-weight: 600;
}
.skyemag-ex-vat {
    color: #d63638;
    font-weight: 600;
}
.skyemag-vat-label {
    font-size: 10px;
    color: #d63638;
    font-weight: 400;
    text-transform: uppercase;
    letter-spacing: 0.3px;
    opacity: 0.75;
}
.skyemag-price-inc {
    color: #00873a;
    font-style: normal;
    font-weight: 600;
}
.skyemag-price-na {
    color: #8c8f94;
}
.skyemag-price-updated {
    animation: skyemag-flash .6s ease;
}
@keyframes skyemag-flash {
    0%   { background: #e0f0ff; }
    100% { background: transparent; }
}

/* Stock zero */
.skyemag-stock-zero { color: #d63638; font-weight: 600; }

/* Never synced */
.skyemag-never { color: #8c8f94; font-style: italic; }

/* Bulk margin extra nav */
.skyemag-bulk-margin-wrap {
    display: flex;
    align-items: center;
    gap: 6px;
}

/* Inline AJAX feedback */
.skyemag-row-saving td {
    opacity: .5;
    pointer-events: none;
}

/* Save All status */
#skyemag-save-all-status {
    font-style: italic;
    color: #2271b1;
}

/* ── Stock % input (same style as margin) ────────────────────────────── */
.skyemag-stock-pct-input {
    width: 60px;
    text-align: right;
    border-color: #8c8f94;
    border-radius: 3px;
    padding: 3px 5px;
}
.skyemag-stock-pct-input:focus {
    border-color: #2271b1;
    box-shadow: 0 0 0 1px #2271b1;
    outline: none;
}
.skyemag-stock-pct-input.is-error { border-color: #d63638; box-shadow: 0 0 0 1px #d63638; }

/* eMAG stock preview */
.skyemag-emag-stock { color: #2271b1; font-weight: 600; }

/* eMAG ID label under SKU */
.skyemag-emag-id {
    font-size: 11px;
    color: #50575e;
    font-style: italic;
}

/* Price out of bounds warning */
.skyemag-price-warn { color: #d63638 !important; font-weight: 600; }

/* Min/max price bounds */
.skyemag-price-bounds { color: #8c8f94; white-space: nowrap; }

/* Column widths for new columns */
.column-stock_percent { width: 90px; }
.column-emag_stock    { width: 80px; text-align: right !important; }

/* Ping result */
#skyemag-ping-result { font-style: italic; }

/* ── Type column toggle checkbox ─────────────────────────────────────── */
.skyemag-type-toggle {
    display: inline-block;
    margin: 8px 0;
    font-size: 13px;
    color: #50575e;
    cursor: pointer;
}
.skyemag-type-toggle input {
    margin-right: 4px;
    vertical-align: middle;
}

/* ── Responsive table ────────────────────────────────────────────────── */
.skyemag-products-wrap .wp-list-table {
    table-layout: auto;
}

/* Make the table container scrollable on small screens */
@media screen and (max-width: 1400px) {
    .skyemag-products-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .skyemag-products-table {
        min-width: 900px;
    }
    /* Compact column widths */
    .skyemag-products-table .column-sync_enabled { width: 50px; }
    .skyemag-products-table .column-type         { width: 70px; }
    .skyemag-products-table .column-stock        { width: 55px; }
    .skyemag-products-table .column-margin       { width: 100px; }
    .skyemag-products-table .column-min_margin   { width: 90px; }
    .skyemag-products-table .column-max_margin   { width: 90px; }
    .skyemag-products-table .column-stock_percent{ width: 80px; }
    .skyemag-products-table .column-emag_stock   { width: 70px; }
    .skyemag-products-table .column-status       { width: 80px; }
    /* Smaller font for compact view */
    .skyemag-products-table td,
    .skyemag-products-table th {
        font-size: 12px;
        padding: 6px 6px;
    }
    /* Shrink price column text */
    .skyemag-products-table .column-woo_price small,
    .skyemag-products-table .column-emag_price small {
        font-size: 10px;
    }
}

/* ── Publish page table ──────────────────────────────────────────── */
.skyemag-publish-wrap .skyemag-publish-table {
    table-layout: auto;
    width: 100%;
}
.skyemag-publish-table .check-column { width: 30px; }
.skyemag-pub-status { display: inline-block; margin-left: 6px; }

/* Scrollable container on smaller screens */
@media screen and (max-width: 1400px) {
    .skyemag-publish-wrap .skyemag-pub-table-wrap {
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .skyemag-publish-table {
        min-width: 1100px;
    }
    .skyemag-publish-table td,
    .skyemag-publish-table th {
        font-size: 12px;
        padding: 6px 6px;
    }
    .skyemag-publish-table small {
        font-size: 10px;
    }
}

/* ── Preview modal ──────────────────────────────────────────────── */
.skyemag-modal-overlay {
    position: fixed; top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(0,0,0,.5); z-index: 99999;
}
.skyemag-modal-content {
    position: fixed; top: 50%; left: 50%;
    transform: translate(-50%, -50%);
    background: #fff; border-radius: 6px;
    padding: 20px; width: 700px; max-width: 90vw;
    max-height: 80vh; overflow: auto;
    z-index: 100000; box-shadow: 0 4px 20px rgba(0,0,0,.3);
}
.skyemag-modal-content h3 {
    margin: 0 0 12px; display: flex; justify-content: space-between; align-items: center;
}
.skyemag-modal-close {
    background: none; border: none; font-size: 22px; cursor: pointer;
    color: #666; line-height: 1;
}
.skyemag-json-preview {
    background: #f5f5f5; border: 1px solid #ddd;
    padding: 12px; font-size: 12px; line-height: 1.5;
    white-space: pre-wrap; word-wrap: break-word;
    max-height: 60vh; overflow: auto;
}

/* ── Progress bar (Publish page) ────────────────────────────────── */
.skyemag-progress-wrap {
    margin: 12px 0; max-width: 600px;
}
.skyemag-progress-bar-outer {
    background: #e5e5e5; border-radius: 4px; height: 24px;
    position: relative; overflow: hidden;
}
.skyemag-progress-bar-inner {
    background: #2271b1; height: 100%; border-radius: 4px;
    transition: width 0.3s ease;
}
.skyemag-progress-text {
    display: inline-block; margin-top: 4px;
    font-size: 13px; color: #50575e;
}

/* ── Buy Button column ──────────────────────────────────────────── */
.skyemag-bb-rank {
    font-size: 18px; line-height: 1;
}
.skyemag-bb-winner {
    color: #155724;
}
.skyemag-bb-low {
    color: #856404;
}
.skyemag-bb-info {
    color: #666; font-size: 11px;
}

/* ── Validation status badges ───────────────────────────────────── */
.skyemag-badge--val-approved  { background:#d4edda; color:#155724; }
.skyemag-badge--val-ok        { background:#d1ecf1; color:#0c5460; }
.skyemag-badge--val-pending   { background:#fff3cd; color:#856404; cursor:help; }
.skyemag-badge--val-rejected  { background:#f8d7da; color:#721c24; cursor:help; }

/* ── Margin history + rollback modal ───────────────────────────── */
.skyemag-margin-history-wrap {
    margin-top: 4px;
    font-size: 11px;
}
.skyemag-margin-history-link {
    text-decoration: none;
    color: #2271b1;
}
.skyemag-margin-history-link:hover { text-decoration: underline; }

.skyemag-modal-backdrop {
    position: fixed;
    inset: 0;
    background: rgba(15, 17, 26, 0.55);
    z-index: 100000;
    align-items: flex-start;
    justify-content: center;
    padding: 60px 16px;
    overflow-y: auto;
}
.skyemag-modal {
    background: #fff;
    border-radius: 6px;
    width: 100%;
    max-width: 640px;
    box-shadow: 0 18px 50px rgba(0,0,0,0.25);
    display: flex;
    flex-direction: column;
}
.skyemag-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    border-bottom: 1px solid #dcdcde;
}
.skyemag-modal-header h2 {
    margin: 0;
    font-size: 15px;
    line-height: 1.3;
}
.skyemag-modal-close {
    background: transparent;
    border: 0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    color: #666;
    padding: 0 6px;
}
.skyemag-modal-close:hover { color: #111; }
.skyemag-modal-body {
    padding: 16px 18px;
    max-height: 60vh;
    overflow-y: auto;
}
.skyemag-mh-table th, .skyemag-mh-table td { font-size: 12px; }
.skyemag-mh-date   { white-space: nowrap; color: #555; }
.skyemag-mh-change { font-family: monospace; }
.skyemag-mh-action { text-align: right; white-space: nowrap; }
.skyemag-arrow     { color: #999; padding: 0 4px; }

/* ── eMAG order badge (WC Orders list) ─────────────────────── */
/* Thin column registered by Admin/OrderListBadge.php, placed just before
   the order number. Header is screen-reader-only — same compact pattern
   as the SkyServers Local Delivery & Pickup marker. */
.column-skyemag_source {
    width: 46px;
    text-align: center;
    padding-left: 4px !important;
    padding-right: 4px !important;
}
.column-skyemag_source .skyemag-emag-state {
    font-size: 10px;
    padding: 1px 4px;
    letter-spacing: 0;
}
.skyemag-emag-state {
    display: inline-block;
    background: #ee4d2d;          /* eMAG brand orange */
    color: #fff;
    padding: 2px 7px;
    border-radius: 3px;
    font-size: 11px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    line-height: 1.5;
}
/* Override default grey post-state wrapper that WP wraps each state in */
.post-state .skyemag-emag-state,
li .skyemag-emag-state {
    background: #ee4d2d !important;
    color: #fff !important;
}

/* ── Products table — Activate / Deactivate row actions ────── */
.skyemag-emag-actions {
    margin-top: 4px;
    line-height: 1.4;
}
.skyemag-emag-actions .skyemag-status-toggle-btn {
    font-size: 12px;
    text-decoration: none;
}
.skyemag-action-activate {
    color: #00a32a !important;     /* WP green */
}
.skyemag-action-activate:hover {
    color: #007a1f !important;
    text-decoration: underline !important;
}
.skyemag-action-deactivate {
    color: #d63638 !important;     /* WP red */
}
.skyemag-action-deactivate:hover {
    color: #a00 !important;
    text-decoration: underline !important;
}

/* ── AWB meta box (eMAG Shipping on WC order edit) ─────────────── */
.skyemag-awb-box p {
    margin: 4px 0;
}
.skyemag-awb-box .skyemag-awb-info {
    font-size: 12px;
    color: #50575e;
    background: #f0f6fc;
    border-left: 3px solid #2271b1;
    padding: 6px 8px;
    margin: 8px 0;
}
.skyemag-awb-validation-error {
    color: #d63638;
    font-size: 12px;
    background: #fcf0f1;
    border-left: 3px solid #d63638;
    padding: 6px 8px;
    margin: 8px 0;
}
.skyemag-awb-issue-btn {
    width: 100%;
    text-align: center;
}
.skyemag-awb-print-btn {
    display: block;
    width: 100%;
    text-align: center;
    margin-top: 8px;
}
.skyemag-awb-other-format {
    margin: 6px 0;
    font-size: 12px;
}
.skyemag-awb-other-toggle {
    color: #2271b1;
    text-decoration: none;
}
.skyemag-awb-format-list {
    margin: 4px 0 0 12px;
    padding: 0;
    list-style: none;
}
.skyemag-awb-format-list li {
    margin: 2px 0;
}
.skyemag-awb-format-list a {
    text-decoration: none;
    color: #2271b1;
}
.skyemag-awb-status {
    margin-top: 8px;
    font-size: 12px;
    min-height: 16px;
}
.skyemag-awb-refresh-btn {
    margin-top: 6px !important;
}
