/* Prevent iOS zoom on double-tap */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    touch-action: manipulation;
    -webkit-tap-highlight-color: transparent;
}
/* Add this new rule right after: */
/* *:not(.container):not(.modal-content) {
    max-width: 100vw !important;
}*/




/* Keep your original html/body rules but add these specific fixes */
html, body {
    min-height: 100vh;
    overflow-x: hidden !important;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #1a365d 0%, #2c5aa0 100%);
    min-height: 100vh;
    color: #333;
    touch-action: pan-x pan-y;
    width: 100%;
    overflow-x: hidden !important;
    -webkit-overflow-scrolling: touch;
}

/* More aggressive container locking */
.container {
    max-width: 400px;
    width: 100%;
    margin: 0 auto;
    padding: 20px;
    background: white;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    margin-top: 50px;
    overflow: hidden; /* Prevent content overflow */
    transform: translateX(0); /* Lock horizontal position */
    min-width: 320px; /* Prevent shrinking on small screens */
    position: relative;
}

.header {
    text-align: center;
    margin-bottom: 20px;
}

/* Logo Styles */
.proximity-logo {
    display: inline-flex;
    align-items: center;
    background: linear-gradient(135deg, #1a365d 0%, #2c5aa0 100%);
    padding: 16px 24px;
    border-radius: 12px;
    gap: 16px;
    margin-bottom: 10px;
}

.logo-circles {
    position: relative;
    width: 40px;
    height: 24px;
}

.logo-circle {
    position: absolute;
    width: 24px;
    height: 24px;
    border-radius: 50%;
}

.circle1 {
    background: radial-gradient(circle at 30% 30%, #f8f9fa 0%, #e9ecef 40%, #dee2e6 100%);
    opacity: 0.9;
    left: 0;
}

.circle2 {
    background: radial-gradient(circle at 30% 30%, #e9ecef 0%, #ced4da 40%, #adb5bd 100%);
    opacity: 0.8;
    left: 12px;
}

.logo-text {
    font-size: 24px;
    font-weight: 400;
    color: #ffffff;
    letter-spacing: -0.02em;
}

.subtitle {
    color: #6c757d;
    font-size: 14px;
}

.location-display {
    background: #f0f4f8;
    padding: 15px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.location-title {
    font-size: 12px;
    color: #1a365d;
    text-transform: uppercase;
    letter-spacing: 1px;
    margin-bottom: 5px;
}

.location-value {
    font-size: 16px;
    color: #1a365d;
    font-weight: 600;
    word-break: break-word; /* Prevent text overflow */
    overflow-wrap: break-word;
    max-width: 100%;
}

.settings-group {
    margin-bottom: 25px;
}

.settings-label {
    font-size: 14px;
    color: #1a365d;
    margin-bottom: 15px;
    display: block;
    text-transform: uppercase;
    letter-spacing: 1px;
    text-align: center;
    font-weight: 600;
}

/* Distance Display Window */
.distance-display {
    background: #f0f4f8;
    border: 2px solid #1a365d;
    border-radius: 8px;
    padding: 10px 20px;
    margin: 0 auto 15px;
    width: 200px;
    text-align: center;
    font-size: 16px;
    font-weight: 600;
    color: #1a365d;
    min-height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.distance-display.active {
    background: #1a365d;
    color: white;
}

/* Database Toggle Styles */
.database-toggle {
    width: 100%;
    padding: 15px;
    background: #f0f4f8;
    border: 2px solid #1a365d;
    border-radius: 8px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
    margin-bottom: 10px;
}

.database-toggle:hover {
    background: #e2e8f0;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.2);
}

.database-toggle:active {
    transform: translateY(0);
}

.db-name {
    font-size: 16px;
    font-weight: 600;
    color: #1a365d;
}

.db-indicator {
    color: #1a365d;
    font-size: 20px;
    transition: transform 0.3s ease;
}

.database-toggle:hover .db-indicator {
    transform: translateX(5px);
}

/* Locations List */
.locations-list {
    margin-top: 30px;
    max-width: 100%; /* Prevent overflow */
    overflow-x: hidden;
}

.locations-title {
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 15px;
    color: #1a365d;
}

.location-item {
    background: #f0f4f8;
    border-left: 4px solid #1a365d;
    padding: 15px;
    margin-bottom: 10px;
    border-radius: 8px;
    transition: all 0.3s ease;
    cursor: pointer;
    max-width: 100%; /* Prevent overflow */
    overflow-x: hidden;
}

.location-item:hover {
    transform: translateX(5px);
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
}

.location-name {
    font-weight: 600;
    color: #1a365d;
    margin-bottom: 5px;
    word-break: break-word; /* Prevent text overflow */
    overflow-wrap: break-word;
    max-width: 100%;
}

.location-address {
    font-size: 14px;
    color: #6c757d;
    margin-bottom: 5px;
    word-break: break-word; /* Prevent text overflow */
    overflow-wrap: break-word;
    max-width: 100%;
}

.location-distance {
    font-size: 14px;
    color: #2c5aa0;
    font-weight: 600;
}

.location-details-hint {
    font-size: 11px;
    color: #999;
    margin-top: 5px;
}

/* Clock Faces */
.clock-container {
    display: flex;
    justify-content: space-around;
    margin-bottom: 25px;
}

.clock-wrapper {
    display: flex;
    flex-direction: column;
    align-items: center;
    cursor: pointer;
}

.clock-face {
    width: 60px;
    height: 60px;
    border: 3px solid #1a365d;
    border-radius: 50%;
    position: relative;
    transition: all 0.3s ease;
    background: white;
}

.clock-face:hover {
    transform: scale(1.1);
    border-color: #2c5aa0;
    box-shadow: 0 4px 12px rgba(26, 54, 93, 0.2);
}

.clock-face.selected {
    background: #1a365d;
    border-color: #1a365d;
    transform: scale(1.15);
    box-shadow: 0 4px 15px rgba(26, 54, 93, 0.4);
}

.clock-center {
    position: absolute;
    width: 6px;
    height: 6px;
    background: #1a365d;
    border-radius: 50%;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 3;
}

.clock-face.selected .clock-center {
    background: white;
}

.clock-hand {
    position: absolute;
    background: #1a365d;
    transform-origin: bottom center;
    left: 50%;
    bottom: 50%;
}

.clock-face.selected .clock-hand {
    background: white;
}

.hour-hand {
    width: 3px;
    height: 15px;
    margin-left: -1.5px;
}

.minute-hand {
    width: 2px;
    height: 20px;
    margin-left: -1px;
}

.clock-label {
    text-align: center;
    margin-top: 5px;
    font-size: 11px;
    color: #6c757d;
}

.clock-wrapper.selected .clock-label {
    color: #1a365d;
    font-weight: bold;
}

/* Concentric Rings */
.rings-container {
    position: relative;
    width: 320px;
    height: 320px;
    margin: 0 auto;
}

.distance-ring {
    position: absolute;
    border-radius: 50%;
    border: 4px solid #1a365d;
    cursor: pointer;
    transition: all 0.3s ease;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: transparent;
}

.distance-ring:hover {
    border-width: 5px;
    border-color: #1a365d;
    box-shadow: 0 0 15px rgba(26, 54, 93, 0.3);
}

.distance-ring.selected {
    border-width: 6px;
    border-color: #1a365d;
}

.ring-1 {
    width: 80px;
    height: 80px;
    z-index: 5;
}

.ring-1.selected {
    background: #1a365d;
}

.ring-2 {
    width: 140px;
    height: 140px;
    z-index: 4;
}

.ring-2.selected {
    background: #1a365d;
    -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 34px, black 34px);
    mask-image: radial-gradient(circle at center, transparent 0, transparent 34px, black 34px);
}

.ring-3 {
    width: 200px;
    height: 200px;
    z-index: 3;
}

.ring-3.selected {
    background: #1a365d;
    -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 64px, black 64px);
    mask-image: radial-gradient(circle at center, transparent 0, transparent 64px, black 64px);
}

.ring-4 {
    width: 260px;
    height: 260px;
    z-index: 2;
}

.ring-4.selected {
    background: #1a365d;
    -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 94px, black 94px);
    mask-image: radial-gradient(circle at center, transparent 0, transparent 94px, black 94px);
}

.ring-5 {
    width: 320px;
    height: 320px;
    z-index: 1;
}

.ring-5.selected {
    background: #1a365d;
    -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 124px, black 124px);
    mask-image: radial-gradient(circle at center, transparent 0, transparent 124px, black 124px);
}

/* Crosshair */
.crosshair {
    position: absolute;
    width: 30px;
    height: 30px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 10;
    pointer-events: none;
}

.crosshair::before,
.crosshair::after {
    content: '';
    position: absolute;
    background: #1a365d;
    opacity: 0.5;
}

.crosshair::before {
    width: 2px;
    height: 30px;
    left: 50%;
    transform: translateX(-50%);
}

.crosshair::after {
    width: 30px;
    height: 2px;
    top: 50%;
    transform: translateY(-50%);
}

/* Controls */
.controls {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.btn {
    flex: 1;
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    max-width: 100%;
}

.btn-primary {
    background: #1a365d;
    color: white;
}

.btn-primary:hover {
    background: #2c5aa0;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(26, 54, 93, 0.4);
}

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

.btn-secondary:hover {
    background: #5a6268;
    transform: translateY(-2px);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

/* Add Project Button */
.btn-add-project {
    background: #28a745;
    color: white;
}

.btn-add-project:hover {
    background: #218838;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(40, 167, 69, 0.4);
}

.btn-navigate {
    margin-top: 10px;
    padding: 8px 16px;
    background: #1a365d;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    transition: all 0.3s ease;
}

.btn-navigate:hover {
    background: #2c5aa0;
    transform: translateY(-2px);
}

/* Status Messages */
.status {
    padding: 10px;
    border-radius: 8px;
    margin-top: 15px;
    text-align: center;
    font-size: 14px;
    display: none;
    max-width: 100%;
    overflow-x: hidden;
}

.status.show {
    display: block;
}

.status.success {
    background: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

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

.status.info {
    background: #d1ecf1;
    color: #0c5460;
    border: 1px solid #bee5eb;
}

/* Loading Spinner */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
}

.loading.show {
    display: block;
}

.spinner {
    border: 4px solid #f3f3f3;
    border-top: 4px solid #1a365d;
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

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

/* Modal Styles */
.modal {
    display: none;
    position: fixed;
    z-index: 10001;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    overflow: auto;
    background-color: rgba(0, 0, 0, 0.7);
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal-content {
    background-color: white;
    border-radius: 15px;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideIn 0.3s ease-out;
    max-width: calc(100vw - 40px); /* Account for padding */
    margin: 0 auto;
}

@keyframes slideIn {
    from {
        transform: translateY(-50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px 25px;
    border-bottom: 2px solid #f0f4f8;
}

.modal-header h2 {
    color: #1a365d;
    margin: 0;
    font-size: 24px;
}

.close-modal {
    font-size: 32px;
    font-weight: bold;
    color: #6c757d;
    cursor: pointer;
    line-height: 1;
    transition: color 0.3s ease;
}

.close-modal:hover {
    color: #1a365d;
}

.modal-body {
    padding: 25px;
}

.modal-footer {
    display: flex;
    gap: 10px;
    padding: 20px 25px;
    border-top: 2px solid #f0f4f8;
    justify-content: flex-end;
}

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

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

.form-group input, .form-group select, .form-group textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #dee2e6;
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom */
    transition: border-color 0.3s ease;
    max-width: 100%;
}

.form-group input:focus, .form-group select:focus, .form-group textarea:focus {
    outline: none;
    border-color: #1a365d;
}

.form-row {
    display: flex;
    gap: 15px;
}

.form-row .form-group {
    flex: 1;
}

.required {
    color: #dc3545;
}

.form-note {
    color: #6c757d;
    font-size: 12px;
    margin-top: 10px;
}

.location-helper {
    margin: 15px 0;
    text-align: center;
}

.btn-small {
    padding: 8px 16px;
    font-size: 14px;
    margin-top: 8px;
    width: 100%;
}

/* Clean button row styling - scoped properly */
div.button-row {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

div.button-row .btn-add-project {
    flex: 1;
}

div.button-row .help-button {
    flex: 0 0 auto;
    background: linear-gradient(135deg, #1a365d 0%, #2c5aa0 100%);
    color: white;
    border: none;
    padding: 12px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-decoration: none;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    white-space: nowrap;
}

div.button-row .help-button:hover {
    background: #2c5aa0;
    transform: translateY(-2px);
    box-shadow: 0 5px 20px rgba(26, 54, 93, 0.4);
}

/* Blitz Button and alert toggle */
.btn-blitz {
    margin-bottom: 18px;
    padding: 12px 24px;
    background: #ff9800;
    color: #fff;
    font-size: 16px;
    border: none;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
    width: 100%;
}

.btn-blitz:hover {
    background: #fb8c00;
}

/* Container for both toggles - stacked vertically */
.toggles-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    margin: 15px 0;
}

#notification-toggle-container,
#alert-mode-container {
    text-align: center;
}

.notification-toggle-label,
.alert-toggle-label {
    font-size: 14px;
    color: #1a365d;
    font-weight: 600;
    margin-bottom: 8px;
}

.notification-toggle-wrapper,
.alert-toggle-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    font-size: 12px;
    color: #666;
    white-space: nowrap;
}

.notification-toggle-switch,
.alert-toggle-switch {
    position: relative;
    width: 60px;
    height: 32px;
    background: #ccc;
    border-radius: 16px;
    cursor: pointer;
    transition: background 0.3s ease;
}

.notification-toggle-switch.active,
.alert-toggle-switch.active {
    background: #1a365d;
}

.notification-toggle-thumb,
.alert-toggle-thumb {
    position: absolute;
    top: 2px;
    left: 2px;
    width: 28px;
    height: 28px;
    background: white;
    border-radius: 50%;
    transition: transform 0.3s ease;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

.notification-toggle-switch.active .notification-toggle-thumb,
.alert-toggle-switch.active .alert-toggle-thumb {
    transform: translateX(28px);
}

/* Prevent PWA layout shifts */
#app-container {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
    overflow-x: hidden;
}

.main-content {
    height: 100%;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100vw;
    overflow-x: hidden;
}

/* Fix for tracking/search dynamic content */
.search-container, .location-list, .tracking-display {
    max-width: 100%;
    overflow-x: hidden;
    word-wrap: break-word;
}

/* Prevent text overflow that might cause the slop */
.value, .contractor-name, .address {
    word-break: break-word;
    overflow-wrap: break-word;
    max-width: 100%;
}

/* Contractor filter input */
#contractor-filter {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ccc;
    border-radius: 8px;
    font-size: 16px; /* Prevents iOS zoom */
    max-width: 100%;
    box-sizing: border-box;
}

/* Responsive adjustments */
@media (max-width: 480px) {
    .container {
        margin-top: 20px;
        border-radius: 0;
        max-width: 100vw;
        overflow-x: hidden;
    }
    
    .rings-container {
        width: 280px;
        height: 280px;
    }
    
    .ring-1 { width: 70px; height: 70px; }
    
    .ring-2 {
        width: 122.5px;
        height: 122.5px;
    }
    .ring-2.selected {
        -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 29.75px, black 29.75px);
        mask-image: radial-gradient(circle at center, transparent 0, transparent 29.75px, black 29.75px);
    }

    .ring-3 {
        width: 175px;
        height: 175px;
    }
    .ring-3.selected {
        -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 56px, black 56px);
        mask-image: radial-gradient(circle at center, transparent 0, transparent 56px, black 56px);
    }

    .ring-4 {
        width: 227.5px;
        height: 227.5px;
    }
    .ring-4.selected {
        -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 82.25px, black 82.25px);
        mask-image: radial-gradient(circle at center, transparent 0, transparent 82.25px, black 82.25px);
    }
    
    .ring-5 {
        width: 280px;
        height: 280px;
    }
    .ring-5.selected {
        -webkit-mask-image: radial-gradient(circle at center, transparent 0, transparent 108.5px, black 108.5px);
        mask-image: radial-gradient(circle at center, transparent 0, transparent 108.5px, black 108.5px);
    }
    
    .modal-content {
        max-width: 100%;
        border-radius: 15px 15px 0 0;
        max-width: calc(100vw - 20px); /* Tighter on mobile */
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}

/* WITH THIS (for smartphone feel on desktop): */
@media (min-width: 769px) {
    .container {
        max-width: 450px;
        margin: 50px auto;
        box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    }
}

/* Additional viewport fixes for dynamic content */
.locations-container, #locations-container {
    max-width: 100%;
    overflow-x: hidden;
}

/* Final safety net for horizontal overflow */
/* body * {
    max-width: 100vw !important;
}
*/

/* Lock down the main content area */
#app, #app-container, .main-content {
    overflow-x: hidden !important;
    max-width: 100vw;
    width: 100%;
}

