/**
 * Mobile-Optimized Styles for Fire Hydrants Map
 */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

button {
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    -webkit-appearance: none;
    appearance: none;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: #333;
    background-color: #f5f5f5;
}

/* Login Page */
.login-page {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
    background: white;
    padding: 30px;
    border-radius: 10px;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.2);
    width: 100%;
    max-width: 400px;
}

.login-container h1 {
    text-align: center;
    margin-bottom: 30px;
    color: #333;
    font-size: 24px;
}

.login-form {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Map Page */
.map-page {
    height: 100vh;
    width: 100vw;
    overflow: hidden;
    position: relative;
}

#map {
    width: 100%;
    height: 100%;
    z-index: 1;
}

/* Form Overlay */
.form-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 1000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}

.form-overlay.active {
    opacity: 1;
    visibility: visible;
}

.form-container {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 500px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    position: relative;
}

.form-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.form-header h2 {
    font-size: 20px;
    color: #333;
}

.btn-close {
    background: none;
    border: none;
    font-size: 32px;
    color: #999;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    line-height: 1;
    transition: color 0.2s;
}

.btn-close:hover {
    color: #333;
}

#hydrantForm {
    padding: 20px;
}

.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #333;
    font-size: 14px;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 6px;
    font-size: 16px;
    font-family: inherit;
    transition: border-color 0.2s;
    -webkit-appearance: none;
    appearance: none;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #667eea;
}

.form-group input[readonly] {
    background-color: #f5f5f5;
    cursor: not-allowed;
}

.form-group select {
    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='%23333' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 12px center;
    padding-right: 40px;
}

/* Search Container */
.search-container {
    position: relative;
}

.search-results {
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: white;
    border: 1px solid #ddd;
    border-top: none;
    border-radius: 0 0 6px 6px;
    max-height: 200px;
    overflow-y: auto;
    z-index: 1000;
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    display: none;
}

.search-results.active {
    display: block;
}

.search-result-item {
    padding: 10px 12px;
    cursor: pointer;
    border-bottom: 1px solid #f0f0f0;
    transition: background-color 0.2s;
}

.search-result-item:hover {
    background-color: #f5f5f5;
}

.search-result-item:last-child {
    border-bottom: none;
}

.search-result-item.selected {
    background-color: #e3f2fd;
}

.search-result-item.created {
    opacity: 0.5;
    background-color: #e8f5e9;
}

.search-result-header {
    font-weight: 600;
    color: #333;
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 6px;
}

.search-result-details {
    font-size: 12px;
    color: #666;
}

.search-result-group {
    display: inline-block;
    background: #667eea;
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 11px;
    margin-left: auto;
}

.search-result-item.created .search-result-group {
    background: #4caf50;
}

/* Warning Indicators */
.warning-indicators {
    display: inline-flex;
    gap: 4px;
    align-items: center;
}

.warning-icon {
    font-size: 14px;
    display: inline-block;
    cursor: help;
    line-height: 1;
}

.warning-section {
    margin-top: 8px;
    padding: 8px;
    background: #fff3cd;
    border-left: 3px solid #ffc107;
    border-radius: 4px;
}

.warning-item {
    font-size: 13px;
    color: #856404;
    margin: 4px 0;
    display: flex;
    align-items: center;
    gap: 6px;
}

.warning-item .warning-icon {
    font-size: 16px;
}

.selected-hydrant-info {
    margin-top: 10px;
    padding: 10px;
    background: #e3f2fd;
    border-radius: 6px;
    border: 1px solid #90caf9;
}

.selected-hydrant-info strong {
    display: block;
    margin-bottom: 5px;
    color: #1976d2;
}

.selected-hydrant-info .info-line {
    font-size: 13px;
    color: #555;
    margin: 3px 0;
}

.selected-hydrant-info .clear-selection {
    margin-top: 8px;
    padding: 6px 12px;
    background: #dc3545;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 12px;
}

.selected-hydrant-info .clear-selection:hover {
    background: #c82333;
}

.form-actions {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
    margin-top: 30px;
}

/* Buttons */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 6px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    font-family: inherit;
    flex: 1;
    min-width: 100px;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover {
    background: #5568d3;
}

.btn-secondary {
    background: #6c757d;
    color: white;
}

.btn-secondary:hover {
    background: #5a6268;
}

.btn-danger {
    background: #dc3545;
    color: white;
}

