/* ==========================================================================
   VARIABLES & BASE SETUP
   ========================================================================== */
:root {
    --accent-cyan: #00c2ff;
    --accent-cyan-dark: #00c3ffbe;
    --accent-violet: #7b2ff7;
    --grey-dark: #2A2A2A;
    --grey-muted: #333333;
    --text-bright: #FFFFFF;
    --bg: #151515;
    --bg-soft: #1E1E1E;
    --app-bg: #0A0A0A;
    --bg-elevated: #1C1C1E;
    --line: #2A2A2A;
    --text: #EDEDED;
    --text-mid: #9E9E9E;
    --text-dim: #6E6E73;
    --status-green: #2EB67D
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    -webkit-tap-highlight-color: transparent;
}

body {
    font-family: 'Inter', sans-serif;
    background: var(--app-bg);
    color: var(--text);
    height: 100dvh;
    width: 100vw;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ==========================================================================
   MAIN LAYOUT & CARDS
   ========================================================================== */
.main {
    position: relative;
    z-index: 5;
    flex: 1;
    display: flex;
    align-items: stretch;
    justify-content: center;
    padding: 10px;
    overflow: hidden;
}

.screen {
    display: none;
    width: 100%;
}

.screen.active {
    display: flex;
    flex-direction: column;
    align-items: stretch;
    height: 100%;
}

.home-layout {
    display: flex;
    align-items: stretch;
    gap: 10px;
    width: 100%;
    max-width: 1600px;
    margin: 0 auto;
    height: 100%;
}

.card {
    background: var(--bg);
    border: 1px solid var(--line);
    padding: 20px;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.08);
    position: relative;
    overflow: hidden;
    animation: fadeUp 0.5s ease both;
    display: flex;
    flex-direction: column;
}

.card::before {
    background: linear-gradient(to bottom, var(--accent-violet), var(--accent-cyan));
}

