/**
 * Smart Product Compare – Frontend Styles
 * Modern, clean, mobile-first design system
 */

/* ============================================================
   CSS Variables – Design Tokens
   ============================================================ */
:root {
    --sc-primary: #2563eb;
    --sc-primary-hover: #1d4ed8;
    --sc-primary-light: #dbeafe;
    --sc-success: #10b981;
    --sc-danger: #ef4444;
    --sc-warning: #f59e0b;
    --sc-gray-50: #f9fafb;
    --sc-gray-100: #f3f4f6;
    --sc-gray-200: #e5e7eb;
    --sc-gray-300: #d1d5db;
    --sc-gray-400: #9ca3af;
    --sc-gray-500: #6b7280;
    --sc-gray-600: #4b5563;
    --sc-gray-700: #374151;
    --sc-gray-800: #1f2937;
    --sc-gray-900: #111827;
    --sc-radius: 12px;
    --sc-radius-sm: 8px;
    --sc-shadow: 0 4px 6px -1px rgb(0 0 0 / 0.07), 0 2px 4px -2px rgb(0 0 0 / 0.05);
    --sc-shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.08), 0 4px 6px -4px rgb(0 0 0 / 0.05);
    --sc-shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.08);
    --sc-transition: 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --sc-font: inherit;
}

/* ============================================================
   Compare Button
   ============================================================ */
.sc-compare-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    font-size: 14px;
    font-weight: 500;
    line-height: 1.4;
    border: 1.5px solid var(--sc-gray-300);
    border-radius: var(--sc-radius-sm);
    background: #fff;
    color: var(--sc-gray-700);
    cursor: pointer;
    transition: all var(--sc-transition);
    margin-top: 10px;
}

.sc-compare-btn:hover {
    border-color: var(--sc-primary);
    color: var(--sc-primary);
    background: var(--sc-primary-light);
}

.sc-compare-btn--added {
    border-color: var(--sc-success);
    background: #ecfdf5;
    color: #047857;
}

.sc-compare-btn--added:hover {
    background: #d1fae5;
    border-color: #059669;
}

.sc-compare-btn__icon {
    display: flex;
    align-items: center;
}

.sc-compare-btn--loop {
    width: 100%;
    justify-content: center;
    margin-top: 8px;
    padding: 8px 14px;
    font-size: 13px;
}

/* ============================================================
   Floating Bar
   ============================================================ */
.sc-floating-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    z-index: 99990;
    background: #fff;
    border-top: 1px solid var(--sc-gray-200);
    box-shadow: 0 -4px 20px rgb(0 0 0 / 0.08);
    transform: translateY(100%);
    transition: transform 0.35s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 12px 16px;
}

.sc-floating-bar.is-visible {
    transform: translateY(0);
}

.sc-floating-bar__inner {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
}

.sc-floating-bar__info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sc-floating-bar__icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 42px;
    height: 42px;
    background: var(--sc-primary-light);
    color: var(--sc-primary);
    border-radius: 50%;
}

.sc-floating-bar__count {
    font-size: 14px;
    color: var(--sc-gray-600);
}

.sc-floating-bar__count strong {
    font-size: 18px;
    font-weight: 700;
    color: var(--sc-gray-900);
    margin-left: 4px;
}

.sc-floating-bar__actions {
    display: flex;
    gap: 10px;
}

/* ============================================================
   Buttons System
   ============================================================ */
.sc-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    font-size: 14px;
    font-weight: 600;
    border-radius: var(--sc-radius-sm);
    border: none;
    cursor: pointer;
    transition: all var(--sc-transition);
    line-height: 1.4;
}

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

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

.sc-btn--primary:hover:not(:disabled) {
    background: var(--sc-primary-hover);
}

.sc-btn--ghost {
    background: transparent;
    color: var(--sc-gray-600);
}

.sc-btn--ghost:hover:not(:disabled) {
    background: var(--sc-gray-100);
    color: var(--sc-gray-800);
}

.sc-btn--outline {
    background: #fff;
    border: 1.5px solid var(--sc-gray-300);
    color: var(--sc-gray-700);
}

.sc-btn--outline:hover {
    border-color: var(--sc-primary);
    color: var(--sc-primary);
}

/* ============================================================
   Modal
   ============================================================ */
.sc-modal-root {
    position: fixed;
    inset: 0;
    z-index: 99999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.sc-modal-root.is-open {
    opacity: 1;
    visibility: visible;
}

.sc-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgb(0 0 0 / 0.5);
    backdrop-filter: blur(4px);
}

