/* Design System Tokens */
:root {
    --primary: #007aff;
    --primary-hover: #0056b3;
    --success: #34c759;
    --success-hover: #28a745;
    --danger: #ff3b30;
    --danger-hover: #c82333;
    --warning: #ff9500;
    --bg-app: #f5f5f7;
    --bg-panel: rgba(255, 255, 255, 0.75);
    --bg-panel-solid: #ffffff;
    --border-panel: rgba(255, 255, 255, 0.4);
    --text-primary: #1d1d1f;
    --text-secondary: #86868b;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.08);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    
    /* Leaflet customization */
    --map-circle-fill: rgba(0, 122, 255, 0.15);
    --map-circle-stroke: #007aff;
}

body.dark-theme {
    --bg-app: #000000;
    --bg-panel: rgba(28, 28, 30, 0.85);
    --bg-panel-solid: #1c1c1e;
    --border-panel: rgba(255, 255, 255, 0.1);
    --text-primary: #f5f5f7;
    --text-secondary: #86868b;
    --card-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.3);
    
    --map-circle-fill: rgba(0, 122, 255, 0.2);
}

/* Global Reset */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
    font-family: 'Outfit', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    -webkit-tap-highlight-color: transparent;
}

body, html {
    width: 100%;
    height: 100%;
    overflow: hidden;
    background-color: var(--bg-app);
    color: var(--text-primary);
    transition: background-color 0.3s ease, color 0.3s ease;
}

/* Layout Wrapper */
.app-container {
    position: relative;
    width: 100%;
    height: 100dvh;
    display: flex;
}

/* Control Panel (Floating Glass Panel) */
.control-panel {
    position: absolute;
    top: 20px;
    left: 20px;
    z-index: 1000;
    width: 360px;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition);
}

.control-panel .btn {
    padding: 10px 16px;
    font-size: 0.88rem;
}

.panel-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1.2rem;
    color: var(--primary);
}

.logo h1 {
    font-size: 1.25rem;
    font-weight: 700;
    color: var(--text-primary);
}

.control-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.control-group label {
    display: flex;
    justify-content: space-between;
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-secondary);
}

.control-group label span:last-child {
    color: var(--primary);
    font-weight: 600;
}

/* Custom range slider styling */
.slider-wrapper {
    width: 100%;
}

#radiusSlider {
    width: 100%;
    height: 6px;
    background: transparent !important;
    padding: 0 !important;
    border: none !important;
    border-radius: 0 !important;
    outline: none;
    -webkit-appearance: none;
    cursor: pointer;
    box-shadow: none !important;
}

#radiusSlider::-webkit-slider-runnable-track {
    width: 100%;
    height: 6px;
    background: rgba(142, 142, 147, 0.3);
    border-radius: 3px;
}

#radiusSlider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 20px;
    height: 20px;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    margin-top: -7px;
    transition: transform 0.1s ease;
}

#radiusSlider::-webkit-slider-thumb:hover {
    transform: scale(1.15);
}

#radiusSlider::-moz-range-track {
    width: 100%;
    height: 6px;
    background: rgba(142, 142, 147, 0.3);
    border-radius: 3px;
}

#radiusSlider::-moz-range-thumb {
    width: 20px;
    height: 20px;
    border: none;
    border-radius: 50%;
    background: var(--primary);
    cursor: pointer;
    box-shadow: 0 2px 6px rgba(0,0,0,0.3);
    transition: transform 0.1s ease;
}

#radiusSlider::-moz-range-thumb:hover {
    transform: scale(1.15);
}

/* Action Buttons */
.action-buttons {
    display: flex;
    gap: 10px;
}

.btn {
    flex: 1;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    border: none;
    font-weight: 600;
    font-size: 0.95rem;
    cursor: pointer;
    transition: var(--transition);
}

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

.btn-primary:hover {
    background: var(--primary-hover);
    transform: translateY(-1px);
}

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

.btn-success:hover {
    background: var(--success-hover);
    transform: translateY(-1px);
}

.btn-secondary {
    background: var(--text-secondary);
    color: #fff;
    opacity: 0.8;
}

.btn-secondary:hover {
    opacity: 1;
}

