/* CSS Variables for theming */
:root {
    --primary-color: #a02c8d;
    --success-color: #27ae60;
    --danger-color: #e74c3c;
    --warning-color: #f39c12;
    --secondary-color: #ba6cdf;
    --dark-color: #2e053f;
    --light-color: #efcef0;
    --border-radius: 4px;
    --transition: all 0.3s ease;
    --header-height: 60px;
}

/* Reset and base styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    font-size: 16px;
    line-height: 1.5;
    color: var(--dark-color);
    background-color: var(--light-color);
}

/* App container */
#app {
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
}

/* Header */
.header {
    height: var(--header-height);
    background-color: var(--dark-color);
    color: white;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 20px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.1);
    z-index: 1000;
    position: relative;
}

.header h1 {
    font-size: 24px;
    font-weight: 600;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 15px;
}

.location-count {
    background-color: rgba(255,255,255,0.1);
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 14px;
}

/* User info in header */
.user-info {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 0 15px;
    border-right: 1px solid rgba(255,255,255,0.2);
    margin-right: 15px;
}

.user-email {
    font-size: 14px;
    color: rgba(255,255,255,0.9);
}

/* Map container */
#map-container {
    position: relative;
    width: 100%;
    height: calc(100vh - var(--header-height));
}

#map {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: #f0f0f0;
}

/* Map controls */
.map-controls {
    position: absolute;
    top: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

/* Buttons */
.btn {
    padding: 10px 16px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    gap: 5px;
    white-space: nowrap;
    outline: none;
}

.btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.15);
}

.btn:active {
    transform: translateY(0);
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-primary:hover {
    background-color: #2471a3;
}

.btn-success {
    background-color: var(--success-color);
    color: white;
}

.btn-success:hover {
    background-color: #229954;
}

.btn-secondary {
    background-color: var(--secondary-color);
    color: white;
}

.btn-secondary:hover {
    background-color: #7f8c8d;
}

.btn-sm {
    padding: 6px 12px;
    font-size: 13px;
}

.btn-danger {
    background-color: var(--danger-color);
    color: white;
}

.btn-danger:hover {
    background-color: #c0392b;
}

/* Crosshair for location selection */
.crosshair {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    pointer-events: none;
    z-index: 999;
}

.crosshair.hidden {
    display: none;
}

.crosshair-x,
.crosshair-y {
    position: absolute;
    background-color: rgba(44, 90, 160, 0.8);
}

.crosshair-x {
    width: 40px;
    height: 2px;
    left: -20px;
    top: -1px;
}

.crosshair-y {
    width: 2px;
    height: 40px;
    left: -1px;
    top: -20px;
}

.crosshair-info {
    position: absolute;
    top: 30px;
    left: 50%;
    transform: translateX(-50%);
    background-color: rgba(44, 62, 80, 0.9);
    color: white;
    padding: 5px 10px;
    border-radius: var(--border-radius);
    font-size: 12px;
    white-space: nowrap;
}

/* Status messages */
.status-container {
    position: fixed;
    top: calc(var(--header-height) + 20px);
    left: 50%;
    transform: translateX(-50%);
    z-index: 2000;
    max-width: 400px;
    width: 90%;
}

.status-message {
    padding: 12px 20px;
    border-radius: var(--border-radius);
    margin-bottom: 10px;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideIn 0.3s ease;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
}

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

.status-message.success {
    background-color: var(--success-color);
    color: white;
}

.status-message.error {
    background-color: var(--danger-color);
    color: white;
}

.status-message.warning {
    background-color: var(--warning-color);
    color: white;
}

.status-message.info {
    background-color: var(--primary-color);
    color: white;
}

/* Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 3000;
    animation: fadeIn 0.3s ease;
}

.modal.hidden {
    display: none;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.modal-content {
    background-color: white;
    border-radius: var(--border-radius);
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 4px 20px rgba(0,0,0,0.15);
    animation: slideUp 0.3s ease;
}

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

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

.modal-header h2 {
    font-size: 20px;
    font-weight: 600;
    color: var(--dark-color);
}

.modal-close {
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--secondary-color);
    width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: var(--transition);
}

.modal-close:hover {
    background-color: var(--light-color);
    color: var(--dark-color);
}

.modal-body {
    padding: 20px;
}

/* Edit Footer Form */
.edit-footer {
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: white;
    border-top: 2px solid var(--primary-color);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1500;
    transition: transform 0.3s ease;
    max-height: 60vh;
    overflow-y: auto;
}

.edit-footer.hidden {
    transform: translateY(100%);
}

.edit-footer-content {
    padding: 20px;
    max-width: 800px;
    margin: 0 auto;
}

.edit-footer-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e0e0e0;
}

.edit-footer-header h2 {
    margin: 0;
    font-size: 20px;
    color: var(--dark-color);
}

