/**
 * Chat Page Styles for Tamil Learning Chatbot
 */

/* Override base styles for chat layout */
html, body {
    overflow: hidden;
}

.app {
    display: flex;
    flex-direction: row !important;
    height: 100vh;
    height: 100dvh;
    max-width: none !important;
    margin: 0 !important;
    overflow: hidden;
}

/* ============================================
   SIDEBAR
   ============================================ */
.sidebar {
    width: 280px;
    min-width: 280px;
    background: var(--bg-card);
    border-right: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    transition: transform 0.3s ease;
    z-index: 100;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 24px 20px;
    border-bottom: 1px solid var(--border);
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.sidebar-controls {
    display: flex;
    gap: 8px;
    align-items: center;
}

.sidebar-controls .language-select {
    flex: 1;
    padding: 8px 10px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-input);
    color: var(--text-primary);
    font-size: 0.85em;
    cursor: pointer;
    transition: border-color 0.2s;
}

.sidebar-controls .language-select:hover {
    border-color: var(--primary);
}

.sidebar-controls .theme-toggle {
    width: 36px;
    height: 36px;
    border: 1px solid var(--border);
    background: var(--bg-input);
    border-radius: 8px;
    cursor: pointer;
    font-size: 1.1em;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.sidebar-controls .theme-toggle:hover {
    border-color: var(--primary);
    background: linear-gradient(135deg, rgba(139, 92, 246, 0.1), rgba(244, 114, 182, 0.1));
}

.sidebar-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    color: inherit;
    text-align: center;
}

.sidebar-logo .logo {
    width: 48px;
    height: 48px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 12px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.6em;
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.sidebar-logo .logo-icon {
    width: 56px;
    height: 56px;
    object-fit: contain;
}

.sidebar-logo .logo-text h1 {
    font-size: 1.4em;
    margin: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-logo .logo-text p {
    font-size: 0.7em;
    color: var(--text-secondary);
    margin: 4px 0 0 0;
}

.sidebar-content {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
}

.sidebar-section {
    margin-bottom: 24px;
}

.sidebar-section-title {
    font-size: 0.75em;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--text-secondary);
    margin-bottom: 12px;
    padding-left: 4px;
}

/* Age Control */
.age-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 16px;
}

.age-control label {
    display: block;
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.age-input-row {
    display: flex;
    align-items: center;
    gap: 12px;
}

.age-control input {
    width: 70px;
    padding: 10px 12px;
    border: 1px solid var(--border);
    border-radius: 8px;
    background: var(--bg-card);
    color: var(--text-primary);
    font-size: 1.1em;
    font-weight: 600;
    text-align: center;
}

.age-control input:focus {
    outline: none;
    border-color: var(--primary);
}

.age-badge {
    font-size: 0.9em;
    padding: 8px 12px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border-radius: 20px;
    font-weight: 500;
}

/* Theme Control */
.theme-control {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 12px;
    padding: 12px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    cursor: pointer;
    transition: all 0.2s;
}

.theme-control:hover {
    border-color: var(--primary);
}

.theme-control-label {
    display: flex;
    align-items: center;
    gap: 10px;
    color: var(--text-primary);
    font-size: 0.95em;
}

.theme-switch {
    width: 50px;
    height: 26px;
    background: var(--border);
    border-radius: 13px;
    position: relative;
    transition: background 0.3s;
}

.theme-switch::after {
    content: '';
    position: absolute;
    width: 22px;
    height: 22px;
    background: white;
    border-radius: 50%;
    top: 2px;
    left: 2px;
    transition: transform 0.3s;
    box-shadow: 0 2px 4px rgba(0,0,0,0.2);
}

[data-theme="light"] .theme-switch {
    background: var(--primary);
}

[data-theme="light"] .theme-switch::after {
    transform: translateX(24px);
}

/* Auth Buttons */
.sidebar-auth-btn {
    display: block;
    padding: 12px 16px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 10px;
    color: var(--text-primary);
    text-decoration: none;
    font-size: 0.9em;
    text-align: center;
    transition: all 0.2s;
    margin-bottom: 8px;
}

.sidebar-auth-btn:hover {
    border-color: var(--primary);
    background: var(--bg-card);
}

.sidebar-auth-btn.profile {
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border: none;
}

.sidebar-auth-btn.profile:hover {
    opacity: 0.9;
    transform: translateY(-1px);
}

.sidebar-auth-btn.logout {
    color: var(--danger);
    border-color: rgba(239, 68, 68, 0.3);
    margin-bottom: 0;
}

.sidebar-auth-btn.logout:hover {
    background: rgba(239, 68, 68, 0.1);
}

.user-email {
    font-size: 0.85em;
    color: var(--text-secondary);
    margin-bottom: 12px;
    word-break: break-all;
}

/* New Chat Button */
.new-chat-btn {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border: none;
    border-radius: 12px;
    color: white;
    font-size: 0.95em;
    font-weight: 600;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    transition: all 0.2s;
}

.new-chat-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.4);
}

