/* ==========================================================================
   Floating Donation Form - Widget Styles
   ========================================================================== */

/* --- Widget container --- */
.fdf-widget {
    position: fixed;
    top: var(--fdf-top, 80px);
    right: var(--fdf-right, 20px);
    z-index: 100000;
    font-family: "Inter", -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    font-size: 14px;
    line-height: 1.5;
    color: var(--fdf-text, #333);
    transition: opacity 0.3s ease;
}

.fdf-widget.fdf-hidden {
    opacity: 0;
    pointer-events: none;
}

.fdf-widget.fdf-visible {
    opacity: 1;
    pointer-events: auto;
}

/* --- Toggle button (collapsed state) --- */
.fdf-toggle-btn {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: var(--fdf-btn-bg, #de8831);
    color: var(--fdf-btn-text, #fff);
    border: none;
    border-radius: var(--fdf-radius, 12px);
    cursor: pointer;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    white-space: nowrap;
    box-shadow: 0 4px 16px rgba(0, 0, 0, 0.15);
    transition: background-color 0.2s ease, transform 0.15s ease, box-shadow 0.2s ease;
    margin-left: auto;
}

.fdf-toggle-btn:hover {
    filter: brightness(1.08);
    box-shadow: 0 6px 20px rgba(0, 0, 0, 0.2);
}

.fdf-toggle-btn:active {
    transform: scale(0.97);
}

.fdf-toggle-icon {
    display: flex;
    align-items: center;
}

.fdf-toggle-icon svg {
    fill: currentColor;
    stroke: currentColor;
}

/* Hide toggle when expanded */
.fdf-widget.fdf-expanded .fdf-toggle-btn {
    display: none;
}

/* --- Panel (expanded state) --- */
.fdf-panel {
    display: none;
    width: var(--fdf-width, 360px);
    max-height: 80vh;
    overflow-y: auto;
    background: var(--fdf-bg, #fff);
    border-radius: var(--fdf-radius, 12px);
    box-shadow: 0 8px 32px rgba(0, 0, 0, 0.18);
    padding: 0;
}

.fdf-widget.fdf-expanded .fdf-panel {
    display: block;
    animation: fdfSlideIn 0.3s ease;
    will-change: transform, opacity;
}

@keyframes fdfSlideIn {
    from {
        opacity: 0;
        transform: translateY(-10px) scale(0.97);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

/* --- Panel header --- */
.fdf-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 16px 20px 12px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.08);
}

.fdf-panel-title {
    margin: 0;
    font-size: 16px;
    font-weight: 700;
    color: var(--fdf-text, #333);
}

.fdf-close-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    padding: 0;
    background: none;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    color: var(--fdf-text, #333);
    opacity: 0.5;
    transition: opacity 0.2s ease, background-color 0.2s ease;
}

.fdf-close-btn:hover {
    opacity: 1;
    background: rgba(0, 0, 0, 0.06);
}

/* --- Panel description --- */
.fdf-panel-desc {
    margin: 0;
    padding: 10px 20px 0;
    font-size: 13px;
    color: var(--fdf-text, #333);
    opacity: 0.7;
}

/* --- Form --- */
.fdf-form {
    padding: 16px 20px 20px;
}

.fdf-field {
    margin-bottom: 14px;
}

.fdf-label {
    display: block;
    margin-bottom: 5px;
    font-size: 13px;
    font-weight: 600;
    color: var(--fdf-text, #333);
}

.fdf-input {
    display: block;
    width: 100%;
    padding: 9px 12px;
    font-family: inherit;
    font-size: 14px;
    line-height: 1.4;
    color: var(--fdf-text, #333);
    background: #fff;
    border: 1px solid #d0d0d0;
    border-radius: 6px;
    outline: none;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    box-sizing: border-box;
}

.fdf-input:focus {
    border-color: var(--fdf-accent, #de8831);
    box-shadow: 0 0 0 3px rgba(222, 136, 49, 0.15);
}

.fdf-input.fdf-has-error {
    border-color: #d63638;
}

.fdf-textarea {
    resize: vertical;
    min-height: 48px;
}

.fdf-select {
    appearance: auto;
}

/* --- Amount buttons grid --- */
.fdf-amounts-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    margin-bottom: 8px;
}

.fdf-amount-btn {
    padding: 10px 8px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    text-align: center;
    background: #f5f5f5;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    cursor: pointer;
    color: var(--fdf-text, #333);
    transition: border-color 0.15s ease, background-color 0.15s ease;
}

.fdf-amount-btn:hover {
    border-color: var(--fdf-accent, #de8831);
    background: #fdf5eb;
}

.fdf-amount-btn.fdf-amount-active {
    border-color: var(--fdf-accent, #de8831);
    background: var(--fdf-accent, #de8831);
    color: #fff;
}

.fdf-custom-amount {
    margin-top: 4px;
}

/* --- Error messages --- */
.fdf-error {
    font-size: 12px;
    color: #d63638;
    margin-top: 4px;
    min-height: 0;
}

.fdf-global-error {
    font-size: 13px;
    color: #d63638;
    text-align: center;
    margin-top: 8px;
}

/* --- Terms checkbox --- */
.fdf-field-terms {
    margin-bottom: 4px;
}

.fdf-terms-label {
    display: flex;
    align-items: flex-start;
    gap: 8px;
    cursor: pointer;
    font-size: 13px;
    color: var(--fdf-text, #333);
    line-height: 1.4;
}

.fdf-terms-label input[type="checkbox"] {
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    margin-top: 1px;
    accent-color: var(--fdf-accent, #de8831);
    cursor: pointer;
}

.fdf-terms-label a {
    color: var(--fdf-accent, #de8831);
    text-decoration: underline;
}

.fdf-terms-label a:hover {
    text-decoration: none;
}

/* --- Submit button --- */
.fdf-field-submit {
    margin-bottom: 0;
    margin-top: 18px;
}

.fdf-submit-btn {
    display: block;
    width: 100%;
    padding: 12px 16px;
    font-family: inherit;
    font-size: 16px;
    font-weight: 700;
    text-align: center;
    background: var(--fdf-btn-bg, #de8831);
    color: var(--fdf-btn-text, #fff);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.15s ease;
}

.fdf-submit-btn:hover {
    filter: brightness(1.08);
}

.fdf-submit-btn:active {
    transform: scale(0.98);
}

.fdf-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* --- Scrollbar styling for panel --- */
.fdf-panel::-webkit-scrollbar {
    width: 6px;
}

.fdf-panel::-webkit-scrollbar-track {
    background: transparent;
}

.fdf-panel::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.15);
    border-radius: 3px;
}

/* ==========================================================================
   Responsive - Mobile
   ========================================================================== */

@media (max-width: 768px) {
    .fdf-widget {
        top: auto !important;
        right: 0 !important;
        bottom: 0;
        left: 0;
        width: 100%;
    }

    .fdf-toggle-btn {
        position: fixed;
        bottom: 16px;
        right: 16px;
        border-radius: 50px;
        padding: 12px 20px;
        box-shadow: 0 4px 20px rgba(0, 0, 0, 0.2);
    }

    .fdf-widget.fdf-expanded .fdf-toggle-btn {
        display: none;
    }

    .fdf-panel {
        width: 100%;
        max-height: 75vh;
        border-radius: var(--fdf-radius, 12px) var(--fdf-radius, 12px) 0 0;
        box-shadow: 0 -4px 32px rgba(0, 0, 0, 0.2);
    }

    .fdf-widget.fdf-expanded .fdf-panel {
        animation: fdfSlideUp 0.3s ease;
    }

    @keyframes fdfSlideUp {
        from {
            opacity: 0;
            transform: translateY(20px);
        }
        to {
            opacity: 1;
            transform: translateY(0);
        }
    }

    .fdf-amounts-grid {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 360px) {
    .fdf-panel {
        max-height: 80vh;
    }

    .fdf-form {
        padding: 12px 16px 16px;
    }
}

/* ==========================================================================
   Exit-Intent Modal
   ========================================================================== */

.fdf-exit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.65);
    z-index: 100001;
    display: flex;
    align-items: center;
    justify-content: center;
    backdrop-filter: blur(4px);
    will-change: opacity;
    opacity: 0;
    transition: opacity 0.2s ease;
}

.fdf-exit-modal--visible {
    opacity: 1;
}

.fdf-exit-content {
    position: relative;
    max-width: 420px;
    width: 90%;
    padding: 32px 28px 24px;
    text-align: center;
    color: #fff;
    background: rgba(11, 33, 64, 0.95);
    border-radius: 14px;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.35);
}

.fdf-exit-close-x {
    position: absolute;
    top: 4px;
    right: 4px;
    background: none;
    border: none;
    color: rgba(255, 255, 255, 0.5);
    font-size: 33px;
    cursor: pointer;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 6px;
    transition: color 0.2s ease, background-color 0.2s ease;
}

.fdf-exit-close-x:hover {
    color: #fff;
    background: rgba(255, 255, 255, 0.1);
}

.fdf-exit-text {
    margin: 0 0 8px;
    font-size: 14px;
    line-height: 1.6;
    color: rgba(255, 255, 255, 0.85);
}

.fdf-exit-text--strong {
    font-weight: 600;
    color: #fff;
    margin-bottom: 20px;
}

.fdf-exit-actions {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 16px;
}

.fdf-exit-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 11px 16px;
    font-family: inherit;
    font-size: 14px;
    font-weight: 600;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    transition: filter 0.2s ease, transform 0.15s ease;
}

.fdf-exit-btn:hover {
    filter: brightness(1.1);
}

.fdf-exit-btn:active {
    transform: scale(0.97);
}

.fdf-exit-btn svg {
    flex-shrink: 0;
}

.fdf-exit-share {
    background: #ff4500;
    color: #fff;
}

.fdf-exit-share:hover {
    filter: brightness(0.8);
    color: #fff;
}

.fdf-exit-newsletter {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.fdf-exit-newsletter:hover {
    background: rgba(255, 255, 255, 0.25);
}

.fdf-exit-back {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.fdf-exit-back:hover {
    background: rgba(255, 255, 255, 0.25);
}

/* Pulse border animation for newsletter name field */
@keyframes fdf-border-pulse {
    0%   { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8); }
    50%  { box-shadow: 0 0 0 4px rgba(255, 255, 255, 0.4); }
    100% { box-shadow: 0 0 0 0 rgba(255, 255, 255, 0.8); }
}

.fdf-pulse-border {
    border-color: #ffffff !important;
    outline: none !important;
    animation: fdf-border-pulse 0.7s ease-in-out infinite;
}

@media (max-width: 768px) {
    .fdf-exit-content {
        width: 92%;
        padding: 28px 20px 20px;
    }
}
