:root {
    --grt-blue: #004F90;
    --grt-gold: #fdb92e;
    --bg-color: #f8f9fa;
    --card-bg: #ffffff;
    --text-main: #212529;
    --text-secondary: #6c757d;
    --text-danger: #b91c1c;
    --bg-danger-light: #fee2e2;
    --border-danger: #fca5a5;
}

* { box-sizing: border-box; }
body { margin: 0; padding: 0; font-family: 'Inter', sans-serif; background-color: var(--bg-color); color: var(--text-main); overflow: hidden; height: 100vh; display: flex; flex-direction: column; }

#map { flex-grow: 1; width: 100vw; z-index: 0; }

#ui-container {
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    pointer-events: none;
    display: flex;
    flex-direction: column;
    justify-content: flex-end;
}

.card {
    background: var(--card-bg);
    border-radius: 20px 20px 0 0;
    padding: 24px;
    box-shadow: 0 -5px 20px rgba(0,0,0,0.1);
    pointer-events: auto;
    width: 100%;
    max-width: 600px;
    margin: 0 auto;
    background: white;
    padding-bottom: max(24px, env(safe-area-inset-bottom));
    display: none;
    flex-direction: column;
}

.card.active { display: flex; }

#search-screen {
    position: absolute;
    top: 0; left: 0; width: 100%; height: 100%;
    background: var(--grt-blue);
    display: block; 
    padding-top: 10vh;
    pointer-events: auto;
    z-index: 2000;
    transition: opacity 0.3s ease;
    overflow-y: auto;
}
#search-screen.hidden { opacity: 0; pointer-events: none; }

.logo-area { text-align: center; color: white; margin-bottom: 30px; }
.logo-area h1 { margin: 0; font-size: 2rem; font-weight: 700; }
.logo-area p { margin: 5px 0 0; opacity: 0.8; }

.search-box {
    background: white;
    padding: 24px;
    border-radius: 16px;
    width: 90%;
    max-width: 400px;
    box-shadow: 0 10px 25px rgba(0,0,0,0.2);
    margin: 0 auto;
}

