/* ============================================================
   MERIDIAN ROUTE - DESIGN SYSTEM
   Modern dark UI with React-like aesthetics
   ============================================================ */

/* ========== CSS VARIABLES (TOKENS) ========== */
:root {
    /* Colors - Exclusive Modern Theme (Brand Identity) */
    --brand-50: #f5f3ff;
    /* Violet 50 */
    --brand-100: #ede9fe;
    /* Violet 100 */
    --brand-500: #7C6CF5;
    /* Primary Purple (from Logo) */
    --brand-600: #6D28D9;
    /* Darker Purple */
    --brand-900: #4C1D95;
    /* Deep Purple */
    --brand-dark: #0f172a;
    /* Slate 900 (Keep dark sidebar base) */
    --brand-pink: #FB7185;
    /* Secondary Pink (from Logo) */

    /* Semantic Colors */
    --bg: #f8fafc;
    /* Slate 50 */
    --surface: #ffffff;
    --surface-2: #f1f5f9;
    /* Slate 100 */
    --border: #e2e8f0;
    /* Slate 200 */

    --text: #334155;
    /* Slate 700 */
    --text-muted: #64748b;
    /* Slate 500 */
    --text-light: #f8fafc;
    /* For dark backgrounds */

    --accent-1: var(--brand-500);
    --accent-2: var(--brand-pink);
    --accent-glow: rgba(124, 108, 245, 0.5);
    /* Purple Glow */

    /* Gradients */
    --gradient-primary: linear-gradient(135deg, #7C6CF5 0%, #FB7185 100%);
    /* Brand Gradient */
    --gradient-hover: linear-gradient(135deg, #6D28D9 0%, #F43F5E 100%);
    --gradient-surface: linear-gradient(to right, rgba(124, 108, 245, 0.1), transparent);

    /* Spacing */
    --space-1: 0.25rem;
    --space-2: 0.5rem;
    --space-3: 0.75rem;
    --space-4: 1rem;
    --space-6: 1.5rem;
    --space-8: 2rem;
    --space-12: 3rem;

    /* Border Radius */
    --radius-sm: 0.375rem;
    --radius-md: 0.5rem;
    --radius-lg: 0.75rem;
    --radius-xl: 1rem;
    --radius-2xl: 1.5rem;

    /* Shadows */
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.05);
    --shadow-card: 0 4px 20px -2px rgba(0, 0, 0, 0.05);
    --shadow-glow: 0 0 20px -5px rgba(124, 108, 245, 0.3);
    /* Purple Shadow */

    /* Typography */
    --font-base: "Plus Jakarta Sans", system-ui, -apple-system, sans-serif;
    --font-mono: "SF Mono", Monaco, "Cascadia Code", monospace;

    /* Transitions */
    --transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
    --transition-fast: all 0.15s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ========== RESET & BASE ========== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}


body {
    font-family: var(--font-base);
    background: var(--bg);
    color: var(--text);
    line-height: 1.6;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    /* Flexbox Layout for fluid sidebar/content */
    display: flex;
    min-height: 100vh;
    overflow: hidden;
}

/* App Layout Container */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
}


/* ========== CUSTOM SCROLLBAR ========== */

