/* =============================================================
   ICR Canada Popup – Frontend Styles
   All visual values driven by CSS custom properties set
   by the admin settings page.
============================================================= */

/* Reset scoped to popup */
#icr-popup-overlay *,
#icr-popup-overlay *::before,
#icr-popup-overlay *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* -------------------------------------------------------
   Overlay
------------------------------------------------------- */
#icr-popup-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 999999;
    background: var(--icr-overlay-bg, rgba(0,0,0,0.6));
    /* Centering default – overridden per layout below */
    align-items: center;
    justify-content: center;
    padding: 16px;
    animation: icr-fadeIn 0.25s ease;
}
#icr-popup-overlay.icr-visible {
    display: flex;
}

/* -------------------------------------------------------
   Popup wrapper
------------------------------------------------------- */
#icr-popup-wrap {
    position: relative;
    background: var(--icr-popup-bg, #ffffff);
    width: 100%;
    max-width: var(--icr-popup-width, 520px);
    border-radius: var(--icr-border-radius, 8px);
    box-shadow: var(--icr-shadow, 0 20px 60px rgba(0,0,0,0.35));
    overflow: hidden;
    animation: icr-slideUp 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    font-family: var(--icr-font, inherit);
}

/* -------------------------------------------------------
   Close button
------------------------------------------------------- */
#icr-popup-close {
    position: absolute;
    top: 12px;
    right: 14px;
    background: transparent;
    border: none;
    color: var(--icr-close-color, #ffffff);
    font-size: 18px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 6px;
    border-radius: 50%;
    transition: opacity 0.2s, background 0.2s;
    z-index: 10;
    opacity: 0.85;
}
#icr-popup-close:hover { opacity: 1; background: rgba(255,255,255,0.15); }
#icr-popup-close:focus { outline: 2px solid #fff; outline-offset: 2px; }

