/* ================================================
   MB Solar Packages v3.1.0 — Frontend CSS
   MinhBee Agency | minhbee.vn
   ================================================ */

:root {
    --mbsp-red:   #e40046;
    --mbsp-red-h: #b8003a;
    --mbsp-text:  #111111;
    --mbsp-muted: #888888;
    --mbsp-div:   #cfcfcf;
    --mbsp-r:     20px;
}

.mbsp-wrapper { font-family: inherit; padding: 40px 0; }

/* ── Section Header ── */
.mbsp-section-header  { text-align: center; margin-bottom: 48px; }
.mbsp-section-title   { font-size: clamp(20px,3vw,30px); font-weight: 800; color: var(--mbsp-text); margin: 0 0 10px; text-transform: uppercase; letter-spacing: .03em; }
.mbsp-section-subtitle{ font-size: 15px; color: var(--mbsp-muted); margin: 0; }

/* ── Grid ── */
.mbsp-grid {
    display: grid;
    grid-template-columns: repeat(var(--mbsp-cols, 3), 1fr);
    gap: 20px;
    max-width: 1100px;
    margin: 0 auto;
    padding: 0 16px;
    /* FIX: align-items stretch → cards trong cùng hàng cao bằng nhau */
    align-items: stretch;
}

/* ── Card ── */
.mbsp-card {
    display: flex;
    flex-direction: column;
    background: var(--card-bg, #eefbff);
    border-radius: var(--mbsp-r);
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(0,0,0,.10);
    position: relative;
    /* FIX: height 100% để stretch hoạt động đúng */
    height: 100%;
    transition: transform .25s ease, box-shadow .25s ease;
}
.mbsp-card:hover {
    transform: translateY(-6px);
    box-shadow: 0 12px 32px rgba(0,0,0,.16);
}

/* Card nổi bật */
.mbsp-card--feat {
    background: var(--feat-bg, #fff0cf);
    box-shadow: 0 6px 28px rgba(0,0,0,.13);
}
.mbsp-card--feat:hover { box-shadow: 0 16px 36px rgba(0,0,0,.2); }

/* FIX: margin nhô lên chỉ trên desktop — mobile không nhô */
@media (min-width: 860px) {
    .mbsp-card--feat {
        margin-top: -10px;
        margin-bottom: -10px;
    }
}

/* ── Ảnh ── */
.mbsp-card-img {
    background: #eef2f7;
    overflow: hidden;
    flex-shrink: 0;
    line-height: 0;
}
.mbsp-card-img img {
    display: block;
    width: 100%;
    /* FIX: không set height cố định — tự nhiên theo ảnh */
    object-fit: contain;
    object-position: center;
    padding: 0;
    margin: 0;
    border-radius: 0;
    background: #eef2f7;
}

/* ── Banner ── */
.mbsp-banner {
    display: block;
    width: 100%;
    padding: 8px 14px;
    font-size: 11px;
    font-weight: 800;
    text-transform: uppercase;
    letter-spacing: .06em;
    text-align: center;
    box-sizing: border-box;
    line-height: 1.3;
    flex-shrink: 0;
}

/* ── Card Body ── */
.mbsp-card-body {
    display: flex;
    flex-direction: column;
    flex: 1;
    padding: 20px 20px 24px;
    text-align: center;
    min-width: 0;
    overflow: hidden;
}

/* ── Package Name ── */
.mbsp-pkg-name {
    margin: 0 0 8px;
    font-size: 18px;
    font-weight: 800;
    color: var(--mbsp-red);
    text-transform: uppercase;
    text-decoration: underline;
    letter-spacing: .03em;
}

/* ── Giá ── */
.mbsp-price {
    display: block;
    /* FIX: clamp responsive — không tràn ra ngoài card */
    font-size: clamp(28px, 8vw, 48px);
    font-weight: 900;
    color: var(--mbsp-text);
    line-height: 1;
    letter-spacing: -1px;
    word-break: break-all;
    overflow-wrap: break-word;
}
.mbsp-unit {
    display: block;
    margin-top: 6px;
    font-size: 11px;
    font-weight: 500;
    color: var(--mbsp-muted);
    text-transform: uppercase;
    letter-spacing: .08em;
}
.mbsp-pkg-sub {
    margin: 10px 0 14px;
    font-size: 14px;
    color: var(--mbsp-muted);
}

/* ── NEW v3.1: Meta badges (thời gian lắp đặt + công suất) ── */
.mbsp-meta-badges {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 6px;
    margin-bottom: 14px;
}
.mbsp-meta-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: rgba(228,0,70,.07);
    color: var(--mbsp-red);
    font-size: 11px;
    font-weight: 600;
    padding: 4px 10px;
    border-radius: 20px;
    border: 1px solid rgba(228,0,70,.2);
}
.mbsp-meta-icon { font-size: 12px; }

/* ── Nút CTA ── */
.mbsp-btn-cta {
    display: block;
    width: 100%;
    padding: 10px 16px;
    border: 1.5px solid #c0c4cc;
    border-radius: 99px;
    background: transparent;
    color: var(--mbsp-text);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: border-color .18s, color .18s, background .18s;
    box-sizing: border-box;
    font-family: inherit;
}
.mbsp-btn-cta:hover {
    border-color: var(--mbsp-red);
    color: var(--mbsp-red);
    background: rgba(228,0,70,.04);
    text-decoration: none;
}
a.mbsp-btn-cta { display: block; }

/* ── Danh sách thiết bị — đẩy xuống đáy card ── */
.mbsp-devices {
    margin-top: auto;
    padding-top: 18px;
    border-top: 1px solid var(--mbsp-div);
    text-align: left;
}
.mbsp-dev-label {
    display: block;
    margin: 0 0 10px;
    font-size: 15px;
    font-weight: 700;
    color: var(--dev-color, var(--mbsp-red));
}
.mbsp-dev-list { list-style: none; margin: 0; padding: 0; }
.mbsp-dev-list li {
    position: relative;
    padding-left: 22px;
    margin-bottom: 10px;
    font-size: 12.5px;
    color: var(--mbsp-text);
    line-height: 1.5;
}
.mbsp-dev-list li::before {
    content: '✔';
    position: absolute;
    left: 0;
    top: 0;
    color: var(--chk-color, #17a34a);
    font-weight: 700;
    font-size: 12px;
}

/* ================================================
   MODAL v3.1
   FIX: z-index cao hơn Flatsome, không dùng !important thừa
   ================================================ */

.mbsp-modal-overlay {
    position: fixed;
    /* FIX: fallback cho trình duyệt cũ không hỗ trợ inset */
    top: 0; left: 0; right: 0; bottom: 0;
    inset: 0;
    background: rgba(0,0,0,.6);
    /* FIX: z-index cao hơn Flatsome header (thường ~9999) */
    z-index: 9999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    box-sizing: border-box;
    animation: mbspFadeIn .2s ease;
}
/* FIX: [hidden] attribute override phải dùng !important */
.mbsp-modal-overlay[hidden] { display: none !important; }

@keyframes mbspFadeIn { from { opacity: 0; } to { opacity: 1; } }

.mbsp-modal {
    background: #fff;
    border-radius: 20px;
    padding: 0;
    /* FIX: min() không support IE nhưng WP 5.8+ không cần IE */
    width: min(520px, calc(100vw - 40px));
    position: relative;
    box-shadow: 0 24px 64px rgba(0,0,0,.22);
    animation: mbspSlideUp .25s ease;
    max-height: calc(100vh - 40px);
    overflow-y: auto;
    overflow-x: hidden;
    /* FIX: tạo stacking context riêng thoát khỏi Flatsome */
    transform: translateZ(0);
    will-change: transform;
}
@keyframes mbspSlideUp {
    from { opacity: 0; transform: translateY(24px) translateZ(0); }
    to   { opacity: 1; transform: translateY(0)    translateZ(0); }
}

/* Modal Header */
.mbsp-modal-close {
    position: absolute; top: 12px; right: 16px;
    background: rgba(255,255,255,.2); border: none;
    width: 28px; height: 28px; border-radius: 50%;
    font-size: 18px; cursor: pointer;
    color: #fff; line-height: 1;
    display: flex; align-items: center; justify-content: center;
    transition: background .15s;
    z-index: 10;
}
.mbsp-modal-close:hover { background: rgba(255,255,255,.35); }

.mbsp-modal-header {
    background: var(--mbsp-red);
    color: #fff;
    padding: 24px 28px 20px;
    text-align: center;
    position: relative;
}
.mbsp-modal-header h2 {
    font-size: 18px; font-weight: 800;
    margin: 0 0 6px; text-transform: uppercase;
    letter-spacing: .05em; color: #fff;
}
.mbsp-modal-desc {
    font-size: 13px; color: rgba(255,255,255,.85);
    margin: 0; line-height: 1.5;
}
.mbsp-modal-desc strong { color: #fff; }

/* Package Badge */
.mbsp-modal-package-badge {
    background: #fff8f0;
    border-bottom: 1px solid #fde8cc;
    padding: 10px 28px;
    text-align: center;
}
.mbsp-modal-package-badge span {
    display: inline-block;
    background: #fff3e0; color: #b45309;
    font-size: 11px; font-weight: 700;
    padding: 3px 12px; border-radius: 20px;
    border: 1px solid #fcd34d;
    text-transform: uppercase; letter-spacing: .04em;
}

/* Form */
.mbsp-form-body { padding: 20px 28px 28px; }

.mbsp-field { margin-bottom: 10px; }
.mbsp-field label {
    display: block; font-size: 12px; font-weight: 600;
    color: #444; margin-bottom: 4px;
}
.mbsp-field input,
.mbsp-field select {
    width: 100%; box-sizing: border-box;
    padding: 10px 13px;
    border: 1.5px solid #e2e5ea; border-radius: 8px;
    font-size: 14px; color: var(--mbsp-text); background: #fff;
    transition: border-color .15s; font-family: inherit;
    /* FIX: appearance auto để select dropdown hoạt động đúng */
    appearance: auto; -webkit-appearance: auto;
}
.mbsp-field input:focus,
.mbsp-field select:focus {
    outline: none;
    border-color: var(--mbsp-red);
    box-shadow: 0 0 0 3px rgba(228,0,70,.08);
}
.mbsp-field input::placeholder { color: #adb5bd; }

.mbsp-field-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 10px;
}

/* FIX: Location row — min-width 0 để không tràn ra ngoài grid */
.mbsp-location-row {
    display: grid;
    grid-template-columns: 1fr 1fr 1fr;
    gap: 8px;
}
.mbsp-location-row select {
    font-size: 12px;
    padding: 10px 6px;
    min-width: 0;
    width: 100%;
}

.mbsp-required { color: var(--mbsp-red); margin-left: 2px; }

.mbsp-error-msg {
    background: #fff0f0; border: 1px solid #ffc9c9;
    color: #c92a2a; padding: 9px 13px;
    border-radius: 8px; font-size: 13px; margin-bottom: 10px;
}
.mbsp-error-msg[hidden]   { display: none; }
.mbsp-success-msg { text-align: center; padding: 28px 0 12px; }
.mbsp-success-msg[hidden] { display: none; }
.mbsp-success-icon { font-size: 48px; display: block; margin-bottom: 12px; }
.mbsp-success-msg h3 { font-size: 18px; color: #16a34a; font-weight: 700; margin: 0 0 6px; }
.mbsp-success-msg p  { font-size: 13px; color: #555; margin: 0; }
.mbsp-btn-loading[hidden] { display: none; }

.mbsp-btn-submit {
    display: block; width: 100%;
    padding: 13px 20px; margin-top: 14px;
    background: var(--mbsp-red); color: #fff;
    border: none; border-radius: 10px;
    font-size: 14px; font-weight: 800; cursor: pointer;
    letter-spacing: .05em; text-transform: uppercase;
    transition: background .18s, transform .12s;
    font-family: inherit;
}
.mbsp-btn-submit:hover    { background: var(--mbsp-red-h); transform: translateY(-1px); }
.mbsp-btn-submit:active   { transform: translateY(0); }
.mbsp-btn-submit:disabled { opacity: .6; cursor: not-allowed; transform: none; }
.mbsp-form-note { text-align: center; margin-top: 10px; font-size: 11px; color: #aaa; }

/* ── Responsive ── */
@media (max-width: 680px) {
    /* FIX: force 1 col trên mobile bất kể --mbsp-cols */
    .mbsp-grid { grid-template-columns: 1fr !important; }
    .mbsp-card--feat { margin-top: 0 !important; margin-bottom: 0 !important; }
    .mbsp-price { font-size: 38px; }
    .mbsp-modal { border-radius: 16px; }
    .mbsp-form-body { padding: 16px 20px 24px; }
    /* FIX: location row 1 cột trên mobile nhỏ */
    .mbsp-location-row { grid-template-columns: 1fr; gap: 8px; }
    .mbsp-field-row { grid-template-columns: 1fr; }
}