/* Webkit browsers */
::-webkit-scrollbar {
    width: 6px;
    height: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Firefox */
* {
    scrollbar-width: thin;
    scrollbar-color: #cbd5e1 transparent;
}

/* ========== DEFINITIVE LAYOUT ENGINE ========== */

/* App Layout Container */
.app-layout {
    display: flex;
    width: 100%;
    min-height: 100vh;
    overflow: hidden;
    background: var(--bg);
}

/* Sidebar - Layout & Behavior */
.sidebar {
    width: 260px;
    flex-shrink: 0;
    /* Dark Theme for Sidebar */
    background: var(--brand-dark);
    border-right: 1px solid rgba(255, 255, 255, 0.05);
    /* Subtle border for dark sidebar */
    padding: var(--space-6);
    overflow-y: auto;
    z-index: 50;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: relative;
    color: var(--text-light);
    /* Enforce light text */
}

/* Collapsed State */
.sidebar.collapsed {
    width: 80px;
    padding: var(--space-6) 0;
    align-items: center;
}

/* Hide Text and Logo when Collapsed */
.sidebar.collapsed .sidebar-nav-text,
.sidebar.collapsed .sidebar-logo-text,
.sidebar.collapsed .sidebar-footer {
    display: none !important;
    opacity: 0;
}

/* Center Icons when Collapsed */
.sidebar.collapsed .sidebar-nav-link {
    justify-content: center;
    padding-left: 0;
    padding-right: 0;
    text-align: center;
}

/* Ensure Icon Visibility */
.sidebar.collapsed .sidebar-nav-icon {
    margin-right: 0;
    width: 24px;
    height: 24px;
    opacity: 1 !important;
}

/* Sidebar Visual Styles */
.sidebar-logo {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    margin-bottom: var(--space-8);
    padding-bottom: var(--space-6);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-toggle-btn {
    position: absolute;
    top: 24px;
    right: -12px;
    width: 24px;
    height: 24px;
    background: var(--brand-500);
    border: 2px solid var(--brand-dark);
    border-radius: 50%;
    color: white;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    z-index: 60;
    transition: transform 0.2s;
    padding: 0;
}

.sidebar-toggle-btn:hover {
    transform: scale(1.1);
    background: var(--brand-600);
}

.sidebar.collapsed .sidebar-toggle-btn {
    transform: rotate(180deg);
}

.sidebar-logo-icon {
    width: 40px;
    height: 40px;
    background: var(--gradient-primary);
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 700;
    font-size: 1.25rem;
    color: white;
    box-shadow: var(--shadow-glow);
}

.sidebar-logo-text {
    font-size: 1.125rem;
    font-weight: 700;
    color: white;
    letter-spacing: -0.025em;
}

.sidebar-nav {
    list-style: none;
    flex: 1;
}

.sidebar-nav-item {
    margin-bottom: var(--space-2);
}

.sidebar-nav-link {
    display: flex;
    align-items: center;
    gap: var(--space-3);
    padding: var(--space-3) var(--space-4);
    color: #94a3b8;
    /* Slate 400 */
    text-decoration: none;
    border-radius: var(--radius-md);
    transition: var(--transition);
    font-size: 0.9375rem;
    font-weight: 500;
    position: relative;
}

.sidebar-nav-link:hover {
    color: white;
    background: rgba(255, 255, 255, 0.05);
    /* Subtle hover */
}

.sidebar-nav-link.active {
    color: white;
    background: transparent;
    /* No background, just glow indicator */
}

/* Active Indicator */
.sidebar-nav-link.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 50%;
    transform: translateY(-50%);
    width: 4px;
    height: 32px;
    background: var(--brand-500);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 15px rgba(124, 108, 245, 0.6);
}

.sidebar-nav-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.2s;
}

.sidebar-nav-link:hover .sidebar-nav-icon {
    transform: scale(1.1);
    color: var(--brand-100);
}

.sidebar-nav-link.active .sidebar-nav-icon {
    color: var(--brand-500);
}

/* Main Content - The Fluid Element */
.main-content {
    flex-grow: 1;
    /* Grows to occupy all remaining space */
    flex-basis: 0;
    /* Starts calculation from 0 to prevent overflows */
    min-width: 0;
    /* Critical for responsive contents */
    height: 100vh;
    overflow-y: auto;
    /* Scroll happens INSIDE here */
    position: relative;
    margin-left: 0 !important;
}

/* Cleanup */
.sidebar.collapsed+.main-content {
    margin-left: 0;
}

/* Glassmorphism Utility */
.glass-panel {
    background: rgba(255, 255, 255, 0.7);
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border: 1px solid rgba(255, 255, 255, 0.5);
}

.topbar {
    background: rgba(255, 255, 255, 0.85);
    /* Glassy background */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    border-bottom: 1px solid var(--border);
    padding: var(--space-4) var(--space-8);
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 90;
    transition: var(--transition);
}

