/* ============================================
   CHAT UI STYLES - AI Movie Recommender
   ============================================ */

/* Global Font - Clean chatbot-friendly font */
@import url('https://fonts.googleapis.com/css2?family=DM+Sans:wght@400;500;600&display=swap');

body {
    font-family: 'DM Sans', -apple-system, BlinkMacSystemFont, sans-serif;
}

/* Layout structure */
.app-layout {
    display: flex;
    height: 100vh;
    width: 100%;
    background-color: var(--bg-color);
}

/* ============ SIDEBAR ============ */
.sidebar {
    width: 260px;
    background-color: #000000;
    display: flex;
    flex-direction: column;
    border-right: 1px solid rgba(255, 255, 255, 0.1);
    flex-shrink: 0;
    z-index: 10;
}

.sidebar-header {
    padding: 1.5rem;
}

.sidebar-header h3 {
    font-family: 'DM Sans', sans-serif;
    font-size: 0.85rem;
    color: var(--text-secondary);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin: 0;
}

.sidebar-header-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.new-chat-btn {
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary);
    width: 32px;
    height: 32px;
    border-radius: 6px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.new-chat-btn:hover {
    background: rgba(255, 255, 255, 0.2);
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem;
}

.rec-item {
    color: var(--text-primary);
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 0.25rem;
    font-size: 0.9rem;
    cursor: pointer;
    transition: background 0.2s;
    display: flex;
    justify-content: space-between;
}

.rec-item:hover {
    background-color: var(--surface-color);
}

.rec-date {
    color: var(--text-secondary);
    font-size: 0.8rem;
}

.empty-state {
    color: var(--text-secondary);
    font-size: 0.9rem;
    padding: 1rem 0;
}

.sidebar-footer {
    padding: 1rem;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-primary);
    font-weight: 600;
    font-size: 0.9rem;
}

.user-avatar {
    width: 32px;
    height: 32px;
    background-color: var(--accent-gold);
    color: #000;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: bold;
}

.logout-icon {
    margin-left: auto;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
    background: none;
    border: none;
    cursor: pointer;
    font-size: 1rem;
    padding: 0;
}

.logout-icon:hover {
    color: var(--error-red);
}

/* ============ CHAT AREA ============ */
.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    background-color: var(--bg-color);
    width: 100%;
    position: relative;
}

.chat-history {
    flex: 1;
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
    padding: 2rem 1rem;
    display: flex;
    flex-direction: column;
    gap: 1.5rem;
    align-items: center;
    /* Center messages */
}

/* ============ MESSAGES ============ */
.message {
    width: 100%;
    max-width: 720px;
    /* Constrain width */
    display: flex;
    animation: fadeIn 0.3s ease-out;
}

.message-user {
    justify-content: flex-end;
}

.message-ai {
    justify-content: flex-start;
}

.message-content {
    max-width: 85%;
    padding: 0.875rem 1.25rem;
    border-radius: 18px;
    line-height: 1.6;
    font-size: 0.95rem;
    font-weight: 400;
}

.message-user .message-content {
    background-color: #2D2D2D;
    color: #fff;
    border-bottom-right-radius: 4px;
}

.message-ai .message-content {
    background-color: transparent;
    color: #E8E8E8;
    padding-left: 0;
}

/* Markdown Styles */
.message-content h1 {
    font-family: 'Cinzel', var(--font-display), serif !important;
    font-size: 1.5rem !important;
    color: #FFD700 !important;
    margin: 0.75rem 0;
    font-weight: 700;
    letter-spacing: 0.5px;
}

.message-content h2 {
    font-family: 'Cinzel', var(--font-display), serif !important;
    font-size: 1.2rem !important;
    color: #FFD700 !important;
    margin: 0.5rem 0;
    font-weight: 700 !important;
}

.message-content h3 {
    font-size: 1.05rem;
    font-weight: 600;
    color: #B3B3B3;
    margin: 0.5rem 0;
}

.message-content p {
    margin-bottom: 0.6rem;
}

.message-content p:last-child {
    margin-bottom: 0;
}

.message-content ul,
.message-content ol {
    padding-left: 1.25rem;
    margin-bottom: 0.75rem;
}

.message-content li {
    margin-bottom: 0.25rem;
}

.message-content strong {
    color: #fff;
    font-weight: 600;
}

/* Word Fade Animation */
@keyframes fadeInWord {
    from {
        opacity: 0;
        transform: translateY(4px);
    }

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

.word-fade {
    display: inline-block;
    opacity: 0;
    animation: fadeInWord 0.8s ease-out forwards;
    white-space: pre-wrap;
}

/* ============ INPUT AREA ============ */
.chat-input-area {
    flex-shrink: 0;
    padding: 1rem 1rem 2rem 1rem;
    background-color: var(--bg-color);
    display: flex;
    justify-content: center;
    /* Center input */
}

.chat-form {
    position: relative;
    width: 100%;
    max-width: 720px;
    /* Match message width */
}

.chat-form input {
    width: 100%;
    background-color: #1E1E1E;
    border: 1px solid rgba(255, 255, 255, 0.08);
    border-radius: 24px;
    padding: 0.875rem 3rem 0.875rem 1.25rem;
    color: var(--text-primary);
    font-size: 0.95rem;
    font-family: 'DM Sans', sans-serif;
    transition: border-color 0.2s, box-shadow 0.2s;
}

.chat-form input::placeholder {
    color: #666;
}

.chat-form input:focus {
    outline: none;
    border-color: rgba(255, 255, 255, 0.2);
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.05);
}