.sc-modal {
    position: relative;
    background: #fff;
    border-radius: 16px;
    width: 100%;
    max-width: 1100px;
    max-height: 90vh;
    overflow: hidden;
    box-shadow: var(--sc-shadow-xl);
    transform: translateY(20px) scale(0.98);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
}

.sc-modal-root.is-open .sc-modal {
    transform: translateY(0) scale(1);
}

.sc-modal__header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 24px;
    border-bottom: 1px solid var(--sc-gray-200);
}

.sc-modal__title {
    font-size: 18px;
    font-weight: 700;
    color: var(--sc-gray-900);
    margin: 0;
}

.sc-modal__close {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: none;
    background: var(--sc-gray-100);
    border-radius: 50%;
    cursor: pointer;
    color: var(--sc-gray-600);
    transition: all var(--sc-transition);
}

.sc-modal__close:hover {
    background: var(--sc-gray-200);
    color: var(--sc-gray-900);
}

.sc-modal__body {
    overflow: auto;
    padding: 0;
    flex: 1;
}

/* ============================================================
   Comparison Table
   ============================================================ */
.sc-compare-wrapper {
    background: #fff;
}

.sc-compare-toolbar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 20px;
    border-bottom: 1px solid var(--sc-gray-200);
    background: var(--sc-gray-50);
    gap: 12px;
    flex-wrap: wrap;
}

.sc-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.sc-compare-table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    min-width: 640px;
}

.sc-compare-table th,
.sc-compare-table td {
    padding: 16px;
    text-align: center;
    vertical-align: middle;
    border-bottom: 1px solid var(--sc-gray-200);
    min-width: 180px;
}

.sc-compare-table th:first-child,
.sc-compare-table td:first-child {
    text-align: right;
    font-weight: 600;
    color: var(--sc-gray-700);
    background: var(--sc-gray-50);
    position: sticky;
    right: 0;
    z-index: 2;
    min-width: 140px;
    max-width: 160px;
}

.sc-product-header {
    position: relative;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 10px;
    padding-top: 8px;
}

.sc-remove-product {
    position: absolute;
    top: -4px;
    left: -4px;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    border: none;
    background: #fff;
    border-radius: 50%;
    box-shadow: var(--sc-shadow);
    cursor: pointer;
    color: var(--sc-gray-500);
    transition: all var(--sc-transition);
    z-index: 1;
}

.sc-remove-product:hover {
    background: var(--sc-danger);
    color: #fff;
}

.sc-product-image-link {
    display: block;
    width: 100px;
    height: 100px;
    border-radius: var(--sc-radius-sm);
    overflow: hidden;
    background: var(--sc-gray-100);
}

.sc-product-image-link img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.sc-product-title {
    font-size: 14px;
    font-weight: 600;
    margin: 0;
    line-height: 1.4;
}

.sc-product-title a {
    color: var(--sc-gray-900);
    text-decoration: none;
}

.sc-product-title a:hover {
    color: var(--sc-primary);
}

/* Badges */
.sc-badge {
    display: inline-flex;
    align-items: center;
    padding: 4px 10px;
    font-size: 12px;
    font-weight: 600;
    border-radius: 999px;
}

.sc-badge--in-stock {
    background: #ecfdf5;
    color: #047857;
}

.sc-badge--out-of-stock {
    background: #fef2f2;
    color: #b91c1c;
}

.sc-badge--backorder {
    background: #fffbeb;
    color: #b45309;
}

/* Rating */
.sc-rating {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 2px;
}

.sc-rating__stars {
    position: relative;
    display: inline-block;
    color: var(--sc-gray-300);
    font-size: 16px;
    letter-spacing: 1px;
}

.sc-rating__stars::before {
    content: '★★★★★';
    position: absolute;
    left: 0;
    top: 0;
    width: var(--rating, 0%);
    overflow: hidden;
    color: #f59e0b;
}

.sc-rating__count {
    font-size: 12px;
    color: var(--sc-gray-500);
}

.sc-price {
    font-weight: 700;
    font-size: 15px;
    color: var(--sc-gray-900);
}

.sc-muted {
    color: var(--sc-gray-400);
}

/* Difference highlighting */
.sc-compare-wrapper[data-highlight="1"] .sc-row td.is-different {
    background: #fef3c7;
}

.sc-compare-wrapper.is-diff-only .sc-row.is-same {
    display: none;
}