.btn-icon {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: none;
    background: rgba(120, 120, 128, 0.16);
    color: var(--text-primary);
    cursor: pointer;
    display: flex;
    justify-content: center;
    align-items: center;
    transition: var(--transition);
}

.btn-icon:hover {
    background: rgba(120, 120, 128, 0.3);
}

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

/* Side Panel (Desktop Sidebar / Mobile Bottom Sheet) */
.side-panel {
    position: absolute;
    right: 20px;
    top: 20px;
    bottom: 20px;
    width: 360px;
    z-index: 1000;
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-lg);
    box-shadow: var(--card-shadow);
    display: flex;
    flex-direction: column;
    overflow: hidden;
    transition: var(--transition);
}

.side-panel-header {
    cursor: pointer;
    user-select: none;
    display: flex;
    flex-direction: column;
    align-items: center;
    width: 100%;
}

.drag-handle {
    display: none;
    width: 40px;
    height: 5px;
    background: var(--text-secondary);
    border-radius: 3px;
    margin: 10px auto 0;
    cursor: grab;
}

/* Side Panel Content wrapper */
.panel-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 0 24px 24px 24px;
    overflow: hidden;
    min-height: 0;
}

.side-panel-header h2 {
    font-size: 1.25rem;
    font-weight: 600;
    margin: 20px 0 12px 0;
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 0 24px;
    box-sizing: border-box;
    width: 100%;
}

/* Customer List */
.customer-list {
    flex: 1;
    overflow-y: scroll;
    display: flex;
    flex-direction: column;
    gap: 12px;
    padding-right: 4px;
    min-height: 0;
    -webkit-overflow-scrolling: touch;
    touch-action: pan-y;
}

.customer-list::-webkit-scrollbar {
    width: 6px;
}

.customer-list::-webkit-scrollbar-track {
    background: transparent;
}

.customer-list::-webkit-scrollbar-thumb {
    background: rgba(120, 120, 128, 0.2);
    border-radius: 3px;
}

/* Customer Card */
.customer-card {
    background: rgba(255, 255, 255, 0.4);
    border: 1px solid rgba(255, 255, 255, 0.2);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    transition: var(--transition);
    touch-action: pan-y;
}

.customer-card * {
    touch-action: pan-y;
}

.dark-theme .customer-card {
    background: rgba(255, 255, 255, 0.04);
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.customer-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 16px rgba(0,0,0,0.04);
    background: rgba(255, 255, 255, 0.6);
}

.dark-theme .customer-card:hover {
    background: rgba(255, 255, 255, 0.08);
}

.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
}

.card-header h3 {
    font-size: 1.05rem;
    font-weight: 600;
    line-height: 1.3;
}

.distance-badge {
    background: rgba(0, 122, 255, 0.12);
    color: var(--primary);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.75rem;
    font-weight: 600;
    white-space: nowrap;
}

.card-details {
    display: flex;
    flex-direction: column;
    gap: 6px;
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.card-details p {
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-details i {
    width: 14px;
    color: var(--primary);
}

.card-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
}

.card-actions .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
}

.btn-icon-only {
    width: 34px;
    height: 34px;
    padding: 0 !important;
    flex: none !important;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    box-sizing: border-box;
}

.btn-delete {
    background: rgba(255, 59, 48, 0.1);
    color: var(--danger);
}

.btn-delete:hover {
    background: var(--danger);
    color: #fff;
}

/* Empty/Loading States */
.empty-state {
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
    height: 100%;
    color: var(--text-secondary);
    gap: 16px;
    padding: 40px 20px;
}

.empty-state i {
    font-size: 3rem;
    color: var(--primary);
    opacity: 0.6;
}

/* Modals */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 2000;
    background: rgba(0, 0, 0, 0.4);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    display: flex;
    justify-content: center;
    align-items: center;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.3s ease;
}

.modal-backdrop.active {
    opacity: 1;
    pointer-events: auto;
}

.modal-card {
    background: var(--bg-panel);
    border: 1px solid var(--border-panel);
    box-shadow: var(--card-shadow);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 500px;
    max-height: 85vh;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 24px;
    position: relative;
    transform: scale(0.9);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    box-sizing: border-box;
}

.modal-backdrop.active .modal-card {
    transform: scale(1);
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
}