.topbar.glass {
    background: rgba(255, 255, 255, 0.7);
    border-bottom-color: rgba(226, 232, 240, 0.5);
}

.topbar-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text);
}

.topbar-actions {
    display: flex;
    gap: var(--space-3);
    align-items: center;
}

.page-container {
    padding: var(--space-8);
    max-width: 100%;
    /* Allow full width expansion */
    width: 100%;
}

/* ========== COMPONENTS ========== */

/* ========== COMPONENTS ========== */

/* Card */
.card {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    /* Larger radius */
    padding: var(--space-6);
    box-shadow: var(--shadow-card);
    transition: var(--transition);
    position: relative;
    overflow: hidden;
}

.card:hover {
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    border-color: rgba(124, 108, 245, 0.2);
    transform: translateY(-2px);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: var(--space-6);
    padding-bottom: var(--space-4);
    border-bottom: 1px solid var(--border);
}

.card-title {
    font-size: 1.125rem;
    font-weight: 700;
    color: var(--text);
    letter-spacing: -0.01em;
}

.card-description {
    color: var(--text-muted);
    font-size: 0.875rem;
    margin-top: var(--space-1);
}

/* Button */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--space-2);
    padding: var(--space-3) var(--space-6);
    border-radius: var(--radius-md);
    font-weight: 600;
    font-size: 0.9375rem;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
    white-space: nowrap;
    position: relative;
    overflow: hidden;
}

.btn-primary {
    background: var(--gradient-primary);
    color: white;
    box-shadow: var(--shadow-md);
}

.btn-primary:hover {
    background: var(--gradient-hover);
    box-shadow: var(--shadow-lg), var(--shadow-glow);
    transform: translateY(-1px);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-secondary {
    background: var(--surface);
    color: var(--text);
    border: 1px solid var(--border);
    box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
    background: var(--surface-2);
    border-color: #cbd5e1;
    color: var(--brand-600);
}

.btn-ghost {
    background: transparent;
    color: var(--text-muted);
}

.btn-ghost:hover {
    background: var(--surface-2);
    color: var(--brand-600);
}

.btn-danger {
    background: #FEF2F2;
    color: #EF4444;
    border: 1px solid #FECACA;
}

.btn-danger:hover {
    background: #FEE2E2;
    border-color: #F87171;
}

.btn-sm {
    padding: var(--space-2) var(--space-4);
    font-size: 0.875rem;
}

.btn-icon {
    padding: var(--space-2);
    border-radius: var(--radius-md);
    color: var(--text-muted);
}

.btn-icon:hover {
    background: var(--surface-2);
    color: var(--brand-500);
}

/* Input */
.input-group {
    margin-bottom: var(--space-6);
}

.input-label {
    display: block;
    margin-bottom: var(--space-2);
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text);
}

.input,
.select,
.textarea {
    width: 100%;
    padding: 0.625rem var(--space-4);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.9375rem;
    transition: var(--transition-fast);
    font-family: var(--font-base);
    box-shadow: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    /* Subtle inner shadow */
}

.input:focus,
.select:focus,
.textarea:focus {
    outline: none;
    border-color: var(--brand-500);
    box-shadow: 0 0 0 4px rgba(124, 108, 245, 0.1);
    /* Brand focus ring */
    background: white;
}

.input::placeholder {
    color: #94a3b8;
}

.textarea {
    resize: vertical;
    min-height: 100px;
    line-height: 1.5;
}

