/* Monitor Market Core — Plugin-Specific Styles */

/* Admin Dashboard KPI cards */
.mmc-admin-wrap { max-width: 1200px; margin: 0 auto; padding: 20px; }
.mmc-admin-wrap h1 { margin-bottom: 20px; }
.mmc-admin-wrap .wp-list-table { background: #fff; border-radius: 12px; overflow: hidden; }

/* CRM grid responsive */
@media (max-width: 782px) {
    .mmc-crm-detail { grid-template-columns: 1fr !important; }
    .mmc-admin-wrap .wp-list-table td, .mmc-admin-wrap .wp-list-table th { padding: 8px; font-size: 12px; }
}

/* Vehicle Browser widget */
.mmc-vehicle-browser select {
    min-height: 40px;
}
.mmc-vehicle-browser button:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Quote/Invoice printable */
@media print {
    .mmc-invoice { font-family: Vazirmatn, Tahoma, sans-serif; direction: rtl; }
    .mmc-invoice table { width: 100%; border-collapse: collapse; }
    .mmc-invoice th, .mmc-invoice td { padding: 8px; border: 1px solid #ddd; text-align: right; }
}

/* Compatibility request form */
.mm-compat-form textarea { width: 100%; min-height: 80px; padding: 10px; border: 1px solid #ddd; border-radius: 8px; }
.mm-compat-form button { background: var(--mm-red, #EF233C); color: #fff; padding: 12px 24px; border: none; border-radius: 8px; cursor: pointer; font-weight: 600; }

/* Ticket list */
.mm-ticket-list { list-style: none; padding: 0; }
.mm-ticket-list li { padding: 12px; border-bottom: 1px solid #eee; }

/* Product comparison table */
.mm-comparison-table table { width: 100%; border-collapse: collapse; }
.mm-comparison-table th, .mm-comparison-table td { padding: 12px; border: 1px solid var(--mm-border-light, #E5EAF1); text-align: center; }
.mm-comparison-table th { background: #F8FAFC; font-weight: 600; }

/* Recently viewed products */
.mm-recently-viewed .products { display: grid; grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 16px; list-style: none; padding: 0; }
.mm-recently-viewed .product img { width: 100%; aspect-ratio: 1/1; object-fit: cover; border-radius: 8px; }

/* Admin settings tabs */
.mmc-settings-wrap .nav-tab-wrapper { margin-bottom: 20px; }

/* Module manager toggle */
.mmc-module-enabled { color: var(--mm-green, #10B981); }
.mmc-module-disabled { color: var(--mm-danger, #DC2626); }

/* Persian price formatting */
.mmc-price, .woocommerce-Price-amount, .price ins .amount, .price del .amount {
    direction: ltr;
    unicode-bidi: embed;
    font-feature-settings: "numr";
}

/* Jalali date display */
.mmc-jalali-date {
    font-family: var(--mm-font-num, Vazirmatn, Tahoma, Arial, sans-serif);
    direction: ltr;
}

/* RTL icon flip for directional icons */
[dir="rtl"] .mmc-icon-flip {
    transform: scaleX(-1);
}

/* ── Mobile Responsive ──────────────────────────────────────────── */

/* Dashboard chart grid */
@media (max-width: 782px) {
    .mmc-admin-wrap .mmc-chart-grid {
        grid-template-columns: 1fr !important;
    }
    .mmc-admin-wrap canvas {
        max-height: 250px;
    }
}

/* Admin tables — horizontal scroll on mobile */
@media (max-width: 782px) {
    .mmc-admin-wrap table.widefat {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }
    .mmc-admin-wrap .form-table th {
        min-width: 120px;
    }
}

/* Quotes forms */
@media (max-width: 782px) {
    .mmc-quote-form-row {
        flex-direction: column;
    }
    .mmc-quote-form-row > * {
        width: 100%;
    }
}

/* Module Manager */
@media (max-width: 782px) {
    .mmc-admin-wrap .wp-list-table th:nth-child(4),
    .mmc-admin-wrap .wp-list-table td:nth-child(4) {
        display: none;
    }
}

/* ── Loading States ─────────────────────────────────────────────── */
.mmc-loading {
    position: relative;
    opacity: 0.6;
    pointer-events: none;
}
.mmc-loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 20px;
    height: 20px;
    margin: -10px 0 0 -10px;
    border: 2px solid var(--mm-border, #d1d5db);
    border-top-color: var(--mm-red);
    border-radius: 50%;
    animation: mmc-spin 0.6s linear infinite;
}
@keyframes mmc-spin {
    to { transform: rotate(360deg); }
}

/* Skeleton loader */
.mmc-skeleton {
    background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
    background-size: 200% 100%;
    animation: mmc-shimmer 1.5s infinite;
    border-radius: 4px;
}
@keyframes mmc-shimmer {
    0% { background-position: 200% 0; }
    100% { background-position: -200% 0; }
}

/* ── Admin Cards ────────────────────────────────────────────────── */
.mmc-card {
    background: var(--mm-white, #fff);
    border: 1px solid var(--mm-border-light, #E5EAF1);
    border-radius: 16px;
    padding: 18px;
    margin-bottom: 18px;
}
.mmc-card h2 {
    margin: 0 0 12px;
    color: var(--mm-navy, #0B132B);
    font-size: 16px;
}
.mmc-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

/* KPI cards */
.mmc-kpi {
    background: var(--mm-white, #fff);
    border: 1px solid var(--mm-border-light, #E5EAF1);
    border-radius: 12px;
    padding: 16px;
    text-align: center;
}
.mmc-kpi-value {
    font-size: 28px;
    font-weight: 700;
    color: var(--mm-navy, #0B132B);
    margin: 8px 0;
}
.mmc-kpi-label {
    font-size: 13px;
    color: var(--mm-muted, #6B7280);
}

/* Form helpers */
.mmc-form-row {
    display: flex;
    gap: 16px;
    align-items: flex-end;
    flex-wrap: wrap;
}
.mmc-form-row > * {
    flex: 1;
    min-width: 200px;
}

/* Table wrapper */
.mmc-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

/* ── Feedback Messages ──────────────────────────────────────────── */
.mmc-notice {
    padding: 12px 16px;
    border-radius: 8px;
    margin-bottom: 16px;
    font-size: 14px;
}
.mmc-notice-success {
    background: #EAFAF4;
    border: 1px solid #10B981;
    color: #065F46;
}
.mmc-notice-error {
    background: #FEF2F2;
    border: 1px solid #DC2626;
    color: #991B1B;
}
.mmc-notice-warning {
    background: #FFF7DF;
    border: 1px solid #F59E0B;
    color: #92400E;
}
.mmc-notice-info {
    background: #ECF8FF;
    border: 1px solid #2563EB;
    color: #1E40AF;
}

/* ── Dashboard KPI Cards ────────────────────────────────────────── */
.mmc-kpi-card { background: #fff; border: 1px solid #dcdcde; border-radius: 8px; padding: 16px; min-width: 180px; }
.mmc-kpi-card-label { font-size: 13px; color: #646970; }
.mmc-kpi-card-value { font-size: 28px; font-weight: 700; }
.mmc-kpi-card-value--ltr { direction: ltr; text-align: right; }
.mmc-chart-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 16px; margin-top: 16px; }
.mmc-kpi-row { display: flex; gap: 16px; flex-wrap: wrap; margin-top: 16px; }

/* ── Form States ──────────────────────────────────────────────── */
.mmc-form-group input:disabled,
.mmc-form-group select:disabled,
.mmc-form-group textarea:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background: var(--mm-soft, #f5f5f5);
}
.mmc-form-group input:invalid {
    border-color: var(--mm-danger, #DC2626);
}

/* ── Tablet Breakpoint ──────────────────────────────────────────── */
@media (max-width: 1024px) {
    .mmc-kpi-row {
        grid-template-columns: repeat(2, 1fr);
    }
    .mmc-chart-grid {
        grid-template-columns: 1fr;
    }
    .mmc-admin-wrap .wp-list-table {
        font-size: 13px;
    }
}
