/**
 * Egypt Payment Buttons - Frontend Styles
 * Fully Responsive with Customizable Surrounding Texts and Floating Contiguous Buttons
 */

:root {
    --epb-btn-size: 58px;
    --epb-divider: rgba(0, 0, 0, 0.15);
    --epb-radius: 14px;
}

/* Container */
.epb-container {
    box-sizing: border-box;
    margin: 16px 0;
    padding: 0;
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    display: flex;
    flex-direction: column;
    width: 100%;
}

.epb-container *, .epb-container *::before, .epb-container *::after,
.epb-modal-overlay *, .epb-modal-overlay *::before, .epb-modal-overlay *::after {
    box-sizing: border-box;
}

/* Surrounding Texts */
.epb-surrounding-title {
    margin: 0 0 8px 0;
    font-weight: 800;
    line-height: 1.3;
}

.epb-surrounding-subtitle {
    margin: 0 0 14px 0;
    line-height: 1.6;
}

.epb-surrounding-footer {
    margin: 14px 0 0 0;
    line-height: 1.6;
}

/* Row & Alignment */
.epb-buttons-row {
    display: flex;
    width: 100%;
}

.epb-align-right {
    justify-content: flex-start;
}
.epb-align-center {
    justify-content: center;
}
.epb-align-left {
    justify-content: flex-end;
}

.epb-mode-floating_bottom {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 99990;
    width: auto;
    margin: 0;
}

/* CONTIGUOUS FLOATING BUTTONS */
.epb-buttons-wrapper.epb-contiguous {
    display: inline-flex;
    align-items: stretch;
    justify-content: center;
    flex-wrap: nowrap;
    border: none !important;
    border-radius: var(--epb-radius, 14px);
    overflow: visible;
    background: transparent !important;
    gap: 0 !important;
    padding: 0 !important;
    margin: 0 !important;
}

.epb-buttons-wrapper.epb-contiguous .epb-row-segment {
    display: inline-flex;
    align-items: stretch;
    justify-content: center;
    border-radius: var(--epb-radius, 14px);
    overflow: visible;
    background: transparent !important;
}