/* Badge */
.badge {
    display: inline-flex;
    align-items: center;
    padding: var(--space-1) var(--space-3);
    border-radius: var(--radius-sm);
    font-size: 0.75rem;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.badge-primary {
    background: rgba(124, 108, 245, 0.1);
    color: var(--accent-1);
    border: 1px solid rgba(124, 108, 245, 0.2);
}

.badge-secondary {
    background: rgba(156, 163, 175, 0.1);
    color: var(--text-muted);
    border: 1px solid rgba(156, 163, 175, 0.2);
}

.badge-success {
    background: rgba(16, 185, 129, 0.1);
    color: #6EE7B7;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.badge-gradient {
    background: var(--gradient-primary);
    color: white;
    border: none;
}

/* Table */
.table-container {
    overflow-x: auto;
    border-radius: var(--radius-lg);
    border: 1px solid var(--border);
}

.table {
    width: 100%;
    border-collapse: collapse;
}

.table th {
    background: var(--surface-2);
    padding: var(--space-4);
    text-align: left;
    font-weight: 600;
    font-size: 0.875rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    border-bottom: 1px solid var(--border);
}

.table td {
    padding: var(--space-4);
    border-bottom: 1px solid var(--border);
    color: var(--text);
}

.table tr:hover {
    background: var(--surface-2);
}

.table tr:last-child td {
    border-bottom: none;
}

/* Divider */
.divider {
    height: 1px;
    background: var(--border);
    margin: var(--space-6) 0;
}

/* Grid System with Responsiveness */
.grid {
    display: grid;
    gap: var(--space-6);
}

.grid-2 {
    grid-template-columns: repeat(2, 1fr);
}

.grid-3 {
    grid-template-columns: repeat(3, 1fr);
}

.grid-4 {
    grid-template-columns: repeat(4, 1fr);
}

/* Responsive Breakpoints */
@media (max-width: 1200px) {
    .grid-4 {
        grid-template-columns: repeat(2, 1fr);
    }

    .grid-3 {
        grid-template-columns: repeat(2, 1fr);
    }
}

@media (max-width: 768px) {

    .grid-4,
    .grid-3,
    .grid-2 {
        grid-template-columns: 1fr;
    }

    .page-container {
        padding: var(--space-4);
    }
}


.mb-4 {
    margin-bottom: var(--space-4);
}

.mb-6 {
    margin-bottom: var(--space-6);
}

.mb-8 {
    margin-bottom: var(--space-8);
}

.text-muted {
    color: var(--text-muted);
}

.text-sm {
    font-size: 0.875rem;
}

.font-mono {
    font-family: var(--font-mono);
}

.hidden {
    display: none !important;
}

/* Toast/Alert */
.toast {
    position: fixed;
    top: var(--space-6);
    right: var(--space-6);
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4) var(--space-6);
    box-shadow: var(--shadow-lg);
    z-index: 1000;
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from {
        transform: translateX(400px);
        opacity: 0;
    }

    to {
        transform: translateX(0);
        opacity: 1;
    }
}

.toast-success {
    border-left: 3px solid #6EE7B7;
}

.toast-error {
    border-left: 3px solid #FCA5A5;
}

/* Modal */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(11, 15, 20, 0.9);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }

    to {
        opacity: 1;
    }
}

.modal {
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-xl);
    max-width: 800px;
    width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
}

.modal-header {
    padding: var(--space-6);
    border-bottom: 1px solid var(--border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-title {
    font-size: 1.25rem;
    font-weight: 600;
    color: var(--text);
}

.modal-body {
    padding: var(--space-6);
}

.modal-footer {
    padding: var(--space-6);
    border-top: 1px solid var(--border);
    display: flex;
    justify-content: flex-end;
    gap: var(--space-3);
}

.modal-close {
    background: var(--surface-2);
    border: 1px solid var(--border);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-sm);
    font-size: 1.5rem;
    cursor: pointer;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition-fast);
    line-height: 1;
    padding: 0;
}

.modal-close:hover {
    background: var(--bg);
    color: var(--text);
    border-color: rgba(255, 255, 255, 0.15);
}

/* Tabs */
.tabs {
    display: flex;
    border-bottom: 2px solid var(--border);
    margin-bottom: var(--space-6);
    gap: var(--space-2);
}

.tab {
    padding: var(--space-3) var(--space-4);
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-size: 0.9375rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: -2px;
    transition: var(--transition-fast);
    display: flex;
    align-items: center;
    white-space: nowrap;
    font-family: var(--font-base);
}

.tab:hover {
    color: var(--text);
    background: rgba(255, 255, 255, 0.03);
}

