/* RouteOptima - Mobile First Modern Dark Theme CSS */

:root {
    --bg-main: #0b0f19;
    --bg-card: #131c2e;
    --bg-card-hover: #1b273e;
    --bg-input: #0d1525;
    --border-color: #23324d;
    --border-focus: #3b82f6;
    
    --text-primary: #f1f5f9;
    --text-secondary: #94a3b8;
    --text-muted: #64748b;
    
    --accent-blue: #3b82f6;
    --accent-indigo: #6366f1;
    --accent-emerald: #10b981;
    --accent-amber: #f59e0b;
    --accent-rose: #ef4444;

    --gradient-brand: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    --gradient-emerald: linear-gradient(135deg, #059669 0%, #10b981 100%);
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --radius-full: 9999px;
    
    --shadow-card: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
    --shadow-glow: 0 0 20px rgba(59, 130, 246, 0.25);
    
    --font-sans: 'Inter', system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

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

body {
    font-family: var(--font-sans);
    background-color: var(--bg-main);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header & Nav */
.navbar {
    background: rgba(19, 28, 46, 0.85);
    backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border-color);
    position: sticky;
    top: 0;
    z-index: 1000;
    padding: 10px 16px;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.brand {
    display: flex;
    align-items: center;
    gap: 10px;
    text-decoration: none;
    color: var(--text-primary);
    font-weight: 700;
    font-size: 1.2rem;
}

.brand-icon {
    width: 36px;
    height: 36px;
    background: var(--gradient-brand);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-glow);
}

.brand-icon svg {
    width: 20px;
    height: 20px;
    fill: none;
    stroke: white;
    stroke-width: 2.2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.nav-badges {
    display: flex;
    gap: 8px;
}

.badge {
    background: rgba(59, 130, 246, 0.15);
    color: var(--accent-blue);
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.75rem;
    font-weight: 600;
}

/* Main Container */
.app-container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 16px;
    width: 100%;
    flex: 1;
    display: grid;
    grid-template-columns: 1fr;
    gap: 20px;
}

@media (min-width: 900px) {
    .app-container {
        grid-template-columns: 420px 1fr;
        align-items: start;
        padding: 24px;
    }
}

/* Cards & Sections */
.card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    padding: 16px;
    box-shadow: var(--shadow-card);
}

@media (min-width: 600px) {
    .card { padding: 20px; }
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 14px;
    flex-wrap: wrap;
    gap: 10px;
}

.card-title {
    font-size: 1.05rem;
    font-weight: 600;
    color: var(--text-primary);
    display: flex;
    align-items: center;
    gap: 8px;
}

.card-title svg {
    width: 20px;
    height: 20px;
    stroke: var(--accent-blue);
    fill: none;
    stroke-width: 2;
}

/* Input Styles */
.form-group {
    margin-bottom: 14px;
}

label {
    display: block;
    font-size: 0.85rem;
    font-weight: 600;
    color: var(--text-secondary);
    margin-bottom: 8px;
}

textarea, input[type="text"] {
    width: 100%;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    color: var(--text-primary);
    font-family: inherit;
    font-size: 0.95rem;
    line-height: 1.5;
    transition: all 0.2s ease;
    resize: vertical;
}

textarea:focus, input[type="text"]:focus {
    outline: none;
    border-color: var(--border-focus);
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

textarea::placeholder {
    color: var(--text-muted);
}

.hint-text {
    font-size: 0.78rem;
    color: var(--text-muted);
    margin-top: 6px;
}

/* Checkbox Toggle */
.toggle-option {
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    user-select: none;
    font-size: 0.88rem;
    color: var(--text-secondary);
    margin-bottom: 16px;
}

.toggle-option input[type="checkbox"] {
    width: 18px;
    height: 18px;
    accent-color: var(--accent-blue);
    cursor: pointer;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    min-height: 48px;
    padding: 12px 18px;
    border: none;
    border-radius: var(--radius-md);
    font-size: 0.95rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    text-decoration: none;
    -webkit-tap-highlight-color: transparent;
}

.btn-primary {
    background: var(--gradient-brand);
    color: white;
    box-shadow: var(--shadow-glow);
}

.btn-primary:hover {
    opacity: 0.95;
}

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

.btn-secondary {
    background: #1e293b;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
}

.btn-secondary:hover {
    background: #334155;
}

.btn-icon-only {
    width: 44px;
    height: 48px;
    min-height: 48px;
    padding: 0;
    border-radius: var(--radius-md);
}

.btn-sm {
    min-height: 36px;
    padding: 6px 12px;
    font-size: 0.82rem;
}

/* Sample Quick Preset Chips */
.preset-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    margin-bottom: 14px;
}

.chip {
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    color: var(--text-secondary);
    padding: 6px 12px;
    border-radius: var(--radius-full);
    font-size: 0.78rem;
    cursor: pointer;
    transition: all 0.2s;
}

.chip:hover {
    background: rgba(59, 130, 246, 0.15);
    border-color: var(--accent-blue);
    color: var(--text-primary);
}

/* Route Summary Header Card */
.route-summary {
    background: linear-gradient(135deg, rgba(59, 130, 246, 0.12) 0%, rgba(99, 102, 241, 0.12) 100%);
    border: 1px solid rgba(59, 130, 246, 0.3);
    border-radius: var(--radius-md);
    padding: 16px;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 14px;
}

@media (min-width: 600px) {
    .route-summary {
        flex-direction: row;
        align-items: center;
        justify-content: space-between;
    }
}

.summary-metrics {
    display: flex;
    gap: 18px;
}

.metric-item {
    display: flex;
    flex-direction: column;
}

.metric-value {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--text-primary);
}

