/* ===========================================
   Company Service Area Map - Styles
   =========================================== */

/* CSS Variables */
:root {
    /* Colors */
    --color-primary: #2196F3;
    --color-primary-dark: #1976D2;
    --color-secondary: #009688;
    --color-success: #4CAF50;
    --color-danger: #F44336;
    --color-warning: #FF9800;
    
    /* Neutrals */
    --color-bg: #f5f7fa;
    --color-bg-dark: #1e1e1e;
    --color-bg-panel: #ffffff;
    --color-bg-section: #f8f9fa;
    --color-text: #333333;
    --color-text-light: #666666;
    --color-text-muted: #999999;
    --color-border: #e0e0e0;
    
    /* Spacing */
    --spacing-xs: 0.25rem;
    --spacing-sm: 0.5rem;
    --spacing-md: 1rem;
    --spacing-lg: 1.5rem;
    --spacing-xl: 2rem;
    
    /* Typography */
    --font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    --font-size-sm: 0.875rem;
    --font-size-base: 1rem;
    --font-size-lg: 1.25rem;
    --font-size-xl: 1.5rem;
    
    /* Shadows */
    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
    --shadow-lg: 0 10px 25px rgba(0, 0, 0, 0.15);
    
    /* Transitions */
    --transition-fast: 150ms ease;
    --transition-normal: 250ms ease;
    
    /* Layout */
    --header-height: 60px;
    --footer-height: 40px;
    --panel-width: 320px;
}

/* Reset */
*, *::before, *::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

/* Base Styles */
html, body {
    height: 100%;
    font-family: var(--font-family);
    font-size: var(--font-size-base);
    color: var(--color-text);
    background-color: var(--color-bg);
    line-height: 1.5;
}

/* ===========================================
   Header
   =========================================== */
.header {
    height: var(--header-height);
    background: linear-gradient(135deg, var(--color-primary) 0%, var(--color-primary-dark) 100%);
    color: white;
    box-shadow: var(--shadow-md);
    position: relative;
    z-index: 1000;
}

.header-content {
    height: 100%;
    max-width: 100%;
    padding: 0 var(--spacing-lg);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.logo {
    display: flex;
    align-items: center;
    gap: var(--spacing-md);
}

.logo-icon {
    width: 32px;
    height: 32px;
    stroke: white;
}

.logo h1 {
    font-size: var(--font-size-xl);
    font-weight: 600;
    letter-spacing: -0.5px;
}

/* ===========================================
   Main Content
   =========================================== */
.main-content {
    display: flex;
    height: calc(100vh - var(--header-height) - var(--footer-height));
    position: relative;
}

/* ===========================================
   Map Container
   =========================================== */
.map-container {
    flex: 1;
    height: 100%;
    z-index: 1;
}

/* Leaflet customizations */
.leaflet-container {
    font-family: var(--font-family);
}

.leaflet-popup-content-wrapper {
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
}

.leaflet-popup-content {
    margin: 12px 16px;
    font-size: var(--font-size-sm);
}

/* Custom marker styles */
.hq-marker {
    background: var(--color-primary);
    border: 3px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow-md);
}

.customer-marker-inside {
    background: var(--color-success);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.customer-marker-outside {
    background: var(--color-danger);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

.tool-shop-marker {
    background: var(--color-warning);
    border: 2px solid white;
    border-radius: 50%;
    box-shadow: var(--shadow-sm);
}

/* ===========================================
   Side Panel
   =========================================== */
.side-panel {
    width: var(--panel-width);
    background: var(--color-bg-panel);
    border-left: 1px solid var(--color-border);
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    z-index: 100;
}

.panel-section {
    padding: var(--spacing-lg);
    border-bottom: 1px solid var(--color-border);
}

.panel-section:last-child {
    border-bottom: none;
}

.section-title {
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    color: var(--color-text-light);
    margin-bottom: var(--spacing-md);
    display: flex;
    align-items: center;
    gap: var(--spacing-sm);
}

.section-icon {
    width: 18px;
    height: 18px;
    stroke: var(--color-text-light);
}

/* ===========================================
   Info Grid
   =========================================== */
.info-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: var(--spacing-md);
}

.info-item {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-xs);
}

.info-item.full-width {
    grid-column: 1 / -1;
}

.info-label {
    font-size: var(--font-size-sm);
    color: var(--color-text-muted);
    font-weight: 500;
}

.info-value {
    font-size: var(--font-size-base);
    color: var(--color-text);
    font-weight: 600;
    font-family: 'Monaco', 'Consolas', monospace;
}

.info-value-large {
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-primary);
    font-family: 'Monaco', 'Consolas', monospace;
}

/* ===========================================
   Customer Info
   =========================================== */
.customer-info {
    background: var(--color-bg-section);
    border-radius: 8px;
    padding: var(--spacing-md);
}

.placeholder-text {
    color: var(--color-text-muted);
    font-style: italic;
    text-align: center;
    font-size: var(--font-size-sm);
}

