/* --- Root Variables & Reset --- */
:root {
    /* Main Branding */
    --primary: #007bff;
    --primary-dark: #0056b3;
    --primary-light: #e7f1ff; /* Great for active states or backgrounds */
    --custom: #b7d8da;
    
    /* Layout & Surfaces */
    --bg: #f8fafc; /* A cleaner, modern light grey-blue background */
    --surface: #ffffff;
    --border: #e2e8f0; /* Soft border color for cards and inputs */
    
    /* Typography */
    --text-main: #1e293b; /* Darker navy-grey for better readability */
    --text-muted: #64748b; /* Balanced grey for subtext like "via" stations */
    --white: #ffffff;

    /* Status & Feedback */
    --success: #10b981; /* Fresh emerald green for Departure */
    --success-bg: #ecfdf5; /* Soft background for success alerts */
    
    --danger: #ef4444; /* Modern red for errors or Arrival (if keeping red) */
    --danger-bg: #fef2f2;
    
    --warning: #f59e0b; /* Amber color for "Edited" or "Pending" status */
    --info: #3b82f6; /* Secondary blue for informative badges */

    /* Special Elements */
    --shadow: rgba(0, 0, 0, 0.1);
    --overlay: rgba(0, 0, 0, 0.5);
    --disabled: #cbd5e1; /* For read-only field backgrounds */
}

* {
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    margin: 0;
    padding: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: #f0f4f8; /* Softer background to let the main card stand out */
    color: var(--text-main);
    line-height: 1.6;
}

/* --- App Bar & Search UI --- */
.app-bar {
    background: var(--primary-dark);
    padding: 10px; /* Reduced padding to save vertical space */
    position: fixed;
    top: 0;
    width: 100%;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.search-container {
    background: var(--white);
    border-radius: 12px;
    padding: 5px;
    display: flex;
    flex-direction: column;
    box-shadow: 0 4px 12px rgba(0,0,0,0.15);
    /* 1) Increased Width */
    width: 98%; 
    margin: 0 auto;
    position: relative;
}

.input-wrapper {
    display: flex;
    align-items: center;
    padding: 8px 12px;
    position: relative; /* CRITICAL: Anchor for suggestions */
}

.input-wrapper ion-icon {
    font-size: 20px;
    flex-shrink: 0;
}

.input-wrapper input {
    border: none;
    outline: none;
    width: 100%;
    margin-left: 12px;
    font-size: 16px;
    background: transparent;
}

.action-btn {
    position: absolute;
    right: 15px;
    top: 50%;
    transform: translateY(-50%);
    background: var(--white);
    border: 1.5px solid var(--primary); /* Matching blue border */
    border-radius: 10px;
    width: 42px;
    height: 42px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--primary);
    box-shadow: 0 4px 10px rgba(0,0,0,0.1);
    z-index: 10;
    transition: transform 0.2s active;
}

.action-btn:active {
    transform: translateY(-50%) scale(0.9); /* Tap animation */
}

/* --- Suggestion Box (The Fix) --- */
.suggestion-box {
    position: absolute;
    top: 100%; /* Sits exactly below the input */
    left: 0;
    right: 0;
    background: white;
    z-index: 2000; /* Floats above everything else */
    box-shadow: 0 8px 24px rgba(0,0,0,0.2);
    border-radius: 0 0 12px 12px;
    display: none;
    max-height: 250px;
    overflow-y: auto;
    border: 1px solid #eee;
    border-top: none;
}

.suggestion-item {
    padding: 14px 16px;
    border-bottom: 1px solid #f0f0f0;
    font-size: 15px;
    color: #333;
    cursor: pointer;
}

.suggestion-item:active {
    background-color: #f5f5f5; /* Mobile tap feedback */
}

.input-divider {
    height: 1px;
    background: #eee;
    margin: 0 45px;
}

/* --- Main Content Area --- */
.feed {
    /* 2) Reduced gap between search and content */
    margin-top: 125px; 
    padding: 15px;
    background: var(--custom);
    margin-left: 0px;
    margin-right: 0px;
    
    /* 3) Fix for bottom border visibility */
    margin-bottom: 85px; /* Ensures space above the bottom nav */
    border-radius: 16px;
    border: 6px solid var(--custom); 
    
    /* Use min-height to ensure the border wraps the content properly */
    min-height: calc(100vh - 250px); 
    box-shadow: 0 8px 20px rgba(0,0,0,0.08);
    display: flex;
    flex-direction: column;
}

