/**
 * CodeMarket Pro Plugin Frontend Styling
 *
 * @package CodeMarket_Pro_Plugin
 * @version 8.0.0
 */

:root {
    --cm-primary: #6366f1;
    --cm-primary-hover: #4f46e5;
    --cm-primary-light: rgba(99, 102, 241, 0.08);
    --cm-secondary: #0ea5e9;
    --cm-accent: #10b981;
    --cm-accent-light: rgba(16, 185, 129, 0.1);
    
    --cm-bg-body: #f8fafc;
    --cm-bg-surface: #ffffff;
    --cm-bg-card: #ffffff;
    --cm-bg-subtle: #f1f5f9;

    --cm-border: #e2e8f0;
    --cm-border-hover: #cbd5e1;
    --cm-border-subtle: #f1f5f9;

    --cm-text-main: #0f172a;
    --cm-text-muted: #64748b;
    --cm-text-light: #94a3b8;

    --cm-font: 'Vazirmatn', -apple-system, BlinkMacSystemFont, 'Segoe UI', Tahoma, Arial, sans-serif;
    --cm-font-mono: 'Fira Code', Consolas, Monaco, monospace;

    --cm-radius-sm: 8px;
    --cm-radius-md: 12px;
    --cm-radius-lg: 16px;
    --cm-radius-full: 9999px;

    --cm-shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
    --cm-shadow-md: 0 4px 16px rgba(15, 23, 42, 0.05);
    --cm-shadow-lg: 0 10px 30px rgba(15, 23, 42, 0.08);

    --cm-transition: all 0.22s cubic-bezier(0.4, 0, 0.2, 1);
}

html.dark-mode {
    --cm-bg-body: #090d16;
    --cm-bg-surface: #111827;
    --cm-bg-card: #151e32;
    --cm-bg-subtle: #1e293b;
    --cm-border: #1e293b;
    --cm-border-hover: #334155;
    --cm-text-main: #f8fafc;
    --cm-text-muted: #94a3b8;
}

/* Base resets for components */
.cm-container { width: 100%; max-width: 1240px; margin-inline: auto; padding-inline: 16px; }

/* Product Cards Grid */
.cm-prod-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(270px, 1fr));
    gap: 24px;
    direction: rtl;
    text-align: right;
    font-family: var(--cm-font);
}
.cm-product-card {
    background: var(--cm-bg-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: var(--cm-transition);
    box-shadow: var(--cm-shadow-sm);
    position: relative;
}
.cm-product-card:hover {
    border-color: var(--cm-border-hover);
    transform: translateY(-4px);
    box-shadow: var(--cm-shadow-md);
}

.cm-card-media {
    position: relative;
    width: 100%;
    aspect-ratio: 16 / 10;
    background: var(--cm-bg-subtle);
    overflow: hidden;
}
.cm-thumb-img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.4s ease;
}
.cm-product-card:hover .cm-thumb-img {
    transform: scale(1.04);
}
.cm-thumb-placeholder {
    width: 100%;
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: var(--cm-text-light);
    font-size: 13px;
    font-weight: 600;
}

.cm-card-badges {
    position: absolute;
    top: 10px;
    inset-inline-start: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 4px;
}
.cm-card-actions-float {
    position: absolute;
    top: 10px;
    inset-inline-end: 10px;
    z-index: 2;
    display: flex;
    flex-direction: column;
    gap: 6px;
}
.cm-float-btn {
    width: 34px;
    height: 34px;
    border-radius: var(--cm-radius-full);
    background: rgba(255, 255, 255, 0.9);
    border: 1px solid var(--cm-border);
    color: #475569;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    backdrop-filter: blur(4px);
    transition: var(--cm-transition);
}
html.dark-mode .cm-float-btn {
    background: rgba(17, 24, 39, 0.85);
    color: #cbd5e1;
}
.cm-float-btn:hover {
    color: var(--cm-primary);
    transform: scale(1.08);
}
.cm-wishlist-btn.active {
    color: #ef4444 !important;
}

