/**
 * Form Persistence Visual Indicators
 * Provides visual feedback when form fields are auto-filled from stored data
 */

/* Auto-filled field indicator */
.form-field-autofilled {
    position: relative;
    border-color: #ff4d00 !important;
    box-shadow: 0 0 0 0.2rem rgba(45,55,72, 0.15) !important;
}

.form-field-autofilled::before {
    content: "📋";
    position: absolute;
    top: -8px;
    right: -8px;
    background: #ff4d00;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 10px;
    z-index: 10;
    animation: fadeInScale 0.3s ease-out;
}

/* Auto-fill notification */
.auto-fill-notification {
    position: fixed;
    top: 20px;
    right: 20px;
    background: #ff4d00;
    color: white;
    padding: 12px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(45,55,72, 0.3);
    z-index: 1000;
    animation: slideInRight 0.3s ease-out;
    font-size: 14px;
    font-weight: 500;
    max-width: 300px;
}

.auto-fill-notification .close-btn {
    background: none;
    border: none;
    color: white;
    font-size: 16px;
    margin-left: 10px;
    cursor: pointer;
    opacity: 0.8;
}

.auto-fill-notification .close-btn:hover {
    opacity: 1;
}

/* Animations */
@keyframes fadeInScale {
    0% {
        opacity: 0;
        transform: scale(0.5);
    }
    100% {
        opacity: 1;
        transform: scale(1);
    }
}

@keyframes slideInRight {
    0% {
        opacity: 0;
        transform: translateX(100%);
    }
    100% {
        opacity: 1;
        transform: translateX(0);
    }
}

@keyframes fadeOut {
    0% {
        opacity: 1;
    }
    100% {
        opacity: 0;
    }
}

/* Form validation enhancement */
.form-control.auto-filled {
    border-color: #ff4d00;
    background-color: rgba(45,55,72, 0.05);
}

.form-control.auto-filled:focus {
    border-color: #ff4d00;
    box-shadow: 0 0 0 0.2rem rgba(45,55,72, 0.25);
}

/* Select box auto-fill styling */
.form-select.auto-filled {
    border-color: #ff4d00;
    background-color: rgba(45,55,72, 0.05);
}

/* Toggle button auto-fill styling */
.location-type-toggle .toggle-option.auto-filled {
    border: 2px solid #ff4d00;
    background-color: rgba(45,55,72, 0.1);
}

/* Progress indicator for form completion */
.form-progress {
    height: 4px;
    background: #e2e8f0;
    border-radius: 2px;
    overflow: hidden;
    margin-bottom: 15px;
}

.form-progress-bar {
    height: 100%;
    background: linear-gradient(90deg, #ff4d00, #17a2b8);
    border-radius: 2px;
    transition: width 0.3s ease;
}

/* Responsive adjustments */
@media (max-width: 768px) {
    .auto-fill-notification {
        top: 10px;
        right: 10px;
        left: 10px;
        max-width: none;
        font-size: 13px;
        padding: 10px 15px;
    }
    
    .form-field-autofilled::before {
        width: 16px;
        height: 16px;
        font-size: 8px;
        top: -6px;
        right: -6px;
    }
}

/* Loading state for form persistence */
.form-loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 100;
    border-radius: 8px;
}

.form-loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid #e2e8f0;
    border-top: 2px solid #ff4d00;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Success indicator */
.form-success-indicator {
    color: #ff4d00;
    font-size: 12px;
    margin-top: 5px;
    display: flex;
    align-items: center;
    gap: 5px;
    opacity: 0;
    animation: fadeIn 0.3s ease-out 0.5s forwards;
}

@keyframes fadeIn {
    to { opacity: 1; }
}

/* Clear data button styling */
.clear-form-data-btn {
    background: transparent;
    border: 1px solid #e2e8f0;
    color: #6c757d;
    padding: 5px 10px;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.clear-form-data-btn:hover {
    border-color: #dc3545;
    color: #dc3545;
    background: rgba(220, 53, 69, 0.05);
}

/* Tooltip for auto-filled fields */
.auto-fill-tooltip {
    position: absolute;
    bottom: 100%;
    left: 50%;
    transform: translateX(-50%);
    background: #2d3748;
    color: white;
    padding: 6px 10px;
    border-radius: 4px;
    font-size: 11px;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s ease;
    z-index: 1000;
}

.auto-fill-tooltip::after {
    content: '';
    position: absolute;
    top: 100%;
    left: 50%;
    transform: translateX(-50%);
    border: 4px solid transparent;
    border-top-color: #2d3748;
}

.form-field-autofilled:hover .auto-fill-tooltip {
    opacity: 1;
}
