/* Auth Overlay Styles */
.auth-overlay {
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
}

.auth-card {
    width: 400px;
    max-width: 90vw;
    background: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 24px;
    box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
}

.auth-card input {
    font-size: 16px;
}

.consent {
    font-size: 12px;
    line-height: 1.4;
}

/* Style settings */
.style-label { 
    display: inline-flex; 
    gap: 8px; 
    align-items: center; 
    font-size: 14px; 
    color: #374151; 
}

#style-select { 
    padding: 8px 10px; 
    border: 1px solid #d9d9db; 
    border-radius: 8px; 
    background: #fff; 
}

/* Send button styling */
#sendButton svg { 
    display: block; 
}

/* ChatGPT-style Message styling */
.msg {
    width: 100%;
    background: transparent;
}

/* Global scaling for better readability (equivalent to 115% zoom) */
html {
    font-size: 115%;
}

/* Reset font-size for desktop to ensure normal size */
@media (min-width: 769px) {
    html {
        font-size: 100% !important; /* Normal desktop size */
    }
    
    .mobile-menu-btn {
        display: none !important; /* Hide hamburger on desktop */
    }
    
    /* Ensure desktop header maintains normal styling */
    .header {
        padding: 16px 24px !important;
        min-height: auto !important;
    }
    
    .header .logo {
        width: 40px !important;
        height: 40px !important;
    }
    
    .header h1 {
        font-size: 32px !important;
        font-weight: bold !important;
    }
    
    .header p {
        display: block !important;
        font-size: 14px !important;
    }
    
    .header .space-x-6 > * {
        font-size: 14px !important;
        margin: 0 24px !important;
        padding: initial !important;
    }
    
    .header .space-x-6 {
        display: flex !important;
    }
    
    .header .flex.items-center.space-x-4 {
        gap: 16px !important;
    }
    
    /* ChatGPT-style chat container mit weißem Rand */
    #chatContainer {
        max-width: 900px !important;
        margin: 24px auto !important;
        padding: 0 !important; /* Kein Container-Padding */
        background: white !important; /* Weißer Hintergrund */
        border-radius: 12px !important;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15) !important; /* Schatten wie ChatGPT */
        border: 1px solid #e5e5e5 !important;
        line-height: 1.6 !important;
        font-size: 16px !important;
        overflow-y: auto !important; /* Vertikales Scrollen erlaubt */
    }
    
    /* ChatGPT-style message styling - kompakte Höhe */
    .msg {
        margin: 0 !important;
        padding: 0 !important; /* Padding wird in content gehandhabt */
        border-bottom: 1px solid #f0f0f0 !important;
        display: flex !important;
        justify-content: center !important;
        min-height: 80px !important; /* Reduzierte Mindesthöhe */
    }
    
    .msg:last-child {
        border-bottom: none !important;
    }
    
    /* ChatGPT-style message content wrapper für Assistant - optimale Größe */
    .msg.assistant .content, .msg-coach-text {
        max-width: none !important; /* Keine Breitenbegrenzung */
        width: 100% !important;
        padding: 20px 120px !important; /* Weniger vertikales Padding, 120px seitlich */
        box-sizing: border-box !important;
        background: transparent !important;
        border: none !important;
        border-radius: 0 !important;
        font-size: 16px !important;
        line-height: 1.6 !important; /* Normaler Zeilenabstand */
        color: #333 !important;
        margin: 0 !important;
        text-align: left !important;
        min-height: 60px !important; /* Deutlich reduzierte Mindesthöhe */
    }
    
    /* User messages styling - blaue Sprechblase rechts */
    .msg.user {
        background: white !important;
        justify-content: flex-end !important; /* Rechts ausrichten */
        padding: 24px 120px !important; /* 120px Abstand für Konsistenz */
    }
    
    .msg.user .content, .msg-user-circle {
        background: #007bff !important; /* Blaue Sprechblase */
        color: white !important;
        border-radius: 18px !important;
        padding: 12px 16px !important;
        max-width: 70% !important;
        width: auto !important; /* Automatische Breite je nach Text */
        display: inline-block !important; /* Nur so breit wie nötig */
        margin: 0 !important;
        box-shadow: 0 1px 2px rgba(0, 123, 255, 0.3) !important;
        word-wrap: break-word !important;
    }
    
    /* Assistant messages - moderate Größe */
    .msg.assistant {
        background: white !important;
        justify-content: flex-start !important;
        padding: 32px 0 !important; /* Moderater vertikaler Abstand */
        min-height: 120px !important; /* Reduzierte Mindesthöhe */
    }
    
    .msg.assistant .content, .msg-coach-text {
        margin-left: 0 !important;
        margin-right: 0 !important;
    }
    
    /* Desktop main content area - ChatGPT style */
    .main-content {
        margin-left: 256px !important;
        padding: 0 !important; /* Kein Padding für ChatGPT-Look */
        background: #f7f7f8 !important; /* Hellgrauer Hintergrund für Kontrast */
        min-height: 100vh !important;
    }
    
    /* Desktop input area styling - ChatGPT style */
    .input-container {
        max-width: 900px !important;
        margin: 0 auto 24px auto !important;
        padding: 16px 24px !important;
        background: white !important;
        border-radius: 0 0 12px 12px !important;
        box-shadow: none !important;
        border-top: 1px solid #e5e5e5 !important;
    }
    
    #messageInput {
        font-size: 16px !important;
        padding: 12px 45px 12px 16px !important;
        line-height: 1.5 !important;
        border: 2px solid #e9ecef !important;
        border-radius: 8px !important;
    }
    
    #messageInput:focus {
        border-color: #007bff !important;
        outline: none !important;
        box-shadow: 0 0 0 3px rgba(0, 123, 255, 0.1) !important;
    }
}