@keyframes fadeUp {
    from {
        opacity: 0;
        transform: translateY(14px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* ==========================================================================
   LEFT PANEL (HERO & MIC)
   ========================================================================== */
.voice-col {
    flex: 0 0 420px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    gap: 40px;
}

.hero-identity {
    text-align: center;
}

.asst-name {
    font-size: 40px;
    font-weight: 700;
    color: var(--text-bright);
    margin-bottom: 12px;
    letter-spacing: -0.02em;
}

.asst-sub {
    font-size: 16px;
    color: var(--text-mid);
    line-height: 1.5;
}

.mic-container {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: none;
}

.talk-btn {
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 220px;
    height: 220px;
    border-radius: 50%;
    border: 1px solid rgba(255, 255, 255, 0.08);
    background: var(--bg-soft);
    cursor: pointer;
    transition: transform 0.15s ease, box-shadow 0.2s ease;
    box-shadow: 0 10px 40px rgba(123, 47, 247, 0.25);
    overflow: hidden;
    padding: 0;
    user-select: none;
    -webkit-user-select: none;
}

.talk-caption {
    margin-top: 20px;
}

.talk-btn:hover {
    transform: translateY(-1px);
    box-shadow: 0 12px 48px rgba(123, 47, 247, 0.42);
}

.talk-btn.active {
    animation: talkPulse 1.8s ease-out infinite;
}

@keyframes talkPulse {
    0% {
        box-shadow: 0 0 30px rgba(123, 47, 247, 0.45), 0 0 0 0 rgba(123, 47, 247, 0.40);
    }

    70% {
        box-shadow: 0 0 46px rgba(0, 194, 255, 0.30), 0 0 0 22px rgba(123, 47, 247, 0);
    }

    100% {
        box-shadow: 0 0 30px rgba(123, 47, 247, 0), 0 0 0 0 rgba(123, 47, 247, 0);
    }
}

.orb-canvas {
    width: 100%;
    height: 100%;
    display: block;
    pointer-events: none;
}

.voice-status {
    font-size: 16px;
    margin-top: 8px;
    color: var(--text-mid);
    text-align: center;
    min-height: 16px;
}

.voice-status.live {
    color: var(--status-green);
    font-weight: 600;
}

.voice-status.thinking,
.voice-status.speaking {
    color: var(--accent-cyan);
    font-weight: 600;
}

.voice-status.error {
    color: var(--accent-violet);
    font-weight: 600;
}

/* ==========================================================================
   RIGHT PANEL: TRIP DASHBOARD
   ========================================================================== */
.content-col {
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 10px;
    min-width: 0;
}

.trip-dashboard {
    padding: 20px;
}

.route-display {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 40px;
    margin-bottom: 24px;
}

.stop {
    text-align: center;
    max-width: 150px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.stop-icon {
    margin-bottom: 6px;
    color: var(--text-mid);
}

.stop-icon svg {
    display: block;
}

.stop-name {
    font-size: 20px;
    font-weight: 700;
    color: var(--text-bright);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    width: 100%;
}

.stop-label {
    font-size: 12px;
    color: var(--text-mid);
    margin-top: 4px;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.route-line {
    flex: 1;
    min-width: 100px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 6px;
}

.cute-taxi {
    position: absolute;
    top: 50%;
    transform: translate(-50%, -50%);
    z-index: 2;
    transition: left 0.3s ease;
    width: 28px;
}

.cute-taxi img {
    width: 100%;
    height: auto;
    display: block;
}

.progress-track {
    position: relative;
    width: 100%;
    height: 2px;
    background: var(--grey-muted);
    border-radius: 3px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(to right, var(--accent-violet), var(--accent-cyan));
    border-radius: 3px;
    width: 0% !important;
    transition: width 0.3s ease;
    position: relative;
}

.trip-stats-row {
    display: flex;
    justify-content: space-between;
    padding-top: 20px;
    border-top: 1px solid var(--line);
}

.stat {
    flex: 1;
    text-align: center;
}

.stat:not(:last-child) {
    border-right: 1px solid var(--line);
}

.stat-label {
    font-size: 12px;
    color: var(--text-mid);
    text-transform: uppercase;
    letter-spacing: 0.08em;
    margin-bottom: 6px;
}

.stat-value {
    font-size: 24px;
    font-weight: 700;
    color: var(--accent-cyan);
}

.stat-sub {
    font-size: 16px;
    color: var(--text-mid);
    font-weight: 500;
    margin-left: 4px;
}

/* ==========================================================================
   CONVERSATION CHAT
   ========================================================================== */
.conversation-col {
    flex: 1;
    justify-content: flex-end;
}

.transcript-hdr {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 8px;
}

.transcript-title {
    font-size: 10px;
    text-transform: uppercase;
    letter-spacing: 0.1em;
    color: var(--text-mid);
    font-weight: 600;
}

.messages {
    flex: 1;
    height: 0;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-bottom: 20px;
    padding-right: 8px;
}

.messages::-webkit-scrollbar {
    width: 4px;
}

.messages::-webkit-scrollbar-track {
    background: transparent;
}

.messages::-webkit-scrollbar-thumb {
    background: rgba(0, 194, 255, 0.25);
    border-radius: 4px;
}

.messages::-webkit-scrollbar-thumb:hover {
    background: rgba(0, 194, 255, 0.45);
}

.msg {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeUp 0.3s ease both;
}

.msg.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.msg.ai {
    align-self: flex-start;
    flex-direction: row;
}

.msg-avatar {
    width: 38px;
    height: 38px;
    border-radius: 50%;
    background: var(--bg);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 20px;
    flex-shrink: 0;
    overflow: hidden;
}

.msg-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
    transform-origin: center center;
}

.msg.user .msg-avatar {
    background: var(--grey-dark);
}

.msg.ai .msg-avatar {
    background: rgba(225, 37, 27, 0.1);
}

.msg-bubble {
    padding: 16px 20px;
    border-radius: 14px;
    font-size: 18px;
    line-height: 1.5;
    color: var(--text-bright);
}

.msg.ai .msg-bubble {
    background: var(--bg-elevated);
    border: 1px solid var(--line);
    border-bottom-left-radius: 4px;
}

.msg.user .msg-bubble {
    background: linear-gradient(135deg, var(--accent-violet), var(--accent-cyan));
    color: white;
    border-bottom-right-radius: 4px;
}

.msg.ai .msg-bubble strong {
    color: var(--accent-cyan);
    font-weight: 600;
}

.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    color: var(--text-mid);
    text-align: center;
    animation: fadeUp 0.5s ease both;
    padding: 20px;
}

.empty-icon {
    font-size: 32px;
    margin-bottom: 12px;
    opacity: 0.6;
}

.empty-text {
    font-size: 15px;
    line-height: 1.5;
}

/* ==========================================================================
   INPUTS & CHIPS
   ========================================================================== */
.chips-wrapper {
    width: 100%;
    overflow-x: auto;
    padding-bottom: 8px;
    margin-bottom: 12px;
    -ms-overflow-style: none;
    scrollbar-width: none;
    cursor: grab;
    user-select: none;
    -webkit-user-select: none;
}

.chips-wrapper::-webkit-scrollbar {
    display: none;
}

.chips-wrapper.dragging {
    cursor: grabbing;
}

.chips {
    display: flex;
    gap: 10px;
    flex-wrap: nowrap;
    width: max-content;
}

.chip {
    background: var(--bg);
    border: 1px solid var(--line);
    padding: 12px 20px;
    font-size: 15px;
    color: var(--text-mid);
    cursor: pointer;
    transition: all 0.2s;
    font-family: 'Inter', sans-serif;
    font-weight: 500;
    border-radius: 24px;
    transition: color 0.3s ease-in-out, border-color 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.chips-wrapper:not(.dragging) .chip:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background-color: rgba(0, 194, 255, 0.05);
}

.input-wrap {
    display: flex;
    align-items: stretch;
    border: 1px solid var(--line);
    background: var(--bg);
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
    transition: box-shadow 0.2s, border-color 0.2s;
}

.input-wrap:focus-within {
    border-color: var(--accent-cyan);
    box-shadow: 0 4px 16px rgba(225, 37, 27, 0.12);
}

.chat-input {
    flex: 1;
    background: transparent;
    border: none;
    padding: 16px 20px;
    font-size: 16px;
    font-family: 'Inter', sans-serif;
    outline: none;
    resize: none;
    min-height: 54px;
    max-height: 80px;
    line-height: 1.4;
    color: white
}

.chat-input::placeholder {
    color: var(--text-dim);
}

.send-btn {
    background: var(--accent-cyan);
    border: none;
    color: white;
    font-size: 16px;
    font-weight: 600;
    font-family: 'Inter', sans-serif;
    padding: 0 28px;
    cursor: pointer;
    transition: background-color 0.3s ease-in-out;
}

.send-btn:hover {
    background: var(--accent-cyan-dark);
}

.footer-line {
    text-align: center;
    padding: 10px 6px;
    font-size: 12px;
    color: var(--text-dim);
    border-top: 1px solid var(--line);
    background: transparent;
}

.footer-line .highlight {
    color: var(--accent-cyan);
    font-weight: 600;
}

/* ==========================================================================
   MISC & RTL SUPPORTS
   ========================================================================== */
.input-wrap,
.chips-wrapper,
.transcript-hdr {
    flex-shrink: 0 !important;
}

body.keyboard-open {
    height: auto !important;
    overflow-y: auto !important;
    padding-bottom: 60vh !important;
}

.input-wrap {
    flex-shrink: 0 !important;
}

.lang-toggle {
    position: absolute;
    top: 16px;
    right: 16px;
    background: var(--bg-soft);
    border: 1px solid var(--line);
    border-radius: 20px;
    padding: 6px 14px;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-mid);
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 6px;
    font-family: inherit;
    z-index: 10;
    transition: color 0.3s ease-in-out, border-color 0.3s ease-in-out, background-color 0.3s ease-in-out;
}

.lang-toggle:hover {
    border-color: var(--accent-cyan);
    color: var(--accent-cyan);
    background-color: rgba(0, 194, 255, 0.05);
}

html[dir="rtl"] .lang-toggle {
    right: auto;
    left: 16px;
}

html[dir="rtl"] {
    font-family: 'Noto Naskh Arabic', 'Tajawal', 'Cairo', sans-serif;
}

html[dir="rtl"] .input-wrap {
    flex-direction: row;
}

html[dir="rtl"] .cute-taxi {
    transform: translate(50%, -50%) scaleX(-1);
}

/* Updated AI class for RTL */
html[dir="rtl"] .msg.user {
    flex-direction: row-reverse;
}

html[dir="rtl"] .msg.ai {
    flex-direction: row;
}

html[dir="rtl"] .msg-bubble {
    text-align: right;
}

html[dir="rtl"] .msg.user .msg-bubble {
    border-bottom-left-radius: 4px;
    border-bottom-right-radius: 14px;
}

html[dir="rtl"] .msg.ai .msg-bubble {
    border-bottom-right-radius: 4px;
    border-bottom-left-radius: 14px;
}