/* --- Bus Card Layout --- */
.bus-card {
    background: linear-gradient(135deg, #ffffff 0%, #faf5ff 50%, #f0f9ff 100%);
    border-radius: 20px;
    padding: 20px;
    margin-bottom: 16px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 4px 20px rgba(124, 58, 237, 0.1), 0 2px 8px rgba(0, 102, 255, 0.05);
    border: 2px solid transparent;
    background-clip: padding-box;
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    position: relative;
    overflow: hidden;
}

/* Travel Time Badge */
.duration-badge {
    position: absolute;
    top: 10px;
    right: 12px;
    background: var(--primary-light);
    color: var(--primary-dark);
    font-size: 11px;
    font-weight: 700;
    padding: 4px 8px;
    border-radius: 6px;
    display: flex;
    align-items: center;
    gap: 4px;
}

.time-section {
    background: #e7f1ff;
    padding: 8px 10px;
    border-radius: 10px;
    text-align: left;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    gap: 4px; /* Space between Dep and Arr */
}

.time {
    font-weight: 700;
    font-size: 12px;
}

.time.dep {
    color: var(--success); /* Green for Departure */
}

.time.arr {
    color: var(--primary) !important; /* Forces the Blue color */
    border-top: 1px solid #e2e8f0;
    margin-top: 4px;
    padding-top: 4px;
}

.info-section {
    flex: 1;
    margin-left: 15px;
    display: flex;
    flex-direction: column;
}

.bus-name {
    font-weight: 700;
    font-size: 15px;
    color: var(--text-main);
}

.bus-no {
    font-size: 11px;
    color: var(--text-muted);
    letter-spacing: 0.5px;
    text-transform: uppercase;
}

.route-line {
    font-size: 13px;
    color: #555;
    margin-top: 4px;
    display: flex;
    align-items: center;
    gap: 5px;
}

/* Via Station styling */
.via-line {
    font-size: 11px;
    color: #718096; /* Muted grey-blue */
    font-style: italic;
    margin-top: 4px;
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 180px; /* Prevents long lists from breaking layout */
}

.edit-icon {
    font-size: 24px;
    color: #cbd5e0;
    padding-left: 10px;
    transition: color 0.2s;
}

/* --- Bottom Navigation --- */
.bottom-nav {
    position: fixed;
    bottom: 0;
    width: 100%;
    height: 65px;
    background: var(--white);
    display: flex;
    border-top: 1px solid #eee;
    z-index: 1000;
}

.nav-link {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    color: #999;
}

.nav-link ion-icon {
    font-size: 22px;
    margin-bottom: 2px;
}

.nav-link span {
    font-size: 11px;
    font-weight: 500;
}

.nav-link.active {
    color: var(--primary);
}

/* --- Edit Form & FAB --- */
.edit-container {
    padding: 15px;
    margin-top: 80px; 
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}

/* Update the existing .save-fab or replace it with the new full-width button class */
.btn-save-full {
    width: 100%;
    background: var(--primary);
    color: white;
    border: none;
    padding: 16px;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 700;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    margin-top: 10px;
    box-shadow: 0 4px 15px rgba(0, 123, 255, 0.3);
    cursor: pointer;
    text-transform: uppercase;
}

.btn-save-full:active {
    transform: scale(0.98);
    background: var(--primary-dark);
}

/* Styling for locked station fields with full grey background */
.readonly-field {
    background-color: #e9ecef !important; /* Solid grey for locked stations */
    border: 1px solid #ced4da;
    box-shadow: none;
}

.readonly-field input {
    background-color: transparent; 
    color: #495057;
    cursor: not-allowed;
}

.readonly-field label {
    color: #6c757d;
}

/* Ensure time input groups remain white */
.input-group {
    margin-bottom: 25px;
    background: white; /* Forces white BG for editable fields */
    padding: 10px 15px;
    border-radius: 10px;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

/* Standard input styling for white fields */
.input-group input:not([readonly]) {
    background-color: white;
    color: var(--text-main);
}

.input-group label {
    display: block;
    font-size: 11px;
    color: var(--primary);
    text-transform: uppercase;
    font-weight: 700;
    margin-bottom: 5px;
}

.input-group input {
    width: 100%;
    border: none;
    font-size: 17px;
    outline: none;
    color: var(--text-main);
}

.save-fab {
    position: fixed;
    bottom: 85px;
    right: 25px;
    background: var(--primary);
    color: white;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,123,255,0.4);
    border: none;
    font-size: 28px;
    cursor: pointer;
    z-index: 1001;
}

/* --- Toast --- */
.toast-message {
    position: fixed;
    bottom: 90px;
    left: 50%;
    transform: translateX(-50%);
    background: #333;
    color: white;
    padding: 12px 20px;
    border-radius: 30px;
    display: flex;
    align-items: center;
    gap: 10px;
    z-index: 2000;
}

/* 3. Centered & Stylish Empty State */
.empty-state {
    text-align: center;
    padding: 40px 20px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
}

.empty-state ion-icon {
    font-size: 48px;
    color: #cbd5e0;
    margin-bottom: 10px;
    background: #e7f1ff; /* Light blue circular background */
    padding: 25px;
    border-radius: 50%;
}

.empty-state p {
    font-size: 18px;
    font-weight: 600;
    color: var(--text-main);
    line-height: 1.5;
    margin: 0;
}

.empty-state span {
    font-size: 20px;
    color: var(--primary-dark);
    margin-top: 8px;
}

.empty-msg {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 5px;
}
.empty-bus-icon {
    font-size: 64px;
    color: var(--danger) !important; /* Forces the Red color */
    margin-bottom: 15px;
    opacity: 0.9;
}
/* 1) Website Name and Tagline Styling */
.brand-group {
    margin-bottom: 15px;
}
.brand-name {
    font-size: 36px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0;
    letter-spacing: -0.5px;
}

.brand-tagline {
    font-size: 13px;
    color: var(--text-muted);
    margin: 2px 0 0 0;
    font-weight: 500;
}
/* Edit Text Button */
.edit-text-btn {
    color: var(--primary);
    font-weight: 700;
    text-decoration: none;
    font-size: 13px;
    padding: 6px 12px;
    background: #f0f7ff;
    border-radius: 20px;
    border: none;
}

/* Floating Add Button (+) */
.add-fab {
    position: fixed;
    bottom: 85px;
    right: 25px;
    background: var(--success); /* Green for 'Add' */
    color: white;
    width: 56px;
    height: 56px;
    border-radius: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    z-index: 1100;
    font-size: 30px;
}