/* Sidebar Footer */
.sidebar-auth {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.sidebar-auth .sidebar-section-title {
    margin-bottom: 12px;
}

.sidebar-footer {
    padding: 16px 20px;
    border-top: 1px solid var(--border);
}

.sidebar-links {
    display: flex;
    flex-wrap: wrap;
    gap: 8px 16px;
    justify-content: center;
}

.sidebar-links a {
    font-size: 0.8em;
    color: var(--text-secondary);
    text-decoration: none;
    transition: color 0.2s;
}

.sidebar-links a:hover {
    color: var(--primary);
}

/* Mobile Menu */
.menu-toggle {
    display: none;
    position: fixed;
    top: 16px;
    left: 16px;
    z-index: 200;
    width: 44px;
    height: 44px;
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-radius: 12px;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.3em;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0,0,0,0.5);
    z-index: 90;
}

/* ============================================
   MAIN CONTENT
   ============================================ */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    min-width: 0;
    min-height: 0;
    height: 100%;
    background: var(--bg-main);
}

/* Mobile Header */
.mobile-header {
    display: none;
    padding: 14px 16px 14px 70px;
    background: var(--bg-card);
    border-bottom: 1px solid var(--border);
    align-items: center;
    gap: 10px;
    flex-shrink: 0;
}

.mobile-header .mobile-logo {
    font-size: 1.4em;
}

.mobile-header .mobile-logo-icon {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.mobile-header h1 {
    font-size: 1.2em;
    margin: 0;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

/* ============================================
   CHAT AREA
   ============================================ */
.chat-container {
    flex: 1 1 0;
    min-height: 0;
    overflow-y: auto;
    padding: 25px;
    background: var(--bg-main);
    scroll-behavior: smooth;
    transition: background 0.3s;
}

.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: var(--bg-main);
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--border);
    border-radius: 3px;
}

/* Messages */
.message {
    max-width: 75%;
    margin-bottom: 20px;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

.message.user {
    margin-left: auto;
}

.message-content {
    padding: 16px 20px;
    border-radius: 20px;
    line-height: 1.7;
    font-size: 1em;
    transition: background 0.3s, border-color 0.3s;
}

.user .message-content {
    background: var(--user-msg-bg);
    border-bottom-right-radius: 6px;
    color: var(--user-msg-text);
}

.bot .message-content {
    background: var(--bg-card);
    border: 1px solid var(--border);
    border-bottom-left-radius: 6px;
    position: relative;
}

.bot-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 12px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border);
}

.bot-name {
    display: flex;
    align-items: center;
    gap: 8px;
    font-weight: 600;
    color: var(--accent);
    font-size: 0.9em;
}

.bot-avatar {
    width: 28px;
    height: 28px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.9em;
}

.bot-avatar-img {
    width: 28px;
    height: 28px;
    object-fit: contain;
}

.copy-btn {
    background: var(--bg-input);
    border: 1px solid var(--border);
    color: var(--text-secondary);
    padding: 5px 10px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.8em;
    transition: all 0.2s;
    opacity: 0;
}

.message:hover .copy-btn {
    opacity: 1;
}

.copy-btn:hover {
    background: var(--border);
    color: var(--text-primary);
}

.copy-btn.copied {
    background: var(--success);
    border-color: var(--success);
    color: white;
}

.bot-text {
    color: var(--text-primary);
}

/* Typing Indicator */
.typing-indicator {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 12px 16px;
    background: var(--bg-card);
    border-radius: 20px;
    border: 1px solid var(--border);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--accent);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 60%, 100% { transform: translateY(0); opacity: 0.4; }
    30% { transform: translateY(-8px); opacity: 1; }
}

/* Welcome Message */
.welcome-message {
    text-align: center;
    padding: 60px 20px;
}

.welcome-icon {
    font-size: 4em;
    margin-bottom: 20px;
}

.welcome-logo {
    width: 100px;
    height: 100px;
    object-fit: contain;
    margin-bottom: 20px;
}

.welcome-message h2 {
    font-size: 2em;
    margin-bottom: 10px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.welcome-message p {
    color: var(--text-secondary);
    font-size: 1.1em;
}

.welcome-hint {
    color: var(--text-secondary);
    font-size: 0.95em;
    margin-top: 10px;
}

/* Example Questions */
.example-questions {
    margin-top: 24px;
    text-align: center;
}

.example-title {
    font-size: 0.9em;
    color: var(--text-secondary);
    margin-bottom: 12px;
}

.example-chips {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    justify-content: center;
    max-width: 500px;
    margin: 0 auto;
}

.example-chip {
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 20px;
    padding: 10px 16px;
    font-size: 0.9em;
    color: var(--text);
    cursor: pointer;
    transition: all 0.2s ease;
    font-family: inherit;
}

.example-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(var(--primary-rgb), 0.3);
}