.modal-header h3 {
    font-size: 1.25rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 10px;
    word-break: break-word;
    flex: 1;
}

.btn-close {
    border: none;
    background: transparent;
    font-size: 1.75rem;
    color: var(--text-secondary);
    cursor: pointer;
    transition: var(--transition);
    flex-shrink: 0;
    margin-left: 15px;
    min-width: 30px;
    height: 30px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-close:hover {
    color: var(--text-primary);
}

/* VCF Import Styles */
.vcf-import-section {
    background: rgba(120, 120, 128, 0.05);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 20px;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.vcf-import-header {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.vcf-import-header i {
    color: var(--primary);
}

.vcf-import-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.vcf-import-controls .btn {
    padding: 8px 12px;
    font-size: 0.85rem;
    flex: unset;
}

.file-name-text {
    flex: 1;
    font-size: 0.8rem;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 80px;
}

.import-divider {
    display: flex;
    align-items: center;
    text-align: center;
    color: var(--text-secondary);
    font-size: 0.7rem;
    font-weight: 700;
    letter-spacing: 0.5px;
    margin-top: 4px;
}

.import-divider::before,
.import-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-panel);
}

.import-divider::before {
    margin-right: .5em;
}

.import-divider::after {
    margin-left: .5em;
}

/* Form Styles */
#formCustomer {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.form-group {
    display: flex;
    flex-direction: column;
    gap: 6px;
}

.form-group-row {
    display: flex;
    gap: 12px;
}

.form-group-row .form-group {
    flex: 1;
}

.zip-group {
    flex: 1 !important;
}

.city-group {
    flex: 2 !important;
}

label {
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-primary);
}

input, select {
    padding: 12px;
    border-radius: var(--radius-md);
    border: 1px solid var(--border-panel);
    background: rgba(120, 120, 128, 0.08);
    color: var(--text-primary);
    font-size: 0.95rem;
    outline: none;
    transition: var(--transition);
    width: 100%;
}

input:focus, select:focus {
    border-color: var(--primary);
    background: rgba(255,255,255,0.9);
    box-shadow: 0 0 0 4px rgba(0, 122, 255, 0.15);
}

.dark-theme input:focus, .dark-theme select:focus {
    background: rgba(30, 30, 40, 0.9);
}

.dark-theme select option {
    background-color: #1c1c1e;
    color: var(--text-primary);
}

/* Badges and Custom Tags styling */
.badges-row {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin-top: 4px;
    margin-bottom: 2px;
}

.badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 4px 8px;
    border-radius: 10px;
    line-height: 1;
}

.status-buying-direct {
    background: rgba(52, 199, 89, 0.12);
    color: var(--success);
}

.status-buying-dealer {
    background: rgba(255, 149, 0, 0.12);
    color: var(--warning);
}

.status-non-buying {
    background: rgba(255, 59, 48, 0.12);
    color: var(--danger);
}

.industry-badge {
    background: rgba(120, 120, 128, 0.12);
    color: var(--text-primary);
}

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

/* Loading Overlay inside Modal */
.loading-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(255,255,255,0.85);
    border-radius: var(--radius-lg);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    gap: 16px;
    z-index: 100;
    opacity: 0;
    pointer-events: none;
    transition: var(--transition);
}

.dark-theme .loading-overlay {
    background: rgba(28,28,30,0.9);
}

.loading-overlay.active {
    opacity: 1;
    pointer-events: auto;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid rgba(0, 122, 255, 0.1);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 1s infinite linear;
}

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

/* Toast Messages */
.toast {
    position: fixed;
    bottom: 24px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    z-index: 9999;
    padding: 12px 24px;
    border-radius: 30px;
    background: rgba(0,0,0,0.8);
    color: #fff;
    font-weight: 500;
    font-size: 0.9rem;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    opacity: 0;
    transition: transform 0.3s cubic-bezier(0.175, 0.885, 0.32, 1.275), opacity 0.3s ease;
}

.toast.show {
    transform: translateX(-50%) translateY(0);
    opacity: 1;
}

.toast.success {
    background: var(--success);
}

.toast.error {
    background: var(--danger);
}