/* Badges */
.cm-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 4px 10px;
    border-radius: var(--cm-radius-full);
    font-size: 12px;
    font-weight: 700;
    line-height: 1.3;
}
.cm-badge-sale { background: #fee2e2; color: #dc2626; }
.cm-badge-hot { background: #ffedd5; color: #ea580c; }
.cm-badge-new { background: #e0e7ff; color: #4f46e5; }
.cm-badge-verified { background: #dcfce7; color: #15803d; }
.cm-badge-custom { background: var(--cm-primary-light); color: var(--cm-primary); }

.cm-card-body {
    padding: 18px;
    display: flex;
    flex-direction: column;
    flex: 1;
}
.cm-card-cat {
    font-size: 12px;
    font-weight: 600;
    color: var(--cm-text-muted);
    margin-bottom: 6px;
}
.cm-card-title {
    font-size: 15.5px;
    font-weight: 700;
    line-height: 1.45;
    margin-bottom: 12px;
    color: var(--cm-text-main);
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}
.cm-card-tags {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-bottom: 14px;
    flex-wrap: wrap;
}
.cm-tag-pill {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: var(--cm-bg-subtle);
    border: 1px solid var(--cm-border-subtle);
    padding: 3px 8px;
    border-radius: var(--cm-radius-sm);
    font-size: 11.5px;
    color: var(--cm-text-muted);
}
.cm-card-meta-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    color: var(--cm-text-muted);
    padding-top: 10px;
    border-top: 1px solid var(--cm-border-subtle);
    margin-top: auto;
    margin-bottom: 14px;
}
.cm-card-rating {
    display: flex;
    align-items: center;
    gap: 4px;
}
.cm-star { color: #f59e0b; }
.cm-card-footer {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}
.cm-card-price {
    font-size: 16px;
    font-weight: 800;
    color: var(--cm-primary);
}
.cm-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    font-weight: 700;
    border-radius: var(--cm-radius-md);
    padding: 8px 16px;
    border: 1px solid transparent;
    cursor: pointer;
    transition: var(--cm-transition);
    white-space: nowrap;
    text-align: center;
    line-height: 1.4;
}
.cm-btn-primary { background: var(--cm-primary); color: #ffffff !important; }
.cm-btn-primary:hover { background: var(--cm-primary-hover); }
.cm-btn-sm { padding: 6px 14px; font-size: 13px; }
.cm-btn-lg { padding: 12px 24px; font-size: 15px; }
.cm-btn-outline { border-color: var(--cm-border); background: var(--cm-bg-card); color: var(--cm-text-main); }
.cm-btn-outline:hover { border-color: var(--cm-primary); color: var(--cm-primary); }

/* Quick View Modal */
.cm-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    align-items: center;
    justify-content: center;
    padding: 16px;
    direction: rtl;
    text-align: right;
    font-family: var(--cm-font);
}
.cm-modal.is-active { display: flex; }
.cm-modal-overlay { position: fixed; inset: 0; background: rgba(0,0,0,0.65); backdrop-filter: blur(4px); }
.cm-modal-box { position: relative; background: var(--cm-bg-card); border: 1px solid var(--cm-border); border-radius: var(--cm-radius-lg); width: 100%; max-width: 760px; max-height: 90vh; overflow-y: auto; z-index: 1; box-shadow: var(--cm-shadow-lg); padding: 28px; }
.cm-modal-close { position: absolute; top: 16px; inset-inline-end: 16px; background: var(--cm-bg-subtle); border: 1px solid var(--cm-border); width: 32px; height: 32px; border-radius: 50%; display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--cm-text-muted); }
.cm-quick-view-content { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; }
.cm-qv-img { width: 100%; border-radius: var(--cm-radius-md); aspect-ratio: 16 / 11; object-fit: cover; }
.cm-qv-cat { font-size: 12px; color: var(--cm-text-muted); margin-bottom: 4px; }
.cm-qv-title { font-size: 18px; font-weight: 800; margin-bottom: 10px; line-height: 1.4; color: var(--cm-text-main); }
.cm-qv-price { font-size: 20px; font-weight: 900; color: var(--cm-primary); margin-bottom: 12px; }
.cm-qv-desc { font-size: 13.5px; color: var(--cm-text-muted); margin-bottom: 16px; line-height: 1.7; }
.cm-qv-specs { background: var(--cm-bg-subtle); border-radius: var(--cm-radius-md); padding: 12px; margin-bottom: 18px; display: grid; grid-template-columns: 1fr 1fr; gap: 8px; font-size: 12.5px; }
.cm-qv-actions { display: flex; gap: 10px; }

/* Toast */
.cm-toast {
    position: fixed;
    bottom: 24px;
    inset-inline-start: 24px;
    background: #0f172a;
    color: #f8fafc;
    padding: 12px 20px;
    border-radius: var(--cm-radius-md);
    font-size: 13.5px;
    font-weight: 600;
    box-shadow: var(--cm-shadow-lg);
    z-index: 9999999;
    opacity: 0;
    transform: translateY(20px);
    pointer-events: none;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    font-family: var(--cm-font);
}
.cm-toast.is-visible { opacity: 1; transform: translateY(0); pointer-events: auto; }

/* Search dropdown */
.cm-search-dropdown {
    display: none;
    position: absolute;
    top: calc(100% + 8px);
    inset-inline-start: 0;
    width: 100%;
    background: var(--cm-bg-card);
    border: 1px solid var(--cm-border);
    border-radius: var(--cm-radius-md);
    box-shadow: var(--cm-shadow-lg);
    z-index: 1001;
    overflow: hidden;
    max-height: 400px;
    overflow-y: auto;
}
.cm-search-dropdown.is-visible { display: block; }
.cm-search-item { display: flex; align-items: center; gap: 12px; padding: 10px 14px; border-bottom: 1px solid var(--cm-border-subtle); }
.cm-search-thumb { width: 44px; height: 44px; border-radius: var(--cm-radius-sm); object-fit: cover; }
.cm-search-info { flex: 1; min-width: 0; }
.cm-search-title { font-size: 13.5px; font-weight: 700; color: var(--cm-text-main); }
.cm-search-price { font-size: 13px; font-weight: 800; color: var(--cm-primary); }

@media (max-width: 768px) {
    .cm-quick-view-content { grid-template-columns: 1fr; }
    .cm-prod-grid { grid-template-columns: 1fr; }
}
