/**
 * Location Search Component Styles
 * Styles for Google Maps Places API integration
 */

.location-search-container {
    position: relative;
    width: 100%;
}

.location-search-wrapper {
    position: relative;
    width: 100%;
}

.location-search-input {
    width: 100%;
    padding: 12px 48px 12px 16px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    transition: border-color 0.3s ease, box-shadow 0.2s ease;
}

.location-search-input:focus {
    outline: none;
    border-color: #007cba;
    box-shadow: 0 0 0 2px rgba(0, 124, 186, 0.1);
}

.location-search-input.error {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.1);
}

.location-search-input.error:focus {
    border-color: #dc3545;
    box-shadow: 0 0 0 2px rgba(220, 53, 69, 0.2);
}

.location-search-input.location-selected {
    border-color: #28a745;
    box-shadow: 0 0 0 2px rgba(40, 167, 69, 0.2);
    transition: all 0.3s ease;
}

.location-suggestions {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #fff;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    display: none;
}

.location-suggestion {
    padding: 12px 16px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s ease;
}

.location-suggestion:hover,
.location-suggestion.selected {
    background-color: #f8f9fa;
}

.location-suggestion:last-child {
    border-bottom: none;
}

.location-suggestion-main {
    font-weight: 500;
    color: #333;
}

.location-suggestion-secondary {
    font-size: 14px;
    color: #666;
    margin-top: 2px;
}

.current-location-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    padding: 0;
    background: #f5f7fb;
    border: 1px solid #dfe3eb;
    border-radius: 50%;
    cursor: pointer;
    color: #1d4ed8;
    transition: background-color 0.2s ease, box-shadow 0.2s ease, color 0.2s ease;
}

.current-location-btn:hover {
    background: #e9eef7;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.08);
}

.current-location-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.current-location-btn.icon-only svg {
    pointer-events: none;
}

.current-location-btn.loading {
    background: #e3f2fd;
    border-color: #2196f3;
    color: #1976d2;
}

.current-location-btn.success {
    background: #e8f5e8;
    border-color: #4caf50;
    color: #2e7d32;
}

.current-location-btn.error {
    background: #ffebee;
    border-color: #f44336;
    color: #c62828;
}

.location-loading {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.location-error {
    color: #dc3545;
    font-size: 14px;
    margin-top: 4px;
    padding: 8px 12px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    border-radius: 4px;
}

.geolocation-error-message {
    line-height: 1.4;
}

.location-success {
    color: #28a745;
    font-size: 14px;
    margin-top: 4px;
    padding: 8px 12px;
    background: #d4edda;
    border: 1px solid #c3e6cb;
    border-radius: 4px;
}

.location-input-feedback {
    font-size: 14px;
    margin-top: 4px;
    padding: 6px 12px;
    border-radius: 4px;
    display: none;
    line-height: 1.4;
}

.location-input-feedback.info {
    color: #0c5460;
    background: #d1ecf1;
    border: 1px solid #bee5eb;
}

.location-input-feedback.error {
    color: #721c24;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
}

.location-input-feedback.warning {
    color: #856404;
    background: #fff3cd;
    border: 1px solid #ffeaa7;
}

.location-toast-container {
    position: fixed;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 2000;
}

.location-toast {
    min-width: 240px;
    max-width: 320px;
    padding: 12px 14px;
    border-radius: 8px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.12);
    color: #0f172a;
    background: #ffffff;
    border: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: toast-in 0.18s ease-out;
}

.location-toast.success {
    border-color: #bbf7d0;
    background: #f0fdf4;
    color: #166534;
}

.location-toast.error {
    border-color: #fecdd3;
    background: #fff1f2;
    color: #9f1239;
}

.location-toast .toast-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
}

