/* ========================================
   Multi Subscribe Pro - 專業響應式樣式
   支援：popup, slide_in, exit_intent, fixed_bar, below_page
   fixed_bar 強制 100vw × 100px + 橫向排列
   ======================================== */

/* 基礎容器 */
.mps-form-container {
    text-align: center;
    margin: 20px auto;
    position: relative;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    /* 關鍵：使用 CSS 變數控制寬度（fixed_bar 例外） */
    max-width: var(--mps-target-width, 420px);
    width: 100%;
}

/* ========================================
   Fixed Bar 強制全寬 + 固定高度
   ======================================== */
.mps-fixed_bar {
    /* 強制覆蓋所有限制 */
    max-width: 100vw !important;
    width: 100vw !important;
    min-height: 100px !important;
    height: 100px !important;
    
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background: #222;
    color: #fff;
    padding: 16px;
    z-index: 9997;
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    flex-wrap: nowrap; /* 大螢幕不換行 */
}

/* fixed_bar 內部表單（橫向） */
.mps-fixed_bar .mps-form {
    flex: 1;
    max-width: 800px;
    margin: 0 auto;
    display: flex;
    gap: 8px;
    align-items: center;
    flex-wrap: nowrap;
}

.mps-fixed_bar input {
    flex: 1;
    min-width: 150px;
    height: 48px;
    padding: 0 16px;
    font-size: 15px;
    border-radius: 8px;
    border: none;
    background: #fff;
    color: #000;
}

.mps-fixed_bar button {
    white-space: nowrap;
    height: 48px;
    padding: 0 24px;
    border-radius: 8px;
    border: none;
    font-weight: 600;
}

/* 標題 */
.mps-fixed_bar h3 {
    margin: 0 12px 0 0;
    font-size: 1.1em;
    font-weight: 600;
    white-space: nowrap;
}

/* ========================================
   其他 Placement（popup / exit_intent 響應式）
   ======================================== */
.mps-popup,
.mps-exit_intent {
    max-width: var(--mps-target-width) !important;
    width: 100% !important;
}

/* 手機：最大 90vw */
@media (max-width: 480px) {
    .mps-popup,
    .mps-exit_intent {
        max-width: 90vw !important;
    }
}

/* 平板：最大 80vw 或設定值 */
@media (min-width: 481px) and (max-width: 768px) {
    .mps-popup,
    .mps-exit_intent {
        max-width: min(var(--mps-target-width), 80vw) !important;
    }
}

/* 大螢幕：精準使用設定值 */
@media (min-width: 769px) {
    .mps-popup,
    .mps-exit_intent {
        max-width: var(--mps-target-width) !important;
    }
}

/* ========================================
   響應式優化（手機時 fixed_bar 變垂直）
   ======================================== */
@media (max-width: 768px) {
    .mps-form-container {
        margin: 15px;
        padding: 16px;
    }

    /* fixed_bar 手機模式：垂直堆疊 */
    .mps-fixed_bar {
        height: auto !important;
        min-height: 80px !important;
        padding: 16px;
        flex-direction: column;
        text-align: center;
        flex-wrap: wrap;
    }

    .mps-fixed_bar .mps-form {
        width: 100%;
        flex-direction: column;
        gap: 12px;
        align-items: stretch;
        flex-wrap: wrap;
    }

    .mps-fixed_bar input,
    .mps-fixed_bar button {
        width: 100% !important;
        min-width: 100% !important;
        flex: none !important;
        margin: 6px 0;
    }

    .mps-fixed_bar h3 {
        font-size: 15px;
        width: 100%;
        margin: 0 0 8px 0;
        text-align: center;
    }

    .mps-fixed_bar .mps-close-btn {
        top: 16px;
        right: 16px;
        transform: none;
    }
}

@media (max-width: 480px) {
    .mps-title {
        font-size: 1.3em;
    }
    .mps-field input {
        font-size: 15px;
        padding: 12px;
    }
    .mps-submit-btn {
        font-size: 15px;
        padding: 12px;
    }
}

/* ========================================
   其他樣式（保持原樣）
   ======================================== */
.mps-form {
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding: 0 10px;
}

.mps-field {
    position: relative;
}

.mps-field input {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 8px;
    font-size: 16px;
    background: #fff;
    color: #000;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    transition: all 0.2s ease;
}

.mps-field input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.3);
    transform: translateY(-1px);
}

.mps-field input::placeholder {
    color: #999;
}

.mps-error {
    color: #e74c3c;
    font-size: 13px;
    min-height: 18px;
    display: block;
    margin-top: 4px;
    text-align: left;
}

.mps-title {
    margin: 0 0 8px;
    font-size: 1.5em;
    font-weight: 600;
    line-height: 1.3;
}

.mps-submit-btn {
    padding: 14px 20px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 16px;
    cursor: pointer;
    transition: all 0.2s ease;
    margin-top: 8px;
}

.mps-submit-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0,0,0,0.2);
}

.mps-submit-btn:active {
    transform: translateY(0);
}

.mps-message {
    margin-top: 12px;
    font-weight: 500;
    min-height: 24px;
    text-align: center;
    font-size: 15px;
}

.mps-media {
    margin-bottom: 16px;
    text-align: center;
}

.mps-image,
.mps-video {
    width: 100%;
    max-height: 200px;
    object-fit: cover;
    border-radius: 8px;
    display: block;
    margin: 0 auto;
}

.mps-video {
    height: 200px;
    border: none;
}

.mps-close-btn {
    position: absolute;
    top: 12px;
    right: 12px;
    width: 36px;
    height: 36px;
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: all 0.2s ease;
}

.mps-close-btn:hover {
    background: rgba(0, 0, 0, 0.85);
    transform: scale(1.1);
}

/* Popup */
.mps-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    color: #000;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    animation: mpsPopupFadeIn 0.4s ease-out;
}

@keyframes mpsPopupFadeIn {
    from { opacity: 0; transform: translate(-50%, -60%); }
    to { opacity: 1; transform: translate(-50%, -50%); }
}

/* Slide In */
.mps-slide_in {
    display: none;
    position: fixed;
    right: -340px;
    bottom: 20px;
    background: #fff;
    color: #000;
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    transition: right 0.6s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 9998;
}

.mps-slide_in.active {
    right: 20px;
    display: block;
}

@media (max-width: 768px) {
    .mps-slide_in {
        width: 90%;
        right: -100%;
        left: 5%;
        bottom: 10px;
    }
    .mps-slide_in.active {
        right: 5%;
    }
}

/* Exit Intent */
.mps-exit_intent {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: #fff;
    padding: 24px;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    z-index: 9998;
    animation: mpsPopupFadeIn 0.4s ease-out;
}

/* Below Page */
.mps-below_page {
    margin: 40px auto;
    padding: 24px;
}

/* Slide In 動畫 */
@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}