.tab.active {
    color: var(--accent-1);
    border-bottom-color: var(--accent-1);
    font-weight: 600;
}

.tab svg {
    flex-shrink: 0;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

/* Mobile Responsive */
@media (max-width: 768px) {
    .sidebar {
        transform: translateX(-100%);
    }

    .sidebar.is-open {
        transform: translateX(0);
    }

    .main-content {
        margin-left: 0;
    }

    .grid-2,
    .grid-3,
    .grid-4 {
        grid-template-columns: 1fr;
    }

    .page-container {
        padding: var(--space-4);
    }

    .topbar {
        padding: var(--space-4);
    }
}

/* Hamburger Menu */
.menu-toggle {
    display: none;
    width: 40px;
    height: 40px;
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    cursor: pointer;
    position: relative;
}

.menu-toggle span {
    display: block;
    width: 20px;
    height: 2px;
    background: var(--text);
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    transition: var(--transition-fast);
}

.menu-toggle span:nth-child(1) {
    top: 12px;
}

.menu-toggle span:nth-child(2) {
    top: 19px;
}

.menu-toggle span:nth-child(3) {
    top: 26px;
}

@media (max-width: 768px) {
    .menu-toggle {
        display: block;
    }
}

/* ========== Save Indicator (Phase 1 UX) ========== */
.save-indicator-container {
    display: inline-flex;
    align-items: center;
    margin-right: 1rem;
}

.save-status {
    font-size: 0.875rem;
    font-weight: 500;
    padding: 0.25rem 0.75rem;
    border-radius: var(--radius-md);
    display: inline-flex;
    align-items: center;
    gap: 0.375rem;
}

.save-status.saving {
    color: var(--text-muted);
    background: var(--surface-2);
}

.save-status.saved {
    color: #10b981;
    background: rgba(16, 185, 129, 0.1);
}

.save-status.unsaved {
    color: var(--accent-2);
    background: rgba(251, 113, 133, 0.1);
}

/* ========== Sortable Drag States (Phase 1 UX) ========== */
.sortable-ghost {
    opacity: 0.4;
    background: var(--surface-2);
}

.sortable-drag {
    opacity: 0.9;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.5);
    transform: rotate(2deg);
    cursor: grabbing !important;
}

.sortable-chosen {
    background: var(--surface-2);
}

/* ========== Card Type Visual Hierarchy (Phase 1 UX) ========== */
.route-item {
    transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
}

