/* ===========================
   General Settings
   =========================== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #3B82F6;
    --secondary-color: #10B981;
    --danger-color: #EF4444;
    --warning-color: #F59E0B;
    --dark: #1F2937;
    --dark-light: #374151;
    --gray: #6B7280;
    --gray-light: #E5E7EB;
    --white: #FFFFFF;
    --sidebar-width: 320px;
    --header-height: 60px;
}

body {
    font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #F3F4F6;
    overflow: hidden;
}

/* ===========================
   Top Bar
   =========================== */
.top-bar {
    height: var(--header-height);
    background: var(--dark);
    color: var(--white);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    gap: 20px;
}

.header-center {
    flex: 1;
    display: flex;
    align-items: center;
    gap: 10px;
    max-width: 600px;
}

.project-title-input {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid var(--gray);
    border-radius: 6px;
    font-size: 14px;
    background: rgba(255, 255, 255, 0.1);
    color: white;
    transition: all 0.3s ease;
}

.project-title-input:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.15);
    border-color: var(--primary-color);
}

.project-title-input::placeholder {
    color: rgba(255, 255, 255, 0.5);
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 20px;
    font-weight: bold;
}

.logo i {
    color: var(--primary-color);
    font-size: 24px;
}

.header-actions {
    display: flex;
    gap: 10px;
}

/* ===========================
   Buttons
   =========================== */
.btn {
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

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

.btn-primary:hover {
    background: #2563EB;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

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

.btn-secondary:hover {
    background: var(--gray);
}

.btn-block {
    width: 100%;
    justify-content: center;
}

.btn-icon {
    width: 40px;
    height: 40px;
    padding: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: 1px solid var(--gray-light);
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-icon:hover {
    background: var(--gray-light);
}

/* ===========================
   Main Container
   =========================== */
.main-container {
    display: flex;
    height: calc(100vh - var(--header-height));
    overflow: hidden;
}

/* ===========================
   Sidebar
   =========================== */
.sidebar {
    width: var(--sidebar-width);
    background: var(--white);
    border-right: 1px solid var(--gray-light);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
}

.sidebar.collapsed {
    transform: translateX(-100%);
}

.sidebar-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.sidebar-header h3 {
    font-size: 18px;
    color: var(--dark);
}

.sidebar-nav {
    border-bottom: 1px solid var(--gray-light);
    padding: 10px 0;
}

.nav-item {
    width: 100%;
    padding: 15px 20px;
    border: none;
    background: transparent;
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
    color: var(--gray);
    font-size: 14px;
    text-align: left;
}

.nav-item:hover {
    background: var(--gray-light);
    color: var(--dark);
}

.nav-item.active {
    background: var(--primary-color);
    color: var(--white);
}

.nav-item i {
    font-size: 18px;
    width: 20px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
}

.section-content {
    display: none;
}

.section-content.active {
    display: block;
}

/* ===========================
   Forms
   =========================== */
.form-group {
    margin-bottom: 20px;
}

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

.form-control {
    width: 100%;
    padding: 10px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 6px;
    font-size: 14px;
    transition: all 0.3s ease;
}

.form-control:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.form-text {
    display: block;
    margin-top: 5px;
    font-size: 12px;
    color: var(--gray);
}

.text-muted {
    color: var(--gray);
    font-size: 14px;
}

/* ===========================
   Map Container
   =========================== */
.map-container {
    flex: 1;
    position: relative;
    overflow: hidden;
}

#map {
    width: 100%;
    height: 100%;
}

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

.control-btn {
    width: 40px;
    height: 40px;
    background: var(--white);
    border: none;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    transition: all 0.3s ease;
}

.control-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: scale(1.1);
}

/* ===========================
   Toggle Sidebar Button
   =========================== */
.toggle-sidebar-btn {
    position: absolute;
    top: 20px;
    left: 20px;
    padding: 12px 20px;
    background: var(--white);
    border: none;
    border-radius: 8px;
    cursor: pointer;
    display: none;
    align-items: center;
    gap: 10px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    transition: all 0.3s ease;
    z-index: 600;
    font-size: 14px;
    font-weight: 500;
    color: var(--dark);
}

.toggle-sidebar-btn.visible {
    display: flex;
}

.toggle-sidebar-btn:hover {
    background: var(--primary-color);
    color: var(--white);
    transform: translateY(-2px);
}

/* ===========================
   Location Info
   =========================== */
.location-info {
    position: absolute;
    bottom: 20px;
    left: 20px;
    background: var(--white);
    padding: 12px 20px;
    border-radius: 6px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 500;
}

.location-info i {
    color: var(--primary-color);
}

/* ===========================
   Modals
   =========================== */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
}

