/* COF Variations Admin CSS — v2 */
*, *::before, *::after { box-sizing: border-box; }

.cof-var-wrap {
    font-family: 'Segoe UI', Tahoma, Arial, sans-serif;
    direction: rtl;
    color: #1e293b;
    max-width: 1200px;
    padding-bottom: 60px;
}

/* ── HEADER ── */
.cof-var-header {
    background: linear-gradient(135deg, #0f4c8b, #259bea);
    color: #fff;
    padding: 24px 28px;
    margin: 20px 0 24px;
    border-radius: 12px;
    box-shadow: 0 4px 20px rgba(37,155,234,.3);
}
.cof-var-header-inner { display: flex; align-items: center; gap: 16px; }
.cof-var-icon { font-size: 48px; }
.cof-var-header h1 { margin: 0 0 4px; font-size: 22px; font-weight: 700; color: #fff; }
.cof-var-header p  { margin: 0; opacity: .85; font-size: 13px; }

/* ── PRODUCT PICKER ── */
.cof-var-product-picker {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px 24px;
    margin-bottom: 20px;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
    display: flex;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}
.cvp-label { font-weight: 700; font-size: 14px; color: #374151; white-space: nowrap; }
.cvp-select-wrap { flex: 1; min-width: 280px; display: flex; align-items: center; gap: 10px; }
#cof-var-product-select {
    flex: 1;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px 14px;
    font-size: 14px;
    font-family: inherit;
    direction: rtl;
    outline: none;
    background: #fff;
    cursor: pointer;
    transition: border-color .2s;
}
#cof-var-product-select:focus {
    border-color: #259bea;
    box-shadow: 0 0 0 3px rgba(37,155,234,.12);
}
.cvp-spinner {
    width: 20px; height: 20px;
    border: 2px solid #e2e8f0;
    border-top-color: #259bea;
    border-radius: 50%;
    animation: spin .6s linear infinite;
}
@keyframes spin { to { transform: rotate(360deg); } }

/* ── EMPTY STATE ── */
.cof-var-empty { text-align: center; padding: 80px 20px; color: #94a3b8; }
.cve-icon { font-size: 64px; margin-bottom: 16px; }
.cof-var-empty h3 { font-size: 20px; color: #64748b; margin: 0 0 8px; }
.cof-var-empty p  { font-size: 14px; margin: 0; }

/* ── SECTION ── */
.cof-var-section {
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    margin-bottom: 20px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0,0,0,.05);
}
.cvs-head {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 18px 22px;
    border-bottom: 1px solid #e2e8f0;
    background: #f8fafc;
    flex-wrap: wrap;
}
.cvs-icon { font-size: 28px; }
.cvs-head h2 { margin: 0 0 3px; font-size: 16px; font-weight: 700; }
.cvs-head p  { margin: 0; font-size: 12px; color: #64748b; }
.cvs-head > div { flex: 1; }

/* ── BUTTONS ── */
.cof-btn-primary {
    background: #259bea;
    color: #fff;
    border: none;
    padding: 9px 20px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    font-family: inherit;
    transition: all .18s;
    white-space: nowrap;
}
.cof-btn-primary:hover { background: #1a7abf; box-shadow: 0 3px 10px rgba(37,155,234,.4); }
.cof-btn-primary:disabled { opacity: .6; cursor: not-allowed; }
.cof-btn-outline {
    background: #fff;
    color: #475569;
    border: 1px solid #e2e8f0;
    padding: 9px 18px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 6px;
    transition: all .18s;
}
.cof-btn-outline:hover { border-color: #259bea; color: #259bea; }

/* ── ATTRS GRID ── */
.cvs-attrs-grid {
    padding: 20px 22px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.cof-attr-card {
    border: 1px solid #e2e8f0;
    border-radius: 10px;
    overflow: hidden;
}
.cof-attr-card-head {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    background: #f8fafc;
    border-bottom: 1px solid #e2e8f0;
    flex-wrap: wrap;
    gap: 8px;
}
.caf-label {
    font-size: 15px;
    font-weight: 700;
    color: #1e293b;
    flex: 1;
    min-width: 100px;
}
.caf-style-tabs { display: flex; gap: 5px; flex-wrap: wrap; }
.caf-style-btn {
    border: 1px solid #e2e8f0;
    background: #fff;
    padding: 5px 12px;
    border-radius: 6px;
    font-size: 12px;
    font-family: inherit;
    cursor: pointer;
    color: #64748b;
    transition: all .15s;
}
.caf-style-btn.active { background: #259bea; border-color: #259bea; color: #fff; font-weight: 700; }
.caf-style-btn:hover:not(.active) { border-color: #259bea; color: #259bea; }

.cof-attr-card-body { padding: 14px 16px; }
.caf-options {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: flex-end;
}

/* ── معاينة الخيارات في الكرت ── */
.caf-opt {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 5px;
}
.caf-opt-name {
    font-size: 11px;
    color: #64748b;
    text-align: center;
    max-width: 70px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

/* دائرة مع color picker */
.caf-opt-circle-type { min-width: 52px; }
.caf-opt-circle-wrap {
    position: relative;
    width: 46px;
    height: 46px;
    cursor: pointer;
}
.caf-circle-preview {
    position: absolute;
    inset: 0;
    border-radius: 50%;
    border: 2px solid rgba(0,0,0,.12);
    box-shadow: 0 2px 6px rgba(0,0,0,.15);
    pointer-events: none;
    display: block;
}
.caf-color-input {
    position: absolute;
    inset: 0;
    width: 100%;
    height: 100%;
    border-radius: 50%;
    border: none;
    padding: 0;
    cursor: pointer;
    opacity: 0; /* مخفي — يُفتح بالكليك على الدائرة */
}
.caf-opt-circle-wrap:hover .caf-circle-preview {
    box-shadow: 0 0 0 3px rgba(37,155,234,.35);
}
.caf-opt-circle-wrap::after {
    content: '✏️';
    position: absolute;
    bottom: -2px;
    right: -2px;
    font-size: 10px;
    background: #fff;
    border-radius: 50%;
    line-height: 16px;
    width: 16px;
    height: 16px;
    text-align: center;
    box-shadow: 0 1px 3px rgba(0,0,0,.2);
    pointer-events: none;
}

/* مربع */
.caf-swatch-box {
    min-width: 44px;
    height: 36px;
    border: 1.5px solid #e2e8f0;
    border-radius: 6px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    background: #fff;
    padding: 0 8px;
}

/* حبة */
.caf-swatch-rounded {
    min-width: 70px;
    height: 32px;
    border: 1.5px solid #e2e8f0;
    border-radius: 16px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: #374151;
    background: #fff;
    padding: 0 12px;
}

/* نص */
.caf-swatch-text {
    padding: 5px 10px;
    border: 1.5px solid #e2e8f0;
    border-radius: 5px;
    font-size: 12px;
    background: #f8fafc;
    color: #374151;
}

/* ── VARIATIONS TABLE ── */
.cvs-variations-table { padding: 0; }
.cvt-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.cvt-table th {
    background: #f8fafc;
    padding: 10px 16px;
    text-align: right;
    font-weight: 700;
    color: #475569;
    font-size: 12px;
    border-bottom: 1px solid #e2e8f0;
}
.cvt-table td { padding: 11px 16px; border-bottom: 1px solid #f1f5f9; vertical-align: middle; }
.cvt-table tr:last-child td { border-bottom: none; }
.cvt-table tr:hover td { background: #f8fafc; }
.cvt-price { font-weight: 700; color: #259bea; }
.cvt-price-old { font-size: 11px; color: #94a3b8; text-decoration: line-through; }
.cvt-stock-in  { color: #16a34a; font-weight: 600; font-size: 12px; }
.cvt-stock-out { color: #dc2626; font-weight: 600; font-size: 12px; }
.cvt-no-vars   { padding: 40px; text-align: center; color: #94a3b8; }

/* ── NOTICE ── */
.cof-var-notice {
    position: fixed;
    bottom: 24px;
    right: 24px;
    padding: 12px 20px;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    box-shadow: 0 4px 16px rgba(0,0,0,.15);
    z-index: 9999;
    animation: slideup .3s ease;
}
@keyframes slideup { from { transform: translateY(20px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.cof-var-notice.ok  { background: #d1fae5; color: #065f46; border: 1px solid #a7f3d0; }
.cof-var-notice.err { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ═══════════════════════════════════════════════
   FRONTEND: سمات الفورم (smart-variations)
═══════════════════════════════════════════════ */
.cof-smart-vars { margin: 14px 0; }
.cof-var-group  { margin-bottom: 14px; }

.cof-var-label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
    font-size: 13px;
    font-weight: 700;
    color: #374151;
    flex-wrap: wrap;
}
.cof-var-label-name { }
.cof-var-selected-val {
    color: var(--cof-primary, #259bea);
    font-weight: 600;
}
.cof-var-options {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
}

/* ── دائرة ── */
.cof-var-circle { position: relative; cursor: pointer; }
.cof-var-circle input { position: absolute; opacity: 0; width: 0; height: 0; }
.cof-swatch-circle {
    width: 34px; height: 34px;
    border-radius: 50%;
    display: block;
    border: 3px solid transparent;
    outline: 2px solid transparent;
    transition: all .2s;
    box-shadow: 0 1px 4px rgba(0,0,0,.2);
    cursor: pointer;
}
.cof-var-circle input:checked + .cof-swatch-circle,
.cof-var-circle.selected .cof-swatch-circle {
    border-color: #fff;
    outline-color: var(--cof-primary, #259bea);
    transform: scale(1.15);
    box-shadow: 0 2px 8px rgba(0,0,0,.3);
}
.cof-swatch-tooltip {
    position: absolute;
    bottom: calc(100% + 6px);
    left: 50%;
    transform: translateX(-50%);
    background: #212121;
    color: #fff;
    font-size: 11px;
    padding: 3px 8px;
    border-radius: 4px;
    white-space: nowrap;
    pointer-events: none;
    opacity: 0;
    transition: opacity .2s;
    z-index: 10;
}
.cof-var-circle:hover .cof-swatch-tooltip { opacity: 1; }

/* ── مربع ── */
.cof-var-box { position: relative; cursor: pointer; }
.cof-var-box input { position: absolute; opacity: 0; width: 0; height: 0; }
.cof-swatch-box {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 42px;
    height: 36px;
    padding: 0 10px;
    border: 1.5px solid #d1d5db;
    border-radius: 7px;
    font-size: 13px;
    font-weight: 700;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
}
.cof-var-box input:checked + .cof-swatch-box,
.cof-var-box.selected .cof-swatch-box {
    border-color: var(--cof-primary, #259bea);
    background: var(--cof-primary, #259bea);
    color: #fff;
    box-shadow: 0 2px 8px rgba(37,155,234,.3);
}
.cof-var-box:hover .cof-swatch-box:not(.selected) {
    border-color: var(--cof-primary, #259bea);
}

/* ── حبة مستديرة ── */
.cof-var-rounded { position: relative; cursor: pointer; }
.cof-var-rounded input { position: absolute; opacity: 0; width: 0; height: 0; }
.cof-swatch-rounded {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    height: 32px;
    padding: 0 16px;
    border: 1.5px solid #d1d5db;
    border-radius: 16px;
    font-size: 12px;
    font-weight: 600;
    background: #fff;
    color: #374151;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
    white-space: nowrap;
}
.cof-var-rounded input:checked + .cof-swatch-rounded,
.cof-var-rounded.selected .cof-swatch-rounded {
    border-color: var(--cof-primary, #259bea);
    background: var(--cof-primary, #259bea);
    color: #fff;
}

/* ── نص ── */
.cof-var-text { position: relative; cursor: pointer; }
.cof-var-text input { position: absolute; opacity: 0; width: 0; height: 0; }
.cof-swatch-text {
    display: inline-flex;
    align-items: center;
    padding: 5px 12px;
    border: 1.5px solid #d1d5db;
    border-radius: 5px;
    font-size: 13px;
    background: #f9fafb;
    color: #374151;
    cursor: pointer;
    transition: all .2s;
    user-select: none;
}
.cof-var-text input:checked + .cof-swatch-text,
.cof-var-text.selected .cof-swatch-text {
    border-color: var(--cof-primary, #259bea);
    color: var(--cof-primary, #259bea);
    background: #e8f4fd;
    font-weight: 700;
}

/* ── رسالة الخطأ ── */
.cof-var-error {
    color: #dc2626;
    font-size: 12px;
    font-weight: 600;
    padding: 8px 12px;
    background: #fef2f2;
    border-radius: 6px;
    border: 1px solid #fca5a5;
    margin-top: 8px;
}