.route-item:hover {
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

/* Point Cards - Show thumbnail */
.route-item.item-type-point {
    display: grid;
    grid-template-columns: 80px 1fr auto;
    gap: 1rem;
    align-items: center;
}

.route-item.item-type-point .item-thumbnail {
    width: 80px;
    height: 60px;
    border-radius: var(--radius-md);
    object-fit: cover;
    background: var(--surface-2);
    border: 1px solid var(--border);
}

.route-item.item-type-point .item-content {
    flex: 1;
}

/* Note Cards - Warning/tip style */
.route-item.item-type-note {
    background: rgba(251, 191, 36, 0.08);
    border-left: 3px solid #f59e0b;
}

.route-item.item-type-note::before {
    content: '⚠';
    position: absolute;
    left: 1rem;
    top: 1rem;
    font-size: 1.25rem;
    opacity: 0.6;
}

.route-item.item-type-note .item-content {
    margin-left: 2rem;
}

/* Free Text Cards - Slim transit style */
.route-item.item-type-free_text {
    background: var(--surface-2);
    border-left: 3px solid var(--accent-tech);
    padding: 0.75rem 1rem;
}

.route-item.item-type-free_text::before {
    content: '🚶';
    position: absolute;
    left: 1rem;
    top: 0.75rem;
    font-size: 1rem;
    opacity: 0.6;
}

.route-item.item-type-free_text .item-content {
    margin-left: 2rem;
    font-size: 0.9rem;
}

/* ========== Point Search Results (Phase 2 UX) ========== */
.point-results {
    background: var(--surface-2);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    margin-top: 0.5rem;
}

.point-result-item {
    padding: 0.75rem 1rem;
    cursor: pointer;
    transition: background 0.15s;
    border-bottom: 1px solid var(--border);
}

.point-result-item:last-child {
    border-bottom: none;
}

.point-result-item:hover {
    background: var(--surface);
}

.point-result-item strong {
    display: block;
    color: var(--text);
    margin-bottom: 0.25rem;
}

.point-result-item small {
    display: block;
    font-size: 0.875rem;
}

/* ========== COLLAPSIBLE SIDEBAR (Enhancement) ========== */
.sidebar {
    width: 260px;
    transition: width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar.collapsed {
    width: 80px;
}

.sidebar-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: var(--space-6) var(--space-4);
    margin-bottom: var(--space-4);
}

.sidebar-logo {
    position: relative;
    max-width: 150px;
}

.sidebar-logo-full {
    display: block;
    max-width: 100%;
    height: auto;
    border-radius: var(--radius-md);
    transition: opacity 0.2s;
}

.sidebar-logo-mini {
    position: absolute;
    top: 0;
    left: 0;
    width: 40px;
    height: 40px;
    border-radius: var(--radius-md);
    opacity: 0;
    transition: opacity 0.2s;
}

.sidebar.collapsed .sidebar-logo-full {
    opacity: 0;
}

.sidebar.collapsed .sidebar-logo-mini {
    opacity: 1;
}

.sidebar-toggle {
    background: var(--surface-2);
    border: 1px solid var(--border);
    color: var(--text);
    width: 32px;
    height: 32px;
    border-radius: var(--radius-md);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.2s;
}

.sidebar-toggle:hover {
    background: var(--surface);
    border-color: var(--accent-1);
}

.sidebar.collapsed .sidebar-toggle svg {
    transform: rotate(180deg);
}

/* Navigation text hiding */
.sidebar-nav-text {
    transition: opacity 0.2s, width 0.2s;
}

.sidebar.collapsed .sidebar-nav-text {
    opacity: 0;
    width: 0;
    overflow: hidden;
    white-space: nowrap;
}

/* Tooltip styling */
.sidebar.collapsed .sidebar-nav-link {
    position: relative;
    justify-content: center;
}

.sidebar.collapsed .sidebar-nav-link::after {
    content: attr(data-tooltip);
    position: absolute;
    left: 100%;
    top: 50%;
    transform: translateY(-50%);
    margin-left: 1rem;
    padding: 0.5rem 0.75rem;
    background: var(--surface);
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    color: var(--text);
    font-size: 0.875rem;
    white-space: nowrap;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.2s;
    z-index: 1000;
    box-shadow: var(--shadow-lg);
}

.sidebar.collapsed .sidebar-nav-link:hover::after {
    opacity: 1;
}

/* Footer adjustments */
.sidebar>div:last-child {
    transition: opacity 0.2s;
}

/* ========== COLLAPSIBLE SIDEBAR (Clean Implementation) ========== */

/* Toggle Button */
.sidebar-toggle-btn {
    position: absolute;
    top: var(--space-6);
    right: var(--space-4);
    width: 28px;
    height: 28px;
    background: transparent;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    z-index: 10;
}

.sidebar-toggle-btn:hover {
    background: var(--surface-2);
    color: var(--accent-1);
    border-color: var(--accent-1);
}

/* Collapsed State */
.sidebar.collapsed {
    width: 70px !important;
}

.sidebar.collapsed .sidebar-logo {
    opacity: 0.3;
    transform: scale(0.6);
}

.sidebar.collapsed .sidebar-toggle-btn svg {
    transform: rotate(180deg);
}

.sidebar.collapsed .sidebar-nav-text {
    display: none;
}

.sidebar.collapsed .sidebar-footer {
    display: none;
}

/* Adjust nav links when collapsed */
.sidebar.collapsed .sidebar-nav-link {
    justify-content: center;
    padding: var(--space-3);
}

/* Tooltip on collapsed state */
.sidebar.collapsed .sidebar-nav-link {
    position: relative;
}

.sidebar.collapsed .sidebar-nav-link:hover::after {
    content: attr(title);
    position: absolute;
    left: calc(100% + 0.75rem);
    top: 50%;
    transform: translateY(-50%);
    background: var(--surface);
    border: 1px solid var(--border);
    padding: 0.5rem 0.75rem;
    border-radius: var(--radius-md);
    font-size: 0.875rem;
    white-space: nowrap;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    z-index: 1000;
}

/* Make icons fully visible when collapsed */
.sidebar.collapsed .sidebar-nav-icon {
    opacity: 1 !important;
    color: var(--text-muted);
}

.sidebar.collapsed .sidebar-nav-link.active .sidebar-nav-icon {
    color: var(--accent-1);
}

/* End of sidebar adjustments */

/* ========== EDITOR SPECIFIC STYLES ========== */

/* Split Screen Layout */
.editor-split-container {
    display: flex;
    /* Flexbox for smoother resizing */
    gap: 0;
    /* Gap handled by resizer or padding */
    height: calc(100vh - 80px);
    width: 100%;
    overflow: hidden;
    padding: 0;
    /* Remove internal padding, move to children if needed */
}

.editor-controls {
    width: var(--editor-width, 450px);
    min-width: 300px;
    /* Minimum width constraint */
    flex-shrink: 0;
    overflow-y: auto;
    padding: 1.5rem;
    border-right: 1px solid var(--border);
    transition: width 0.1s linear;
    /* Smooth but fast for dragging */
}

/* Resizer Handle */
.resizer {
    width: 8px;
    /* Hit area width */
    cursor: col-resize;
    background: transparent;
    transition: background 0.2s;
    flex-shrink: 0;
    z-index: 10;
    margin-left: -4px;
    /* Centered visually on the border */
    position: relative;
}

.resizer:hover,
.resizer.dragging {
    background: var(--accent-1);
    opacity: 0.5;
}

.live-preview-panel {
    flex-grow: 1;
    min-width: 0;
    /* Allow shrinking */
    display: flex;
    flex-direction: column;
    height: 100%;
    background: var(--bg);
    /* Ensure visually distinct */
}

/* Hidden States */
.editor-controls.hidden-panel,
.live-preview-panel.hidden-panel {
    display: none !important;
}


/* Utility class to hide elements (used by Route Map toggle) */
.hidden-map {
    display: none !important;
}

/* === Toggle Switch (iOS style) === */
.toggle-switch-container {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 12px;
    background: var(--surface-2);
    border-radius: var(--radius-md);
    border: 1px solid var(--border);
}

.toggle-switch-label {
    font-size: 0.875rem;
    font-weight: 500;
    color: var(--text);
    user-select: none;
}

.toggle-switch {
    position: relative;
    display: inline-block;
    width: 44px;
    height: 24px;
    cursor: pointer;
}

.toggle-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.toggle-slider {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #ccc;
    transition: 0.3s;
    border-radius: 24px;
}

.toggle-slider:before {
    position: absolute;
    content: "";
    height: 18px;
    width: 18px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: 0.3s;
    border-radius: 50%;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

.toggle-switch input:checked+.toggle-slider {
    background-color: #10b981;
    /* Green quando ativo */
}

.toggle-switch input:checked+.toggle-slider:before {
    transform: translateX(20px);
}

.toggle-switch:hover .toggle-slider {
    opacity: 0.9;
}

.preview-toolbar {
    background: var(--surface-1);
    border: 1px solid var(--border);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
    padding: 0.75rem 1rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.preview-iframe-container {
    flex: 1;
    background: white;
    border: 1px solid var(--border);
    border-top: none;
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
    overflow: hidden;
}

#livePreviewFrame {
    width: 100%;
    height: 100%;
    border: none;
    display: block;
}

.preview-loading {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: var(--text-muted);
}

@media (max-width: 1200px) {
    .editor-split-container {
        grid-template-columns: 1fr;
        height: auto;
        overflow: visible;
    }

    .live-preview-panel {
        display: none;
    }
}

/* Route Statistics */
.route-stats {
    margin-top: 1rem;
}

.stat-item {
    display: flex;
    flex-direction: column;
    gap: 0.25rem;
}

.stat-label {
    font-size: 0.75rem;
    color: var(--text-muted);
    text-transform: uppercase;
    letter-spacing: 0.05em;
    font-weight: 600;
}

.stat-value {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--accent-1);
    line-height: 1;
}

.stat-value.warning {
    color: var(--warning);
}

/* Drag & Drop Sortable */
.sortable-container {
    min-height: 100px;
    border: 2px dashed var(--border);
    border-radius: var(--radius-md);
    padding: var(--space-4);
    transition: background-color 0.2s, border-color 0.2s;
}

.sortable-container.sortable-drag-active {
    background-color: rgba(255, 255, 255, 0.02);
    border-color: var(--accent-1);
}

.sortable-container:empty::before {
    content: 'Drag points here or click "Add Point" to start building your route';
    display: block;
    text-align: center;
    color: var(--text-muted);
    padding: var(--space-8);
    font-size: 0.875rem;
}

/* --- Card Unificado (New Standard) --- */
.route-card {
    display: grid;
    /* Grid de 4 colunas: Handle | Visual | Conteúdo (Fluido) | Ações */
    grid-template-columns: 24px 40px 1fr auto;
    gap: 12px;
    align-items: center;
    background: var(--surface-2);
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 6px;
    margin-bottom: 8px;
    transition: all 0.2s;
    height: 72px;
    /* Altura fixa para uniformidade visual */
    user-select: none;
}

.route-card:hover {
    border-color: var(--accent-1);
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
    background: var(--surface-1);
}

.route-card.sortable-ghost {
    opacity: 0.5;
    border: 1px dashed var(--accent-1);
}

/* --- Cores por Tipo (Barra lateral colorida) --- */
.route-card.type-point {
    border-left: 4px solid var(--accent-1);
}

.route-card.type-text {
    border-left: 4px solid var(--text-muted);
}

.route-card.type-note {
    border-left: 4px solid #F59E0B;
}

/* --- Coluna 1: Handle --- */
.card-handle {
    color: var(--text-muted);
    cursor: grab;
    display: flex;
    justify-content: center;
}

.card-handle:hover {
    color: var(--text);
}

/* --- Coluna 2: Visual (Thumb ou Icon) --- */
.card-visual {
    width: 40px;
    height: 40px;
    border-radius: 4px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--surface);
    flex-shrink: 0;
    /* Impede de amassar */
    border: 1px solid var(--border);
}