/* Ultra-compact design for small mobile devices */
@media (max-width: 425px) {
    html {
        font-size: 70%; /* Even smaller for 375px */
    }
}

@media (max-width: 375px) {
    html {
        font-size: 65%; /* Ultra small for 375px */
    }
    /* Ultra-compact header for mobile */
    .header {
        padding: 2px 4px !important;
        min-height: 24px !important;
    }
    
    .header .logo {
        width: 16px !important;
        height: 16px !important;
    }
    
    .header h1 {
        font-size: 10px !important;
        font-weight: 600 !important;
    }
    
    .header p {
        display: none !important;
    }
    
    .header .flex.items-center.space-x-4 {
        gap: 2px !important;
    }
    
    .header .space-x-6 > * {
        font-size: 8px !important;
        margin: 0 1px !important;
        padding: 1px 2px !important;
    }
    
    /* Hide all navigation except user info */
    .header .space-x-6 a {
        display: none !important;
    }
    
    .header #userInfo {
        font-size: 8px !important;
    }
    
    /* Mobile hamburger button in header */
    .mobile-menu-btn {
        display: block !important;
        background: none !important;
        border: none !important;
        font-size: 16px !important;
        padding: 4px 6px !important;
        color: #d4af37 !important;
        cursor: pointer !important;
        order: -1 !important; /* Move to left side */
    }
    
    /* Hide desktop navigation on mobile */
    .header .space-x-6 {
        display: none !important;
    }
    
    /* Show user info and hamburger in header */
    .header .mobile-header-controls {
        display: flex !important;
        align-items: center !important;
        gap: 6px !important;
    }
}

/* Tablet and medium mobile devices */
@media (min-width: 426px) and (max-width: 768px) {
    html {
        font-size: 90%; /* Normal mobile size */
    }
    
    /* Mobile header optimization - compact */
    .header {
        padding: 6px 8px !important;
        min-height: 40px !important;
    }
    
    .header .logo {
        width: 24px !important;
        height: 24px !important;
    }
    
    .header h1 {
        font-size: 14px !important;
        font-weight: 600 !important;
    }
    
    .header p {
        display: none !important;
    }
    
    .header .flex.items-center.space-x-4 {
        gap: 8px !important;
    }
    
    .header .space-x-6 > * {
        font-size: 11px !important;
        margin: 0 4px !important;
    }
}

@media (max-width: 768px) {
    /* Mobile sidebar overlay - optimized for all mobile */
    .sidebar {
        position: fixed !important;
        top: 0 !important;
        left: -100% !important;
        width: 240px !important;
        height: 100vh !important;
        background: white !important;
        z-index: 1000 !important;
        transition: left 0.3s ease !important;
        box-shadow: 2px 0 10px rgba(0,0,0,0.1) !important;
    }
    .sidebar.open {
        left: 0 !important;
    }
}

