/* ===== CSS Variables ===== */
:root {
    --primary: #3b82f6;
    --primary-dark: #2563eb;
    --secondary: #06b6d4;
    --accent: #8b5cf6;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #0f172a;
    --dark-light: #1e293b;
    --gray: #64748b;
    --light: #f1f5f9;
    --white: #ffffff;
    --gradient: linear-gradient(135deg, #3b82f6 0%, #06b6d4 50%, #8b5cf6 100%);
    --gradient-dark: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
    --shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    --shadow-light: 0 4px 20px rgba(0, 0, 0, 0.2);
    --radius: 16px;
    --radius-sm: 8px;
    --transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* ===== Reset & Base ===== */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
    background: var(--dark);
    color: var(--white);
    min-height: 100vh;
    overflow-x: hidden;
    line-height: 1.6;
}

/* ===== Animated Background ===== */
.bg-animation {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: -1;
    overflow: hidden;
    pointer-events: none;
}

.circle {
    position: absolute;
    border-radius: 50%;
    background: radial-gradient(circle, rgba(59, 130, 246, 0.15) 0%, transparent 70%);
    animation: float 20s infinite ease-in-out;
}

.circle-1 {
    width: 600px;
    height: 600px;
    top: -200px;
    right: -200px;
    animation-delay: 0s;
}

.circle-2 {
    width: 400px;
    height: 400px;
    bottom: -100px;
    left: -100px;
    animation-delay: -7s;
    background: radial-gradient(circle, rgba(6, 182, 212, 0.12) 0%, transparent 70%);
}

.circle-3 {
    width: 300px;
    height: 300px;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    animation-delay: -14s;
    background: radial-gradient(circle, rgba(139, 92, 246, 0.1) 0%, transparent 70%);
}

@keyframes float {

    0%,
    100% {
        transform: translate(0, 0) scale(1);
    }

    33% {
        transform: translate(30px, -30px) scale(1.1);
    }

    66% {
        transform: translate(-20px, 20px) scale(0.9);
    }
}

/* ===== Header ===== */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 24px 40px;
    max-width: 1200px;
    margin: 0 auto;
    position: relative;
    z-index: 10;
}

.logo {
    display: flex;
    align-items: center;
    gap: 16px;
}

.logo-icon {
    font-size: 48px;
    animation: pulse-glow 2s infinite;
}

@keyframes pulse-glow {

    0%,
    100% {
        filter: drop-shadow(0 0 8px rgba(59, 130, 246, 0.5));
    }

    50% {
        filter: drop-shadow(0 0 20px rgba(6, 182, 212, 0.8));
    }
}

.logo-text h1 {
    font-size: 28px;
    font-weight: 800;
    background: var(--gradient);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    letter-spacing: -0.5px;
}

.tagline {
    font-size: 14px;
    color: var(--gray);
    font-weight: 500;
    margin-top: 2px;
}

.status-indicator {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    font-weight: 600;
    color: var(--success);
    background: rgba(16, 185, 129, 0.1);
    padding: 8px 16px;
    border-radius: 20px;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.pulse {
    width: 8px;
    height: 8px;
    background: var(--success);
    border-radius: 50%;
    animation: pulse 2s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
        transform: scale(1);
    }

    50% {
        opacity: 0.5;
        transform: scale(1.2);
    }
}

/* ===== Container ===== */
.container {
    max-width: 900px;
    margin: 0 auto;
    padding: 0 20px 60px;
    position: relative;
    z-index: 1;
}

/* ===== Card Styles ===== */
.card {
    background: rgba(30, 41, 59, 0.7);
    -webkit-backdrop-filter: blur(20px);
    backdrop-filter: blur(20px);
    border-radius: var(--radius);
    border: 1px solid rgba(255, 255, 255, 0.08);
    box-shadow: var(--shadow);
    margin-bottom: 24px;
    overflow: hidden;
    transition: var(--transition);
    animation: slideUp 0.6s ease-out backwards;
}

.card:nth-child(1) {
    animation-delay: 0.1s;
}

.card:nth-child(2) {
    animation-delay: 0.2s;
}

.card:nth-child(3) {
    animation-delay: 0.3s;
}

.card:nth-child(4) {
    animation-delay: 0.4s;
}

@keyframes slideUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.card:hover {
    transform: translateY(-4px);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.4);
    border-color: rgba(59, 130, 246, 0.3);
}

.card-header {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 20px 24px;
    border-bottom: 1px solid rgba(255, 255, 255, 0.06);
    background: rgba(15, 23, 42, 0.4);
}