/* Embed Friendly / Lovelace Dashboard Mode */
body.embedded .control-panel {
    top: 10px;
    left: 10px;
    width: calc(100% - 20px);
    border-radius: var(--radius-md);
    padding: 12px;
    gap: 12px;
}

body.embedded .logo {
    display: none; /* Hide logo/header to save space in HA card */
}

body.embedded .side-panel {
    top: 115px; /* Position below the full-width control panel header */
    right: 10px;
    bottom: 10px;
    width: 320px;
    border-radius: var(--radius-md);
}

/* Reset for mobile screens inside embedded view */
@media (max-width: 768px) {
    body.embedded .side-panel {
        top: auto;
        right: 0;
        bottom: 0;
        left: 0;
        width: 100%;
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    }
}

/* Leaflet Map UI Adjustments */
.leaflet-bar {
    border: none !important;
    box-shadow: var(--card-shadow) !important;
    border-radius: var(--radius-md) !important;
    overflow: hidden;
}

.leaflet-bar a {
    background-color: var(--bg-panel) !important;
    color: var(--text-primary) !important;
    border-bottom: 1px solid var(--border-panel) !important;
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
}

.leaflet-bar a:hover {
    background-color: rgba(120, 120, 128, 0.2) !important;
}

/* Custom Marker Popup Styling */
.leaflet-popup-content-wrapper {
    background: var(--bg-panel) !important;
    backdrop-filter: blur(15px);
    -webkit-backdrop-filter: blur(15px);
    color: var(--text-primary) !important;
    border-radius: var(--radius-md) !important;
    border: 1px solid var(--border-panel);
    box-shadow: var(--card-shadow) !important;
}

.leaflet-popup-tip {
    background: var(--bg-panel) !important;
}

.leaflet-popup-content h3 {
    margin-bottom: 6px;
    font-size: 1.05rem;
    font-weight: 600;
}

.leaflet-popup-content p {
    font-size: 0.85rem;
    color: var(--text-secondary);
    margin-bottom: 4px;
    display: flex;
    align-items: center;
    gap: 6px;
}

.leaflet-popup-content .btn-popup-call {
    margin-top: 8px;
    width: 100%;
    padding: 6px 10px;
    background: var(--success);
    color: white;
    text-align: center;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
}

.leaflet-popup-content .btn-popup-route {
    margin-top: 6px;
    width: 100%;
    padding: 6px 10px;
    background: var(--primary);
    color: white;
    text-align: center;
    border-radius: var(--radius-sm);
    text-decoration: none;
    display: inline-flex;
    justify-content: center;
    align-items: center;
    gap: 6px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: var(--transition);
    box-sizing: border-box;
}

.leaflet-popup-content .btn-popup-route:hover {
    background: var(--primary-hover);
}

/* Media Queries for Mobile Responsiveness */
@media (max-width: 768px) {
    .app-container {
        flex-direction: column;
    }
    
    .control-panel {
        top: 8px;
        left: 8px;
        right: 8px;
        width: auto;
        padding: 8px 10px;
        border-radius: var(--radius-md);
        gap: 6px; /* Super compact spacing */
    }
    
    .control-panel .panel-header {
        margin-bottom: 0;
    }
    
    .control-panel .logo h1 {
        font-size: 0.95rem;
    }
    
    .control-panel .logo img {
        width: 22px !important;
        height: 22px !important;
    }
    
    .control-panel .btn-icon {
        width: 28px;
        height: 28px;
        font-size: 0.85rem;
    }
    
    .control-panel .user-profile-info {
        display: none !important; /* Hide on mobile to save entire row */
    }
    
    .control-panel .control-group {
        flex-direction: row !important; /* Move label and slider to same row */
        align-items: center !important;
        justify-content: space-between !important;
        gap: 8px !important;
    }
    
    .control-panel .control-group label {
        display: flex !important;
        flex-direction: row !important;
        gap: 4px !important;
        font-size: 0.78rem !important;
        margin-bottom: 0 !important;
        flex-shrink: 0 !important;
    }
    
    .control-panel .slider-wrapper {
        flex-grow: 1 !important;
    }
    
    .control-panel .slider-wrapper input[type="range"] {
        margin: 0 !important;
    }
    
    .control-panel .action-buttons {
        gap: 6px;
    }
    
    .control-panel .btn {
        padding: 6px 10px;
        font-size: 0.8rem;
        border-radius: var(--radius-sm);
    }
    
    .side-panel {
        top: auto;
        left: 0;
        right: 0;
        bottom: 0;
        width: 100%;
        height: 75px; /* Collapsed height by default */
        border-radius: var(--radius-lg) var(--radius-lg) 0 0;
        z-index: 1001;
        transition: height 0.3s cubic-bezier(0.1, 0.76, 0.55, 0.94);
        background: var(--bg-panel-solid) !important;
        backdrop-filter: none !important;
        -webkit-backdrop-filter: none !important;
    }
    
    .side-panel.expanded {
        height: 400px; /* Stable fixed pixel height to resolve iOS Safari flexbox bugs */
    }
    
    .drag-handle {
        display: block;
    }
    
    .side-panel-header h2 {
        font-size: 1.1rem;
        margin: 5px 0 10px 0;
        padding: 0 16px;
        justify-content: center;
    }
    
    .panel-content {
        padding: 0 16px 16px 16px;
        height: calc(100% - 54px);
    }
    
    .leaflet-bottom.leaflet-right {
        bottom: 60px !important; /* Move map controls up so bottom sheet doesn't overlap them */
    }
}