.modal-content {
    background: var(--white);
    border-radius: 8px;
    width: 90%;
    max-width: 500px;
    max-height: 90vh;
    overflow: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.2);
}

.modal-header {
    padding: 20px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

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

.close-modal {
    width: 32px;
    height: 32px;
    border: none;
    background: transparent;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 4px;
    transition: all 0.3s ease;
}

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

.modal-body {
    padding: 20px;
}

/* ===========================
   Alerts
   =========================== */
.alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.alert-success {
    background: #D1FAE5;
    color: #065F46;
    border: 1px solid #10B981;
}

.alert-error {
    background: #FEE2E2;
    color: #991B1B;
    border: 1px solid #EF4444;
}

.alert-warning {
    background: #FEF3C7;
    color: #92400E;
    border: 1px solid #F59E0B;
}

/* ===========================
   Responsive Design
   =========================== */
@media (max-width: 768px) {
    .sidebar {
        position: absolute;
        left: 0;
        height: 100%;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1);
    }
    
    .header-actions span {
        display: none;
    }
    
    .logo span {
        display: none;
    }
    
    .toggle-sidebar-btn.visible {
        display: flex !important;
    }
}

/* ===========================
   Timeline Panel
   =========================== */
.timeline-panel {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: white;
    border-top: 2px solid var(--gray-light);
    box-shadow: 0 -4px 12px rgba(0,0,0,0.1);
    z-index: 600;
    transition: transform 0.3s ease;
}

.timeline-panel.collapsed {
    transform: translateY(calc(100% - 50px));
}

.timeline-header {
    padding: 12px 20px;
    border-bottom: 1px solid var(--gray-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: #F9FAFB;
}

.timeline-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.timeline-btn {
    padding: 8px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 6px;
    color: var(--dark);
}

.timeline-btn:hover {
    background: var(--gray-light);
    border-color: var(--gray);
}

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

.timeline-btn.primary:hover {
    background: #2563EB;
}

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

.timeline-body {
    padding: 10px 20px;
    overflow-x: auto;
    max-height: 100px;
}

.frames-container {
    display: flex;
    gap: 12px;
    min-width: min-content;
}

.frame-card {
    width: 110px;
    min-width: 110px;
    border: 2px solid var(--gray-light);
    border-radius: 6px;
    padding: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
}

.frame-card:hover {
    border-color: var(--primary-color);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.2);
    transform: translateY(-2px);
}

.frame-card.active {
    border-color: var(--primary-color);
    background: #EEF2FF;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.frame-thumbnail {
    width: 100%;
    height: 45px;
    background: #F3F4F6;
    border-radius: 4px;
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    font-size: 11px;
    overflow: hidden;
}

.frame-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.frame-number {
    font-size: 13px;
    font-weight: 600;
    color: var(--dark);
}

.frame-actions {
    display: flex;
    gap: 4px;
}

.frame-action-btn {
    width: 24px;
    height: 24px;
    border: none;
    background: transparent;
    cursor: pointer;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    color: var(--gray);
    transition: all 0.2s ease;
}

.frame-action-btn:hover {
    background: var(--gray-light);
    color: var(--dark);
}

.frame-action-btn.delete:hover {
    background: #FEE2E2;
    color: #EF4444;
}

.timeline-settings {
    padding: 12px 20px;
    border-top: 1px solid var(--gray-light);
    background: #F9FAFB;
}