/* Additional optimization for 375px screens */
@media (max-width: 375px) {
    .sidebar {
        width: 220px !important;
    }
    
    /* Make hamburger more visible on 375px */
    .mobile-menu-btn {
        font-size: 18px !important;
        padding: 6px 8px !important;
        background: rgba(212, 175, 55, 0.1) !important;
        border-radius: 4px !important;
    }
    
    .mobile-menu-btn svg {
        width: 18px !important;
        height: 18px !important;
    }
}
    
    /* Mobile overlay for sidebar */
    .sidebar-overlay {
        position: fixed;
        top: 0;
        left: 0;
        width: 100vw;
        height: 100vh;
        background: rgba(0,0,0,0.5);
        z-index: 999;
        display: none;
    }
    
    .sidebar-overlay.active {
        display: block;
    }
    
    /* Mobile main content */
    .main-content {
        margin-left: 0 !important;
        width: 100% !important;
    }
    
    /* Mobile chat container - much more compact */
    #chatContainer {
        max-width: 100% !important;
        margin: 0 !important;
        padding: 4px 6px !important;
    }
    
    /* Ultra-compact chat for 425px */
    #chatContainer {
        padding: 1px 2px !important;
    }
    
    /* Mobile input area - compact */
    .input-container {
        padding: 8px !important;
        position: sticky !important;
        bottom: 0 !important;
        background: white !important;
        border-top: 1px solid #e5e7eb !important;
    }
    
    .input-wrapper {
        max-width: 100% !important;
    }
    
    #messageInput {
        font-size: 14px !important; /* Smaller for compact view */
        padding: 6px 35px 6px 6px !important;
        min-height: 32px !important;
        line-height: 1.2 !important;
    }
    
    /* Ultra-compact input for 425px */
    #messageInput {
        font-size: 10px !important;
        padding: 2px 25px 2px 2px !important;
        min-height: 20px !important;
    }
    
    .input-container {
        padding: 2px !important;
    }
    
    /* Make send button smaller */
    .input-container button {
        width: 20px !important;
        height: 20px !important;
        right: 2px !important;
        bottom: 2px !important;
    }
    
    .input-container button svg {
        width: 12px !important;
        height: 12px !important;
    }
    
    /* Mobile message styling - very compact */
    .msg {
        margin: 4px 0 !important;
        max-width: 100% !important;
    }
    
    .msg.user .content {
        background: #007bff !important;
        color: white !important;
        padding: 3px 5px !important;
        border-radius: 8px 8px 2px 8px !important;
        margin-left: 10% !important;
        font-size: 9px !important;
        line-height: 1.2 !important;
    }
    
    .msg.assistant .content {
        background: #f8f9fa !important;
        border: 1px solid #e9ecef !important;
        padding: 3px 5px !important;
        border-radius: 8px 8px 8px 2px !important;
        margin-right: 10% !important;
        font-size: 9px !important;
        line-height: 1.2 !important;
    }
    
    /* Ultra-compact welcome screen for 425px */
    #welcomeScreen {
        padding: 6px 4px !important;
    }
    
    #welcomeScreen img {
        width: 24px !important;
        height: 24px !important;
        margin-bottom: 3px !important;
    }
    
    #welcomeScreen h2 {
        font-size: 11px !important;
        margin-bottom: 3px !important;
    }
    
    #welcomeScreen p {
        font-size: 8px !important;
        margin-bottom: 4px !important;
        line-height: 1.2 !important;
    }
    
    /* Ultra-compact buttons for 425px */
    #getStartedButton, .btn {
        width: 100% !important;
        padding: 3px 6px !important;
        font-size: 9px !important;
        min-height: 20px !important;
    }
    
    /* Ultra-compact footer for 425px */
    .footer {
        padding: 2px 4px !important;
        min-height: 16px !important;
        font-size: 7px !important;
    }
    
    .footer a {
        font-size: 7px !important;
    }
    
    /* Compact verbosity selector */
    select, .form-select {
        font-size: 8px !important;
        padding: 1px 2px !important;
        height: 18px !important;
    }
    
    /* Hide unnecessary elements to save space */
    .footer p {
        display: none !important;
    }
    
    /* Ensure hidden class works on mobile */
    .hidden {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
        pointer-events: none !important;
    }
    
    /* Mobile settings - compact */
    .settings-container {
        flex-direction: column !important;
        gap: 8px !important;
        padding: 8px !important;
    }
    
    .style-label {
        font-size: 12px !important;
    }
    
    #style-select {
        width: 100% !important;
        padding: 6px 8px !important;
        font-size: 14px !important;
        min-height: 32px !important;
    }
    
    /* Mobile chat header - ultra compact for 425px */
    .bg-white.border-b.border-gray-200.px-6.py-4 {
        padding: 4px 8px 3px 8px !important;
    }
    
    .bg-white.border-b.border-gray-200.px-6.py-4 h2 {
        font-size: 12px !important;
        margin-bottom: 1px !important;
    }
    
    .bg-white.border-b.border-gray-200.px-6.py-4 p {
        font-size: 9px !important;
        margin-top: 1px !important;
    }
    
    /* Ultra-compact coach header for 425px */
    .bg-white.border-b.border-gray-200.px-6.py-4 svg {
        display: none !important;
    }
    
    .bg-white.border-b.border-gray-200.px-6.py-4 p {
        display: none !important;
    }
    
    .bg-white.border-b.border-gray-200.px-6.py-4 {
        padding: 2px 4px !important;
        min-height: 20px !important;
    }
    
    .bg-white.border-b.border-gray-200.px-6.py-4 h2 {
        font-size: 9px !important;
        margin: 0 !important;
        line-height: 1 !important;
    }
    
    /* Mobile analytics notice - very compact */
    .bg-blue-50.border.border-blue-200.rounded-md {
        padding: 6px 8px !important;
        margin-top: 4px !important;
    }
    
    .bg-blue-50 .text-xs {
        font-size: 10px !important;
        line-height: 1.2 !important;
    }
    
    /* Ultra-compact auth card for 425px */
    .auth-card {
        width: 90vw !important;
        max-width: 280px !important;
        padding: 6px !important;
        margin: 0 auto !important;
        position: relative !important;
        top: 50% !important;
        transform: translateY(-50%) !important;
    }
    
    /* Ensure auth overlay respects display: none on mobile */
    .auth-overlay[style*="display: none"] {
        display: none !important;
    }
    
    .auth-overlay:not([style*="display: none"]) {
        display: flex !important;
        align-items: center !important;
        justify-content: center !important;
    }
    
    .auth-card h3 {
        font-size: 12px !important;
        margin-bottom: 6px !important;
    }
    
    .auth-card input {
        font-size: 10px !important;
        padding: 4px 6px !important;
        height: 24px !important;
    }
    
    .auth-card button {
        font-size: 10px !important;
        padding: 4px 8px !important;
        height: 24px !important;
    }
    
    .auth-card h3 {
        font-size: 16px !important;
        margin-bottom: 8px !important;
    }
    
    .auth-card p {
        font-size: 12px !important;
        margin-bottom: 8px !important;
        line-height: 1.3 !important;
    }
    
    .auth-card input {
        font-size: 14px !important;
        padding: 8px 10px !important;
        margin-bottom: 8px !important;
        min-height: 36px !important;
        border-radius: 6px !important;
    }
    
    .auth-card button {
        font-size: 14px !important;
        padding: 8px 12px !important;
        min-height: 36px !important;
        border-radius: 6px !important;
    }
    
    .auth-card .consent {
        font-size: 10px !important;
        line-height: 1.2 !important;
        margin: 6px 0 !important;
    }
    
    .auth-card .consent input[type="checkbox"] {
        width: 12px !important;
        height: 12px !important;
        margin: 0 4px 0 0 !important;
    }
    
    /* Mobile auth step 2 - compact code entry */
    .auth-card #auth-step2 {
        margin-top: 8px !important;
    }
    
    .auth-card #auth-step2 p {
        font-size: 11px !important;
        margin-bottom: 6px !important;
    }
    
    .auth-card #auth-code {
        text-align: center !important;
        letter-spacing: 2px !important;
        font-weight: 600 !important;
    }
    
    .auth-card #auth-hint {
        font-size: 10px !important;
        margin-top: 4px !important;
    }
    
    /* Mobile auth skip section - very compact */
    .auth-card .border-t.border-gray-200 {
        margin-top: 8px !important;
        padding-top: 6px !important;
    }
    
    .auth-card .border-t p {
        font-size: 9px !important;
        margin-bottom: 4px !important;
    }
    
    .auth-card #auth-skip {
        padding: 6px 8px !important;
        font-size: 11px !important;
        min-height: 30px !important;
    }
    
    /* Mobile hamburger menu */
    .hamburger-menu {
        display: block !important;
        background: none;
        border: none;
        font-size: 24px;
        color: #333;
        cursor: pointer;
        padding: 8px;
        margin-right: 12px;
    }
    
    /* Hide desktop elements on mobile */
    .desktop-only {
        display: none !important;
    }
}