.btn-danger:hover {
    background: #c82333;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

/* Floating Action Buttons */
.map-controls {
    position: fixed;
    bottom: 80px;
    right: 20px;
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.btn-fab {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 24px;
    padding: 0;
    flex: none;
    min-width: auto;
    border: none;
    margin: 0;
    position: relative;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.btn-fab span {
    line-height: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.btn-fab.active {
    background-color: #4CAF50;
    color: white;
    box-shadow: 0 4px 16px rgba(76, 175, 80, 0.5);
}

.btn-fab.active:hover {
    background-color: #45a049;
}

/* User Info */
.user-info {
    position: fixed;
    top: 10px;
    left: 10px;
    z-index: 1000;
    background: rgba(255, 255, 255, 0.95);
    padding: 10px 15px;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.15);
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 10px;
}

.user-info.compact {
    padding: 8px 12px;
}

.user-info-text {
    font-size: 14px;
    color: #333;
}

.user-info.compact .user-info-text {
    display: none;
}

.logout-link {
    color: #d32f2f;
    text-decoration: none;
    font-size: 13px;
    font-weight: 500;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    white-space: nowrap;
}

.logout-link:hover {
    background: rgba(211, 47, 47, 0.1);
    text-decoration: underline;
}

.user-info.compact .logout-link {
    font-size: 12px;
    padding: 6px 10px;
}

/* Error Message */
.error-message {
    background: #fee;
    color: #c33;
    padding: 12px;
    border-radius: 6px;
    margin-top: 15px;
    font-size: 14px;
    border: 1px solid #fcc;
}

/* Marker Popup */
.marker-popup {
    padding: 5px;
}

.marker-popup strong {
    display: inline-block;
    min-width: 60px;
}

.btn-edit {
    margin-top: 10px;
    padding: 6px 12px;
    background: #667eea;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 14px;
    width: 100%;
}

.btn-edit:hover {
    background: #5568d3;
}

/* Mobile Optimizations */
@media (max-width: 768px) {
    .form-container {
        max-width: 100%;
        max-height: 100vh;
        border-radius: 0;
    }
    
    .form-overlay {
        padding: 0;
    }
    
    .form-overlay.active {
        align-items: flex-end;
    }
    
    .user-info {
        font-size: 12px;
        padding: 8px 12px;
        flex-wrap: wrap;
        gap: 5px;
    }
    
    .map-controls {
        bottom: 20px;
        right: 15px;
        gap: 12px;
    }
    
    .btn-fab {
        width: 50px;
        height: 50px;
        font-size: 20px;
        box-shadow: 0 3px 10px rgba(0, 0, 0, 0.25);
        flex-shrink: 0;
    }
    
    .btn-fab span {
        font-size: 20px;
        line-height: 1;
    }
    
    .login-container {
        padding: 25px;
    }
    
    .login-container h1 {
        font-size: 22px;
    }
}

@media (max-width: 480px) {
    .form-actions {
        flex-direction: column;
    }
    
    .btn {
        width: 100%;
    }
    
    .user-info {
        font-size: 11px;
    }
    
    .map-controls {
        bottom: 15px;
        right: 10px;
        gap: 10px;
    }
    
    .btn-fab {
        width: 48px;
        height: 48px;
        font-size: 18px;
        min-width: 48px;
        min-height: 48px;
    }
    
    .btn-fab span {
        font-size: 18px;
        line-height: 1;
    }
}

/* Touch-friendly improvements */
@media (hover: none) and (pointer: coarse) {
    .btn,
    .btn-fab,
    .btn-close {
        min-height: 44px;
    }
    
    .form-group input,
    .form-group select {
        min-height: 44px;
    }
}

/* Prevent text selection on buttons */
.btn,
.btn-fab,
.btn-close {
    -webkit-tap-highlight-color: transparent;
    user-select: none;
    -webkit-user-select: none;
}

/* Scrollbar styling for form */
.form-container::-webkit-scrollbar {
    width: 8px;
}

.form-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.form-container::-webkit-scrollbar-thumb {
    background: #888;
    border-radius: 4px;
}

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

/* Run Mode Styles */
.run-dialog-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2000;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.run-dialog {
    background: white;
    border-radius: 10px;
    width: 100%;
    max-width: 600px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
}

.run-dialog-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    border-bottom: 1px solid #eee;
}

.run-dialog-header h2 {
    margin: 0;
    font-size: 20px;
}

.run-dialog-content {
    padding: 20px;
}

.run-selection-section {
    margin-bottom: 30px;
}

.run-selection-section h3 {
    margin-bottom: 15px;
    font-size: 16px;
    color: #333;
}

.checkbox-list {
    max-height: 200px;
    overflow-y: auto;
    border: 1px solid #ddd;
    border-radius: 5px;
    padding: 10px;
}

.checkbox-item {
    display: flex;
    align-items: center;
    padding: 8px;
    cursor: pointer;
    border-radius: 4px;
    transition: background 0.2s;
}

.checkbox-item:hover {
    background: #f5f5f5;
}

.checkbox-item input[type="checkbox"] {
    margin-right: 10px;
    width: 18px;
    height: 18px;
    cursor: pointer;
}

.run-dialog-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
    margin-top: 20px;
    padding-top: 20px;
    border-top: 1px solid #eee;
}

/* Run Info Bar */
.run-info-bar {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background: #4CAF50;
    color: white;
    z-index: 1500;
    padding: 12px 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

.run-info-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    flex-wrap: wrap;
    gap: 15px;
}

.run-info-text {
    font-size: 14px;
}

.run-progress {
    font-weight: bold;
    font-size: 14px;
}

.btn-small {
    padding: 6px 12px;
    font-size: 13px;
    background: rgba(255, 255, 255, 0.2);
    border: 1px solid rgba(255, 255, 255, 0.3);
    color: white;
    border-radius: 4px;
    cursor: pointer;
    transition: background 0.2s;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.3);
}