.metric-label {
    font-size: 0.72rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    color: var(--text-muted);
}

/* Map Container */
#map-container {
    width: 100%;
    height: 240px;
    border-radius: var(--radius-md);
    overflow: hidden;
    border: 1px solid var(--border-color);
    margin-bottom: 16px;
    z-index: 1;
}

@media (min-width: 900px) {
    #map-container {
        height: 320px;
    }
}

/* Optimized Route List */
.route-list {
    display: flex;
    flex-direction: column;
    gap: 10px;
    list-style: none;
}

.stop-item {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 12px 14px;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: all 0.2s ease;
}

.stop-badge {
    width: 32px;
    height: 32px;
    min-width: 32px;
    border-radius: var(--radius-full);
    background: #1e293b;
    border: 2px solid var(--accent-blue);
    color: var(--text-primary);
    font-weight: 700;
    font-size: 0.88rem;
    display: flex;
    align-items: center;
    justify-content: center;
}

.stop-item.start-stop .stop-badge {
    background: var(--accent-emerald);
    border-color: #34d399;
    color: white;
}

.stop-details {
    flex: 1;
    min-width: 0;
}

.stop-address {
    font-weight: 600;
    font-size: 0.9rem;
    color: var(--text-primary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.stop-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    font-size: 0.75rem;
    color: var(--text-muted);
    margin-top: 3px;
}

.stop-actions {
    display: flex;
    align-items: center;
    gap: 6px;
}

.gmaps-btn {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: var(--accent-emerald);
    padding: 6px 10px;
    border-radius: var(--radius-sm);
    font-size: 0.8rem;
    font-weight: 600;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    white-space: nowrap;
    min-height: 36px;
}

.gmaps-btn:hover {
    background: var(--accent-emerald);
    color: white;
}

/* Modal Popup Styles */
.modal-overlay {
    position: fixed;
    top: 0; left: 0; right: 0; bottom: 0;
    background: rgba(11, 15, 25, 0.85);
    backdrop-filter: blur(8px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
    padding: 20px;
}

.modal-card {
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 600px;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.6);
}

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

.modal-header h3 {
    font-size: 1.1rem;
    color: var(--text-primary);
}

.modal-close {
    background: transparent;
    border: none;
    color: var(--text-muted);
    font-size: 1.5rem;
    cursor: pointer;
    line-height: 1;
}

.modal-close:hover { color: white; }

.modal-body {
    padding: 20px;
    overflow-y: auto;
}

.saved-routes-grid {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.saved-route-card {
    background: #0d1525;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 14px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 12px;
}

.saved-route-info h4 {
    font-size: 0.95rem;
    color: var(--text-primary);
    margin-bottom: 4px;
}

.saved-route-meta {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    font-size: 0.78rem;
    color: var(--text-muted);
}

.saved-route-actions {
    display: flex;
    gap: 6px;
}

/* Drag / Move Handles */
.move-controls {
    display: flex;
    flex-direction: column;
    gap: 1px;
}

.move-btn {
    background: transparent;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    padding: 1px 4px;
    font-size: 0.7rem;
    border-radius: 3px;
}

.move-btn:hover {
    color: var(--text-primary);
    background: rgba(255, 255, 255, 0.1);
}

.move-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Loading Spinner Overlay */
.spinner {
    width: 18px;
    height: 18px;
    border: 3px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

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

/* Sticky Mobile Bottom Navigation Bar */
.mobile-bottom-bar {
    display: none;
}

@media (max-width: 899px) {
    .mobile-bottom-bar {
        display: flex;
        position: sticky;
        bottom: 0;
        left: 0;
        right: 0;
        background: rgba(11, 15, 25, 0.95);
        backdrop-filter: blur(12px);
        border-top: 1px solid var(--border-color);
        padding: 10px 14px;
        gap: 10px;
        z-index: 999;
        box-shadow: 0 -5px 15px rgba(0,0,0,0.5);
    }
}

/* Footer */
footer {
    border-top: 1px solid var(--border-color);
    padding: 18px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-top: 30px;
}

footer strong {
    color: var(--text-secondary);
}

/* User Profile Badge & Tags */
.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--border-color);
    padding: 4px 10px;
    border-radius: var(--radius-full);
    font-size: 0.82rem;
}

.user-name {
    color: var(--text-primary);
    font-weight: 600;
}

.user-role-tag {
    font-size: 0.65rem;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 4px;
    letter-spacing: 0.04em;
}

.role-admin {
    background: rgba(245, 158, 11, 0.2);
    color: #fbbf24;
    border: 1px solid rgba(245, 158, 11, 0.4);
}

.role-user {
    background: rgba(59, 130, 246, 0.2);
    color: #93c5fd;
    border: 1px solid rgba(59, 130, 246, 0.4);
}

/* Alerts */
.alert {
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-size: 0.88rem;
    margin-bottom: 14px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.15);
    border: 1px solid rgba(16, 185, 129, 0.4);
    color: #6ee7b7;
}

.alert-danger {
    background: rgba(239, 68, 68, 0.15);
    border: 1px solid rgba(239, 68, 68, 0.4);
    color: #fca5a5;
}

.alert-info {
    background: rgba(59, 130, 246, 0.15);
    border: 1px solid rgba(59, 130, 246, 0.4);
    color: #93c5fd;
}

/* Admin User Management Modal */
.user-create-box {
    background: #0d1525;
    border: 1px solid var(--border-color);
    border-radius: var(--radius-md);
    padding: 16px;
}

.table-responsive {
    width: 100%;
    overflow-x: auto;
}

.user-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    color: var(--text-primary);
}

.user-table th, .user-table td {
    padding: 10px 12px;
    border-bottom: 1px solid var(--border-color);
    text-align: left;
}

.user-table th {
    background: rgba(255, 255, 255, 0.03);
    color: var(--text-muted);
    font-size: 0.75rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-table tr:hover td {
    background: rgba(255, 255, 255, 0.02);
}