/* -------------------------------------------------------
   Header
------------------------------------------------------- */
.icr-popup-header {
    background: var(--icr-header-bg, #1a3a6b);
    padding: 32px 32px 28px;
    text-align: center;
    color: var(--icr-header-text, #ffffff);
}
.icr-popup-logo {
    max-height: 60px;
    max-width: 200px;
    object-fit: contain;
    margin-bottom: 14px;
    display: block;
    margin-left: auto;
    margin-right: auto;
}
.icr-popup-headline {
    font-size: var(--icr-headline-size, 26px);
    font-weight: 700;
    color: var(--icr-headline-color, #ffffff);
    line-height: 1.2;
    margin-bottom: 10px;
}
.icr-popup-sub {
    font-size: var(--icr-sub-size, 15px);
    color: var(--icr-sub-color, #e8edf5);
    line-height: 1.5;
    opacity: 0.9;
}

/* -------------------------------------------------------
   Body / Form
------------------------------------------------------- */
.icr-popup-body {
    padding: 28px 32px 32px;
    background: var(--icr-popup-bg, #ffffff);
}

/* Error notice */
.icr-popup-notice {
    padding: 10px 14px;
    border-radius: 4px;
    font-size: 14px;
    margin-bottom: 16px;
}
.icr-error {
    background: #fef2f2;
    border: 1px solid #fca5a5;
    color: #b91c1c;
}

/* Fields container */
.icr-fields { display: flex; flex-direction: column; gap: 16px; }
.icr-fields-row { flex-direction: row; gap: 14px; }
.icr-fields-row .icr-field-group { flex: 1; min-width: 0; }

/* Individual field */
.icr-field-group { display: flex; flex-direction: column; gap: 6px; }
.icr-field-group label {
    font-size: 13px;
    font-weight: 600;
    color: var(--icr-label-color, #1a3a6b);
    letter-spacing: 0.02em;
}
.icr-required { color: var(--icr-btn-bg, #cc1f29); }

.icr-field-group input {
    width: 100%;
    padding: 11px 14px;
    border: 1.5px solid var(--icr-input-border, #d0d7e3);
    border-radius: var(--icr-input-radius, 4px);
    font-size: var(--icr-input-size, 15px);
    font-family: var(--icr-font, inherit);
    color: var(--icr-body-text, #333333);
    background: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
    -webkit-appearance: none;
    appearance: none;
}
.icr-field-group input:focus {
    outline: none;
    border-color: var(--icr-input-focus, #1a3a6b);
    box-shadow: 0 0 0 3px rgba(26,58,107,0.12);
}
.icr-field-group input.icr-invalid {
    border-color: #e53e3e;
    box-shadow: 0 0 0 3px rgba(229,62,62,0.12);
}

/* Submit button */
#icr-popup-submit {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    margin-top: 20px;
    padding: 13px 20px;
    background: var(--icr-btn-bg, #cc1f29);
    color: var(--icr-btn-text, #ffffff);
    border: none;
    border-radius: var(--icr-btn-radius, 4px);
    font-size: var(--icr-btn-size, 15px);
    font-weight: 700;
    font-family: var(--icr-font, inherit);
    letter-spacing: 0.03em;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}
#icr-popup-submit:hover { background: var(--icr-btn-hover, #a01520); }
#icr-popup-submit:active { transform: scale(0.98); }
#icr-popup-submit:disabled { opacity: 0.65; cursor: not-allowed; }
#icr-popup-submit:focus { outline: 3px solid var(--icr-btn-bg, #cc1f29); outline-offset: 3px; }

.icr-btn-spinner {
    display: inline-block;
    animation: icr-spin 0.7s linear infinite;
    font-size: 18px;
}

/* Privacy note */
.icr-privacy {
    margin-top: 12px;
    font-size: 12px;
    color: var(--icr-privacy-color, #888888);
    text-align: center;
    line-height: 1.4;
}

/* -------------------------------------------------------
   Layout variants
------------------------------------------------------- */

/* LEFT SLIDE-IN */
#icr-popup-overlay.icr-layout-left {
    justify-content: flex-start;
    align-items: flex-end;
    padding: 0;
}
#icr-popup-overlay.icr-layout-left #icr-popup-wrap {
    max-width: 380px;
    min-height: 100%;
    border-radius: 0;
    animation: icr-slideRight 0.35s ease;
}

/* RIGHT SLIDE-IN */
#icr-popup-overlay.icr-layout-right {
    justify-content: flex-end;
    align-items: flex-end;
    padding: 0;
}
#icr-popup-overlay.icr-layout-right #icr-popup-wrap {
    max-width: 380px;
    min-height: 100%;
    border-radius: 0;
    animation: icr-slideLeft 0.35s ease;
}

/* BOTTOM BAR */
#icr-popup-overlay.icr-layout-bottom-bar {
    align-items: flex-end;
    padding: 0;
}
#icr-popup-overlay.icr-layout-bottom-bar #icr-popup-wrap {
    max-width: 100%;
    width: 100%;
    border-radius: var(--icr-border-radius, 8px) var(--icr-border-radius, 8px) 0 0;
    animation: icr-slideUp 0.3s ease;
}
#icr-popup-overlay.icr-layout-bottom-bar .icr-popup-header {
    padding: 20px 32px;
}
#icr-popup-overlay.icr-layout-bottom-bar .icr-popup-body {
    padding: 16px 32px 24px;
}
#icr-popup-overlay.icr-layout-bottom-bar .icr-fields {
    flex-direction: row;
    align-items: flex-end;
    gap: 14px;
    flex-wrap: wrap;
}
#icr-popup-overlay.icr-layout-bottom-bar .icr-field-group {
    flex: 1;
    min-width: 180px;
}
#icr-popup-overlay.icr-layout-bottom-bar #icr-popup-submit {
    width: auto;
    min-width: 160px;
    margin-top: 0;
    align-self: flex-end;
}

/* -------------------------------------------------------
   Animations
------------------------------------------------------- */
@keyframes icr-fadeIn    { from { opacity: 0; }            to { opacity: 1; } }
@keyframes icr-slideUp   { from { transform: translateY(30px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
@keyframes icr-slideRight{ from { transform: translateX(-100%); } to { transform: translateX(0); } }
@keyframes icr-slideLeft { from { transform: translateX(100%); }  to { transform: translateX(0); } }
@keyframes icr-spin      { to { transform: rotate(360deg); } }

/* -------------------------------------------------------
   Responsive – mobile
------------------------------------------------------- */
@media (max-width: 600px) {
    #icr-popup-overlay.icr-layout-center {
        padding: 0;
        align-items: flex-end;
    }
    #icr-popup-overlay.icr-layout-center #icr-popup-wrap {
        max-width: 100%;
        width: 100%;
        border-radius: var(--icr-border-radius, 8px) var(--icr-border-radius, 8px) 0 0;
        animation: icr-slideUp 0.3s ease;
    }
    .icr-fields-row { flex-direction: column; }
    .icr-popup-header { padding: 24px 20px 20px; }
    .icr-popup-body   { padding: 20px 20px 28px; }
    .icr-popup-headline { font-size: calc(var(--icr-headline-size, 26px) * 0.85); }

    /* Bottom bar stacks on mobile */
    #icr-popup-overlay.icr-layout-bottom-bar .icr-fields { flex-direction: column; }
    #icr-popup-overlay.icr-layout-bottom-bar #icr-popup-submit { width: 100%; }

    /* Side panels become full-height on mobile */
    #icr-popup-overlay.icr-layout-left #icr-popup-wrap,
    #icr-popup-overlay.icr-layout-right #icr-popup-wrap { max-width: 100%; }
}

@media (max-width: 380px) {
    .icr-popup-header { padding: 20px 16px 16px; }
    .icr-popup-body   { padding: 16px 16px 24px; }
}