.card-icon {
    font-size: 28px;
    width: 48px;
    height: 48px;
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gradient);
    border-radius: 12px;
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

.card-header h2 {
    font-size: 20px;
    font-weight: 700;
    letter-spacing: -0.3px;
}

.card-body {
    padding: 24px;
}

/* ===== Route Card ===== */
.input-group {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 20px;
}

.input-wrapper {
    flex: 1;
    position: relative;
}

.input-icon {
    position: absolute;
    left: 16px;
    top: 50%;
    transform: translateY(-50%);
    font-size: 20px;
    pointer-events: none;
}

.input-group input {
    width: 100%;
    padding: 16px 16px 16px 52px;
    background: rgba(15, 23, 42, 0.6);
    border: 2px solid rgba(255, 255, 255, 0.1);
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 16px;
    font-family: inherit;
    transition: var(--transition);
}

.input-group input:focus {
    outline: none;
    border-color: var(--primary);
    background: rgba(15, 23, 42, 0.8);
    box-shadow: 0 0 0 4px rgba(59, 130, 246, 0.15);
}

.input-group input::placeholder {
    color: var(--gray);
}

.input-divider {
    font-size: 24px;
    color: var(--gray);
    font-weight: 300;
}

.btn-primary {
    width: 100%;
    padding: 16px 24px;
    background: var(--gradient);
    border: none;
    border-radius: var(--radius-sm);
    color: var(--white);
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    transition: var(--transition);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 6px 25px rgba(59, 130, 246, 0.5);
}

.btn-primary:active {
    transform: translateY(0);
}

.btn-icon {
    width: 20px;
    height: 20px;
    transition: transform 0.3s;
}

.btn-primary:hover .btn-icon {
    transform: translateX(4px);
}

.result-box {
    margin-top: 20px;
    min-height: 80px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.result-placeholder {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 12px;
    color: var(--gray);
    padding: 30px;
}

.result-placeholder svg {
    width: 48px;
    height: 48px;
    opacity: 0.5;
}

.result-content {
    width: 100%;
    animation: fadeIn 0.4s ease-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.route-display {
    background: rgba(59, 130, 246, 0.1);
    border: 1px solid rgba(59, 130, 246, 0.2);
    border-radius: var(--radius-sm);
    padding: 20px;
}

.route-path {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
    font-size: 18px;
    font-weight: 600;
    margin-bottom: 12px;
    flex-wrap: wrap;
}

.route-step {
    padding: 8px 16px;
    background: rgba(59, 130, 246, 0.2);
    border-radius: 20px;
}

.route-arrow {
    color: var(--gray);
    font-size: 20px;
}

.route-stats {
    display: flex;
    justify-content: center;
    gap: 24px;
    flex-wrap: wrap;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 14px;
    color: var(--gray);
}

.stat-value {
    color: var(--white);
    font-weight: 600;
}

/* ===== Chat Assistant ===== */
.chat-container {
    display: flex;
    flex-direction: column;
    height: 350px;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    padding-right: 8px;
    margin-bottom: 16px;
}

.chat-history::-webkit-scrollbar {
    width: 6px;
}

.chat-history::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 3px;
}

.chat-history::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.2);
    border-radius: 3px;
}

.message {
    display: flex;
    gap: 12px;
    margin-bottom: 16px;
    animation: messageIn 0.3s ease-out;
}

@keyframes messageIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.bot-message {
    align-items: flex-start;
}

.user-message {
    flex-direction: row-reverse;
    align-items: flex-end;
}

.message-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--gradient);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    flex-shrink: 0;
}

.user-message .message-avatar {
    background: var(--accent);
}

.message-content {
    background: rgba(15, 23, 42, 0.6);
    padding: 12px 16px;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.08);
    max-width: 80%;
}

.user-message .message-content {
    background: var(--gradient);
    border: none;
}

.message-content p {
    margin-bottom: 8px;
}

.message-content ul {
    list-style: none;
    padding: 0;
}

.message-content li {
    padding: 4px 0;
    font-size: 14px;
    color: var(--gray);
}

