/* ===================================================================
   Contact Widget – Smart FAB + Modal
   Theme-aware using CSS variable fallbacks for all page types.
   =================================================================== */

/* --- Floating Action Button --- */
.contact-fab {
    position: fixed;
    bottom: 24px;
    left: 24px;
    z-index: 9998;
    display: flex;
    align-items: center;
    gap: 0;
    height: 52px;
    border: none;
    border-radius: 26px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: #fff;
    cursor: pointer;
    padding: 0;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
    transition: transform 0.3s ease, box-shadow 0.3s ease, width 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    width: 52px;
    outline: none;
    opacity: 0;
    transform: translateY(20px);
    animation: contactFabEntry 0.6s cubic-bezier(0.34, 1.56, 0.64, 1) 1s forwards;
}

@keyframes contactFabEntry {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.contact-fab:hover {
    transform: scale(1.08);
    box-shadow: 0 6px 28px rgba(255, 107, 107, 0.55);
}

.contact-fab:active {
    transform: scale(0.95);
}

.contact-fab-icon {
    flex-shrink: 0;
    width: 52px;
    height: 52px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-fab-icon svg {
    width: 22px;
    height: 22px;
    fill: none;
    stroke: #fff;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
    transition: transform 0.3s ease;
}

.contact-fab:hover .contact-fab-icon svg {
    transform: rotate(-8deg) scale(1.1);
}

.contact-fab-text {
    white-space: nowrap;
    font-family: 'Nunito', 'Outfit', sans-serif;
    font-size: 0.85rem;
    font-weight: 600;
    letter-spacing: 0.3px;
    padding-right: 0;
    opacity: 0;
    max-width: 0;
    transition: opacity 0.3s ease 0.1s, max-width 0.5s cubic-bezier(0.4, 0, 0.2, 1), padding 0.5s ease;
}

/* Expanded state (Smart intro) */
.contact-fab.expanded {
    width: auto;
}

.contact-fab.expanded .contact-fab-text {
    opacity: 1;
    max-width: 200px;
    padding-right: 20px;
}

/* --- Modal Backdrop --- */
.contact-backdrop {
    position: fixed;
    inset: 0;
    z-index: 10000;
    background: rgba(0, 0, 0, 0.5);
    backdrop-filter: blur(6px);
    -webkit-backdrop-filter: blur(6px);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.contact-backdrop.open {
    opacity: 1;
    visibility: visible;
}

/* --- Modal Panel --- */
.contact-modal {
    position: fixed;
    top: 50%;
    left: 50%;
    z-index: 10001;
    transform: translate(-50%, -50%) scale(0.9);
    width: 90%;
    max-width: 440px;
    border-radius: 20px;
    background: var(--bg-panel, var(--panel, rgba(15, 23, 42, 0.95)));
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.5);
    padding: 32px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, transform 0.3s cubic-bezier(0.34, 1.56, 0.64, 1), visibility 0.3s ease;
}

.contact-modal.open {
    opacity: 1;
    visibility: visible;
    transform: translate(-50%, -50%) scale(1);
}

/* Light mode modal */
[data-theme="light"] .contact-modal {
    background: var(--bg-panel, var(--panel, rgba(224, 222, 216, 0.98)));
    box-shadow: 0 24px 64px rgba(0, 0, 0, 0.15);
}

/* --- Modal Header --- */
.contact-modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 24px;
}

.contact-modal-title {
    font-family: 'Caveat', 'Nunito', sans-serif;
    font-size: 2rem;
    font-weight: 700;
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    line-height: 1.2;
}

.contact-close-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    background: transparent;
    color: var(--text-secondary, var(--text-muted, #94a3b8));
    font-size: 1.2rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s ease;
}

.contact-close-btn:hover {
    background: rgba(255, 107, 107, 0.15);
    color: #ff6b6b;
    border-color: rgba(255, 107, 107, 0.3);
}

/* --- Form --- */
.contact-form {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.contact-field {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.contact-field label {
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--text-secondary, var(--text-muted, #94a3b8));
    text-transform: uppercase;
    letter-spacing: 0.8px;
}

.contact-field input,
.contact-field textarea {
    width: 100%;
    padding: 12px 16px;
    border-radius: 12px;
    border: 1px solid var(--border, rgba(255, 255, 255, 0.1));
    background: var(--bg-input, var(--bg-deep, rgba(10, 22, 40, 0.6)));
    color: var(--text-primary, var(--text, #f1f5f9));
    font-family: 'Nunito', 'Outfit', sans-serif;
    font-size: 0.95rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    outline: none;
}

.contact-field textarea {
    min-height: 100px;
    resize: vertical;
}

.contact-field input::placeholder,
.contact-field textarea::placeholder {
    color: var(--text-muted, #64748b);
    opacity: 0.7;
}

.contact-field input:focus,
.contact-field textarea:focus {
    border-color: #ff6b6b;
    box-shadow: 0 0 0 3px rgba(255, 107, 107, 0.15);
}

/* --- Submit Button --- */
.contact-submit {
    width: 100%;
    padding: 14px;
    border: none;
    border-radius: 14px;
    background: linear-gradient(135deg, #ff6b6b, #ee5a24);
    color: #fff;
    font-family: 'Nunito', 'Outfit', sans-serif;
    font-size: 1rem;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-top: 4px;
    position: relative;
    overflow: hidden;
}

.contact-submit:hover {
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.4);
    transform: translateY(-1px);
}

.contact-submit:active {
    transform: translateY(0);
}

.contact-submit:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loading spinner */
.contact-submit .spinner {
    display: none;
    width: 18px;
    height: 18px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-top-color: #fff;
    border-radius: 50%;
    animation: contactSpin 0.6s linear infinite;
    margin: 0 auto;
}

.contact-submit.loading .spinner {
    display: inline-block;
}

.contact-submit.loading .btn-text {
    display: none;
}

@keyframes contactSpin {
    to { transform: rotate(360deg); }
}

/* --- Feedback Messages --- */
.contact-feedback {
    text-align: center;
    padding: 8px 0;
    font-size: 0.9rem;
    font-weight: 600;
    border-radius: 10px;
    display: none;
}

.contact-feedback.success {
    display: block;
    color: #22c55e;
    animation: contactFeedbackIn 0.4s ease;
}

.contact-feedback.error {
    display: block;
    color: #ef4444;
    animation: contactFeedbackIn 0.4s ease;
}

@keyframes contactFeedbackIn {
    from { opacity: 0; transform: translateY(6px); }
    to { opacity: 1; transform: translateY(0); }
}

/* --- Success checkmark (replaces form on success) --- */
.contact-success-view {
    display: none;
    text-align: center;
    padding: 20px 0;
}

.contact-success-view.show {
    display: block;
    animation: contactFeedbackIn 0.5s ease;
}

.contact-success-check {
    width: 64px;
    height: 64px;
    margin: 0 auto 16px;
    border-radius: 50%;
    background: rgba(34, 197, 94, 0.12);
    display: flex;
    align-items: center;
    justify-content: center;
}

.contact-success-check svg {
    width: 32px;
    height: 32px;
    stroke: #22c55e;
    stroke-width: 3;
    fill: none;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.contact-success-check svg path {
    stroke-dasharray: 40;
    stroke-dashoffset: 40;
    animation: contactCheckDraw 0.5s ease 0.2s forwards;
}

@keyframes contactCheckDraw {
    to { stroke-dashoffset: 0; }
}

.contact-success-text {
    color: var(--text-primary, var(--text, #f1f5f9));
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.contact-success-sub {
    color: var(--text-secondary, var(--text-muted, #94a3b8));
    font-size: 0.9rem;
}

/* --- Light mode FAB --- */
[data-theme="light"] .contact-fab {
    box-shadow: 0 4px 20px rgba(255, 107, 107, 0.25);
}

[data-theme="light"] .contact-fab:hover {
    box-shadow: 0 6px 28px rgba(255, 107, 107, 0.35);
}

/* --- Responsive --- */
@media (max-width: 640px) {
    .contact-fab {
        bottom: 16px;
        left: 16px;
        height: 46px;
        width: 46px;
        border-radius: 23px;
    }

    .contact-fab-icon {
        width: 46px;
        height: 46px;
    }

    .contact-fab-icon svg {
        width: 20px;
        height: 20px;
    }

    .contact-modal {
        width: 95%;
        padding: 24px 20px;
        border-radius: 16px;
    }

    .contact-modal-title {
        font-size: 1.6rem;
    }
}
