/* ============================================================
   FORM WIDGET - Floating Button + Slide Panel
   ============================================================ */

/* --- Floating Action Button --- */
.form-fab {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 9990;
    display: flex;
    align-items: center;
    gap: .5rem;
    padding: .75rem 1.25rem;
    background: var(--fab-color, #C8302A);
    color: #fff;
    border: none;
    border-radius: 50px;
    cursor: pointer;
    box-shadow: 0 4px 20px rgba(0,0,0,.25);
    font-family: 'Inter', sans-serif;
    font-weight: 600;
    font-size: .9rem;
    transition: transform .2s, box-shadow .2s;
    animation: fab-pulse 2.5s infinite;
}
.form-fab:hover {
    transform: translateY(-2px) scale(1.03);
    box-shadow: 0 6px 28px rgba(0,0,0,.35);
}
.form-fab-icon {
    font-size: 1.3rem;
    line-height: 1;
}
.form-fab-text {
    font-size: .85rem;
    white-space: nowrap;
}
.form-fab--left {
    right: auto;
    left: 24px;
}

@keyframes fab-pulse {
    0%, 100% { box-shadow: 0 4px 20px rgba(0,0,0,.25); }
    50% { box-shadow: 0 4px 20px rgba(0,0,0,.25), 0 0 0 8px rgba(200,48,42,.15); }
}

/* --- Slide Panel --- */
.form-panel {
    position: fixed;
    top: 0;
    width: 420px;
    max-width: 92vw;
    height: 100vh;
    height: 100dvh;
    z-index: 10000;
    background: var(--panel-bg, #ffffff);
    box-shadow: -4px 0 40px rgba(0,0,0,.15);
    transition: transform .35s cubic-bezier(.4,0,.2,1);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    font-family: 'Inter', sans-serif;
}
.form-panel--right {
    right: 0;
    transform: translateX(100%);
    border-radius: 16px 0 0 16px;
}
.form-panel--left {
    left: 0;
    transform: translateX(-100%);
    border-radius: 0 16px 16px 0;
}
.form-panel.active {
    transform: translateX(0);
}

/* Panel header */
.form-panel-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e2e8f0;
    flex-shrink: 0;
}
.form-panel-header h3 {
    margin: 0;
    font-size: 1.1rem;
    font-weight: 700;
    color: var(--title-color, #1e293b);
}
.form-panel-close {
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f1f5f9;
    border: none;
    border-radius: 50%;
    font-size: 1.3rem;
    color: #64748b;
    cursor: pointer;
    transition: background .2s, color .2s;
}
.form-panel-close:hover {
    background: #e2e8f0;
    color: #1e293b;
}

/* Panel body */
.form-panel-body {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
}

/* Form fields */
.form-field {
    margin-bottom: 1rem;
}
.form-field label {
    display: block;
    font-size: .8rem;
    font-weight: 600;
    color: #475569;
    margin-bottom: .35rem;
}
.form-field .req {
    color: #ef4444;
}
.form-field input[type=text],
.form-field input[type=email],
.form-field input[type=tel],
.form-field input[type=number],
.form-field input[type=date],
.form-field input[type=file],
.form-field textarea,
.form-field select {
    width: 100%;
    padding: .6rem .8rem;
    border: 1.5px solid #e2e8f0;
    border-radius: .5rem;
    font-size: .9rem;
    font-family: 'Inter', sans-serif;
    color: #1e293b;
    background: #f8fafc;
    transition: border-color .2s, box-shadow .2s;
    box-sizing: border-box;
}
.form-field input:focus,
.form-field textarea:focus,
.form-field select:focus {
    outline: none;
    border-color: var(--btn-color, #C8302A);
    box-shadow: 0 0 0 3px rgba(200,48,42,.1);
    background: #fff;
}
.form-field textarea {
    min-height: 80px;
    resize: vertical;
}
.form-field select {
    appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2364748b' d='M6 8L1 3h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    padding-right: 2rem;
}

/* Radio & Checkbox */
.form-field .radio-label,
.form-field .checkbox-label {
    display: flex;
    align-items: center;
    gap: .5rem;
    font-size: .85rem;
    color: #475569;
    margin-bottom: .3rem;
    cursor: pointer;
}
.form-field .radio-label input,
.form-field .checkbox-label input {
    width: 16px;
    height: 16px;
    accent-color: var(--btn-color, #C8302A);
}

/* Submit button */
.form-submit-btn {
    width: 100%;
    padding: .75rem 1.5rem;
    margin-top: .5rem;
    background: var(--btn-color, #C8302A);
    color: #fff;
    border: none;
    border-radius: .5rem;
    font-size: .95rem;
    font-weight: 700;
    font-family: 'Inter', sans-serif;
    cursor: pointer;
    transition: opacity .2s, transform .1s;
}
.form-submit-btn:hover {
    opacity: .92;
}
.form-submit-btn:active {
    transform: scale(.98);
}
.form-submit-btn:disabled {
    opacity: .5;
    cursor: not-allowed;
}

/* Success message */
.form-success-msg {
    text-align: center;
    padding: 2rem 1rem;
    font-size: 1rem;
    font-weight: 600;
    color: #059669;
    line-height: 1.6;
}

/* Loading overlay */
.form-panel-loading {
    position: absolute;
    inset: 0;
    background: rgba(255,255,255,.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1;
}
.form-panel-loading::after {
    content: '';
    width: 32px;
    height: 32px;
    border: 3px solid #e2e8f0;
    border-top-color: var(--btn-color, #C8302A);
    border-radius: 50%;
    animation: spin .6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Panel overlay */
.form-panel-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,.3);
    z-index: 9999;
    opacity: 0;
    pointer-events: none;
    transition: opacity .3s;
}
.form-panel-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

/* Mobile responsive */
@media (max-width: 480px) {
    .form-panel {
        width: 100vw;
        max-width: 100vw;
        border-radius: 0 !important;
    }
    .form-fab {
        bottom: 16px;
        right: 16px;
        padding: .6rem 1rem;
        font-size: .8rem;
    }
    .form-fab-icon {
        font-size: 1.1rem;
    }
}

/* RTL support */
html[dir="rtl"] .form-fab {
    right: auto;
    left: 24px;
}
html[dir="rtl"] .form-fab--left {
    left: auto;
    right: 24px;
}
html[dir="rtl"] .form-panel--right {
    right: auto;
    left: 0;
    transform: translateX(-100%);
    border-radius: 0 16px 16px 0;
}
html[dir="rtl"] .form-panel--left {
    left: auto;
    right: 0;
    transform: translateX(100%);
    border-radius: 16px 0 0 16px;
}