.user-message .message-content li {
    color: rgba(255, 255, 255, 0.9);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    padding: 4px;
    background: rgba(15, 23, 42, 0.6);
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.chat-input-wrapper input {
    flex: 1;
    padding: 14px 18px;
    background: transparent;
    border: none;
    color: var(--white);
    font-size: 15px;
    font-family: inherit;
}

.chat-input-wrapper input:focus {
    outline: none;
}

.chat-input-wrapper input::placeholder {
    color: var(--gray);
}

.btn-send {
    width: 48px;
    height: 48px;
    padding: 0;
    background: var(--gradient);
    border: none;
    border-radius: 10px;
    color: var(--white);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

.btn-send:hover {
    transform: scale(1.05);
    box-shadow: 0 4px 15px rgba(59, 130, 246, 0.4);
}

.btn-send svg {
    width: 20px;
    height: 20px;
}

/* ===== Status Card ===== */
.status-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 16px;
    margin-bottom: 20px;
}

.status-item {
    background: rgba(15, 23, 42, 0.5);
    padding: 20px;
    border-radius: var(--radius-sm);
    border: 1px solid rgba(255, 255, 255, 0.06);
    transition: var(--transition);
}

.status-item:hover {
    border-color: rgba(59, 130, 246, 0.3);
    transform: translateY(-2px);
}

.status-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 12px;
}

.gate-name {
    font-weight: 600;
    font-size: 16px;
}

.status-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: var(--success);
    transition: var(--transition);
}

.status-item.high .status-dot {
    background: var(--danger);
}

.status-item.medium .status-dot {
    background: var(--warning);
}

.status-item.low .status-dot {
    background: var(--success);
}

.crowd-meter {
    height: 8px;
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
    overflow: hidden;
    margin-bottom: 8px;
}

.meter-fill {
    height: 100%;
    background: var(--gradient);
    border-radius: 4px;
    transition: width 0.5s ease-out;
    width: 0%;
}

.crowd-value {
    text-align: right;
    font-size: 24px;
    font-weight: 700;
    color: var(--white);
}

.alert-box {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 16px 20px;
    background: rgba(245, 158, 11, 0.1);
    border: 1px solid rgba(245, 158, 11, 0.3);
    border-radius: var(--radius-sm);
    animation: alertPulse 2s infinite;
}

@keyframes alertPulse {

    0%,
    100% {
        box-shadow: 0 0 0 0 rgba(245, 158, 11, 0.2);
    }

    50% {
        box-shadow: 0 0 0 8px rgba(245, 158, 11, 0);
    }
}

.alert-icon {
    font-size: 24px;
}

.alert-content {
    font-size: 14px;
}

.alert-content strong {
    color: var(--warning);
}

/* ===== Map Card ===== */
.map-wrapper {
    border-radius: 12px;
    overflow: hidden;
    position: relative;
}

.map-wrapper iframe {
    display: block;
}

.map-overlay {
    position: absolute;
    bottom: 16px;
    left: 16px;
    background: rgba(15, 23, 42, 0.9);
    -webkit-backdrop-filter: blur(10px);
    backdrop-filter: blur(10px);
    padding: 10px 16px;
    border-radius: 8px;
    border: 1px solid rgba(255, 255, 255, 0.1);
}

.overlay-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 13px;
    font-weight: 500;
}

.overlay-icon {
    font-size: 16px;
}

/* ===== Toast Notification ===== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%) translateY(100px);
    background: var(--success);
    color: var(--white);
    padding: 14px 24px;
    border-radius: 12px;
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.4);
    z-index: 1000;
    opacity: 0;
    transition: all 0.4s cubic-bezier(0.68, -0.55, 0.265, 1.55);
    pointer-events: none;
}

.toast.show {
    opacity: 1;
    transform: translateX(-50%) translateY(0);
}

.toast-content {
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.toast-icon {
    font-size: 18px;
}

/* ===== Responsive ===== */
@media (max-width: 768px) {
    .header {
        padding: 20px;
        flex-direction: column;
        gap: 16px;
        text-align: center;
    }

    .logo {
        flex-direction: column;
        gap: 8px;
    }

    .logo-icon {
        font-size: 40px;
    }

    .logo-text h1 {
        font-size: 24px;
    }

    .input-group {
        flex-direction: column;
    }

    .input-divider {
        display: none;
    }

    .input-group input {
        width: 100%;
    }

    .card-body {
        padding: 20px;
    }

    .status-grid {
        grid-template-columns: 1fr;
    }

    .route-path {
        flex-direction: column;
        gap: 8px;
    }

    .route-arrow {
        display: none;
    }
}

/* ===== Utility Classes ===== */
.hidden {
    display: none !important;
}

/* ===== Loading Animation ===== */
@keyframes shimmer {
    0% {
        background-position: -200% 0;
    }

    100% {
        background-position: 200% 0;
    }
}

.loading {
    background: linear-gradient(90deg,
            rgba(255, 255, 255, 0.05) 25%,
            rgba(255, 255, 255, 0.1) 50%,
            rgba(255, 255, 255, 0.05) 75%);
    background-size: 200% 100%;
    animation: shimmer 1.5s infinite;
}