.item-thumbnail {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.item-icon-wrapper {
    color: var(--text-muted);
    display: flex;
    /* Centering fix */
}

/* --- Coluna 3: Conteúdo e Truncamento (CRÍTICO) --- */
.card-content {
    display: flex;
    flex-direction: column;
    justify-content: center;
    min-width: 0;
    /* OBRIGATÓRIO para o text-overflow funcionar em Grid/Flex */
    height: 100%;
}

.card-title {
    font-weight: 600;
    font-size: 0.95rem;
    color: var(--text);

    /* Truncamento com ... */
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
    margin-bottom: 2px;
}

.card-subtitle {
    font-size: 0.8rem;
    color: var(--text-muted);
    white-space: nowrap;
    /* Force single line for uniformity */
    overflow: hidden;
    text-overflow: ellipsis;
}

/* --- Coluna 4: Ações --- */
.card-actions {
    display: flex;
    gap: 4px;
    opacity: 0.5;
    transition: opacity 0.2s;
}

.route-card:hover .card-actions {
    opacity: 1;
}

.btn-icon-small {
    background: none;
    border: 1px solid transparent;
    padding: 4px;
    cursor: pointer;
    color: var(--text-muted);
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.btn-icon-small:hover {
    background: var(--surface);
    color: var(--text);
    border-color: var(--border);
}

.btn-icon-small.text-danger:hover {
    color: #FCA5A5;
    background: rgba(239, 68, 68, 0.1);
    border-color: transparent;
}