/* Visit date styling */
.visit-row {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-top: 4px;
    border-top: 1px dashed var(--border-panel);
    padding-top: 6px;
    font-size: 0.82rem;
}

.visit-row label {
    font-size: 0.82rem;
    color: var(--text-secondary);
    font-weight: 500;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.visit-row label i {
    color: var(--primary);
    width: 14px;
}

.visit-date-input {
    width: 140px;
    padding: 4px 6px;
    font-size: 0.82rem;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border-panel);
    background: rgba(120, 120, 128, 0.05);
    color: var(--text-primary);
    cursor: pointer;
    font-family: inherit;
    height: auto;
}

.visit-date-input:focus {
    border-color: var(--primary);
    background: rgba(255, 255, 255, 0.95);
    box-shadow: 0 0 0 2px rgba(0, 122, 255, 0.15);
}

.dark-theme .visit-date-input:focus {
    background: rgba(30, 30, 40, 0.95);
}

/* ==========================================
   AUTH OVERLAY & CARD (GLASSMORPHISM)
   ========================================== */
.auth-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 5000;
    background: var(--bg-app);
    display: flex;
    justify-content: center;
    align-items: center;
    transition: opacity 0.4s ease, visibility 0.4s ease;
    opacity: 1;
    visibility: visible;
    padding: 20px;
}

.auth-overlay.hidden {
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
}

.auth-card {
    background: var(--bg-panel);
    backdrop-filter: blur(20px);
    -webkit-backdrop-filter: blur(20px);
    border: 1px solid var(--border-panel);
    box-shadow: var(--card-shadow);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 400px;
    padding: 30px;
    display: flex;
    flex-direction: column;
    gap: 20px;
    animation: authCardEnter 0.5s cubic-bezier(0.16, 1, 0.3, 1);
}

@keyframes authCardEnter {
    from {
        transform: translateY(20px) scale(0.96);
        opacity: 0;
    }
    to {
        transform: translateY(0) scale(1);
        opacity: 1;
    }
}

.auth-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    text-align: center;
}

.auth-logo img {
    width: 64px;
    height: 64px;
    border-radius: 50%;
    object-fit: cover;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
}

.auth-logo h2 {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-primary);
}

.auth-tabs {
    display: flex;
    background: rgba(120, 120, 128, 0.1);
    border-radius: var(--radius-md);
    padding: 4px;
    margin-bottom: 5px;
}

.auth-tab {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px;
    font-size: 0.95rem;
    font-weight: 600;
    color: var(--text-secondary);
    border-radius: calc(var(--radius-md) - 2px);
    cursor: pointer;
    transition: var(--transition);
}

.auth-tab.active {
    background: var(--bg-panel);
    color: var(--text-primary);
    box-shadow: 0 2px 8px rgba(0,0,0,0.06);
}

.input-wrapper {
    position: relative;
    display: flex;
    align-items: center;
    width: 100%;
}

.input-wrapper i {
    position: absolute;
    left: 14px;
    color: var(--text-secondary);
    font-size: 1rem;
    pointer-events: none;
}

