/**
 * File Path: public/assets/css/frontend/components/stickyForm.css
 * Sticky Form Component Styles - FINAL FIXED VERSION
 * Fixed: Media query gaps, positioning to match back-to-top button exactly
 */

/* ============================================
   CSS Variables
   ============================================ */
:root {
    --sticky-primary-blue: #003EAA;
    --sticky-primary-orange: #ff7a00;
    --sticky-text-dark: #1e293b;
    --sticky-text-light: #64748b;
    --sticky-border-color: #e2e8f0;
    --sticky-background-light: #f8fafc;
    --sticky-error-color: #ef4444;
    --sticky-success-color: #10b981;
    --sticky-large-screen: 1200px;
}

/* ============================================
   Base Widget Container
   ============================================ */
.sticky-form-widget {
    position: fixed !important;
    z-index: 800;
    will-change: transform;
}

/* Collapsed state */
.sticky-form-widget.sticky-collapsed {
    cursor: pointer;
    z-index: 800;
}

/* Expanded state - HIGHEST Z-INDEX */
.sticky-form-widget.sticky-expanded {
    position: fixed !important;
    top: 50% !important;
    left: 50% !important;
    right: auto !important;
    bottom: auto !important;
    transform: translate(-50%, -50%) !important;
    cursor: auto;
    z-index: 9999 !important;
}

/* Hide floating button when expanded */
.sticky-form-widget.sticky-expanded .sticky-floating-button {
    display: none !important;
    visibility: hidden !important;
    opacity: 0 !important;
    pointer-events: none !important;
}

/* ============================================
   Overlay Styles
   ============================================ */
.sticky-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.4);
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.2s ease, visibility 0.2s ease;
    z-index: 9998;
}

.sticky-overlay.sticky-show {
    opacity: 1;
    visibility: visible;
}

/* ============================================
   Floating Button Styles
   ============================================ */