/* Desktop: Hide hamburger menu by default */
.hamburger-menu {
    display: none;
}

.msg.user {
    background: transparent;
}

.msg.assistant {
    background: transparent;
}

/* Old message styles - completely disabled */
.msg-content,
.msg-avatar,
.msg-text {
    display: none !important;
}

/* Sidebar Styles */
.chat-history-item {
    transition: all 0.2s ease;
    border-radius: 6px;
    padding: 8px 12px;
    margin: 2px 0;
    cursor: pointer;
    border: 1px solid transparent;
}

.chat-history-item:hover {
    background-color: #f3f4f6;
    border-color: #e5e7eb;
}

.chat-history-item.active,
.chat-history-item.bg-gray-700 {
    background-color: #e5e7eb;
    border-color: #d1d5db;
}

.chat-history-item .chat-title {
    font-size: 0.875rem;
    font-weight: 500;
    color: #111827;
    line-height: 1.25rem;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-history-item .chat-meta {
    font-size: 0.75rem;
    color: #6b7280;
    margin-top: 2px;
}

/* Custom scrollbar for sidebar */
#chatHistory::-webkit-scrollbar {
    width: 6px;
}

#chatHistory::-webkit-scrollbar-track {
    background: #f9fafb;
    border-radius: 3px;
}

