/* AI Course Finder Layout */
.ai-course-finder-page {
    background-color: var(--color-bg-warm, #fafafa);
    min-height: calc(100vh - 80px);
    /* Adjust based on header height */
    padding: 30px 0;
    /* Prevent flash of unstyled content during initial render */
    opacity: 0;
    animation: smoothPageFadeIn 0.2s ease-out forwards;
    animation-delay: 0.01s;
}

@keyframes smoothPageFadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.ai-finder-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Chat Sidebar */
.chat-sidebar {
    background: #fff;
    border-radius: 16px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.04);
    border: 1px solid #f0f0f0;
    display: flex;
    flex-direction: column;
    height: calc(100vh - 140px);
    /* Sticky height */
    position: sticky;
    top: 90px;
    overflow: hidden;
}

.chat-header {
    padding: 20px;
    border-bottom: 1px solid #f0f0f0;
    display: flex;
    align-items: center;
    gap: 12px;
    background: linear-gradient(135deg, rgba(212, 175, 55, 0.05) 0%, rgba(255, 255, 255, 0) 100%);
}

.chat-header-icon {
    width: 40px;
    height: 40px;
    background: var(--color-secondary, #D4AF37);
    color: #fff;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    box-shadow: 0 4px 10px rgba(212, 175, 55, 0.3);
}

.chat-header-text h3 {
    margin: 0;
    font-size: 16px;
    font-family: var(--font-heading, 'Cardo', serif);
    font-weight: 700;
    color: var(--color-primary, #1a1a1a);
}

.chat-header-text p {
    margin: 0;
    font-size: 12px;
    color: #666;
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 16px;
    scroll-behavior: smooth;
}

/* Scrollbar styling for chat */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}

.chat-messages::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-messages::-webkit-scrollbar-thumb {
    background: #ccc;
    border-radius: 3px;
}

.message {
    display: flex;
    flex-direction: column;
    max-width: 85%;
    animation: fadeIn 0.3s ease-in-out;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.message.ai {
    align-self: flex-start;
}

.message.user {
    align-self: flex-end;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 16px;
    font-size: 14px;
    line-height: 1.5;
    position: relative;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.message.ai .message-bubble {
    background: #f8f9fa;
    color: #333;
    border: 1px solid #e9ecef;
    border-bottom-left-radius: 4px;
}

.message.user .message-bubble {
    background: var(--color-secondary, #D4AF37);
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-time {
    font-size: 10px;
    color: #999;
    margin-top: 4px;
    align-self: flex-end;
}

.message.ai .message-time {
    align-self: flex-start;
}

/* AI Quote Block (Marketing Injection) */
.ai-quote-block {
    display: flex;
    align-items: flex-start;
    gap: 12px;
    background: #ffffff;
    border: 1px solid var(--color-secondary, #D4AF37);
    border-radius: 8px;
    padding: 16px;
    margin-top: 12px;
    box-shadow: 0 4px 12px rgba(212, 175, 55, 0.08);
}

.ai-quote-block .quote-icon {
    margin-top: 2px;
    color: var(--color-secondary, #D4AF37);
    font-size: 1.2rem;
}

.ai-quote-block .quote-content {
    display: flex;
    flex-direction: column;
}

.ai-quote-block .quote-title {
    font-size: 13px;
    font-weight: 700;
    color: #666;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0 0 4px 0;
}

.ai-quote-block .quote-text {
    font-size: 15px;
    font-weight: 500;
    color: var(--color-primary, #1a1a1a);
    margin: 0 0 8px 0;
}

.ai-quote-block .quote-btn {
    align-self: flex-start;
    font-weight: 600;
    border-color: var(--color-secondary, #D4AF37);
    color: var(--color-secondary, #D4AF37);
}

.ai-quote-block .quote-btn:hover {
    background-color: var(--color-secondary, #D4AF37);
    color: #ffffff;
}

/* Typing indicator */
.typing-indicator {
    display: flex;
    gap: 4px;
    padding: 8px 12px;
    align-items: center;
}

.typing-dot {
    width: 6px;
    height: 6px;
    background: #a0a0a0;
    border-radius: 50%;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dot:nth-child(1) {
    animation-delay: -0.32s;
}

.typing-dot:nth-child(2) {
    animation-delay: -0.16s;
}

@keyframes typing {

    0%,
    80%,
    100% {
        transform: scale(0);
    }

    40% {
        transform: scale(1);
    }
}

/* Chat Input Area */
.chat-input-area {
    padding: 16px;
    background: #fff;
    border-top: 1px solid #f0f0f0;
}

/* Powered-by footer at bottom of chat sidebar */
.chat-powered-footer {
    text-align: center;
    padding: 8px 16px;
    font-size: 11px;
    color: #9ca3af;
    background: #fff;
    border-top: 1px solid #f3f4f6;
}

.chat-powered-footer a {
    color: #b8941f;
    font-weight: 600;
    text-decoration: none;
}

.chat-powered-footer a:hover {
    text-decoration: underline;
}

.chat-input-form {
    display: flex;
    gap: 10px;
    position: relative;
}

.chat-input {
    flex: 1;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 12px 45px 12px 16px;
    font-size: 15px;
    outline: none;
    transition: border-color 0.2s, box-shadow 0.2s;
    background: #fff;
    resize: none;
    line-height: 1.5;
    min-height: 48px;
    max-height: 200px;
    overflow-y: auto;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.chat-input:focus {
    border-color: #ccc;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

.btn-send {
    position: absolute;
    right: 6px;
    bottom: 6px;
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: var(--color-secondary, #D4AF37);
    color: #fff;
    border: none;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s, transform 0.1s;
}

.btn-send:hover:not(:disabled) {
    background: #c19f32;
}

.btn-send:active:not(:disabled) {
    transform: scale(0.95);
}

.btn-send:disabled {
    background: #e0e0e0;
    cursor: not-allowed;
    color: #a0a0a0;
}

/* Results Area */
.results-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    padding-bottom: 16px;
    border-bottom: 1px solid rgba(0, 0, 0, 0.05);
}

.results-title {
    font-family: var(--font-heading, 'Cardo', serif);
    font-size: 24px;
    font-weight: 700;
    margin: 0;
    color: var(--color-primary, #1a1a1a);
}

.results-title .highlight {
    color: var(--color-secondary, #D4AF37);
}

.results-meta {
    font-size: 14px;
    color: #666;
    background: #fff;
    padding: 6px 16px;
    border-radius: 20px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.03);
    border: 1px solid #f0f0f0;
    font-weight: 500;
}

/* Skeleton Loading for Cards */
.skeleton-card {
    background: #fff;
    border-radius: 8px;
    border: 1px solid #f0f0f0;
    height: 100%;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.skeleton-img {
    height: 160px;
    background: #f0f0f0;
    animation: pulse 1.5s infinite;
}

.skeleton-body {
    padding: 16px;
    flex: 1;
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.skeleton-line {
    height: 12px;
    background: #f0f0f0;
    border-radius: 4px;
    animation: pulse 1.5s infinite;
}

.skeleton-line.short {
    width: 60%;
}

.skeleton-line.title {
    height: 16px;
    width: 90%;
}

.skeleton-line.price {
    height: 20px;
    width: 40%;
    margin-top: auto;
}

@keyframes pulse {
    0% {
        background-color: #f0f0f0;
    }

    50% {
        background-color: #e0e0e0;
    }

    100% {
        background-color: #f0f0f0;
    }
}

/* ============================================================
   MOBILE TAB BAR
   Fixed sticky bar visible only on mobile (< lg).
   ============================================================ */
.mobile-ai-tabs {
    display: none; /* shown via d-lg-none utility */
    position: sticky;
    top: 0;
    z-index: 200;
    background: #fff;
    border-bottom: 2px solid #f0f0f0;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.06);
    align-items: center;
    padding-right: 8px;
}

.mobile-ai-tab {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 13px 8px;
    font-size: 14px;
    font-weight: 600;
    color: #888;
    background: transparent;
    border: none;
    border-bottom: 3px solid transparent;
    cursor: pointer;
    transition: color 0.2s, border-color 0.2s, box-shadow 0.2s;
    position: relative;
}

.mobile-ai-tab.chat-tab {
    flex: 1;
}

/* Compact pill on the right — saves tab-bar height & keeps courses always reachable */
.mobile-ai-tab.courses-tab {
    flex: 0 0 auto;
    padding: 7px 14px;
    margin: 5px 0 5px 4px;
    border-radius: 20px;
    border: 1.5px solid #e8e8e8;
    border-bottom: 1.5px solid #e8e8e8;
    font-size: 13px;
    background: #f9f9f9;
    gap: 5px;
}

.mobile-ai-tab.courses-tab.active {
    background: #fff8e6;
    border-color: var(--color-secondary, #D4AF37);
    border-bottom-color: var(--color-secondary, #D4AF37);
    color: var(--color-secondary, #D4AF37);
}

/* 3-shot glow fired every time the bot delivers fresh course results */
.mobile-ai-tab.tab-pulse {
    animation: tabGlow 1s ease-in-out 3;
}

.mobile-ai-tab.active {
    color: var(--color-secondary, #D4AF37);
    border-bottom-color: var(--color-secondary, #D4AF37);
}

.mobile-ai-tab i {
    font-size: 16px;
}

/* Course count badge on the Courses tab */
.mobile-tab-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-width: 20px;
    height: 20px;
    padding: 0 6px;
    font-size: 11px;
    font-weight: 700;
    color: #fff;
    background: var(--color-secondary, #D4AF37);
    border-radius: 10px;
    animation: badgePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both;
}

@keyframes badgePop {
    from { transform: scale(0); opacity: 0; }
    to   { transform: scale(1); opacity: 1; }
}

/* Infinite ring pulse on the badge — stops when user taps the courses tab */
.mobile-tab-badge.badge-pulse {
    animation: badgePop 0.35s cubic-bezier(0.34, 1.56, 0.64, 1) both,
               badgePulse 1.2s ease-in-out 0.35s infinite;
}

@keyframes badgePulse {
    0%, 100% { transform: scale(1);    box-shadow: 0 0 0 0   rgba(212, 175, 55, 0.7); }
    50%       { transform: scale(1.2); box-shadow: 0 0 0 5px rgba(212, 175, 55, 0);   }
}

@keyframes tabGlow {
    0%, 100% { box-shadow: none; }
    50%       { box-shadow: 0 0 0 4px rgba(212, 175, 55, 0.35); }
}

/* ============================================================
   FLOATING COURSES NOTIFICATION CTA
   Appears at the bottom of the chat panel on mobile when the
   AI finds matching courses — prompts students to switch tab.
   ============================================================ */
.mobile-courses-cta {
    display: flex;
    align-items: center;
    gap: 10px;
    width: 100%;
    padding: 14px 18px;
    background: linear-gradient(135deg, #D4AF37 0%, #b8941f 100%);
    color: #fff;
    font-size: 14px;
    border: none;
    border-top: 1px solid rgba(255,255,255,0.2);
    cursor: pointer;
    animation: slideUp 0.4s ease-out both;
}

.mobile-courses-cta:hover {
    background: linear-gradient(135deg, #c9a52f 0%, #a8841a 100%);
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to   { transform: translateY(0);    opacity: 1; }
}

/* ============================================================
   RESPONSIVE — MOBILE OVERHAUL (< 992 px)
   ============================================================ */
@media (max-width: 991.98px) {

    /* Force the tab bar to be a single horizontal row —
       "Chat with SARA  |  Live Courses (n)"
       Without this the browser falls back to block layout and stacks them. */
    .mobile-ai-tabs {
        display: flex !important;
        flex-direction: row;
        align-items: center;
    }

    /* Remove page padding — tabs + panels fill full viewport */
    .ai-course-finder-page {
        padding: 0;
        background: #fff;
    }

    .ai-finder-container {
        padding: 0;
        max-width: 100%;
    }

    /* Chat sidebar fills available height below the sticky tab bar */
    .chat-sidebar {
        height: calc(100dvh - 140px); /* dvh for mobile browsers that hide/show URL bar */
        border-radius: 0;
        border: none;
        box-shadow: none;
        position: relative;
        top: 0;
        margin-bottom: 0;
    }

    /* Slightly smaller chat bubbles on mobile */
    .message-bubble {
        font-size: 13px;
        padding: 10px 13px;
    }

    /* Courses panel: full viewport height below tab bar + small padding */
    .col-12.col-lg-8 {
        padding: 0 10px 80px; /* bottom padding for BottomNav */
    }

    .results-header {
        flex-direction: row;
        align-items: center;
        flex-wrap: wrap;
        gap: 8px;
        padding: 14px 4px 10px;
        margin-bottom: 12px;
    }

    .results-title {
        font-size: 18px;
    }

    .results-meta {
        font-size: 12px;
    }

    /* 2-column course cards on mobile — better density */
    .program-grid-card .card-content {
        padding: 10px !important;
    }

    /* Tighter course card titles on 2-col grid */
    .program-grid-card h3.program-title {
        font-size: 12px !important;
        min-height: 32px !important;
    }

    .program-grid-card .price-tag {
        font-size: 14px !important;
    }

    .program-grid-card .university-info span {
        font-size: 10px !important;
    }

    .program-grid-card .tags-row span {
        font-size: 10px !important;
        padding: 2px 6px !important;
    }

    /* Skeleton cards on 2-col grid */
    .skeleton-img {
        height: 100px;
    }

    /* Quick filter chips — smaller on mobile */
    .chat-chips-area .btn {
        font-size: 11px !important;
        padding: 4px 10px !important;
    }

    /* Quote blocks inside chat — full width on mobile */
    .ai-quote-block {
        padding: 12px;
        gap: 8px;
    }

    .ai-quote-block .quote-text {
        font-size: 13px;
    }
}