.input-wrapper input {
    padding-left: 40px;
}

.input-wrapper i.toggle-password {
    position: absolute;
    right: 14px;
    left: auto;
    color: var(--text-secondary);
    font-size: 1rem;
    cursor: pointer;
    pointer-events: auto !important;
    transition: color 0.2s;
}

.input-wrapper i.toggle-password:hover {
    color: var(--primary);
}

.input-wrapper input.with-toggle {
    padding-right: 40px;
}

.auth-info-box {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 12px 16px;
    border-radius: var(--radius-md);
    font-size: 0.85rem;
    line-height: 1.4;
}

.auth-info-box.error {
    background: rgba(255, 59, 48, 0.1);
    border: 1px solid rgba(255, 59, 48, 0.2);
    color: var(--danger);
}

.auth-info-box.success {
    background: rgba(52, 199, 89, 0.1);
    border: 1px solid rgba(52, 199, 89, 0.2);
    color: var(--success);
}

.auth-info-box.info {
    background: rgba(0, 122, 255, 0.1);
    border: 1px solid rgba(0, 122, 255, 0.2);
    color: var(--primary);
}

/* =====================================================================
   BESUCHSBERICHTE & KI-SEKRETÄRIN STYLES
   ===================================================================== */

/* Leaflet Popup Buttons */
.btn-popup-reports, .btn-popup-dictate {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--radius-sm);
    border: none;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
    margin-top: 6px;
    box-sizing: border-box;
}

.btn-popup-reports {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
}

.btn-popup-reports:hover {
    background: rgba(0, 122, 255, 0.2);
}

.btn-popup-dictate {
    background: rgba(52, 199, 89, 0.1);
    color: var(--success);
}

.btn-popup-dictate:hover {
    background: rgba(52, 199, 89, 0.2);
}

/* Modals sizing */
.modal-large {
    max-width: 600px !important;
}

/* Reports List Items */
.report-card {
    background: rgba(120, 120, 128, 0.08);
    border: 1px solid var(--border-panel);
    border-radius: var(--radius-md);
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    transition: var(--transition);
}

.report-card:hover {
    background: rgba(120, 120, 128, 0.12);
    box-shadow: 0 4px 12px rgba(0,0,0,0.05);
}

.report-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px dashed var(--border-panel);
    padding-bottom: 8px;
}

.report-card-date {
    font-size: 0.8rem;
    color: var(--text-secondary);
    font-weight: 600;
}

.report-card-meta {
    font-size: 0.85rem;
    display: flex;
    flex-direction: column;
    gap: 4px;
    color: var(--text-primary);
}

.report-card-meta strong {
    color: var(--primary);
}

.report-card-content {
    font-size: 0.88rem;
    line-height: 1.45;
    color: var(--text-primary);
    background: rgba(0, 0, 0, 0.05);
    padding: 10px;
    border-radius: var(--radius-sm);
    border-left: 3px solid var(--primary);
}

.report-card-actions {
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.btn-report-read {
    background: rgba(0, 122, 255, 0.1);
    color: var(--primary);
    border: none;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 500;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}

.btn-report-read:hover {
    background: rgba(0, 122, 255, 0.2);
}

/* Secretary Dialogue Bubbles */
.bubble {
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 85%;
    font-size: 0.9rem;
    line-height: 1.35;
    word-wrap: break-word;
}

.bubble.assistant {
    background: rgba(255, 255, 255, 0.08);
    color: #ffffff;
    align-self: flex-start;
    border-radius: 14px 14px 14px 0;
    border: 1px solid rgba(255, 255, 255, 0.05);
}

.bubble.user {
    background: var(--primary);
    color: #ffffff;
    align-self: flex-end;
    border-radius: 14px 14px 0 14px;
}

/* Mic pulsing animation when listening */
.btn-secretary-mic.listening {
    background: #ff3b30 !important;
    animation: mic-pulse 1.5s infinite ease-in-out;
    box-shadow: 0 4px 20px rgba(255, 59, 48, 0.6) !important;
}

@keyframes mic-pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.1);
    }
    100% {
        transform: scale(1);
    }
}

/* Audio Visualizer Wave Animation */
.visualizer-bars.active .bar {
    animation: bounce 0.6s infinite alternate ease-in-out;
}