/* Target dynamic content specifically */
.locations-list, .location-item, #locations-container {
    overflow-x: hidden !important;
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
}

/* Force text wrapping on dynamic content */
.location-name, .location-address, .contractor-name, .address {
    word-break: break-word !important;
    overflow-wrap: break-word !important;
    white-space: normal !important;
    max-width: 100% !important;
}

/* Nuclear option for any remaining overflow - exclude container */
/* *:not(.container) {
    max-width: 100vw !important;
    box-sizing: border-box !important;
}
*/

/* Targeted box-sizing fixes for overflow prevention */
.location-item, .location-name, .location-address, 
#contractor-filter, .value, .contractor-name, .address {
    box-sizing: border-box !important;
}

/* Fix for contractor filter causing horizontal slop */
#contractor-filter {
    width: 100% !important;
    max-width: 100% !important;
    padding: 10px !important;
    margin: 10px 0 !important;
    border: 1px solid #ccc !important;
    border-radius: 8px !important;
    font-size: 16px !important; /* Prevents iOS zoom */
    box-sizing: border-box !important; /* This is key */
    overflow: hidden !important;
    word-wrap: break-word !important;
}

/* Also lock down its parent container */
.locations-list {
    overflow-x: hidden !important;
    max-width: 100% !important;
}
/* Clear filter button styling - match Blitz button exactly */
#clear-filter-btn {
    margin-bottom: 8px !important;  /* Small gap between clear and blitz */
    padding: 12px 24px !important;  /* Same as Blitz button */
    background: #6c757d !important;
    color: #fff !important;
    font-size: 16px !important;     /* Same as Blitz button */
    border: none !important;
    border-radius: 6px !important;  /* Same as Blitz button */
    font-weight: 600 !important;    /* Same as Blitz button */
    cursor: pointer !important;
    width: 100% !important;
    transition: all 0.3s ease !important;
    margin-top: 5px !important;     /* Reduce gap from search box */
}

#clear-filter-btn:hover {
    background: #5a6268 !important;
}

/* Prevent bounce during dynamic updates */
.container {
    min-height: 600px;  /* Set a minimum height to prevent expansion/contraction */
}

#current-location,
#status,
#locations-container {
    min-height: 24px;   /* Reserve space for these dynamic elements */
    transition: none;   /* Disable transitions during rapid updates */
}

/* Prevent loading spinner from affecting layout */
#loading {
    position: absolute;
    top: 0;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
}

/* Add scale button - JK */

.scale-button {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #1a365d;
    color: white;
    border: 3px solid white;
    font-size: 20px;
    font-weight: bold;
    cursor: pointer;
    z-index: 10;
    transition: all 0.3s ease;
    box-shadow: 0 2px 10px rgba(26, 54, 93, 0.3);
}

.scale-button:hover {
    transform: translate(-50%, -50%) scale(1.1);
    box-shadow: 0 4px 15px rgba(26, 54, 93, 0.5);
}

.scale-button:active {
    transform: translate(-50%, -50%) scale(0.95);
}