#chatHistory::-webkit-scrollbar-thumb {
    background: #d1d5db;
    border-radius: 3px;
}

#chatHistory::-webkit-scrollbar-thumb:hover {
    background: #9ca3af;
}

/* Context menu styles */
.context-menu {
    position: absolute;
    background: white;
    border: 1px solid #e5e7eb;
    border-radius: 6px;
    box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
    padding: 4px 0;
    min-width: 120px;
    z-index: 1000;
}

.context-menu-item {
    padding: 8px 12px;
    cursor: pointer;
    font-size: 0.875rem;
    color: #374151;
    display: flex;
    align-items: center;
    gap: 8px;
}

.context-menu-item:hover {
    background-color: #f3f4f6;
}

.context-menu-item.delete {
    color: #dc2626;
}

.context-menu-item.delete:hover {
    background-color: #fef2f2;
}

/* New chat layout - User messages in circles on right, Coach as plain text on left */

/* User message bubble on right */
.msg-user-right {
    display: flex;
    justify-content: flex-end;
    margin: 1.1rem auto;
    padding-right: 1.6rem;
    max-width: 800px;
}

.msg-user-circle {
    background: linear-gradient(135deg, #3b82f6 0%, #6366f1 100%);
    color: white;
    border-radius: 20px;
    padding: 0.9rem 1.2rem;
    max-width: 320px;
    min-width: 90px;
    font-size: 1rem;
    line-height: 1.45;
    box-shadow: 0 2px 9px rgba(59, 130, 246, 0.3);
    word-wrap: break-word;
}

/* Coach message plain text on left */
.msg-coach-left {
    display: flex;
    justify-content: flex-start;
    margin: 1.6rem auto;
    padding-left: 1.6rem;
    padding-right: 1.6rem;
    max-width: 800px;
    background: transparent;
}

.msg-coach-text {
    max-width: 100%;
    color: #374151;
    line-height: 1.75;
    font-size: 1.05rem;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

.msg-coach-text p {
    margin: 0 0 1rem 0;
}

.msg-coach-text p:last-child {
    margin-bottom: 0;
}

.msg-coach-text ul, .msg-coach-text ol {
    margin: 1rem 0;
    padding-left: 1.5rem;
}

.msg-coach-text li {
    margin: 0.5rem 0;
    line-height: 1.6;
}

.msg-coach-text strong {
    font-weight: 600;
    color: #111827;
}

.msg-coach-text a {
    color: #2563eb;
    text-decoration: none;
    border-bottom: 1px solid transparent;
    transition: border-bottom-color 0.2s;
}

.msg-coach-text a:hover {
    border-bottom-color: #2563eb;
}

/* Hide ALL old message styles */
.msg .bubble,
.msg .avatar,
.msg-content,
.msg-avatar,
.msg-text {
    display: none !important;
}

.chat-container {
    height: 400px;
    overflow-y: auto;
}

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

.chat-container::-webkit-scrollbar-track {
    background: #f1f5f9;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: #94a3b8;
}

/* Smooth animations */
.fade-in {
    animation: fadeIn 0.3s ease-in-out;
}

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

/* Message animations */
.message-appear {
    animation: messageAppear 0.4s ease-out;
}

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

/* Loading pulse */
.loading-pulse {
    animation: pulse 1.5s ease-in-out infinite;
}

@keyframes pulse {
    0%, 100% { opacity: 1; }
    50% { opacity: 0.6; }
}

/* Button hover effects */
.button-hover-scale {
    transition: transform 0.2s ease-in-out;
}

.button-hover-scale:hover {
    transform: scale(1.02);
}

/* Focus styles for accessibility */
.focus-visible {
    outline: 2px solid #3B82F6;
    outline-offset: 2px;
}

/* Responsive adjustments */
@media (max-width: 640px) {
    .chat-container {
        height: 300px;
    }
}
