/**
 * GPS Validator Styles
 * Styling for GPS location validation interface
 */

/* Main GPS Container */
.gps-validation-container {
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 8px;
    padding: 20px;
    margin: 20px 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
}

/* GPS Status Indicator */
.gps-status-indicator {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px;
    background: white;
    border: 1px solid #ddd;
    border-radius: 6px;
    margin-bottom: 15px;
}

.gps-status-icon {
    font-size: 24px;
    width: 32px;
    text-align: center;
    animation: pulse 2s infinite;
}

.gps-status-text {
    flex: 1;
}

.gps-status-text strong {
    display: block;
    font-weight: 600;
    color: #333;
    margin-bottom: 2px;
}

.gps-status-message {
    font-size: 14px;
    color: #666;
}

.gps-status-message.searching {
    color: #007cba;
}

.gps-status-message.found {
    color: #46b450;
}

.gps-status-message.error {
    color: #d63638;
}

.gps-status-message.warning {
    color: #dba617;
}

.gps-accuracy-display {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-align: center;
}

.accuracy-label {
    font-size: 11px;
    color: #666;
    margin-bottom: 2px;
}

.accuracy-value {
    font-weight: 600;
    font-size: 13px;
    padding: 2px 6px;
    border-radius: 3px;
    background: #f0f0f0;
}

.accuracy-value.good {
    background: #d7eddd;
    color: #155724;
}

.accuracy-value.poor {
    background: #f8d7da;
    color: #721c24;
}

/* Coordinates Display */
.gps-coordinates-display {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 12px;
    margin-bottom: 15px;
}

.coordinate-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 4px 0;
    font-size: 13px;
}

.coordinate-item label {
    font-weight: 600;
    color: #555;
    margin: 0;
}

.coordinate-item .lat-display,
.coordinate-item .lng-display {
    font-family: Monaco, Consolas, "Courier New", monospace;
    background: #f8f9fa;
    padding: 2px 6px;
    border-radius: 3px;
    border: 1px solid #e9ecef;
    color: #333;
}

/* GPS Controls */
.gps-controls {
    display: flex;
    gap: 10px;
    margin-bottom: 15px;
}

.gps-controls .button {
    font-size: 13px;
    padding: 8px 12px;
    height: auto;
    line-height: 1.4;
    border-radius: 4px;
}

.refresh-gps-btn {
    background: #007cba;
    color: white;
    border: none;
}

.refresh-gps-btn:hover:not(:disabled) {
    background: #005a87;
}

.refresh-gps-btn:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.toggle-coordinates-btn {
    background: transparent;
    color: #007cba;
    border: 1px solid #007cba;
}

.toggle-coordinates-btn:hover {
    background: #007cba;
    color: white;
}

/* Manual Address Fallback */
.manual-address-fallback {
    background: #fff3cd;
    border: 1px solid #ffeaa7;
    border-radius: 6px;
    padding: 20px;
    margin-top: 15px;
}

.fallback-header {
    margin-bottom: 20px;
}

.fallback-header h4 {
    color: #856404;
    margin: 0 0 8px;
    font-size: 16px;
}

.fallback-header p {
    color: #664d03;
    margin: 0;
    font-size: 14px;
}

.manual-address-fields {
    background: white;
    border: 1px solid #ddd;
    border-radius: 4px;
    padding: 15px;
    margin-bottom: 15px;
}

.field-row {
    margin-bottom: 15px;
}

.field-row:last-child {
    margin-bottom: 0;
}

.field-row label {
    display: block;
    font-weight: 600;
    margin-bottom: 5px;
    color: #333;
}

.field-row input,
.field-row select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ccd0d4;
    border-radius: 3px;
    font-size: 14px;
    box-sizing: border-box;
}

.field-row input:focus,
.field-row select:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
    outline: none;
}

.checkbox-label {
    display: flex !important;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    font-weight: normal !important;
}

.checkbox-label input[type="checkbox"] {
    width: auto !important;
    margin: 0 !important;
}

/* Fallback Actions */
.fallback-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.fallback-actions .button {
    font-size: 13px;
    padding: 8px 16px;
    height: auto;
    line-height: 1.4;
}

.try-gps-again-btn {
    background: transparent;
    color: #007cba;
    border: 1px solid #007cba;
}

.try-gps-again-btn:hover {
    background: #007cba;
    color: white;
}

.confirm-manual-address-btn:disabled {
    background: #ccc !important;
    border-color: #ccc !important;
    color: #666 !important;
    cursor: not-allowed;
}

