/* Logo Styles */
.app-logo {
    max-width: 300px;
    height: auto;
    margin-bottom: 20px;
}

.header-logo {
    max-height: 60px;
    height: auto;
    width: auto;
}

.chat-logo {
    max-height: 40px;
    height: auto;
    width: auto;
    margin-right: 10px;
}

/* Tablet Optimizations (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .chat-sidebar {
        width: 250px;
    }
    
    .chat-right-panel {
        width: 250px;
    }
    
    .message {
        max-width: 75%;
    }
    
    #messageInput {
        font-size: 15px;
    }
}

/* Mobile Chat Improvements */
@media (max-width: 768px) {
    /* Hide sidebar on mobile */
    .chat-sidebar {
        display: none !important;
    }
    
    /* Make chat full width on mobile */
    .chat-main {
        width: 100% !important;
        max-width: 100% !important;
    }
    
    /* Mobile chat header */
    .chat-header {
        display: flex;
        align-items: center;
        justify-content: space-between;
        padding: 10px 15px;
        background: white;
        border-bottom: 1px solid #e1e5e9;
        position: sticky;
        top: 0;
        z-index: 100;
    }
    
    .back-button-mobile {
        background: none;
        border: none;
        font-size: 1.5rem;
        color: #667eea;
        cursor: pointer;
        padding: 5px 10px;
        display: flex;
        align-items: center;
        gap: 5px;
        /* Larger tap target */
        min-width: 44px;
        min-height: 44px;
    }
    
    .chat-header-info {
        display: flex;
        align-items: center;
        flex: 1;
        margin: 0 10px;
    }
    
    .chat-topic-mobile {
        display: flex;
        flex-direction: column;
        font-size: 0.85rem;
    }
    
    .topic-day-mobile {
        font-weight: 600;
        color: #667eea;
        font-size: 0.75rem;
    }
    
    .topic-text-mobile {
        color: #666;
        font-size: 0.8rem;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
        max-width: 200px;
    }
    
    /* Show back button on mobile */
    .back-button {
        display: flex !important;
        align-items: center;
        gap: 5px;
        background: none;
        border: none;
        font-size: 1.2rem;
        color: #667eea;
        cursor: pointer;
        padding: 8px 12px;
        border-radius: 6px;
        transition: background-color 0.3s ease;
        min-width: 44px;
        min-height: 44px;
    }
    
    .back-button:active {
        background: rgba(102, 126, 234, 0.2);
    }
    
    .back-text {
        display: none;
    }
    
    .chat-layout {
        display: flex;
        flex-direction: column;
        height: 100vh; /* Full viewport height */
        height: -webkit-fill-available; /* iOS Safari fix */
        position: fixed;
        width: 100%;
        top: 0;
        left: 0;
    }

    .chat-main {
        flex: 1; /* Take up remaining vertical space */
        display: flex;
        flex-direction: column;
        overflow: hidden; /* Hide anything that overflows */
    }

    .chat-messages {
        flex: 1; /* Take up remaining space in chat-main */
        overflow-y: auto; /* Allow vertical scrolling */
        overflow-x: hidden;
        -webkit-overflow-scrolling: touch; /* Smooth scrolling on iOS */
        padding: 15px 10px;
        scroll-behavior: smooth;
    }

    .chat-input-container {
        position: sticky;
        bottom: 0;
        background: rgba(255, 255, 255, 0.98);
        backdrop-filter: blur(10px);
        border-top: 1px solid #e1e5e9;
        padding: 10px;
        box-sizing: border-box;
        /* Fix for iOS keyboard */
        padding-bottom: max(10px, env(safe-area-inset-bottom));
    }

    .chat-header {
        position: sticky;
        top: 0;
        width: 100%;
        z-index: 10;
        /* Fix for iOS notch */
        padding-top: max(10px, env(safe-area-inset-top));
    }
    
    .message {
        max-width: 85%;
        margin-bottom: 15px;
    }
    
    .message-content {
        padding: 12px 15px;
        font-size: 15px;
        line-height: 1.5;
    }
    
    .message-avatar {
        width: 36px;
        height: 36px;
        font-size: 1rem;
    }
    
    /* Mobile input area */
    .chat-input {
        padding: 10px;
        background: white;
        border-top: 1px solid #e1e5e9;
    }
    
    .input-container {
        display: flex;
        gap: 8px;
    }
    
    .input-group {
        width: 100%;
        max-width: 100%;
    }
    
    #messageInput {
        flex: 1;
        padding: 12px;
        font-size: 16px; /* Prevents zoom on iOS */
        min-height: 44px;
        max-height: 120px;
        border-radius: 12px;
    }
    
    #sendButton, #voiceButton {
        min-width: 44px;
        min-height: 44px;
        height: 44px;
        width: 44px;
        padding: 0;
        flex-shrink: 0;
    }
    
    .send-button, .voice-button {
        min-width: 44px !important;
        min-height: 44px !important;
        width: 44px !important;
        height: 44px !important;
    }
    
    /* Icon buttons larger tap targets */
    .icon-button {
        min-width: 44px;
        min-height: 44px;
        font-size: 1.2rem;
    }
    
    /* TTS button */
    .tts-button {
        min-width: 44px;
        min-height: 44px;
        padding: 8px;
        font-size: 1.1rem;
    }
}

