/* =============================================================================
   components/modal.css
   Generic popup / modal overlay used for confirmations and plan-limit notices.
   ============================================================================= */

/* -----------------------------------------------------------------------------
   Overlay backdrop
   ----------------------------------------------------------------------------- */

.popup-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
}

.popup-overlay.show {
    opacity: 1;
    visibility: visible;
}

/* -----------------------------------------------------------------------------
   Popup card
   ----------------------------------------------------------------------------- */

.popup {
    position: relative;
    width: 90%;
    max-width: 420px;
    background-color: var(--background, #ffffff);
    border-radius: 12px;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    transform: scale(0.9);
    opacity: 0;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    z-index: 10000;
    overflow: hidden;
    border: 1px solid var(--border-color, #e5e7eb);
}

.popup.show {
    opacity: 1;
    transform: scale(1);
}

/* -----------------------------------------------------------------------------
   Popup header
   ----------------------------------------------------------------------------- */

.popup-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 16px 20px;
    color: white;
    background: var(--primary, #003ec5);
}

.popup-header.success { background: var(--success, #10b981); }
.popup-header.error   { background: var(--danger,  #ef4444); }
.popup-header.info    { background: var(--primary, #003ec5); }

.popup-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 600;
    color: white;
    display: flex;
    align-items: center;
    gap: 8px;
}

.popup-header.success h3::before { content: "✓"; font-size: 20px; font-weight: bold; color: white; }
.popup-header.error   h3::before { content: "✕"; font-size: 18px; font-weight: bold; color: white; }
.popup-header.info    h3::before { content: "ℹ"; font-size: 18px; font-weight: bold; color: white; }

/* -----------------------------------------------------------------------------
   Popup body / footer
   ----------------------------------------------------------------------------- */

.popup-body {
    padding: 24px 20px;
    color: var(--text-dark, #374151);
    font-size: 15px;
    line-height: 1.6;
}

.popup-body p {
    margin: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

.popup-footer {
    padding: 12px 20px;
    display: flex;
    justify-content: flex-end;
    border-top: 1px solid var(--border-color, #e5e7eb);
    background-color: var(--input-bg, #f9fafb);
}

/* -----------------------------------------------------------------------------
   Close controls
   ----------------------------------------------------------------------------- */

.close-popup {
    background: none;
    border: none;
    font-size: 24px;
    color: rgba(255, 255, 255, 0.9);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 4px;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    transition: all 0.3s ease;
    line-height: 1;
    font-weight: 300;
}

.close-popup:hover  { background-color: rgba(255, 255, 255, 0.2); color: white; transform: scale(1.1); }
.close-popup:active { transform: scale(0.95); }

.close-popup-btn {
    background-color: var(--primary, #003ec5);
    color: white;
    border: none;
    border-radius: 6px;
    padding: 8px 16px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: background-color 0.3s ease;
    min-width: 70px;
}

.close-popup-btn:hover { background-color: var(--primary-dark, #002aa3); }

/* Blur background when popup is open */
body.popup-open { overflow: hidden; }

body.popup-open > *:not(.popup):not(.popup-overlay):not(.plan-limit-overlay):not(.plan-limit-popup) {
    filter: blur(2px);
    transition: filter 0.3s ease;
}

/* =============================================================================
   Plan-limit popup
   A specialised modal shown when the user hits their subscription plan limit.
   ============================================================================= */

.plan-limit-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10000;
    opacity: 0;
    transition: opacity 0.3s ease;
}

.plan-limit-overlay.show { opacity: 1; }

.plan-limit-popup {
    background: white;
    border-radius: 12px;
    max-width: 550px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    padding: 32px;
    position: relative;
    transform: translateY(-20px);
    transition: transform 0.3s ease, max-width 0.3s ease;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.plan-limit-popup.show { transform: translateY(0); }

.plan-limit-popup.demo-expanded {
    max-width: 900px;
    padding: 20px;
}

.plan-limit-popup * {
    filter: none;
    backdrop-filter: none;
}

.close-plan-popup {
    position: absolute;
    top: 16px;
    right: 16px;
    background: #f3f4f6;
    border: none;
    font-size: 1.5rem;
    color: #6b7280;
    cursor: pointer;
    width: 36px;
    height: 36px;
    margin-bottom: 2px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
    line-height: 1;
    z-index: 10;
}

.close-plan-popup:hover { background: #fee2e2; color: #dc2626; }

.plan-limit-error-content {
    text-align: center;
    margin-bottom: 16px;
    padding: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.plan-limit-popup.demo-expanded .plan-limit-error-content { margin-bottom: 8px; }

.plan-limit-error-icon {
    width: 64px;
    height: 64px;
    background-color: #dc2626;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 12px;
}

.plan-limit-popup.demo-expanded .plan-limit-error-icon { margin-bottom: 8px; }

.plan-limit-error-icon i { font-size: 2rem; color: white; }

.plan-limit-error-info { text-align: center; width: 100%; }

.plan-limit-error-info h2 {
    margin: 0 0 10px 0;
    font-size: 1.5rem;
    color: #111827;
    font-weight: 700;
    text-align: center;
}

.plan-limit-popup.demo-expanded .plan-limit-error-info h2 {
    margin-bottom: 6px;
    font-size: 1.25rem;
}

.plan-limit-error-info p {
    margin: 8px 0;
    color: #6b7280;
    line-height: 1.5;
    font-size: 0.9375rem;
    text-align: center;
}

.plan-limit-popup.demo-expanded .plan-limit-error-info p {
    font-size: 0.875rem;
    line-height: 1.4;
    margin: 15px 0;
}

/* Demo section within plan-limit popup */
.plan-limit-demo-toggle-btn {
    background: var(--primary);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 0.9375rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0, 62, 197, 0.3);
    width: 100%;
    margin: 0;
}

.plan-limit-demo-toggle-btn:hover {
    background: #001f99;
    transform: translateY(-2px);
    box-shadow: 0 6px 16px rgba(0, 62, 197, 0.4);
}

.plan-limit-demo-toggle-icon {
    transition: transform 0.3s ease;
    font-size: 0.875rem;
}

.plan-limit-demo-section {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.5s ease;
    margin: 0;
    padding: 0;
}

.plan-limit-demo-section.expanded {
    max-height: 600px;
    margin-top: 6px;
}

.plan-limit-demo-iframe {
    width: 100%;
    height: auto;
    aspect-ratio: 2.157;
    border: none;
    border-radius: 8px;
    display: block;
    margin: 0;
    padding: 0;
}

/* =============================================================================
   Responsive
   ============================================================================= */

@media (max-width: 768px) {
    .popup {
        max-width: 95%;
        width: 95%;
        margin: 1rem;
    }

    .popup-header      { padding: 14px 18px; }
    .popup-header h3   { font-size: 16px; }
    .popup-body        { padding: 20px 18px; font-size: 14px; }
    .popup-footer      { padding: 10px 18px; }
    .close-popup       { width: 28px; height: 28px; font-size: 20px; }

    .plan-limit-popup {
        max-width: 95%;
        padding: 24px;
    }

    .plan-limit-popup.demo-expanded {
        max-width: 95%;
        padding: 16px;
    }

    .plan-limit-demo-section.expanded { max-height: 420px; }
    .plan-limit-error-icon             { width: 56px; height: 56px; }
    .plan-limit-error-icon i           { font-size: 1.75rem; }
}

@media (max-width: 480px) {
    .popup {
        max-width: 98%;
        width: 98%;
        margin: 0.5rem;
        border-radius: 10px;
    }

    .popup-header      { padding: 12px 16px; }
    .popup-header h3   { font-size: 15px; }
    .popup-body        { padding: 18px 16px; font-size: 13px; }
    .popup-footer      { padding: 10px 16px; }
    .close-popup       { width: 26px; height: 26px; font-size: 18px; }
    .close-popup-btn   { padding: 8px 14px; font-size: 13px; }
}

@media (max-width: 320px) {
    .close-popup-btn { padding: 6px 16px; font-size: 13px; }
    .popup-body      { padding: 16px; }
    .popup-body p    { font-size: 13px; }
    .popup-header    { padding: 12px 16px; }
    .popup-header h3 { font-size: 16px; }
}