.send-btn {
    position: absolute;
    right: 0.5rem;
    top: 50%;
    transform: translateY(-50%);
    background: #333;
    border: none;
    color: var(--text-primary);
    width: 34px;
    height: 34px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.2s;
}

.send-btn:hover {
    background-color: #fff;
    color: #000;
}

/* ============ LOADING INDICATOR ============ */
.loading-indicator {
    width: 100%;
    max-width: 720px;
    margin: 0 auto;
    padding: 0 1rem 1rem 0;
    display: flex;
    gap: 0.4rem;
    align-items: center;
    justify-content: flex-start;
}

.typing-dot {
    width: 7px;
    height: 7px;
    background-color: #666;
    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);
    }
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(8px);
    }

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

/* ============ LANDING PAGE ============ */
.landing-view {
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    text-align: center;
}

.landing-title {
    font-size: 3.5rem;
    background: linear-gradient(135deg, #fff 0%, #888 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-weight: 600;
}

.landing-subtitle {
    font-size: 1.1rem;
    color: var(--text-secondary);
    margin-bottom: 2.5rem;
}

.landing-actions {
    display: flex;
    gap: 1rem;
}

nav {
    display: none !important;
}

/* ============ SCROLLBAR ============ */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
    margin: 8px 0;
}

::-webkit-scrollbar-thumb {
    background: #333;
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: #444;
}

/* ============ MOBILE RESPONSIVE ============ */
@media screen and (max-width: 768px) {

    /* App layout adjustments for mobile */
    .app-layout {
        flex-direction: column;
    }

    /* Hide sidebar by default on mobile */
    .sidebar {
        position: fixed;
        left: -280px;
        top: 0;
        height: 100vh;
        width: 280px;
        transition: left 0.3s ease;
        box-shadow: 2px 0 10px rgba(0, 0, 0, 0.5);
        z-index: 20;
    }

    .sidebar.open {
        left: 0;
    }

    /* Overlay when sidebar is open */
    .sidebar-overlay {
        display: none;
        position: fixed;
        top: 0;
        left: 0;
        width: 100%;
        height: 100%;
        background: rgba(0, 0, 0, 0.6);
        z-index: 15;
    }

    .sidebar-overlay.active {
        display: block;
    }

    /* Mobile menu toggle button */
    .mobile-menu-toggle {
        display: flex;
        position: fixed;
        top: 1rem;
        left: 1rem;
        z-index: 15;
        background: #1E1E1E;
        border: 1px solid rgba(255, 255, 255, 0.1);
        color: var(--text-primary);
        width: 44px;
        height: 44px;
        border-radius: 8px;
        align-items: center;
        justify-content: center;
        cursor: pointer;
        transition: background 0.2s;
    }

    .mobile-menu-toggle:hover {
        background: #2D2D2D;
    }

    /* Chat area takes full width */
    .chat-area {
        width: 100%;
    }

    /* Adjust chat history padding for mobile */
    .chat-history {
        padding: 4rem 0.75rem 1rem 0.75rem;
        overflow-y: auto;
        -webkit-overflow-scrolling: touch;
        min-height: 0;
    }

    /* Chat area needs proper height on mobile */
    .chat-area {
        height: 100vh;
        min-height: 0;
        overflow: hidden;
    }

    /* Landing page adjustments */
    .landing-title {
        font-size: 2rem;
        padding: 0 1rem;
    }

    .landing-subtitle {
        font-size: 0.95rem;
        padding: 0 1rem;
    }

    .landing-actions {
        flex-direction: column;
        gap: 0.75rem;
        padding: 0 1rem;
    }

    /* Input area adjustments */
    .chat-input-area {
        padding: 0.75rem;
        padding-bottom: 1.5rem;
    }

    .chat-form {
        max-width: 100%;
    }

    .chat-form input {
        padding: 0.75rem 3rem 0.75rem 1rem;
        font-size: 16px;
        /* Prevents zoom on iOS */
    }

    /* Message adjustments */
    .message {
        max-width: 100%;
    }

    .message-content {
        max-width: 90%;
        padding: 0.75rem 1rem;
        font-size: 0.9rem;
    }

    /* Loading indicator */
    .loading-indicator {
        max-width: 100%;
        padding: 0 0.75rem 1rem 0.75rem;
    }
}

/* Hide mobile menu toggle on desktop */
@media screen and (min-width: 769px) {
    .mobile-menu-toggle {
        display: none;
    }

    .sidebar-overlay {
        display: none !important;
    }
}