/* ══════════════════════════════════════════════════════════════
 *  Iran Busbar Proforma — Frontend Stylesheet
 *
 *  Design System: Light theme matching iranbusbar.com
 *  Colors: White/light grey backgrounds, #d97706 (copper/orange) accent,
 *          #1e293b (dark slate) text, #f8fafc surfaces.
 *  Font:   KFC (loaded by Elementor), fallback Vazirmatn.
 *  Scoped: All selectors under .ibp-wrap to avoid theme conflicts.
 * ══════════════════════════════════════════════════════════════ */

/* ── CSS Custom Properties ── */
.ibp-wrap {
    --ibp-font: KFC, Vazirmatn, Tahoma, sans-serif;
    --ibp-bg-primary: #ffffff;
    --ibp-bg-secondary: #f8fafc;
    --ibp-bg-tertiary: #f1f5f9;
    --ibp-text-primary: #1e293b;
    --ibp-text-secondary: #475569;
    --ibp-text-muted: #94a3b8;
    --ibp-accent: #d97706;
    --ibp-accent-hover: #b45309;
    --ibp-accent-light: #fef3c7;
    --ibp-accent-subtle: #fffbeb;
    --ibp-border: #e2e8f0;
    --ibp-border-subtle: #f1f5f9;
    --ibp-success: #059669;
    --ibp-success-light: #d1fae5;
    --ibp-danger: #dc2626;
    --ibp-danger-light: #fee2e2;
    --ibp-radius: 8px;
    --ibp-radius-lg: 12px;
    --ibp-shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
    --ibp-shadow-md: 0 4px 12px rgba(0,0,0,0.08);
    --ibp-transition: 0.2s ease;
}

/* ── Base ── */
.ibp-wrap {
    direction: rtl;
    text-align: right;
    font-family: var(--ibp-font);
    color: var(--ibp-text-primary);
    background: var(--ibp-bg-primary);
    max-width: 960px;
    margin: 24px auto;
    padding: 28px 32px;
    border-radius: var(--ibp-radius-lg);
    border: 1px solid var(--ibp-border);
    box-shadow: var(--ibp-shadow);
    line-height: 1.7;
}

.ibp-wrap *,
.ibp-wrap *::before,
.ibp-wrap *::after {
    box-sizing: border-box;
}

/* ══════════════════════════════════════════
 *  Header
 * ══════════════════════════════════════════ */
.ibp-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 24px;
    padding-bottom: 18px;
    border-bottom: 3px solid var(--ibp-accent);
}

.ibp-header__brand {
    flex: 1;
    min-width: 200px;
}

.ibp-header__title {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--ibp-text-primary);
    margin: 0 0 4px;
    letter-spacing: -0.01em;
}

.ibp-header__subtitle {
    font-size: 0.85rem;
    color: var(--ibp-text-muted);
    margin: 0;
}

/* ══════════════════════════════════════════
 *  Product Selector
 * ══════════════════════════════════════════ */
.ibp-selector {
    background: var(--ibp-bg-secondary);
    border: 1px solid var(--ibp-border);
    border-radius: var(--ibp-radius-lg);
    padding: 20px 24px;
    margin-bottom: 24px;
}

/* ── Filter Row ── */
.ibp-selector__filters {
    display: flex;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
    margin-bottom: 16px;
    padding-bottom: 16px;
    border-bottom: 1px dashed var(--ibp-border);
}

.ibp-selector__field--filter {
    flex: 1;
    min-width: 140px;
    max-width: 260px;
}

.ibp-selector__field--filter label {
    display: flex;
    align-items: center;
    gap: 5px;
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ibp-text-secondary);
    margin-bottom: 5px;
}

.ibp-selector__field--filter label::before {
    content: '';
    display: inline-block;
    width: 7px;
    height: 7px;
    border-radius: 50%;
    background: var(--ibp-accent);
}

/* ── Main Row ── */
.ibp-selector__row {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    flex-wrap: wrap;
}