/* Desktop styles */
@media (min-width: 769px) {
    .back-button-mobile {
        display: none;
    }
    
    .chat-topic-mobile {
        display: none;
    }
    
    .back-button {
        display: inline-flex;
        align-items: center;
        gap: 8px;
        padding: 10px 20px;
        background: #667eea;
        color: white;
        border: none;
        border-radius: 8px;
        cursor: pointer;
        font-size: 1rem;
        transition: background 0.3s ease;
    }
    
    .back-text {
        display: inline;
    }
    
    .back-button:hover {
        background: #5568d3;
    }
}

/* Typing Indicator */
.typing-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 10px 15px;
    background: #f0f2f5;
    border-radius: 18px;
}

.typing-indicator span {
    width: 8px;
    height: 8px;
    background: #667eea;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

.typing-indicator span:nth-child(2) {
    animation-delay: 0.2s;
}

.typing-indicator span:nth-child(3) {
    animation-delay: 0.4s;
}

@keyframes typing {
    0%, 60%, 100% {
        transform: translateY(0);
        opacity: 0.7;
    }
    30% {
        transform: translateY(-10px);
        opacity: 1;
    }
}

.koko-typing-text {
    font-size: 0.9rem;
    color: #667eea;
    font-style: italic;
    margin-left: 10px;
}

/* Coffee Button Styles */
.coffee-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: linear-gradient(135deg, #ff6b6b 0%, #ff8e53 100%);
    color: white;
    text-decoration: none;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(255, 107, 107, 0.3);
    margin-top: 10px;
}

.coffee-button:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(255, 107, 107, 0.4);
}

.coffee-button i {
    font-size: 1.1rem;
}

/* Coffee button in message bubble */
.message-coffee-button {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 6px 12px;
    background: rgba(255, 107, 107, 0.1);
    color: #ff6b6b;
    text-decoration: none;
    border-radius: 15px;
    font-size: 0.85rem;
    font-weight: 600;
    transition: all 0.3s ease;
    margin-top: 8px;
    border: 1px solid rgba(255, 107, 107, 0.3);
}

.message-coffee-button:hover {
    background: rgba(255, 107, 107, 0.2);
    transform: scale(1.05);
}

/* Coffee section in pages */
.coffee-section {
    background: linear-gradient(135deg, #fff5f5 0%, #ffe5e5 100%);
    padding: 20px;
    border-radius: 15px;
    text-align: center;
    margin: 20px 0;
    border: 2px solid #ff6b6b;
}

.coffee-section h3 {
    color: #ff6b6b;
    margin-bottom: 10px;
    font-size: 1.3rem;
}

.coffee-section p {
    color: #666;
    margin-bottom: 15px;
    font-size: 0.95rem;
}


/* Hide Grammar Assistant on mobile */
@media (max-width: 768px) {
    .chat-desktop-only {
        display: none !important;
    }
    
    .chat-right-panel {
        display: none !important;
    }
}

/* Show Grammar Assistant on desktop */
@media (min-width: 769px) {
    .chat-desktop-only {
        display: block;
    }
}