/* Add to cart in table */
.sc-compare-table .button,
.sc-compare-table .sc-add-to-cart,
.sc-compare-table .sc-view-product {
    display: inline-flex;
    padding: 8px 16px;
    font-size: 13px;
    font-weight: 600;
    border-radius: var(--sc-radius-sm);
    background: var(--sc-primary);
    color: #fff !important;
    text-decoration: none;
    border: none;
    transition: background var(--sc-transition);
}

.sc-compare-table .button:hover,
.sc-compare-table .sc-add-to-cart:hover {
    background: var(--sc-primary-hover);
}

/* Empty State */
.sc-empty-state {
    text-align: center;
    padding: 60px 20px;
    color: var(--sc-gray-500);
}

.sc-empty-state__icon {
    margin-bottom: 16px;
    color: var(--sc-gray-300);
}

.sc-empty-state h3 {
    font-size: 18px;
    font-weight: 600;
    color: var(--sc-gray-700);
    margin: 0 0 8px;
}

.sc-empty-state p {
    margin: 0;
    font-size: 14px;
}

/* ============================================================
   Toast Notification
   ============================================================ */
.sc-toast {
    position: fixed;
    bottom: 100px;
    left: 50%;
    transform: translateX(-50%) translateY(20px);
    background: var(--sc-gray-900);
    color: #fff;
    padding: 12px 24px;
    border-radius: 999px;
    font-size: 14px;
    font-weight: 500;
    box-shadow: var(--sc-shadow-lg);
    z-index: 100000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    white-space: nowrap;
}

.sc-toast.is-visible {
    opacity: 1;
    visibility: visible;
    transform: translateX(-50%) translateY(0);
}

/* ============================================================
   Floating Bar – Compact Style (Style 2)
   ============================================================ */
.sc-floating-bar--compact {
    max-width: 440px;
    right: 10%;
    left: auto;
    bottom: 0;
    border-radius: 15px;
    border: 1px solid var(--sc-gray-200);
    box-shadow: var(--sc-shadow-xl);
}

.sc-floating-bar--compact.is-visible {
    bottom: 4%;
}

.sc-floating-bar--compact .sc-floating-bar__inner {
    padding: 4px 0;
}

/* RTL Compact default */
[dir="rtl"] .sc-floating-bar--compact {
    left: auto;
    right: 10%;
}

/* ============================================================
   Responsive
   ============================================================ */
@media (max-width: 768px) {
    .sc-floating-bar__inner {
        flex-direction: column;
        gap: 12px;
    }

    .sc-floating-bar__actions {
        width: 100%;
    }

    .sc-floating-bar__actions .sc-btn {
        flex: 1;
    }

    .sc-compare-table th,
    .sc-compare-table td {
        padding: 12px 10px;
        min-width: 140px;
    }

    .sc-compare-table th:first-child,
    .sc-compare-table td:first-child {
        min-width: 120px;
        max-width: 155px;
    }

    .sc-product-image-link {
        width: 70px;
        height: 70px;
    }

    .sc-modal-root {
        padding: 0;
    }

    .sc-modal {
        max-height: 88vh;
        border-radius: 12px 12px 0 0;
        margin-top: auto;
    }
}

/* Tablet and below */
@media screen and (max-width: 1024px) {
    [dir="rtl"] .sc-floating-bar--compact {
        left: auto;
        right: 2%;
    }
}

/* Mobile specific for compact bar */
/* Mobile specific – فقط برای حالت جمع‌شونده (compact) */
@media screen and (max-width: 767px) {
    .sc-floating-bar--compact .sc-floating-bar__icon {
        width: 23px;
        height: 23px;
    }

    .sc-floating-bar--compact .sc-floating-bar__icon svg {
        width: 13px;
    }

    .sc-floating-bar--compact .sc-floating-bar__count {
        font-size: 13px;
    }

    .sc-floating-bar--compact .sc-floating-bar__inner {
        align-items: flex-start;
    }

    [dir="rtl"] .sc-floating-bar--compact {
        right: auto;
        left: 0%;
        border-radius: 0 8px 8px 0;
        width: 65%;
        padding: 8px 16px 8px 8px;
    }

    .sc-floating-bar--compact button#sc-clear-compare {
        border: 1px solid #d1d5db;
    }
}

/* RTL refinements */
[dir="rtl"] .sc-compare-table th:first-child,
[dir="rtl"] .sc-compare-table td:first-child {
    text-align: right;
}

[dir="rtl"] .sc-remove-product {
    left: auto;
    right: -4px;
}