.ibp-selector__field {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.ibp-selector__field label {
    font-size: 0.82rem;
    font-weight: 600;
    color: var(--ibp-text-secondary);
}

.ibp-selector__field--product {
    flex: 2;
    min-width: 220px;
}

.ibp-selector__field--qty {
    flex: 0 0 130px;
}

.ibp-selector__field--btn {
    flex: 0 0 auto;
}

/* ── Inputs ── */
.ibp-wrap select,
.ibp-wrap input[type="number"] {
    font-family: var(--ibp-font);
    font-size: 0.9rem;
    padding: 9px 12px;
    border: 1px solid var(--ibp-border);
    border-radius: var(--ibp-radius);
    background: var(--ibp-bg-primary);
    color: var(--ibp-text-primary);
    direction: rtl;
    transition: border-color var(--ibp-transition), box-shadow var(--ibp-transition);
    width: 100%;
    outline: none;
}

.ibp-wrap select:focus,
.ibp-wrap input[type="number"]:focus {
    border-color: var(--ibp-accent);
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

/* ── Hint ── */
.ibp-selector__hint {
    margin-top: 8px;
    font-size: 0.82rem;
    color: var(--ibp-accent);
    min-height: 1.4em;
    font-weight: 500;
}

/* ══════════════════════════════════════════
 *  Buttons
 * ══════════════════════════════════════════ */

/* Base button reset */
.ibp-btn {
    font-family: var(--ibp-font);
    font-weight: 600;
    border: none;
    cursor: pointer;
    border-radius: var(--ibp-radius);
    transition: all var(--ibp-transition);
    display: inline-flex;
    align-items: center;
    gap: 6px;
    text-decoration: none;
    line-height: 1.2;
}

/* Primary: Add to cart */
.ibp-btn--primary {
    background: var(--ibp-accent);
    color: #ffffff;
    padding: 9px 18px;
    font-size: 0.88rem;
}

.ibp-btn--primary:hover {
    background: var(--ibp-accent-hover);
}

.ibp-btn__icon {
    font-size: 1.1rem;
    font-weight: 700;
    line-height: 1;
    color: #ffffff;
}

/* Generate button */
.ibp-btn--generate {
    background: var(--ibp-accent);
    color: #ffffff;
    padding: 14px 36px;
    font-size: 1rem;
    font-weight: 700;
    border-radius: var(--ibp-radius);
    width: 100%;
    justify-content: center;
    letter-spacing: 0.01em;
    box-shadow: 0 2px 8px rgba(217, 119, 6, 0.25);
}

.ibp-btn--generate:hover {
    background: var(--ibp-accent-hover);
    box-shadow: 0 4px 16px rgba(217, 119, 6, 0.35);
    transform: translateY(-1px);
}

.ibp-btn--generate:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Remove button */
.ibp-btn--remove {
    background: var(--ibp-danger-light);
    color: var(--ibp-danger);
    border: 1px solid #fca5a5;
    padding: 4px 10px;
    font-size: 0.85rem;
    cursor: pointer;
    border-radius: 6px;
    font-family: var(--ibp-font);
    font-weight: 600;
    line-height: 1.2;
    transition: all var(--ibp-transition);
}

.ibp-btn--remove:hover {
    background: var(--ibp-danger);
    color: #ffffff;
    border-color: var(--ibp-danger);
}

/* Download PDF */
.ibp-btn--download {
    background: var(--ibp-success);
    color: #ffffff;
    padding: 12px 28px;
    font-size: 0.95rem;
    text-decoration: none;
    justify-content: center;
}

.ibp-btn--download:hover {
    background: #047857;
}

/* Secondary: New proforma */
.ibp-btn--secondary {
    background: transparent;
    color: var(--ibp-text-secondary);
    border: 1px solid var(--ibp-border);
    padding: 10px 22px;
    font-size: 0.88rem;
    font-family: var(--ibp-font);
    cursor: pointer;
}

.ibp-btn--secondary:hover {
    background: var(--ibp-bg-secondary);
    border-color: var(--ibp-text-muted);
    color: var(--ibp-text-primary);
}

/* ══════════════════════════════════════════
 *  Cart Table
 * ══════════════════════════════════════════ */
.ibp-cart {
    margin-bottom: 24px;
}

.ibp-cart__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ibp-text-primary);
    margin: 0 0 14px;
}

.ibp-cart__empty {
    text-align: center;
    padding: 32px 20px;
    color: var(--ibp-text-muted);
}

.ibp-cart__empty svg {
    margin-bottom: 10px;
    opacity: 0.4;
}

.ibp-cart__empty p {
    font-size: 0.88rem;
    margin: 0;
}

.ibp-cart__table-wrap {
    overflow-x: auto;
    border-radius: var(--ibp-radius);
    border: 1px solid var(--ibp-border);
}

/* ── Table ── */
.ibp-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
    white-space: nowrap;
}

.ibp-table thead th {
    background: var(--ibp-text-primary);
    color: #ffffff;
    padding: 10px 10px;
    font-weight: 600;
    text-align: center;
    font-size: 0.8rem;
    border: none;
    border-bottom: 2px solid var(--ibp-accent);
}