/* Form styles */
.form-group {
    margin-bottom: 15px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

.form-group label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
    color: var(--dark-color);
    font-size: 14px;
}

.form-group input,
.form-group textarea {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
}

.form-group input:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.1);
}

.form-group input.valid {
    border-color: var(--success-color);
}

.form-group input.invalid {
    border-color: var(--danger-color);
}

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

.form-group select {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: var(--border-radius);
    font-size: 14px;
    transition: var(--transition);
    background-color: white;
    cursor: pointer;
}

.form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(44, 90, 160, 0.1);
}

.form-group input[type="checkbox"] {
    width: auto;
    margin-right: 8px;
    cursor: pointer;
}

.form-group label input[type="checkbox"] {
    vertical-align: middle;
}

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

/* Loading overlay */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(255,255,255,0.9);
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    z-index: 4000;
}

.loading-overlay.hidden {
    display: none;
}

.spinner {
    width: 50px;
    height: 50px;
    border: 3px solid var(--light-color);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-overlay p {
    margin-top: 20px;
    color: var(--dark-color);
    font-size: 16px;
}

/* Leaflet customizations */
.leaflet-popup-content-wrapper {
    border-radius: var(--border-radius);
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.leaflet-popup-content {
    margin: 13px 19px;
    line-height: 1.5;
}

.popup-content h3 {
    margin: 0 0 10px 0;
    color: var(--dark-color);
    font-size: 16px;
}

.popup-content p {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
}

.popup-content .popup-meta {
    font-size: 12px;
    color: #999;
    margin-top: 10px;
    padding-top: 10px;
    border-top: 1px solid #eee;
}

/* Popup actions section */
.popup-content .popup-actions {
    margin-top: 15px;
    padding-top: 15px;
    border-top: 1px solid #eee;
    display: flex;
    gap: 10px;
    justify-content: center;
}

.popup-content .popup-actions .btn {
    flex: 1;
    max-width: 120px;
}

/* Distinctive start location marker styles */
.start-location-custom-marker {
    z-index: 2000 !important;
}

.start-location-marker-wrapper {
    position: relative;
    width: 48px;
    height: 48px;
}

.start-location-marker-pin {
    position: absolute;
    width: 48px;
    height: 48px;
    background: #ff4444;
    border-radius: 50% 50% 50% 0;
    transform: rotate(-45deg);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid white;
    animation: bounce-marker 2s ease-in-out infinite;
}

.start-location-marker-inner {
    transform: rotate(45deg);
    width: 24px;
    height: 24px;
}

.start-location-marker-pulse {
    position: absolute;
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: rgba(255, 68, 68, 0.3);
    animation: pulse-ring 2s ease-out infinite;
}

@keyframes bounce-marker {
    0%, 100% {
        transform: rotate(-45deg) translateY(0);
    }
    50% {
        transform: rotate(-45deg) translateY(-5px);
    }
}

@keyframes pulse-ring {
    0% {
        transform: scale(0.5);
        opacity: 1;
    }
    100% {
        transform: scale(2);
        opacity: 0;
    }
}

/* Enhanced popup for start location */
.start-location-popup-enhanced .leaflet-popup-content-wrapper {
    padding: 0;
    overflow: hidden;
    border: none;
    box-shadow: 0 5px 20px rgba(0,0,0,0.3);
}

.start-location-popup-enhanced .leaflet-popup-content {
    margin: 0;
}

/* Mobile dropdown menu */
.mobile-dropdown {
    position: relative;
    display: none;
}

.mobile-dropdown-toggle {
    background: none;
    border: none;
    color: white;
    font-size: 18px;
    cursor: pointer;
    padding: 8px;
    border-radius: var(--border-radius);
    transition: var(--transition);
    display: flex;
    align-items: center;
    gap: 5px;
}

.mobile-dropdown-toggle:hover {
    background-color: rgba(255,255,255,0.1);
}

.mobile-dropdown-content {
    position: absolute;
    top: 100%;
    right: 0;
    background-color: white;
    color: var(--dark-color);
    min-width: 250px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    border-radius: var(--border-radius);
    overflow: hidden;
    transform: translateY(-10px);
    opacity: 0;
    visibility: hidden;
    transition: var(--transition);
    z-index: 1001;
}

.mobile-dropdown.active .mobile-dropdown-content {
    transform: translateY(0);
    opacity: 1;
    visibility: visible;
}

.mobile-dropdown-item {
    padding: 12px 15px;
    border-bottom: 1px solid #eee;
    font-size: 14px;
}

.mobile-dropdown-item:last-child {
    border-bottom: none;
    border-top: 1px solid #ddd;
    background-color: #fff5f5;
}

.mobile-dropdown-item:last-child button {
    color: var(--danger-color);
    font-weight: 500;
}

.mobile-dropdown-item:last-child:hover {
    background-color: #fee;
}

.mobile-dropdown-item.location-info {
    background-color: var(--primary-color);
    color: white;
    font-weight: 500;
}

.mobile-dropdown-item.user-info {
    background-color: var(--light-color);
    color: var(--dark-color);
}

/* Add logout button specific styles */
.mobile-dropdown-item button {
    background: none;
    border: none;
    color: inherit;
    font-size: inherit;
    cursor: pointer;
    width: 100%;
    text-align: left;
    padding: 0;
    font-family: inherit;
}

.mobile-dropdown-item button:hover {
    background-color: rgba(0, 0, 0, 0.05);
}

/* Logout button danger styling */
.mobile-dropdown-item.logout-item {
    border-top: 1px solid #eee;
    background-color: #fee;
}

.mobile-dropdown-item.logout-item button {
    color: var(--danger-color);
    font-weight: 500;
}

.mobile-dropdown-item.logout-item:hover {
    background-color: #fdd;
}

/* Floating sidebar for mobile */
.mobile-sidebar {
    position: fixed;
    top: 50%;
    right: 10px;
    transform: translateY(-50%);
    background-color: white;
    border-radius: var(--border-radius);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    z-index: 1000;
    display: none;
    flex-direction: column;
    gap: 5px;
    padding: 8px;
}

.mobile-sidebar .btn {
    margin: 0;
    min-width: 44px;
    min-height: 44px;
    padding: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 16px;
}

/* Active state for mobile buttons */
.mobile-sidebar .btn.active {
    background-color: var(--dark-color);
    color: white;
}

.mobile-sidebar .btn:active {
    transform: scale(0.95);
}

/* Desktop styles - show normal layout */
@media (min-width: 769px) {
    .mobile-dropdown {
        display: none;
    }
    
    .mobile-sidebar {
        display: none;
    }
    
    .header-actions {
        display: flex;
    }
    
    .user-info,
    .location-count {
        display: flex;
    }
    
    .map-controls {
        display: flex;
    }
    
    /* Show shifts button on desktop */
    .header-actions a[href="/shifts.html"] {
        display: inline-flex !important;
    }
    
    .btn span.btn-icon {
        margin-right: 5px;
    }
}

/* Hide desktop elements on mobile */
@media (max-width: 768px) {
    .header h1 {
        font-size: 18px;
    }
    
    .header-actions {
        display: none;
    }
    
    /* Hide any floating shifts button on mobile - but NOT the one in dropdown */
    .header-actions a[href="/shifts.html"] {
        display: none !important;
    }
    
    .mobile-dropdown {
        display: block;
    }
    
    .mobile-sidebar {
        display: flex;
    }
    
    .map-controls {
        display: none;
    }
    
    /* Hide user info and location count on desktop header for mobile */
    .user-info,
    .location-count {
        display: none;
    }
    
    /* Adjust modal for mobile */
    .modal-content {
        width: 95%;
        margin: 10px;
    }
    
    .form-row {
        grid-template-columns: 1fr;
    }
    
    /* Adjust edit footer for mobile */
    .edit-footer-content {
        padding: 15px;
    }
    
    .edit-footer-header h2 {
        font-size: 18px;
    }
}

/* Fullscreen styles */
.fullscreen #map-container {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5000;
}

.fullscreen .header {
    display: none;
}

/* Print styles */
@media print {
    .header,
    .map-controls,
    .status-container,
    .modal {
        display: none !important;
    }
    
    #map-container {
        height: 100vh;
    }
}