.visualizer-bars.active .bar:nth-child(1) { animation-delay: 0.1s; height: 18px; }
.visualizer-bars.active .bar:nth-child(2) { animation-delay: 0.2s; height: 25px; }
.visualizer-bars.active .bar:nth-child(3) { animation-delay: 0.3s; height: 12px; }
.visualizer-bars.active .bar:nth-child(4) { animation-delay: 0.4s; height: 28px; }
.visualizer-bars.active .bar:nth-child(5) { animation-delay: 0.5s; height: 15px; }

@keyframes bounce {
    10% { transform: scaleY(0.3); }
    90% { transform: scaleY(1.1); }
}

/* Modal Tabs Layout */
.modal-tabs {
    display: flex;
    border-bottom: 1px solid var(--border-panel);
    margin: 0 20px 15px 20px;
    gap: 10px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
}

.modal-tabs::-webkit-scrollbar {
    display: none;
}

.modal-tab {
    flex: 1 0 auto !important;
    flex-shrink: 0 !important;
    min-width: max-content !important;
    padding: 12px;
    background: none;
    border: none;
    border-bottom: 3px solid transparent;
    color: var(--text-secondary);
    font-size: 0.95rem;
    font-weight: 500;
    font-family: 'Outfit', sans-serif;
    cursor: pointer;
    transition: all 0.25s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
}

@media (max-width: 480px) {
    .modal-tabs {
        gap: 6px;
        margin: 0 10px 10px 10px;
    }
    .modal-tab {
        padding: 10px 8px;
        font-size: 0.85rem;
        gap: 5px;
    }
}

.modal-tab:hover {
    color: var(--text-primary);
}

.modal-tab.active {
    color: var(--primary);
    border-bottom-color: var(--primary);
    font-weight: 600;
}

/* Document Folders Grid */
.documents-folders {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.folder-card {
    flex: 1;
    padding: 18px 15px;
    background: var(--bg-card);
    border: 1px solid var(--border-panel);
    border-radius: 14px;
    cursor: pointer;
    text-align: center;
    transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    align-items: center;
}

.folder-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.15);
    border-color: var(--primary-light);
}

.folder-card.active {
    background: rgba(10, 132, 255, 0.12);
    border-color: #0a84ff;
}

#folderAuftraege.folder-card.active {
    background: rgba(48, 209, 88, 0.12);
    border-color: #30d158;
}

.folder-icon {
    font-size: 2.2rem;
    color: var(--text-secondary);
    margin-bottom: 10px;
    transition: color 0.25s ease;
}

.folder-card.active .folder-icon {
    color: #0a84ff;
}

#folderAuftraege.folder-card .folder-icon {
    color: var(--text-secondary);
}

#folderAuftraege.folder-card.active .folder-icon {
    color: #30d158;
}

.folder-title {
    font-size: 1rem;
    font-weight: 600;
    color: var(--text-primary);
}

.folder-count {
    font-size: 0.8rem;
    color: var(--text-secondary);
    margin-top: 4px;
}

/* Document List Item Styling */
.document-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-panel);
    border-radius: 10px;
    cursor: pointer;
    transition: all 0.2s ease;
}

.document-item:hover {
    background: rgba(255, 255, 255, 0.03);
    border-color: var(--primary);
    transform: translateX(3px);
}

.document-info {
    display: flex;
    align-items: center;
    gap: 12px;
    overflow: hidden;
}

.document-info i {
    font-size: 1.3rem;
    color: #ff453a; /* Red PDF icon */
}

.document-meta {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.document-name {
    font-size: 0.9rem;
    font-weight: 500;
    color: var(--text-primary);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.document-size-date {
    font-size: 0.75rem;
    color: var(--text-secondary);
    margin-top: 2px;
}

.document-action-icon {
    color: var(--text-secondary);
    font-size: 0.9rem;
    transition: color 0.2s ease;
}

.document-item:hover .document-action-icon {
    color: var(--primary);
}

.clear-search-icon {
    transition: color 0.2s ease, transform 0.2s ease;
}

.clear-search-icon:hover {
    color: var(--danger) !important;
    transform: translateY(-50%) scale(1.15) !important;
}