.ibp-table tbody td {
    padding: 9px 10px;
    text-align: center;
    border-bottom: 1px solid var(--ibp-border);
    font-variant-numeric: tabular-nums;
}

.ibp-table tbody tr:nth-child(even) {
    background: var(--ibp-bg-secondary);
}

.ibp-table tbody tr:hover {
    background: var(--ibp-accent-light);
}

/* Row entrance animation */
@keyframes ibp-row-enter {
    from {
        opacity: 0;
        transform: translateX(20px);
    }
    to {
        opacity: 1;
        transform: translateX(0);
    }
}

.ibp-row-new {
    animation: ibp-row-enter 0.35s ease-out;
}

/* ══════════════════════════════════════════
 *  Summary Box
 * ══════════════════════════════════════════ */
.ibp-summary {
    margin-bottom: 24px;
}

.ibp-summary__title {
    font-size: 1rem;
    font-weight: 700;
    color: var(--ibp-text-primary);
    margin: 0 0 14px;
}

.ibp-summary__grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 14px;
}

.ibp-summary__item {
    background: var(--ibp-bg-secondary);
    border: 1px solid var(--ibp-border);
    border-radius: var(--ibp-radius);
    padding: 14px 16px;
    text-align: center;
}

.ibp-summary__item--total {
    background: var(--ibp-accent-subtle);
    border-color: var(--ibp-accent);
}

.ibp-summary__label {
    display: block;
    font-size: 0.78rem;
    color: var(--ibp-text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.ibp-summary__value {
    display: block;
    font-size: 1.15rem;
    font-weight: 700;
    color: var(--ibp-text-primary);
    font-variant-numeric: tabular-nums;
}

.ibp-summary__item--total .ibp-summary__value {
    color: var(--ibp-accent);
}

.ibp-summary__unit {
    display: block;
    font-size: 0.72rem;
    color: var(--ibp-text-muted);
    margin-top: 2px;
}

/* Value pop animation */
@keyframes ibp-pop {
    0% { transform: scale(1); }
    50% { transform: scale(1.08); }
    100% { transform: scale(1); }
}

.ibp-updated {
    animation: ibp-pop 0.3s ease;
}

/* ══════════════════════════════════════════
 *  Actions Section
 * ══════════════════════════════════════════ */
.ibp-actions {
    margin-bottom: 24px;
}

/* ══════════════════════════════════════════
 *  Result Card
 * ══════════════════════════════════════════ */
.ibp-result__card {
    text-align: center;
    background: var(--ibp-bg-secondary);
    border: 1px solid var(--ibp-border);
    border-radius: var(--ibp-radius-lg);
    padding: 36px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 14px;
}

.ibp-result__message {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--ibp-success);
    margin: 0;
}

.ibp-result__proforma-num {
    font-size: 0.9rem;
    color: var(--ibp-text-secondary);
    margin: 0;
    font-variant-numeric: tabular-nums;
}

/* ══════════════════════════════════════════
 *  Loading Overlay
 * ══════════════════════════════════════════ */
.ibp-loading {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.85);
    backdrop-filter: blur(4px);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 16px;
    z-index: 99999;
}

.ibp-loading p {
    font-family: var(--ibp-font);
    font-size: 0.95rem;
    color: var(--ibp-text-secondary);
    font-weight: 600;
}

@keyframes ibp-spin {
    to { transform: rotate(360deg); }
}

.ibp-loading__spinner {
    width: 40px;
    height: 40px;
    border: 4px solid var(--ibp-border);
    border-top-color: var(--ibp-accent);
    border-radius: 50%;
    animation: ibp-spin 0.8s linear infinite;
}

/* ══════════════════════════════════════════
 *  User Dashboard (shortcode: busbar_user_proformas)
 * ══════════════════════════════════════════ */
.ibp-dashboard__title {
    font-size: 1.2rem;
    font-weight: 700;
    margin: 0 0 20px;
    color: var(--ibp-text-primary);
}

.ibp-dashboard__empty {
    text-align: center;
    padding: 28px;
    color: var(--ibp-text-muted);
    font-size: 0.9rem;
}

.ibp-dashboard-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.84rem;
}

.ibp-dashboard-table thead th {
    background: var(--ibp-text-primary);
    color: #ffffff;
    padding: 10px 12px;
    font-weight: 600;
    text-align: center;
    font-size: 0.8rem;
}

.ibp-dashboard-table tbody td {
    padding: 9px 12px;
    text-align: center;
    border-bottom: 1px solid var(--ibp-border);
}