/* Hydrant List Panel */
.hydrant-list-panel {
    position: fixed;
    right: 0;
    top: 0;
    bottom: 0;
    width: 100%;
    max-width: 400px;
    background: white;
    z-index: 1001;
    box-shadow: -2px 0 10px rgba(0, 0, 0, 0.2);
    display: flex;
    flex-direction: column;
}

.hydrant-list-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 15px 20px;
    border-bottom: 1px solid #eee;
    background: #f8f9fa;
}

.hydrant-list-header h3 {
    margin: 0;
    font-size: 18px;
}

.hydrant-list-content {
    flex: 1;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.list-search-container {
    padding: 15px;
    border-bottom: 1px solid #eee;
}

.list-search-container input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 5px;
    font-size: 14px;
}

.hydrant-list-items {
    flex: 1;
    overflow-y: auto;
    padding: 10px;
}

.hydrant-list-item {
    padding: 12px;
    margin-bottom: 8px;
    border: 1px solid #ddd;
    border-radius: 5px;
    background: white;
    transition: all 0.2s;
}

.hydrant-list-item:hover:not(.completed) {
    background: #f0f7ff;
    border-color: #4CAF50;
    transform: translateX(-2px);
}

.hydrant-list-item.completed {
    opacity: 0.6;
    background: #f5f5f5;
}

.item-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 6px;
}

.item-header strong {
    flex: 1;
    font-size: 15px;
}

.warning-badge {
    font-size: 16px;
    cursor: help;
}

.completed-badge {
    background: #4CAF50;
    color: white;
    padding: 2px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: normal;
}

.item-comment {
    font-size: 13px;
    color: #666;
    margin-top: 4px;
    font-style: italic;
}

.item-group {
    font-size: 12px;
    color: #888;
    margin-top: 4px;
}

.list-actions {
    padding: 15px;
    border-top: 1px solid #eee;
    background: #f8f9fa;
}

.list-actions .btn {
    width: 100%;
}

/* Position Selection Info Bar */
.position-selection-info {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    background: #2196F3;
    color: white;
    z-index: 1500;
    padding: 15px 20px;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    max-width: 90%;
    display: none;
}

.position-info-content {
    display: flex;
    flex-direction: column;
    gap: 10px;
    align-items: center;
}

.position-info-text {
    font-size: 14px;
    font-weight: 500;
}

.position-info-hint {
    font-size: 13px;
    opacity: 0.9;
    text-align: center;
}

.position-info-content .btn {
    margin: 0 5px;
    padding: 8px 16px;
    font-size: 13px;
}

.position-info-content .btn-small {
    padding: 6px 12px;
    font-size: 12px;
}

/* Mobile adjustments */
@media (max-width: 768px) {
    .hydrant-list-panel {
        max-width: 100%;
    }
    
    .run-dialog {
        max-width: 100%;
    }
    
    .run-info-content {
        flex-direction: column;
        align-items: flex-start;
    }
    
    .position-selection-info {
        bottom: 10px;
        left: 10px;
        right: 10px;
        transform: none;
        max-width: 100%;
    }
    
    .position-info-content {
        flex-direction: column;
    }
    
    .position-info-content .btn {
        width: 100%;
        margin: 5px 0;
    }
}