.sticky-floating-button {
    display: flex;
    width: 50px;
    height: 50px;
    background: linear-gradient(135deg, var(--sticky-primary-orange) 0%, #e65a00 100%);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 22px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 15px rgba(243, 109, 33, 0.3);
    transition: all 0.3s ease;
    animation: sticky-pulse 2s infinite;
    position: relative;
    overflow: hidden;
    z-index: 800;
}

.sticky-floating-button:hover {
    background: #e55a00;
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(243, 109, 33, 0.4);
}

.sticky-floating-button:active {
    transform: scale(0.95);
}

.sticky-floating-button:focus {
    background: var(--sticky-primary-orange);
    box-shadow: 0 0 0 3px rgba(243, 109, 33, 0.3);
}

.sticky-floating-button i {
    font-size: 1.2rem;
    transition: transform 0.2s ease;
}

.sticky-floating-button:hover i {
    transform: scale(1.1);
}

/* Button text tooltip */
.sticky-button-text {
    position: absolute;
    right: 60px;
    background: var(--sticky-primary-orange);
    color: white;
    padding: 6px 12px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    white-space: nowrap;
    opacity: 0;
    transform: translateX(10px);
    transition: all 0.3s ease;
    pointer-events: none;
    box-shadow: 0 4px 12px rgba(255, 122, 0, 0.3);
}

.sticky-floating-button:hover .sticky-button-text {
    opacity: 1;
    transform: translateX(0);
}

@keyframes sticky-pulse {
    0% {
        box-shadow: 0 4px 15px rgba(243, 109, 33, 0.3), 0 0 0 0 rgba(243, 109, 33, 0.4);
    }
    70% {
        box-shadow: 0 4px 15px rgba(243, 109, 33, 0.3), 0 0 0 10px rgba(243, 109, 33, 0);
    }
    100% {
        box-shadow: 0 4px 15px rgba(243, 109, 33, 0.3), 0 0 0 0 rgba(243, 109, 33, 0);
    }
}

/* ============================================
   Collapsed Mini Form - Large Screens Only
   ============================================ */
.sticky-collapsed-form {
    display: none;
    width: 280px;
    background: white;
    border-radius: 16px;
    box-shadow: 0 8px 32px rgba(0, 62, 170, 0.12);
    overflow: hidden;
}

.sticky-collapsed-form:hover {
    box-shadow: 0 10px 36px rgba(0, 62, 170, 0.15);
}

.sticky-form-header-collapsed {
    background: linear-gradient(135deg, var(--sticky-primary-blue) 0%, #0056d6 100%);
    color: white;
    padding: 20px;
    text-align: center;
}

.sticky-form-header-collapsed h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0 0 6px 0;
    color: white;
}

.sticky-form-header-collapsed p {
    font-size: 0.85rem;
    opacity: 0.95;
    margin: 0;
    font-weight: 400;
}

.sticky-form-preview {
    padding: 20px;
    background: white;
}

.sticky-input-preview {
    margin-bottom: 12px;
}

.sticky-input-preview input {
    width: 100%;
    padding: 12px 10px;
    border: 2px solid var(--sticky-border-color);
    border-radius: 10px;
    font-size: 0.9rem;
    background: var(--sticky-background-light);
    color: var(--sticky-text-light);
    cursor: pointer;
    box-sizing: border-box;
    transition: all 0.2s ease;
}

.sticky-input-preview input:hover {
    border-color: var(--sticky-primary-orange);
    background: white;
}

.sticky-expand-hint {
    text-align: center;
    margin-top: 16px;
    padding: 12px 16px;
    background: #f0f4ff;
    border-radius: 10px;
    color: var(--sticky-primary-blue);
    font-size: 0.8rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: background 0.2s ease;
}

.sticky-expand-hint:hover {
    background: #e0e7ff;
}

.sticky-expand-hint i {
    color: var(--sticky-primary-orange);
    font-size: 0.9rem;
}

/* ============================================
   POSITIONING - FIXED WITH CASCADING MEDIA QUERIES
   ============================================ */

/* Large screens (1200px+): Show mini form */
@media (min-width: 1200px) {
    .sticky-collapsed-form {
        display: block !important;
    }
    
    .sticky-floating-button {
        display: none !important;
    }
    
    .sticky-form-widget.sticky-collapsed {
        left:10px;
        top: 50%;
        transform: translateY(-50%);
        bottom: auto;
    }
    
    .sticky-form-widget.sticky-expanded .sticky-collapsed-form {
        display: none !important;
    }
}

/* Base positioning for all screens below 1200px */
@media (max-width: 1199px) {
    .sticky-form-widget.sticky-collapsed {
        position: fixed !important;
        right: 2rem; /* 32px - matches back-to-top */
        bottom: calc(3.5rem + 50px + 30px); /* back-to-top bottom + height + gap */
        transform: none;
    }
    
    .sticky-collapsed-form {
        display: none !important;
    }
    
    .sticky-floating-button {
        display: flex !important;
        width: 50px;
        height: 50px;
        font-size: 22px;
    }
}

/* Tablet screens override */
@media (max-width: 768px) {
    .sticky-form-widget.sticky-collapsed {
        right: 1.5rem; /* 24px - matches back-to-top */
        bottom: calc(2.5rem + 45px + 30px); /* back-to-top bottom + height + gap */
    }
    
    .sticky-floating-button {
        width: 45px;
        height: 45px;
        font-size: 20px;
    }
    
    .sticky-button-text {
        display: none;
    }
}

/* Mobile screens override */
@media (max-width: 480px) {
    .sticky-form-widget.sticky-collapsed {
        right: 1rem; /* 16px - matches back-to-top */
        bottom: calc(2rem + 40px + 30px); /* back-to-top bottom + height + gap */
    }
    
    .sticky-floating-button {
        width: 40px;
        height: 40px;
        font-size: 18px;
    }
}

/* ============================================
   Expanded Form Styles
   ============================================ */
.sticky-expanded-form {
    width: 550px;
    max-width: calc(100vw - 40px);
    max-height: calc(100vh - 40px);
    background: white;
    border-radius: 16px;
    box-shadow: 0 20px 60px rgba(0, 62, 170, 0.15);
    overflow: hidden;
    box-sizing: border-box;
    opacity: 1;
    z-index: 9999;
    position: relative;
}

.sticky-expanded-form.sticky-fade-in {
    animation: fadeIn 0.2s ease-out;
}

.sticky-expanded-form.sticky-fade-out {
    animation: fadeOut 0.2s ease-out;
}

@keyframes fadeIn {
    from { 
        opacity: 0;
        transform: scale(0.95);
    }
    to { 
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes fadeOut {
    from { 
        opacity: 1;
        transform: scale(1);
    }
    to { 
        opacity: 0;
        transform: scale(0.95);
    }
}

.sticky-form-header {
    background: linear-gradient(135deg, var(--sticky-primary-blue) 0%, #0056d6 100%);
    color: white;
    padding: 16px 20px;
    text-align: center;
    position: relative;
}

.sticky-form-header h2 {
    font-size: 1.8rem;
    font-weight: 600;
    margin: 0 0 4px 0;
    color: white;
}

.sticky-form-header p {
    font-size: 0.8rem;
    opacity: 0.9;
    margin: 0;
}

.sticky-close-button {
    position: absolute;
    top: 12px;
    right: 12px;
    background: rgba(255, 255, 255, 0.2);
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    transition: background 0.2s ease;
    z-index: 10000;
}

.sticky-close-button:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* ============================================
   Form Body Styles
   ============================================ */
.sticky-form-body {
    padding: 16px 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 12px;
    align-items: start;
    box-sizing: border-box;
    max-height: calc(100vh - 180px);
    overflow-y: auto;
}

.sticky-form-row {
    display: contents;
}

.sticky-form-row.sticky-full-width {
    display: block;
    grid-column: 1 / -1;
    width: 100%;
}

.sticky-input-group {
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.sticky-input-group label {
    font-weight: 600;
    color: var(--sticky-text-dark);
    margin-bottom: 4px;
    font-size: 0.7rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.sticky-input-group input,
.sticky-input-group select,
.sticky-input-group textarea {
    width: 100%;
    padding: 8px 10px;
    border: 2px solid var(--sticky-border-color);
    border-radius: 8px;
    font-size: 0.8rem;
    font-family: inherit;
    transition: all 0.2s ease;
    background: white;
    box-sizing: border-box;
    min-width: 0;
}

.sticky-input-group input:focus,
.sticky-input-group select:focus,
.sticky-input-group textarea:focus {
    outline: none;
    border-color: var(--sticky-primary-orange);
    box-shadow: 0 0 0 3px rgba(255, 122, 0, 0.1);
}

.sticky-input-group input.sticky-error,
.sticky-input-group select.sticky-error,
.sticky-input-group textarea.sticky-error {
    border-color: var(--sticky-error-color);
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.1);
}

.sticky-input-group textarea {
    resize: vertical;
    min-height: 50px;
}

.sticky-error-message {
    color: var(--sticky-error-color);
    font-size: 0.7rem;
    margin-top: 3px;
    font-weight: 500;
    display: none;
}

.sticky-error-message.sticky-show {
    display: block;
}

/* ============================================
   Captcha Styles
   ============================================ */
.sticky-captcha-wrapper {
    width: 100%;
}

.sticky-captcha-container {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
}

.sticky-captcha-question {
    background: linear-gradient(135deg, var(--sticky-primary-blue) 0%, #0056d6 100%);
    color: white;
    padding: 8px 14px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 0.85rem;
    min-width: 90px;
    text-align: center;
    box-shadow: 0 4px 12px rgba(0, 62, 170, 0.2);
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sticky-captcha-container input {
    flex: 1;
    min-width: 60px;
    max-width: 100px;
}

.sticky-captcha-refresh {
    background: #f3f4f6;
    border: 2px solid var(--sticky-border-color);
    border-radius: 6px;
    width: 36px;
    height: 36px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s ease;
    color: var(--sticky-text-light);
    flex-shrink: 0;
}

.sticky-captcha-refresh:hover {
    background: var(--sticky-primary-orange);
    border-color: var(--sticky-primary-orange);
    color: white;
    transform: rotate(180deg);
}

.sticky-captcha-refresh:active {
    transform: rotate(180deg) scale(0.95);
}

.sticky-captcha-refresh i {
    font-size: 0.85rem;
}

/* ============================================
   Submit Button Styles
   ============================================ */
.sticky-submit-button {
    background: linear-gradient(135deg, var(--sticky-primary-orange) 0%, #e65a00 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 10px;
    font-size: 0.9rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    margin-top: 8px;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    width: 100%;
    box-sizing: border-box;
}

.sticky-submit-button:hover {
    background: linear-gradient(135deg, #e65a00 0%, #cc4700 100%);
    transform: translateY(-1px);
    box-shadow: 0 6px 20px rgba(255, 122, 0, 0.3);
}

.sticky-submit-button:active {
    transform: translateY(0);
}

.sticky-submit-button.sticky-loading {
    pointer-events: none;
    opacity: 0.8;
}

.sticky-submit-button.sticky-loading i {
    animation: sticky-spin 1s linear infinite;
}

@keyframes sticky-spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* ============================================
   Success Message Styles
   ============================================ */
.sticky-form-message {
    position: fixed;
    top: 20px;
    right: 20px;
    background: white;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.1);
    padding: 16px 20px;
    z-index: 10000;
    animation: sticky-slide-in 0.3s ease-out;
}

@keyframes sticky-slide-in {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.sticky-message-content {
    display: flex;
    align-items: center;
    gap: 12px;
}

.sticky-message-content i {
    font-size: 1.5rem;
    color: var(--sticky-success-color);
}

.sticky-message-content p {
    margin: 0;
    font-weight: 500;
    color: var(--sticky-text-dark);
}

/* ============================================
   Scrollbar Styles
   ============================================ */
.sticky-form-body::-webkit-scrollbar {
    width: 6px;
}

.sticky-form-body::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.sticky-form-body::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 10px;
}

.sticky-form-body::-webkit-scrollbar-thumb:hover {
    background: #555;
}

/* ============================================
   Mobile Responsive for Expanded Form
   ============================================ */
@media (max-width: 768px) {
    .sticky-expanded-form {
        width: calc(100vw - 20px);
        max-height: calc(100vh - 40px);
        border-radius: 12px;
    }
    
    .sticky-form-header {
        padding: 12px 14px;
    }
    
    .sticky-form-header h2 {
        font-size: 1.2rem;
    }
    
    .sticky-form-body {
        grid-template-columns: 1fr 1fr;
        gap: 8px;
        padding: 12px 14px;
    }
    
    .sticky-input-group label {
        font-size: 0.65rem;
        margin-bottom: 3px;
    }
    
    .sticky-input-group input,
    .sticky-input-group select,
    .sticky-input-group textarea {
        padding: 7px 9px;
        font-size: 0.75rem;
    }
}

@media (max-width: 480px) {
    .sticky-expanded-form {
        width: calc(100vw - 16px);
        border-radius: 10px;
    }
    
    .sticky-form-body {
        grid-template-columns: 1fr;
        padding: 10px 12px;
    }
    
    .sticky-captcha-container {
        flex-wrap: wrap;
        gap: 8px;
    }
    
    .sticky-captcha-question {
        width: 100%;
        padding: 8px 12px;
    }
    
    .sticky-captcha-container input {
        flex: 1;
        max-width: none;
        min-width: 0;
    }
    
    .sticky-captcha-refresh {
        flex-shrink: 0;
    }
}

/* ============================================
   Accessibility
   ============================================ */
@media (prefers-reduced-motion: reduce) {
    * {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

.sticky-close-button:focus,
.sticky-submit-button:focus,
.sticky-floating-button:focus {
    outline: 2px solid var(--sticky-primary-orange);
    outline-offset: 2px;
}

/* ============================================
   Print Styles
   ============================================ */
@media print {
    .sticky-form-widget {
        display: none !important;
    }
    
    .sticky-overlay {
        display: none !important;
    }
    
    .sticky-form-message {
        display: none !important;
    }
}