.frame-label-input {
    width: 100%;
    padding: 4px 6px;
    border: 1px solid var(--gray-light);
    border-radius: 4px;
    font-size: 11px;
    margin-top: 5px;
}

.frame-label-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* ===========================
   Icon Selector Buttons
   =========================== */
.icon-btn {
    width: 100%;
    height: 50px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    color: #6B7280;
}

.icon-btn:hover {
    border-color: #3B82F6;
    background: #EEF2FF;
    color: #3B82F6;
    transform: scale(1.05);
}

.icon-btn.active {
    border-color: #3B82F6;
    background: #3B82F6;
    color: white;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

.marker-color-preset {
    width: 100%;
    height: 40px;
    border: 3px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.marker-color-preset:hover {
    border-color: #1F2937;
    transform: scale(1.1);
}

.marker-color-preset.active {
    border-color: #1F2937;
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* ===========================
   Shape Labels
   =========================== */
.shape-label-tooltip {
    background: rgba(255, 255, 255, 0.95) !important;
    border: 2px solid #1F2937 !important;
    border-radius: 4px !important;
    padding: 4px 8px !important;
    font-weight: bold !important;
    font-size: 13px !important;
    color: #1F2937 !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2) !important;
}

.shape-label-tooltip::before {
    border-top-color: #1F2937 !important;
}

/* ===========================
   Color Preset Buttons
   =========================== */
.color-preset {
    width: 100%;
    height: 40px;
    border: 2px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.color-preset:hover {
    border-color: var(--dark);
    transform: scale(1.1);
}

.color-preset.active {
    border-color: var(--dark);
    box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

/* ===========================
   Leaflet Customization
   =========================== */
.leaflet-popup-content-wrapper {
    border-radius: 8px;
}

.leaflet-popup-content {
    margin: 15px;
    font-family: inherit;
}

.leaflet-control-attribution {
    font-size: 10px;
}

/* ===========================
   Project Card in Load Modal
   =========================== */
.project-card {
    border: 2px solid var(--gray-light);
    border-radius: 8px;
    padding: 15px;
    margin-bottom: 12px;
    display: flex;
    gap: 15px;
    align-items: center;
    cursor: pointer;
    transition: all 0.3s ease;
}

.project-card:hover {
    border-color: var(--primary-color);
    background: #F9FAFB;
    transform: translateX(-4px);
}

.project-thumbnail {
    width: 100px;
    height: 80px;
    background: #F3F4F6;
    border-radius: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    flex-shrink: 0;
}

.project-info {
    flex: 1;
}

.project-title-text {
    font-size: 16px;
    font-weight: 600;
    color: var(--dark);
    margin-bottom: 5px;
}

.project-meta {
    font-size: 13px;
    color: var(--gray);
}

.project-actions {
    display: flex;
    gap: 8px;
}

.project-action-btn {
    padding: 6px 12px;
    border: 1px solid var(--gray-light);
    border-radius: 6px;
    background: white;
    cursor: pointer;
    font-size: 12px;
    transition: all 0.3s ease;
}

.project-action-btn:hover {
    background: var(--gray-light);
}

.project-action-btn.delete:hover {
    background: #FEE2E2;
    color: #EF4444;
    border-color: #EF4444;
}
/* ===========================
   Marker Tabs System - IMPROVED
   =========================== */
.marker-tabs {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    margin-bottom: 12px;
    background: linear-gradient(135deg, #F3F4F6 0%, #E5E7EB 100%);
    padding: 8px;
    border-radius: 12px;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.06);
}

.marker-tab {
    width: 38px;
    height: 38px;
    border: none;
    background: white;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    opacity: 0.7;
    font-size: 18px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.marker-tab:hover {
    background: white;
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.marker-tab.active {
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563EB 100%);
    opacity: 1;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

/* Icon Buttons with SVG - IMPROVED */
.icon-btn {
    width: 100%;
    aspect-ratio: 1;
    border: 2px solid #E5E7EB;
    background: linear-gradient(135deg, #FFFFFF 0%, #F9FAFB 100%);
    border-radius: 12px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 10px;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    color: #4B5563;
    box-shadow: 0 1px 3px rgba(0,0,0,0.08);
    position: relative;
    overflow: hidden;
}

.icon-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: linear-gradient(135deg, var(--primary-color) 0%, #2563EB 100%);
    opacity: 0;
    transition: opacity 0.25s;
    border-radius: 10px;
}

.icon-btn svg {
    width: 26px;
    height: 26px;
    position: relative;
    z-index: 1;
    transition: all 0.25s;
}

.icon-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-3px) scale(1.02);
    box-shadow: 0 8px 20px rgba(59, 130, 246, 0.25);
    color: var(--primary-color);
}

.icon-btn.active {
    border-color: var(--primary-color);
    color: white;
}

.icon-btn.active::before {
    opacity: 1;
}

.icon-btn.active svg {
    color: white;
    fill: white;
}

/* Color Presets - IMPROVED */
.marker-color-preset {
    width: 100%;
    aspect-ratio: 1;
    border: 3px solid transparent;
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    box-shadow: 0 2px 6px rgba(0,0,0,0.15);
}

.marker-color-preset:hover {
    transform: scale(1.15) translateY(-2px);
    box-shadow: 0 6px 15px rgba(0,0,0,0.2);
}

.marker-color-preset.active {
    border-color: #1F2937;
    box-shadow: 0 0 0 3px white, 0 0 0 5px var(--primary-color), 0 6px 15px rgba(0,0,0,0.2);
    transform: scale(1.1);
}

/* Selected Icon Preview */
#selectedIconPreview svg {
    width: 100%;
    height: 100%;
}

/* ===========================
   Login Wall
   =========================== */
.login-wall {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: #0f172a;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9000;
}

.login-wall.hidden {
    display: none;
}

.login-wall-content {
    text-align: center;
    color: white;
    padding: 40px;
    max-width: 400px;
}

.login-wall-content h2 {
    margin-bottom: 10px;
}

.login-wall-content p {
    color: #94A3B8;
}

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

.modal.active {
    display: flex;
}

.modal-content {
    background: white;
    border-radius: 12px;
    max-width: 500px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
}

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

.modal-header h3 {
    margin: 0;
}

.modal-body {
    padding: 20px;
}

.close-modal {
    background: none;
    border: none;
    font-size: 20px;
    cursor: pointer;
    color: #6B7280;
}

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

/* Fix duplicate marker icons */
.custom-marker-icon {
    background: none !important;
    border: none !important;
}

.custom-marker-icon img {
    display: none !important;
}

.leaflet-marker-icon.custom-marker-icon {
    margin: 0 !important;
}

/* Hide marker label default styling */
.marker-label {
    background: none !important;
    border: none !important;
    box-shadow: none !important;
}

/* Hide default leaflet marker image for labels */
.marker-label img,
.leaflet-marker-icon.marker-label img {
    display: none !important;
}

/* Ensure marker-label has no default marker appearance */
.leaflet-marker-icon.marker-label {
    background: transparent !important;
    border: none !important;
    box-shadow: none !important;
    width: auto !important;
    height: auto !important;
}

/* Hide Leaflet Draw toolbar - using sidebar buttons instead */
.leaflet-draw {
    display: none !important;
}

.leaflet-draw-toolbar {
    display: none !important;
}

/* Drawing tool buttons */
.draw-tool-btn {
    padding: 10px 12px;
    border: 2px solid #E5E7EB;
    border-radius: 8px;
    background: white;
    cursor: pointer;
    font-size: 13px;
    font-weight: 500;
    color: #374151;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
}

.draw-tool-btn:hover {
    background: #EEF2FF;
    border-color: #3B82F6;
    color: #3B82F6;
}

.draw-tool-btn.active {
    background: #3B82F6;
    border-color: #3B82F6;
    color: white;
}

.draw-tool-btn i {
    font-size: 14px;
}