/* Property Map Application Styles */

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html, body {
    height: 100%;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    overflow: hidden;
}

/* Header */
#header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    height: 50px;
    padding: 0 15px;
    background: #2c3e50;
    color: white;
    z-index: 1000;
}

.header-left, .header-right {
    flex: 0 0 auto;
}

.header-center {
    flex: 1;
    text-align: center;
}

#project-title {
    font-size: 1.2rem;
    font-weight: 500;
}

#project-selector {
    padding: 5px 10px;
    border-radius: 4px;
    border: none;
    background: #34495e;
    color: white;
    font-size: 0.9rem;
    cursor: pointer;
}

#project-selector:hover {
    background: #4a6278;
}

#toggle-sidebar {
    background: none;
    border: none;
    color: white;
    font-size: 1.5rem;
    cursor: pointer;
    padding: 5px 10px;
}

#toggle-sidebar:hover {
    background: rgba(255,255,255,0.1);
    border-radius: 4px;
}

/* Main Container */
#main-container {
    display: flex;
    height: calc(100% - 50px);
    position: relative;
}

/* Map */
#map {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* Sidebar */
#sidebar {
    width: 280px;
    background: #f8f9fa;
    border-left: 1px solid #dee2e6;
    overflow-y: auto;
    transition: transform 0.3s ease;
    z-index: 500;
}

#sidebar.closed {
    transform: translateX(100%);
    position: absolute;
    right: 0;
    height: 100%;
}

.sidebar-section {
    padding: 15px;
    border-bottom: 1px solid #dee2e6;
}

.sidebar-section h3 {
    font-size: 0.85rem;
    text-transform: uppercase;
    color: #6c757d;
    margin-bottom: 10px;
    letter-spacing: 0.5px;
}

/* Layer Controls */
.layer-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.layer-item {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 8px;
    background: white;
    border-radius: 4px;
    border: 1px solid #e9ecef;
}

.layer-item:hover {
    border-color: #adb5bd;
}

.layer-item input[type="checkbox"],
.layer-item input[type="radio"] {
    margin: 0;
    cursor: pointer;
}

.layer-item label {
    flex: 1;
    cursor: pointer;
    font-size: 0.9rem;
}

.layer-item .opacity-slider {
    width: 60px;
    cursor: pointer;
}

.layer-item .layer-actions-btns {
    display: flex;
    gap: 4px;
    margin-left: auto;
}

.layer-item .layer-action-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 2px 4px;
    font-size: 0.8rem;
    opacity: 0.6;
    border-radius: 3px;
}

.layer-item .layer-action-btn:hover {
    opacity: 1;
    background: #e9ecef;
}

.layer-item .layer-action-btn.delete:hover {
    background: #ffebee;
}

.layer-color {
    width: 16px;
    height: 16px;
    border-radius: 3px;
    border: 1px solid #ccc;
}

/* Layer Actions */
.layer-actions {
    display: flex;
    gap: 8px;
    margin-top: 10px;
}

.layer-actions button {
    flex: 1;
    padding: 8px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.85rem;
}

.layer-actions button:hover {
    background: #e9ecef;
}

/* Drawing Tools */
#draw-controls {
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
}

.draw-btn {
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1rem;
}

.draw-btn:hover {
    background: #e9ecef;
}

.draw-btn.active {
    background: #3498db;
    border-color: #3498db;
}

.draw-btn.save {
    background: #27ae60;
    border-color: #27ae60;
    color: white;
}

.draw-btn.save:hover {
    background: #219a52;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 8px;
    min-width: 300px;
    max-width: 90%;
}

.modal-content h2 {
    margin-bottom: 15px;
    font-size: 1.2rem;
}

.modal-content input[type="text"],
.modal-content input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 15px;
    font-size: 1rem;
}

.modal-actions {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-actions button {
    padding: 10px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
}

.modal-actions button:first-child {
    background: #e9ecef;
}

.modal-actions button:last-child {
    background: #3498db;
    color: white;
}

.modal-actions button:hover {
    opacity: 0.9;
}

/* Parcel popup styling */
.parcel-popup {
    font-size: 0.9rem;
}

.parcel-popup h4 {
    margin-bottom: 8px;
    color: #2c3e50;
}

.parcel-popup p {
    margin: 4px 0;
}

.parcel-popup .label {
    font-weight: 600;
    color: #6c757d;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    #sidebar {
        position: absolute;
        right: 0;
        height: 100%;
        width: 260px;
        transform: translateX(100%);
    }

    #sidebar.open {
        transform: translateX(0);
    }

    #project-title {
        font-size: 1rem;
    }

    .layer-item .opacity-slider {
        width: 50px;
    }
}

@media (max-width: 480px) {
    #header {
        padding: 0 10px;
    }

    #sidebar {
        width: 100%;
    }

    .header-center {
        display: none;
    }
}

/* Leaflet overrides */
.leaflet-control-layers {
    display: none; /* We use our own layer control */
}

/* Custom layer colors */
.parcel-boundary {
    stroke: #e74c3c;
    stroke-width: 3;
    fill: #e74c3c;
    fill-opacity: 0.1;
}

.track-line {
    stroke: #9b59b6;
    stroke-width: 3;
}

.custom-layer {
    stroke: #f39c12;
    stroke-width: 2;
}

/* GPS Tracking */
#gps-controls {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.track-btn {
    padding: 10px 15px;
    border: 1px solid #dee2e6;
    background: white;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    text-align: center;
}

.track-btn:hover {
    background: #e9ecef;
}

.track-btn.hidden {
    display: none;
}

#btn-track-start {
    background: #27ae60;
    border-color: #27ae60;
    color: white;
}

#btn-track-start:hover {
    background: #219a52;
}

#btn-track-start.tracking {
    background: #e74c3c;
    border-color: #e74c3c;
    animation: pulse 2s infinite;
}

#btn-track-stop {
    background: #e74c3c;
    border-color: #e74c3c;
    color: white;
}

#btn-track-stop:hover {
    background: #c0392b;
}

#btn-track-save {
    background: #3498db;
    border-color: #3498db;
    color: white;
}

#btn-track-save:hover {
    background: #2980b9;
}

.gps-status {
    margin-top: 8px;
    padding: 8px;
    background: #f0f0f0;
    border-radius: 4px;
    font-size: 0.8rem;
    color: #666;
    display: flex;
    flex-direction: column;
    gap: 4px;
}

.gps-status.hidden {
    display: none;
}

.gps-status.tracking {
    background: #d4edda;
    border: 1px solid #c3e6cb;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.7; }
}

/* GPS position marker */
.gps-marker {
    background: #3498db;
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: 0 0 10px rgba(52, 152, 219, 0.5);
}

.gps-accuracy-circle {
    fill: rgba(52, 152, 219, 0.15);
    stroke: rgba(52, 152, 219, 0.5);
    stroke-width: 1;
}