/* Validation Messages */
.gps-validation-messages {
    margin-top: 15px;
}

.validation-message {
    padding: 12px 15px;
    border-radius: 4px;
    margin-bottom: 10px;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.validation-message:last-child {
    margin-bottom: 0;
}

.success-message {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #b8daff;
}

.error-message {
    background: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}

.warning-message {
    background: #fff3cd;
    color: #856404;
    border: 1px solid #ffeaa7;
}

/* Animations */
@keyframes pulse {
    0% { opacity: 1; }
    50% { opacity: 0.7; }
    100% { opacity: 1; }
}

.gps-status-icon {
    animation: pulse 2s infinite;
}

.gps-status-message.searching + .gps-accuracy-display .accuracy-value {
    animation: blink 1s infinite;
}

@keyframes blink {
    0%, 50% { opacity: 1; }
    51%, 100% { opacity: 0.3; }
}

/* Responsive Design */
@media (max-width: 768px) {
    .gps-validation-container {
        padding: 15px;
    }
    
    .gps-status-indicator {
        flex-direction: column;
        gap: 10px;
        text-align: center;
    }
    
    .gps-controls {
        flex-direction: column;
    }
    
    .fallback-actions {
        flex-direction: column;
    }
    
    .coordinate-item {
        flex-direction: column;
        gap: 4px;
        align-items: flex-start;
    }
    
    .field-row input,
    .field-row select {
        font-size: 16px; /* Prevent zoom on iOS */
    }
}

/* RTL Support */
.rtl .gps-validation-container {
    direction: rtl;
}

.rtl .gps-status-indicator {
    direction: rtl;
}

.rtl .coordinate-item {
    direction: ltr; /* Keep coordinates LTR */
}

.rtl .checkbox-label {
    flex-direction: row-reverse;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
    .gps-validation-container {
        background: linear-gradient(135deg, #2d3748 0%, #1a202c 100%);
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .gps-status-indicator,
    .gps-coordinates-display,
    .manual-address-fields {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
    
    .accuracy-value {
        background: #4a5568;
        color: #e2e8f0;
    }
    
    .accuracy-value.good {
        background: #2f855a;
        color: #c6f6d5;
    }
    
    .accuracy-value.poor {
        background: #e53e3e;
        color: #fed7d7;
    }
    
    .field-row input,
    .field-row select {
        background: #2d3748;
        border-color: #4a5568;
        color: #e2e8f0;
    }
}

/* Print Styles */
@media print {
    .gps-validation-container {
        background: white;
        border: 1px solid #000;
        box-shadow: none;
    }
    
    .gps-controls,
    .fallback-actions {
        display: none;
    }
    
    .manual-address-fallback {
        background: white;
        border: 1px solid #000;
    }
}

/* High Contrast Mode */
@media (prefers-contrast: high) {
    .gps-validation-container {
        border: 2px solid #000;
    }
    
    .validation-message {
        border: 2px solid currentColor;
        font-weight: bold;
    }
    
    .accuracy-value.good {
        background: #00ff00;
        color: #000;
    }
    
    .accuracy-value.poor {
        background: #ff0000;
        color: #fff;
    }
}

/* Loading State */
.gps-validation-container.loading {
    position: relative;
    pointer-events: none;
    opacity: 0.7;
}

.gps-validation-container.loading::after {
    content: '';
    position: absolute;
    top: 50%;
    left: 50%;
    width: 32px;
    height: 32px;
    margin: -16px 0 0 -16px;
    border: 3px solid #f3f3f3;
    border-top: 3px solid #007cba;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    z-index: 10;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Integration with WordPress Admin */
.wp-admin .gps-validation-container {
    font-family: inherit;
}

.wp-admin .gps-validation-container .button {
    font-size: 13px;
    text-decoration: none;
    vertical-align: baseline;
}

/* Form Integration */
.geo-report-form .gps-validation-container {
    margin: 20px 0;
    order: 1; /* Place GPS validation early in form */
}

.postbox .gps-validation-container {
    background: transparent;
    border: 1px solid #ccd0d4;
    padding: 15px;
}

/* Accessibility */
.gps-validation-container button:focus,
.gps-validation-container input:focus,
.gps-validation-container select:focus {
    outline: 2px solid #007cba;
    outline-offset: 2px;
}

/* Screen readers will announce validation messages automatically due to role="alert" */

/* Status Icons with Screen Reader Text */
.gps-status-icon::after {
    content: attr(aria-label);
    position: absolute;
    left: -10000px;
    width: 1px;
    height: 1px;
    overflow: hidden;
}