@keyframes toast-in {
    from { opacity: 0; transform: translateY(-8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Responsive design */
@media (max-width: 768px) {
    .location-search-input {
        font-size: 16px; /* Prevent zoom on iOS */
        padding: 14px 48px 14px 16px; /* Larger touch target + icon space */
    }
    
    .location-suggestions {
        max-height: 150px;
    }
    
    .location-suggestion {
        padding: 12px 16px; /* Larger touch target */
        min-height: 44px; /* iOS recommended minimum touch target */
        display: flex;
        flex-direction: column;
        justify-content: center;
    }
    
    .current-location-btn {
        width: 40px;
        height: 40px;
        right: 10px;
    }
    
    .location-search-help {
        font-size: 14px;
        margin-top: 8px;
    }
}

@media (max-width: 480px) {
    .location-search-container {
        margin-bottom: 16px;
    }
    
    .location-search-input {
        padding: 16px 52px 16px 16px;
        font-size: 16px;
    }
    
    .location-suggestion {
        padding: 16px;
        min-height: 48px;
    }
    
    .current-location-btn {
        width: 42px;
        height: 42px;
        right: 12px;
    }
    
    .location-suggestion-main {
        font-size: 15px;
        line-height: 1.3;
    }
    
    .location-suggestion-secondary {
        font-size: 13px;
        margin-top: 4px;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .location-search-input {
        border-width: 2px;
    }
    
    .location-search-input:focus {
        border-width: 3px;
    }
    
    .location-suggestion:hover,
    .location-suggestion.selected {
        background-color: #000;
        color: #fff;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .location-search-input,
    .location-suggestion,
    .current-location-btn {
        transition: none;
    }
    
    .location-loading {
        animation: none;
    }
}

/* Focus visible support for better keyboard navigation */
.location-search-input:focus-visible {
    outline: 2px solid #005a9c;
    outline-offset: 2px;
}

.current-location-btn:focus-visible {
    outline: 2px solid #005a9c;
    outline-offset: 2px;
}

.location-suggestion:focus-visible {
    outline: 2px solid #005a9c;
    outline-offset: -2px;
}

/* Screen reader only content */
.sr-only {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

/* Fallback styles for JavaScript disabled scenarios */
.location-search-fallback {
    margin: 15px 0;
}

.location-search-noscript-notice {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
}

.location-search-noscript-notice p {
    margin: 0 0 8px 0;
    color: #856404;
}

.location-search-noscript-notice p:last-child {
    margin-bottom: 0;
}

.location-search-manual {
    background: #f8f9fa;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 15px;
}

.location-search-label {
    display: block;
    font-weight: 600;
    margin-bottom: 8px;
    color: #333;
}

.location-search-label .required {
    color: #dc3545;
    margin-left: 3px;
}

.location-input-group {
    margin-bottom: 12px;
}

.location-search-input-manual {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid #ced4da;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    background-color: #fff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
}

.location-search-input-manual:focus {
    border-color: #80bdff;
    outline: 0;
    box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.25);
}

.location-search-input-manual:invalid {
    border-color: #dc3545;
}

.location-manual-help {
    margin-top: 6px;
}

.location-manual-help small {
    color: #6c757d;
    font-size: 12px;
    line-height: 1.4;
}

.location-validation-info {
    margin-top: 12px;
    padding-top: 12px;
    border-top: 1px solid #dee2e6;
}

.location-validation-note {
    margin: 0;
    font-size: 13px;
    color: #495057;
    line-height: 1.4;
}

.location-validation-note strong {
    color: #333;
}

/* Error handling styles for comprehensive errors */
.location-suggestion.error {
    padding: 12px 16px;
    background: #f8d7da;
    border: 1px solid #f5c6cb;
    color: #721c24;
}

.location-suggestion.error .error-message {
    font-weight: 600;
    margin-bottom: 6px;
}

.location-suggestion.error .error-fallback {
    font-size: 14px;
    color: #856404;
    margin-bottom: 8px;
}

.location-suggestion.error .error-actions {
    margin-top: 8px;
}

.retry-search-btn {
    background: #007cba;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 3px;
    font-size: 12px;
    cursor: pointer;
    transition: background-color 0.2s ease;
}

.retry-search-btn:hover {
    background: #005a87;
}

/* Responsive adjustments for fallback */
@media (max-width: 768px) {
    .location-search-fallback {
        margin: 10px 0;
    }
    
    .location-search-manual {
        padding: 12px;
    }
    
    .location-search-input-manual {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* Print styles */
@media print {
    .location-search-noscript-notice {
        display: none;
    }
    
    .location-search-fallback {
        break-inside: avoid;
    }
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    .location-search-noscript-notice {
        border-width: 2px;
    }
    
    .location-search-manual {
        border-width: 2px;
    }
    
    .location-search-input-manual:focus {
        border-width: 2px;
    }
}

/* Reduced motion support */
@media (prefers-reduced-motion: reduce) {
    .location-search-input-manual {
        transition: none;
    }
    
    .retry-search-btn {
        transition: none;
    }
}