.ibp-dashboard-table tbody tr:nth-child(even) {
    background: var(--ibp-bg-secondary);
}

.ibp-dashboard-table tbody tr:hover {
    background: var(--ibp-accent-light);
}

.ibp-dashboard-table a {
    color: var(--ibp-accent);
    text-decoration: none;
    font-weight: 600;
}

.ibp-dashboard-table a:hover {
    color: var(--ibp-accent-hover);
    text-decoration: underline;
}

/* ══════════════════════════════════════════
 *  Login Required Message
 * ══════════════════════════════════════════ */
.ibp-login-required {
    text-align: center;
    padding: 40px 20px;
}

.ibp-login-required h2 {
    font-size: 1.3rem;
    color: var(--ibp-text-primary);
    margin-bottom: 10px;
}

.ibp-login-required p {
    color: var(--ibp-text-muted);
    margin-bottom: 18px;
}

.ibp-login-required a.ibp-btn {
    background: var(--ibp-accent);
    color: #ffffff;
    padding: 10px 24px;
    font-size: 0.9rem;
    text-decoration: none;
    display: inline-flex;
}

.ibp-login-required a.ibp-btn:hover {
    background: var(--ibp-accent-hover);
}

/* ══════════════════════════════════════════
 *  Responsive
 * ══════════════════════════════════════════ */
@media (max-width: 768px) {
    .ibp-summary__grid {
        grid-template-columns: 1fr 1fr;
    }
}

@media (max-width: 640px) {
    .ibp-wrap {
        padding: 16px 14px;
        margin: 12px;
        border-radius: var(--ibp-radius);
    }

    .ibp-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .ibp-header__title {
        font-size: 1.3rem;
    }

    .ibp-selector__filters {
        flex-direction: column;
    }

    .ibp-selector__field--filter {
        width: 100%;
        max-width: unset;
        min-width: unset;
    }

    .ibp-selector__row {
        flex-direction: column;
    }

    .ibp-selector__field--product,
    .ibp-selector__field--qty,
    .ibp-selector__field--btn {
        width: 100%;
        min-width: unset;
    }

    .ibp-selector__field--btn .ibp-btn {
        width: 100%;
        justify-content: center;
    }

    .ibp-summary__grid {
        grid-template-columns: 1fr 1fr;
    }

    .ibp-table {
        font-size: 0.75rem;
    }

    .ibp-table thead th,
    .ibp-table tbody td {
        padding: 7px 6px;
    }

    .ibp-result__card {
        padding: 24px 16px;
    }

    .ibp-btn--generate {
        font-size: 0.92rem;
        padding: 12px 20px;
    }
}

@media (max-width: 400px) {
    .ibp-summary__grid {
        grid-template-columns: 1fr;
    }
}
/* ??????????????????????????????????????????
 *  Buyer Profile Modal
 * ?????????????????????????????????????????? */
.ibp-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.7);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100000;
    padding: 20px;
}

.ibp-modal__content {
    background: var(--ibp-bg-primary);
    width: 100%;
    max-width: 600px;
    border-radius: var(--ibp-radius-lg);
    box-shadow: var(--ibp-shadow-md);
    padding: 30px;
    max-height: 90vh;
    overflow-y: auto;
}

.ibp-modal__title {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--ibp-text-primary);
    margin: 0 0 8px;
}

.ibp-modal__desc {
    font-size: 0.9rem;
    color: var(--ibp-text-muted);
    margin: 0 0 24px;
}

.ibp-form-row {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    margin-bottom: 16px;
}

.ibp-form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.ibp-col-12 { flex: 1 1 100%; }
.ibp-col-6  { flex: 1 1 calc(50% - 8px); }
.ibp-col-4  { flex: 1 1 calc(33.333% - 11px); }

.ibp-form-group label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--ibp-text-secondary);
}

.ibp-form-group input {
    font-family: var(--ibp-font);
    font-size: 0.9rem;
    padding: 10px 12px;
    border: 1px solid var(--ibp-border);
    border-radius: var(--ibp-radius);
    background: var(--ibp-bg-primary);
    color: var(--ibp-text-primary);
    direction: rtl;
    transition: all var(--ibp-transition);
}

.ibp-form-group input:focus {
    border-color: var(--ibp-accent);
    outline: none;
    box-shadow: 0 0 0 3px rgba(217, 119, 6, 0.15);
}

.ibp-modal__actions {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 32px;
    padding-top: 20px;
    border-top: 1px solid var(--ibp-border);
}

@media (max-width: 640px) {
    .ibp-col-6, .ibp-col-4 {
        flex: 1 1 100%;
    }
}
