/* Your3Words Web App Styles */

/* Reset and base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    width: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
}

/* Map container - full viewport minus status bar */
#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 40px;
    z-index: 1;
}

/* Search container */
#search-container {
    position: absolute;
    top: 10px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1000;
    display: flex;
    gap: 0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    border-radius: 8px;
    overflow: hidden;
}

#address-input {
    width: 320px;
    padding: 12px 16px;
    border: none;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 14px;
    outline: none;
    background: white;
}

#address-input::placeholder {
    color: #999;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

#address-input:focus {
    box-shadow: inset 0 0 0 2px #3498db;
}

#address-input.error {
    box-shadow: inset 0 0 0 2px #e74c3c;
    animation: shake 0.3s ease-in-out;
}

@keyframes shake {
    0%, 100% { transform: translateX(0); }
    25% { transform: translateX(-5px); }
    75% { transform: translateX(5px); }
}

#search-btn {
    padding: 12px 16px;
    border: none;
    background: #3498db;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

#search-btn:hover {
    background: #2980b9;
}

#search-btn:active {
    background: #1f6dad;
}

/* Search marker styles */
.y3w-search-marker {
    background: transparent;
}

.marker-pin {
    width: 20px;
    height: 20px;
    background: #e74c3c;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

.marker-pulse {
    width: 30px;
    height: 30px;
    background: rgba(231, 76, 60, 0.4);
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation: pulse 2s ease-out infinite;
}

@keyframes pulse {
    0% {
        transform: translate(-50%, -50%) scale(0.5);
        opacity: 1;
    }
    100% {
        transform: translate(-50%, -50%) scale(2);
        opacity: 0;
    }
}

/* Status bar - fixed at bottom */
#status-bar {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    height: 40px;
    background: #2c3e50;
    color: #ecf0f1;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-weight: 500;
    letter-spacing: 0.5px;
    z-index: 1000;
    box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.2);
}

#status-bar.error {
    background: #c0392b;
}

/* Loading overlay */
#loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(44, 62, 80, 0.95);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.loading-content {
    text-align: center;
    color: #ecf0f1;
}

.loading-content p {
    margin-top: 16px;
    font-size: 18px;
}

/* Spinner */
.spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.2);
    border-top-color: #3498db;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Popup styles */
.y3w-popup .leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.25);
}

.y3w-popup .leaflet-popup-content {
    margin: 12px 16px;
}

.y3w-popup .leaflet-popup-content-wrapper {
    max-width: none !important;
}

.popup-content {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
}

.popup-row {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.popup-row:last-child {
    margin-bottom: 0;
}

.row-label {
    font-size: 12px;
    font-weight: 600;
    color: #7f8c8d;
    min-width: 40px;
}

.coord-value {
    font-family: 'Consolas', 'Monaco', 'Courier New', monospace;
    font-size: 13px;
    color: #2c3e50;
    white-space: nowrap;
}

.copy-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    color: #7f8c8d;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    flex-shrink: 0;
}

.copy-btn:hover {
    background: #ecf0f1;
    color: #3498db;
}

.copy-btn.copied {
    color: #27ae60;
}

/* Share button row */
.popup-share-row {
    margin-top: 12px;
    padding-top: 10px;
    border-top: 1px solid #ecf0f1;
    display: flex;
    justify-content: center;
}

.share-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 16px;
    background: #3498db;
    color: white;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    font-size: 13px;
    font-weight: 500;
    transition: background 0.2s;
}

.share-btn:hover {
    background: #2980b9;
}

.share-btn:active {
    background: #1f6dad;
}

.share-btn svg {
    flex-shrink: 0;
}

/* Mobile responsive */
@media (max-width: 768px) {
    #status-bar {
        height: 50px;
        font-size: 14px;
    }

    #map {
        bottom: 50px;
    }

    #search-container {
        width: calc(100% - 20px);
        max-width: 400px;
    }

    #address-input {
        width: 100%;
        flex: 1;
        font-size: 13px;
        padding: 10px 12px;
    }

    #search-btn {
        padding: 10px 14px;
    }

    .y3w-popup .leaflet-popup-content {
        margin: 10px 12px;
    }

    .coord-value {
        font-size: 12px;
    }
}

/* High contrast for better readability */
@media (prefers-contrast: high) {
    #status-bar {
        background: #000;
        color: #fff;
    }

    .coord-value {
        color: #000;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    .y3w-popup .leaflet-popup-content-wrapper {
        background: #2c3e50;
        color: #ecf0f1;
    }

    .y3w-popup .leaflet-popup-tip {
        background: #2c3e50;
    }

    .coord-value {
        color: #ecf0f1;
    }

    .row-label {
        color: #95a5a6;
    }

    .copy-btn {
        color: #bdc3c7;
    }

    .copy-btn:hover {
        background: #34495e;
        color: #3498db;
    }

    .popup-share-row {
        border-top-color: #34495e;
    }

    .share-btn {
        background: #2980b9;
    }

    .share-btn:hover {
        background: #3498db;
    }
}

/* Grid overlay canvas */
.y3w-grid-canvas {
    pointer-events: none;
}

/* Ensure popup pane appears above grid */
.leaflet-popup-pane {
    z-index: 700 !important;
}

/* Grid toggle control */
.grid-toggle-control {
    background: white !important;
    border-radius: 6px !important;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.3) !important;
}

.grid-toggle-btn {
    display: flex !important;
    align-items: center !important;
    gap: 8px !important;
    padding: 8px 12px !important;
    min-width: 90px !important;
    color: #333 !important;
    text-decoration: none !important;
    background: white !important;
    border-radius: 6px !important;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif !important;
    font-size: 13px !important;
    font-weight: 500 !important;
    cursor: pointer !important;
    white-space: nowrap !important;
}

.grid-toggle-btn:hover {
    background: #f0f0f0 !important;
}

.grid-toggle-btn .toggle-label {
    color: #333 !important;
}

/* Toggle switch */
.toggle-switch {
    display: inline-block !important;
    position: relative !important;
    width: 36px !important;
    min-width: 36px !important;
    height: 20px !important;
    border-radius: 10px !important;
    flex-shrink: 0 !important;
}

.toggle-switch.on {
    background-color: #27ae60 !important;
}

.toggle-switch.off {
    background-color: #bdc3c7 !important;
}

.toggle-knob {
    position: absolute !important;
    top: 2px !important;
    width: 16px !important;
    height: 16px !important;
    background: white !important;
    border-radius: 50% !important;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3) !important;
    transition: left 0.2s ease !important;
}

.toggle-switch.on .toggle-knob {
    left: 18px !important;
}

.toggle-switch.off .toggle-knob {
    left: 2px !important;
}

/* Dark mode for grid toggle */
@media (prefers-color-scheme: dark) {
    .grid-toggle-control {
        background: #2c3e50;
    }

    .grid-toggle-btn {
        background: #2c3e50;
        color: #ecf0f1;
    }

    .grid-toggle-btn:hover {
        background: #34495e;
    }

    .grid-toggle-btn .toggle-label {
        color: #ecf0f1;
    }

    .toggle-switch.off {
        background-color: #5d6d7e;
    }

    #search-container {
        box-shadow: 0 2px 10px rgba(0, 0, 0, 0.4);
    }

    #address-input {
        background: #34495e;
        color: #ecf0f1;
    }

    #address-input::placeholder {
        color: #7f8c8d;
    }
}