/* Leaflet Circle Markers - Add this section */
.leaflet-marker-icon {
    background-color: transparent !important;
    border: none !important;
}

.leaflet-interactive {
    cursor: pointer;
}

/* Ensure circle markers are visible */
path.leaflet-interactive {
    stroke: #fff;
    stroke-opacity: 1;
    stroke-width: 2;
    fill-opacity: 0.8;
}

/* Fix for marker z-index */
.leaflet-pane.leaflet-marker-pane {
    z-index: 600;
}

.leaflet-pane.leaflet-tooltip-pane {
    z-index: 650;
}

.leaflet-pane.leaflet-popup-pane {
    z-index: 700;
}

/* Ensure markers are above the map tiles */
.leaflet-marker-pane svg {
    position: relative;
    z-index: 1;
}

/* Force circle markers to be visible */
.leaflet-overlay-pane svg {
    z-index: 1;
}

.leaflet-overlay-pane svg path {
    cursor: pointer;
    pointer-events: auto;
}

/* Ensure SVG circle markers are rendered */
.location-marker {
    cursor: pointer !important;
}

/* Override any conflicting styles */
.leaflet-container path.leaflet-interactive {
    stroke: #ffffff !important;
    stroke-opacity: 1 !important;
    stroke-width: 2px !important;
    fill-opacity: 0.8 !important;
}