.epb-buttons-wrapper.epb-contiguous .epb-button {
    width: var(--epb-btn-size, 58px);
    height: var(--epb-btn-size, 58px);
    min-width: var(--epb-btn-size, 58px);
    min-height: var(--epb-btn-size, 58px);
    border: none !important;
    border-radius: 0 !important;
    box-shadow: none !important;
    border-left: 1px solid var(--epb-divider, rgba(0, 0, 0, 0.15)) !important;
    background: transparent !important;
    padding: 0 !important;
    margin: 0 !important;
    position: relative;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: transform 0.22s cubic-bezier(0.2, 0.8, 0.2, 1), box-shadow 0.22s ease, filter 0.22s ease;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

/* Outer corner radius for seamless contiguous look */
.epb-buttons-wrapper.epb-contiguous .epb-row-segment:first-child .epb-button:first-child,
.epb-buttons-wrapper.epb-contiguous > .epb-button:first-child {
    border-top-right-radius: var(--epb-radius, 14px) !important;
    border-bottom-right-radius: var(--epb-radius, 14px) !important;
}
.epb-buttons-wrapper.epb-contiguous .epb-row-segment:last-child .epb-button:last-child,
.epb-buttons-wrapper.epb-contiguous > .epb-button:last-child {
    border-top-left-radius: var(--epb-radius, 14px) !important;
    border-bottom-left-radius: var(--epb-radius, 14px) !important;
    border-left: none !important;
}

/* On desktop, keep divider between segments */
.epb-buttons-wrapper.epb-contiguous:not(.epb-mobile-two-rows) .epb-row-segment:not(:last-child) .epb-button:last-child {
    border-left: 1px solid var(--epb-divider, rgba(0, 0, 0, 0.15)) !important;
}

/* Standard hover */
.epb-buttons-wrapper.epb-contiguous .epb-button:hover {
    transform: scale(1.06);
    z-index: 10;
    filter: brightness(1.05);
}

/* HOVER GLOW EFFECT (تأثير التوهج الخفيف) */
.epb-has-glow.epb-intensity-subtle {
    --epb-glow-size: 14px 2px;
}
.epb-has-glow.epb-intensity-medium {
    --epb-glow-size: 20px 4px;
}
.epb-has-glow.epb-intensity-strong {
    --epb-glow-size: 28px 6px;
}

/* Brand specific glow colors */
.epb-has-glow.epb-glow-brand .epb-btn-vodafone { --epb-btn-glow: #e60000; }
.epb-has-glow.epb-glow-brand .epb-btn-instapay { --epb-btn-glow: #582c83; }
.epb-has-glow.epb-glow-brand .epb-btn-wepay { --epb-btn-glow: #6b2d82; }
.epb-has-glow.epb-glow-brand .epb-btn-cib { --epb-btn-glow: #00549a; }
.epb-has-glow.epb-glow-brand .epb-btn-adib { --epb-btn-glow: #0066b2; }

/* Preset & Custom glow colors */
.epb-has-glow.epb-glow-blue .epb-button { --epb-btn-glow: #2563eb; }
.epb-has-glow.epb-glow-gold .epb-button { --epb-btn-glow: #f59e0b; }
.epb-has-glow.epb-glow-custom .epb-button { --epb-btn-glow: var(--epb-custom-glow, #3b82f6); }

.epb-has-glow .epb-button:hover {
    transform: scale(1.10);
    z-index: 25;
    border-radius: 8px !important;
    box-shadow: 0 0 var(--epb-glow-size, 20px 4px) var(--epb-btn-glow, rgba(59, 130, 246, 0.6)), 0 6px 18px rgba(0, 0, 0, 0.22) !important;
}

.epb-buttons-wrapper.epb-contiguous .epb-btn-icon-wrapper {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0 !important;
    margin: 0 !important;
    background: transparent !important;
}

.epb-buttons-wrapper.epb-contiguous .epb-btn-img {
    width: 100%;
    height: 100%;
    object-fit: cover !important;
    border-radius: 0;
    display: block;
    user-select: none;
    -webkit-user-drag: none;
}

/* Modal Popup Overlay */
.epb-modal-overlay {
    position: fixed;
    inset: 0;
    z-index: 999999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 16px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.25s ease, visibility 0.25s ease;
}

.epb-modal-overlay.epb-active {
    opacity: 1;
    visibility: visible;
}

.epb-modal-backdrop {
    position: absolute;
    inset: 0;
    background: rgba(15, 23, 42, 0.65);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
}

.epb-modal-card {
    position: relative;
    width: 100%;
    max-width: 460px;
    max-height: 90vh;
    overflow-y: auto;
    border-radius: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.35);
    z-index: 2;
    transform: translateY(20px) scale(0.95);
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.epb-modal-overlay.epb-active .epb-modal-card {
    transform: translateY(0) scale(1);
}

.epb-theme-light {
    background: #ffffff;
    color: #1e293b;
}

.epb-theme-dark {
    background: #0f172a;
    color: #f8fafc;
}

.epb-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
    border-top: 5px solid #2563eb;
    border-top-left-radius: inherit;
    border-top-right-radius: inherit;
}

.epb-theme-dark .epb-modal-header {
    border-bottom-color: rgba(255, 255, 255, 0.1);
}

.epb-modal-brand {
    display: flex;
    align-items: center;
    gap: 14px;
}

.epb-modal-logo {
    width: 48px;
    height: 48px;
    object-fit: contain;
    border-radius: 12px;
    border: 1px solid rgba(0, 0, 0, 0.08);
    background: #fff;
    padding: 2px;
}

.epb-modal-headings {
    display: flex;
    flex-direction: column;
}

.epb-modal-title {
    margin: 0;
    font-size: 17px;
    font-weight: 800;
    color: inherit;
    line-height: 1.3;
}

.epb-modal-subtitle {
    margin: 3px 0 0;
    font-size: 13px;
    color: #64748b;
}

.epb-theme-dark .epb-modal-subtitle {
    color: #94a3b8;
}

.epb-modal-close {
    width: 36px;
    height: 36px;
    border-radius: 9999px;
    border: none;
    background: rgba(0, 0, 0, 0.05);
    color: inherit;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.15s ease;
}

.epb-modal-close:hover {
    background: rgba(0, 0, 0, 0.12);
}

.epb-modal-body {
    padding: 20px 24px 24px;
    display: flex;
    flex-direction: column;
    gap: 18px;
}

.epb-account-card {
    background: #f1f5f9;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    padding: 14px 18px;
}

.epb-theme-dark .epb-account-card {
    background: #1e293b;
    border-color: #334155;
}

.epb-account-label {
    display: flex;
    align-items: center;
    justify-content: space-between;
    font-size: 12px;
    font-weight: 600;
    color: #64748b;
    margin-bottom: 8px;
}

.epb-copy-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.epb-account-number {
    font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
    font-size: 17px;
    font-weight: 800;
    letter-spacing: 0.04em;
    color: #0f172a;
    user-select: all;
    word-break: break-all;
    direction: ltr;
    text-align: left;
}

.epb-theme-dark .epb-account-number {
    color: #38bdf8;
}

.epb-copy-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 7px 14px;
    background: #0f172a;
    color: #ffffff;
    border: none;
    border-radius: 10px;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background 0.15s ease, transform 0.1s ease;
    white-space: nowrap;
}

.epb-instructions-block {
    background: rgba(248, 250, 252, 0.7);
    border: 1px dashed #cbd5e1;
    border-radius: 14px;
    padding: 14px;
}

.epb-section-title {
    margin: 0 0 6px 0;
    font-size: 13px;
    font-weight: 700;
    color: #475569;
}

.epb-instructions-text {
    font-size: 13px;
    line-height: 1.6;
    color: #334155;
    white-space: pre-line;
}

.epb-qr-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    padding: 12px;
    background: #fff;
    border: 1px solid #e2e8f0;
    border-radius: 14px;
}

.epb-qr-image {
    max-width: 160px;
    max-height: 160px;
    object-fit: contain;
}

.epb-qr-hint {
    font-size: 12px;
    color: #64748b;
    font-weight: 600;
}

.epb-notes-block {
    font-size: 12px;
    color: #64748b;
    text-align: center;
}

.epb-whatsapp-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 12px 20px;
    background: #25D366;
    color: #ffffff;
    text-decoration: none;
    border-radius: 14px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 4px 14px rgba(37, 211, 102, 0.35);
    transition: background 0.15s ease, transform 0.1s ease;
}

.epb-whatsapp-btn:hover {
    background: #20ba5a;
    color: #fff;
    transform: translateY(-2px);
}

.epb-toast {
    position: fixed;
    bottom: 24px;
    right: 50%;
    transform: translateX(50%) translateY(40px);
    background: #0f172a;
    color: #ffffff;
    padding: 10px 20px;
    border-radius: 9999px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 14px;
    font-weight: 700;
    box-shadow: 0 10px 25px rgba(0, 0, 0, 0.25);
    opacity: 0;
    visibility: hidden;
    transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1), opacity 0.25s ease, visibility 0.25s ease;
    z-index: 1000000;
    pointer-events: none;
}

.epb-toast.epb-show {
    opacity: 1;
    visibility: visible;
    transform: translateX(50%) translateY(0);
}

.epb-toast-icon {
    width: 20px;
    height: 20px;
    border-radius: 9999px;
    background: #22c55e;
    color: #fff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    /* If mobile two rows is active (when large button size exceeds mobile screen) */
    .epb-buttons-wrapper.epb-contiguous.epb-mobile-two-rows {
        display: flex !important;
        flex-direction: column !important;
        align-items: center !important;
        justify-content: center !important;
        gap: 8px !important;
        width: 100% !important;
    }

    .epb-buttons-wrapper.epb-contiguous.epb-mobile-two-rows .epb-row-segment {
        display: inline-flex !important;
        align-items: stretch !important;
        justify-content: center !important;
        border-radius: var(--epb-radius, 14px) !important;
        box-shadow: 0 4px 14px rgba(0, 0, 0, 0.12) !important;
    }

    .epb-buttons-wrapper.epb-contiguous.epb-mobile-two-rows .epb-row-segment .epb-button:first-child {
        border-top-right-radius: var(--epb-radius, 14px) !important;
        border-bottom-right-radius: var(--epb-radius, 14px) !important;
    }

    .epb-buttons-wrapper.epb-contiguous.epb-mobile-two-rows .epb-row-segment .epb-button:last-child {
        border-top-left-radius: var(--epb-radius, 14px) !important;
        border-bottom-left-radius: var(--epb-radius, 14px) !important;
        border-left: none !important;
    }

    /* Fallback when single row is active */
    .epb-buttons-wrapper.epb-contiguous:not(.epb-mobile-two-rows) .epb-button {
        width: clamp(38px, 16vw, var(--epb-btn-size, 58px));
        height: clamp(38px, 16vw, var(--epb-btn-size, 58px));
        min-width: clamp(38px, 16vw, var(--epb-btn-size, 58px));
        min-height: clamp(38px, 16vw, var(--epb-btn-size, 58px));
    }
}