/* Status Badge */
.status-badge {
    display: inline-block;
    padding: var(--spacing-xs) var(--spacing-sm);
    border-radius: 4px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.status-badge.inside {
    background: rgba(76, 175, 80, 0.15);
    color: var(--color-success);
}

.status-badge.outside {
    background: rgba(244, 67, 54, 0.15);
    color: var(--color-danger);
}

/* ===========================================
   Actions Section
   =========================================== */
.actions-section {
    display: flex;
    flex-direction: column;
    gap: var(--spacing-sm);
}

.action-button {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--spacing-sm);
    padding: var(--spacing-md) var(--spacing-lg);
    border: none;
    border-radius: 8px;
    font-size: var(--font-size-sm);
    font-weight: 600;
    cursor: pointer;
    transition: all var(--transition-fast);
    width: 100%;
}

.action-button.primary,
.action-button:not(.secondary) {
    background: var(--color-secondary);
    color: white;
}

.action-button.primary:hover,
.action-button:not(.secondary):hover {
    background: #00796B;
    transform: translateY(-1px);
    box-shadow: var(--shadow-md);
}

.action-button.secondary {
    background: transparent;
    color: var(--color-text-light);
    border: 1px solid var(--color-border);
}

.action-button.secondary:hover {
    background: var(--color-bg-section);
    color: var(--color-text);
}

.action-button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.button-icon {
    width: 18px;
    height: 18px;
    stroke: currentColor;
}

/* ===========================================
   Statistics
   =========================================== */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: var(--spacing-sm);
}

.stat-item {
    text-align: center;
    padding: var(--spacing-sm);
    background: var(--color-bg-section);
    border-radius: 8px;
}

.stat-value {
    display: block;
    font-size: var(--font-size-xl);
    font-weight: 700;
    color: var(--color-primary);
}

.stat-label {
    display: block;
    font-size: 0.75rem;
    color: var(--color-text-muted);
    margin-top: var(--spacing-xs);
}

#total-customers {
    color: var(--color-primary);
}

#inside-count {
    color: var(--color-success);
}

#outside-count {
    color: var(--color-danger);
}

/* ===========================================
   Footer
   =========================================== */
.footer {
    height: var(--footer-height);
    background: var(--color-bg-dark);
    color: rgba(255, 255, 255, 0.8);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: var(--font-size-sm);
}

/* ===========================================
   Notification
   =========================================== */
.notification {
    position: fixed;
    bottom: calc(var(--footer-height) + var(--spacing-lg));
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--color-bg-dark);
    color: white;
    padding: var(--spacing-md) var(--spacing-xl);
    border-radius: 8px;
    box-shadow: var(--shadow-lg);
    z-index: 2000;
    opacity: 0;
    transition: all var(--transition-normal);
    font-size: var(--font-size-sm);
    font-weight: 500;
}

.notification.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.notification.error {
    background: var(--color-danger);
}

.notification.success {
    background: var(--color-success);
}

/* ===========================================
   Loading Spinner
   =========================================== */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* ===========================================
   Responsive Design
   =========================================== */
@media (max-width: 768px) {
    :root {
        --header-height: 50px;
        --footer-height: auto;
        --panel-width: 100%;
    }

    .main-content {
        flex-direction: column;
    }

    .header-content {
        padding: 0 var(--spacing-md);
    }

    .logo h1 {
        font-size: var(--font-size-lg);
    }

    .logo-icon {
        width: 24px;
        height: 24px;
    }

    .map-container {
        height: 50vh;
        min-height: 300px;
    }

    .side-panel {
        width: 100%;
        height: auto;
        max-height: 50vh;
        border-left: none;
        border-top: 1px solid var(--color-border);
    }

    .panel-section {
        padding: var(--spacing-md);
    }

    .stats-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .footer {
        height: auto;
        padding: var(--spacing-sm);
        text-align: center;
    }

    .notification {
        width: calc(100% - var(--spacing-xl));
        max-width: 400px;
    }
}

@media (max-width: 480px) {
    .info-grid {
        grid-template-columns: 1fr;
    }

    .action-button {
        padding: var(--spacing-sm) var(--spacing-md);
    }

    .stat-value {
        font-size: var(--font-size-lg);
    }
}

/* ===========================================
   Print Styles
   =========================================== */
@media print {
    .header,
    .footer,
    .action-button,
    .notification {
        display: none;
    }

    .main-content {
        height: auto;
    }

    .map-container {
        height: 60vh;
    }

    .side-panel {
        width: 100%;
        border: 1px solid #ccc;
    }
}

/* ===========================================
   Accessibility
   =========================================== */
@media (prefers-reduced-motion: reduce) {
    *,
    *::before,
    *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

/* Focus styles for keyboard navigation */
.action-button:focus-visible {
    outline: 2px solid var(--color-primary);
    outline-offset: 2px;
}

/* High contrast mode support */
@media (prefers-contrast: high) {
    :root {
        --color-border: #333333;
        --color-text-muted: #555555;
    }

    .action-button {
        border: 2px solid currentColor;
    }
}