/* Disclaimer */
.disclaimer {
    text-align: center;
    padding: 10px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    font-size: 0.75em;
    color: var(--text-secondary);
    flex-shrink: 0;
}

/* ============================================
   INPUT AREA
   ============================================ */
.input-container {
    padding: 20px 25px;
    background: var(--bg-card);
    border-top: 1px solid var(--border);
    flex-shrink: 0;
}

.input-wrapper {
    display: flex;
    gap: 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 8px;
    transition: border-color 0.3s;
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 12px 16px;
    font-size: 1em;
    color: var(--text-primary);
    outline: none;
    font-family: inherit;
    resize: none;
    min-height: 24px;
    max-height: 150px;
    line-height: 1.5;
    overflow-y: auto;
}

.input-wrapper textarea::placeholder {
    color: var(--text-secondary);
}

.btn-group {
    display: flex;
    gap: 8px;
}

/* ============================================
   CHAT SESSIONS
   ============================================ */
.new-session-btn {
    width: 100%;
    padding: 10px 14px;
    background: linear-gradient(135deg, var(--primary) 0%, var(--accent) 100%);
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 0.9em;
    cursor: pointer;
    margin-bottom: 12px;
    transition: transform 0.2s, box-shadow 0.2s;
}

.new-session-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 15px rgba(139, 92, 246, 0.3);
}

.chat-sessions-list {
    display: flex;
    flex-direction: column;
    gap: 8px;
    max-height: 200px;
    overflow-y: auto;
}

.session-item {
    padding: 10px 12px;
    background: var(--bg-input);
    border: 1px solid var(--border);
    border-radius: 8px;
    cursor: pointer;
    transition: background 0.2s, border-color 0.2s;
}

.session-item:hover {
    background: var(--bg-card);
    border-color: var(--primary);
}

.session-item.active {
    border-color: var(--primary);
    background: rgba(139, 92, 246, 0.1);
}

.session-title {
    font-size: 0.9em;
    color: var(--text-primary);
    margin-bottom: 4px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.session-meta {
    font-size: 0.75em;
    color: var(--text-secondary);
}

/* ============================================
   RESPONSIVE
   ============================================ */
@media (max-width: 900px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        bottom: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    .menu-toggle {
        display: flex;
    }
    
    .mobile-header {
        display: flex;
    }
    
    .message {
        max-width: 90%;
    }
}

@media (max-width: 480px) {
    .sidebar {
        width: 100%;
    }
    
    .chat-container {
        padding: 15px;
    }
    
    .input-container {
        padding: 12px;
    }
    
    .message {
        max-width: 95%;
    }
    
    .btn span {
        display: none;
    }
    
    .input-mode-toggle {
        margin-right: 4px;
    }
    
    .mode-btn {
        padding: 6px 8px;
    }
}

/* ============================================
   UTILITY CLASSES
   ============================================ */
.hidden {
    display: none !important;
}

/* ============================================
   GUEST LIMIT MODAL & WARNING
   ============================================ */
.guest-limit-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    animation: fadeIn 0.3s ease;
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

.guest-limit-content {
    background: var(--bg-card);
    border-radius: 20px;
    padding: 40px;
    max-width: 400px;
    text-align: center;
    position: relative;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease;
}

@keyframes slideUp {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.guest-limit-icon {
    font-size: 4em;
    margin-bottom: 16px;
}

.guest-limit-content h3 {
    color: var(--text-primary);
    font-size: 1.5em;
    margin-bottom: 12px;
}

.guest-limit-content p {
    color: var(--text-secondary);
    margin-bottom: 8px;
    line-height: 1.6;
}

.guest-limit-buttons {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    justify-content: center;
}

.guest-limit-buttons .btn-primary,
.guest-limit-buttons .btn-secondary {
    padding: 12px 28px;
    border-radius: 12px;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s;
}

.guest-limit-buttons .btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--accent));
    color: white;
}

.guest-limit-buttons .btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(139, 92, 246, 0.4);
}

.guest-limit-buttons .btn-secondary {
    background: var(--bg-input);
    color: var(--text-primary);
    border: 1px solid var(--border);
}

.guest-limit-buttons .btn-secondary:hover {
    border-color: var(--primary);
}

.guest-limit-content .btn-close {
    position: absolute;
    top: 16px;
    right: 16px;
    background: none;
    border: none;
    color: var(--text-secondary);
    font-size: 1.2em;
    cursor: pointer;
    padding: 4px 8px;
}

.guest-limit-content .btn-close:hover {
    color: var(--text-primary);
}

/* Guest warning banner */
.guest-warning {
    background: linear-gradient(135deg, #f59e0b, #d97706);
    color: white;
    padding: 10px 16px;
    text-align: center;
    font-size: 0.9em;
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.guest-warning a {
    color: white;
    font-weight: 600;
    text-decoration: underline;
}

.guest-warning a:hover {
    text-decoration: none;
}