.feedback-section {
    position: absolute;
    bottom: 0;
    width: 100%;
    text-align: center;
    padding-bottom: max(20px, env(safe-area-inset-bottom));
    color: #fdb92e;
    font-size: 0.9rem;
    opacity: 0.8;
    text-shadow: 0px 2px 4px rgba(0,0,0,0.8);
}
.feedback-section a { color: #fdb92e; text-decoration: none; border-bottom: 1px solid rgba(253,185,46,0.5); padding-bottom: 1px; }

/* Keypad Styles */
.keypad-container {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 16px; 
    margin-top: 24px;
    max-width: 340px; 
    margin-left: auto;
    margin-right: auto;
}
.key-btn {
    background: white;
    border: 1px solid #fdb92e; 
    border-radius: 8px; 
    font-size: 1.5rem;
    font-weight: 500; 
    padding: 20px 0;
    color: var(--text-main);
    cursor: pointer;
    touch-action: manipulation;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    user-select: none;
    -webkit-tap-highlight-color: transparent;
    box-shadow: 0 2px 4px rgba(0,0,0,0.05); 
}
.key-btn:active { background: #fffbeb; transform: translateY(1px); box-shadow: none; }
.key-btn.action-btn { background: var(--grt-blue); color: white; border-color: var(--grt-blue); font-weight: 700; }
.key-btn.action-btn:active { background: #003d70; }
.key-btn.sec-btn { color: #dc2626; border-color: #fee2e2; background: #fff; }

/* Input Display Styles */
.display-container {
    display: flex;
    justify-content: center;
    align-items: center;
    border-bottom: 2px solid #e9ecef;
    padding: 10px;
    min-height: 60px;
    margin-bottom: 10px;
    cursor: text;
}
.display-digits { font-size: 2rem; letter-spacing: 4px; font-weight: 700; color: var(--grt-blue); min-height: 38px; }
.cursor {
    display: inline-block; width: 3px; height: 36px; background-color: var(--grt-blue);
    margin-left: 2px; animation: blink 1.2s step-end infinite; opacity: 1;
}
@keyframes blink { 0%, 100% { opacity: 1; } 50% { opacity: 0; } }

#error-msg {
    display: none;
    margin-top: 24px;
    padding: 16px;
    background: var(--bg-danger-light);
    color: var(--text-danger);
    border: 2px solid var(--border-danger);
    border-radius: 12px;
    font-weight: 700;
    text-align: center;
    font-size: 1.1rem;
    box-shadow: 0 4px 6px rgba(220, 38, 38, 0.1);
}
@keyframes shake {
    10%, 90% { transform: translate3d(-1px, 0, 0); }
    20%, 80% { transform: translate3d(2px, 0, 0); }
    30%, 50%, 70% { transform: translate3d(-4px, 0, 0); }
    40%, 60% { transform: translate3d(4px, 0, 0); }
}

/* Route Sheet Styles */
#route-sheet { max-height: 60vh; }
#route-list { overflow-y: auto; flex-grow: 1; padding-right: 4px; }
#route-list::-webkit-scrollbar { width: 6px; }
#route-list::-webkit-scrollbar-track { background: transparent; }
#route-list::-webkit-scrollbar-thumb { background: #e9ecef; border-radius: 10px; }

.sheet-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 16px; padding-bottom: 12px; border-bottom: 1px solid #eee; flex-shrink: 0; }
.sheet-title { font-size: 1.25rem; font-weight: 700; }
.close-btn { background: none; border: none; font-size: 1.5rem; color: #999; cursor: pointer; }

.route-option { padding: 16px; margin-bottom: 12px; border: 1px solid #eee; border-radius: 12px; cursor: pointer; display: flex; align-items: center; }
.route-badge { background: var(--grt-blue); color: white; padding: 6px 12px; border-radius: 8px; font-weight: 700; margin-right: 12px; min-width: 50px; text-align: center; }
.route-dest { font-weight: 600; color: var(--text-main); }

#tracking-card { transform: translateY(100%); transition: transform 0.3s ease; }
#tracking-card.active { transform: translateY(0); }

/* Status Colors */
.arrival-large { font-size: 2.5rem; font-weight: 800; color: var(--grt-blue); line-height: 1; }
.arrival-large.final-stop { color: var(--text-secondary); } /* Fix for 'Final Stop' looking active */
.due-now { color: #dc2626; animation: breathe 1.5s ease-in-out infinite; }
@keyframes breathe { 0%, 100% { opacity: 1; } 50% { opacity: 0.6; } }

.arrival-sub { font-size: 1rem; color: var(--text-secondary); margin-top: 4px; }
.bus-info { margin-top: 16px; display: flex; align-items: center; gap: 10px; flex-wrap: wrap;}
.status-badge { padding: 4px 8px; border-radius: 4px; font-size: 0.8rem; font-weight: 600; }

#bus-id-badge {
    background: #fdb92e;
    color: #FDFD96;
    text-shadow: 0px 1px 2px rgba(0,0,0,0.4);
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
}
.status-badge.late { background: #fee2e2; color: #dc2626; }

.heading-to { width: 100%; font-size: 0.9rem; color: var(--text-main); margin-top: 8px; display: flex; align-items: center; gap: 6px; }
.heading-to span { font-weight: 600; }

.refresh-bar { height: 4px; background: #e9ecef; border-radius: 2px; margin-top: 20px; overflow: hidden; }
.refresh-fill { height: 100%; background: var(--grt-blue); width: 100%; transform-origin: left; transition: transform 1s linear; }

.leaflet-bus-marker { background: transparent; border: none; margin-left: -30px; margin-top: -30px; }

.bus-icon-glow { 
    position: absolute; 
    width: 90px;
    height: 44px;
    top: 0;
    left: 0;
    background: rgba(0, 79, 144, 0.4); 
    border-radius: 6px; 
    animation: pulse 4s infinite; 
    transform-origin: center center;
    pointer-events: none;
}
@keyframes pulse { 
    0% { transform: scale(0.6); opacity: 0.6; } 
    100% { transform: scale(1.5); opacity: 0; } 
}

.grt-icon {
    width: 90px;
    height: 44px;
    border-radius: 6px;
    position: relative;
    background-image: 
        linear-gradient(#e74c3c, #e74c3c), linear-gradient(#f39c12, #f39c12), linear-gradient(to right, #000, #1a1a1a),
        linear-gradient(to right, #000, #2c3e50), linear-gradient(to right, #1a252f, #000),
        linear-gradient(to right, #bdc3c7 1px, #1a252f 1px, #1a252f 15px, #bdc3c7 15px),
        linear-gradient(to right, #2c3e50, #000), linear-gradient(to bottom, #d4af37 20%, #005696 20%),
        linear-gradient(to bottom, #ffffff 70%, #7f8c8d 70%);
    background-size: 2px 4px, 2px 4px, 6px 6px, 6px 14px, 16px 8px, 16px 26px, 64% 30%, 100% 13%, 100% 100%;
    background-position: 0px 30px, 88px 30px, 84px 2px, 84px 8px, 68px 8px, 68px 16px, 6px 8px, 0 24px, 0 0;
    background-repeat: no-repeat;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    transform: scale(0.45); 
    transform-origin: center center;
    pointer-events: none; 
}
.grt-icon::before { content: ''; position: absolute; bottom: -6px; left: 12px; width: 14px; height: 14px; background: #222; border-radius: 50%; box-shadow: 38px 0 0 #222; }
.grt-icon::after { content: ''; position: absolute; bottom: 2px; right: -2px; width: 3px; height: 18px; background: #2c3e50; border-radius: 2px; }

.bus-hit-area {
    position: absolute;
    width: 60px;
    height: 60px;
    top: 0;
    left: 0;
    cursor: pointer;
    z-index: 10;
}

.back-btn { 
    position: absolute; top: 20px; left: 20px; z-index: 1500; background: white;
    padding: 12px 20px; border-radius: 50px; border: none; font-weight: 600; font-size: 1rem; 
    display: none; cursor: pointer; align-items: center; gap: 8px; 
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
}
.back-btn svg { width: 18px; height: 18px; stroke-width: 3; }
