/* Reset and Base Styles */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Top Navigation */
.top-nav {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-bottom: 1px solid rgba(255, 255, 255, 0.2);
    padding: 0.75rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.nav-container {
    max-width: 800px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    align-items: center;
    gap: 1rem;
}

.nav-home {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    text-decoration: none;
    color: #333;
    font-weight: 600;
    font-size: 1.1rem;
    transition: all 0.3s ease;
    padding: 0.5rem 1rem;
    border-radius: 8px;
}

.nav-home:hover {
    background: rgba(102, 126, 234, 0.1);
    color: #667eea;
    transform: translateY(-1px);
}

.nav-icon {
    font-size: 1.2rem;
}

.nav-breadcrumb {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    color: #666;
    font-size: 0.9rem;
}

.breadcrumb-separator {
    color: #999;
    font-weight: 300;
}

.current-tool {
    color: #667eea;
    font-weight: 500;
}

body {
    font-family: 'Poppins', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
    overflow-x: hidden;
}

.app-container {
    max-width: 800px;
    margin: 0 auto;
    min-height: 100vh;
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    box-shadow: 0 0 30px rgba(0, 0, 0, 0.1);
}

/* Header */
.app-header {
    text-align: center;
    padding: 1.5rem 1rem;
    background: linear-gradient(135deg, #ff6b6b, #feca57);
    color: white;
    position: relative;
    overflow: hidden;
}

.app-header::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: url('data:image/svg+xml,<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 100 100"><circle cx="50" cy="50" r="2" fill="rgba(255,255,255,0.1)"/></svg>') repeat;
    animation: float 20s infinite linear;
}

@keyframes float {
    0% { transform: translateX(-50px) translateY(-50px); }
    100% { transform: translateX(50px) translateY(50px); }
}

.app-header h1 {
    font-size: 2.5rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
    position: relative;
    z-index: 1;
}

.app-header p {
    font-size: 1.1rem;
    opacity: 0.9;
    position: relative;
    z-index: 1;
}

/* Character Selection */
.character-selection {
    padding: 1.5rem 1rem;
}

.character-selection h2 {
    text-align: center;
    margin-bottom: 1.5rem;
    font-size: 1.6rem;
    color: #444;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 1.5rem;
    max-width: 900px;
    margin: 0 auto;
}

.character-card {
    background: white;
    border-radius: 20px;
    padding: 1.5rem 1.2rem;
    text-align: center;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
    cursor: pointer;
    transition: all 0.3s ease;
    border: 3px solid transparent;
    position: relative;
    overflow: hidden;
}

.character-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255, 255, 255, 0.4), transparent);
    transition: left 0.5s;
}

.character-card:hover::before {
    left: 100%;
}

.character-card:hover {
    transform: translateY(-10px);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
}

.character-card[data-character="pirate"]:hover {
    border-color: #e74c3c;
}

.character-card[data-character="caveman"]:hover {
    border-color: #8b4513;
}

.character-card[data-character="grandpa"]:hover {
    border-color: #2c3e50;
}

.character-card[data-character="valley"]:hover {
    border-color: #e91e63;
}

.character-avatar {
    font-size: 3.5rem;
    margin-bottom: 0.8rem;
    display: block;
}

.character-card h3 {
    font-size: 1.4rem;
    margin-bottom: 0.5rem;
    color: #333;
}

.character-card p {
    color: #666;
    font-size: 0.9rem;
    line-height: 1.4;
}

/* Chat Container */
.chat-container {
    height: 100vh;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.chat-header {
    background: white;
    padding: 1rem;
    border-bottom: 1px solid #eee;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
}

.character-info {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.character-avatar-small {
    font-size: 2.5rem;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 3px solid #e9ecef;
}

.character-details h3 {
    font-size: 1.2rem;
    margin-bottom: 0.2rem;
}

.status-indicator {
    color: #28a745;
    font-size: 0.8rem;
    font-weight: 500;
}

.status-indicator::before {
    content: '●';
    margin-right: 0.3rem;
}

.back-button {
    background: #6c757d;
    color: white;
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 20px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: background 0.3s ease;
}

.back-button:hover {
    background: #5a6268;
}

/* Messages */
.messages-container {
    flex: 1;
    overflow-y: auto;
    padding: 1rem;
    background: #f8f9fa;
    min-height: 0; /* Important for flex child to shrink */
}

.message {
    display: flex;
    margin-bottom: 1.5rem;
    animation: slideIn 0.3s ease;
}

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

.message-avatar {
    font-size: 2rem;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    background: white;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-right: 1rem;
    flex-shrink: 0;
    border: 2px solid #e9ecef;
}

.user-message {
    flex-direction: row-reverse;
}

.user-message .message-avatar {
    background: #007bff;
    color: white;
    margin-right: 0;
    margin-left: 1rem;
}

.message-content {
    background: white;
    padding: 1rem 1.2rem;
    border-radius: 20px;
    max-width: 70%;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    position: relative;
}

.user-message .message-content {
    background: #007bff;
    color: white;
}

.message-content p {
    margin-bottom: 0.5rem;
    line-height: 1.4;
}

.message-time {
    font-size: 0.7rem;
    opacity: 0.7;
    display: block;
}

/* Input Area */
.input-container {
    background: white;
    padding: 1rem;
    border-top: 1px solid #eee;
}

.input-wrapper {
    display: flex;
    gap: 0.5rem;
    align-items: center;
}

#messageInput {
    flex: 1;
    padding: 1rem 1.2rem;
    border: 2px solid #e9ecef;
    border-radius: 25px;
    font-size: 1rem;
    outline: none;
    transition: border-color 0.3s ease;
}

#messageInput:focus {
    border-color: #007bff;
}

.send-button {
    background: #007bff;
    color: white;
    border: none;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.send-button:hover {
    background: #0056b3;
    transform: scale(1.1);
}

.send-button:disabled {
    background: #6c757d;
    cursor: not-allowed;
    transform: none;
}

.input-footer {
    text-align: center;
    margin-top: 0.5rem;
}

.input-footer small {
    color: #6c757d;
    font-size: 0.8rem;
}

/* Footer */
.app-footer {
    background: #2c3e50;
    color: white;
    text-align: center;
    padding: 2rem 1rem;
}

.social-links {
    margin-top: 1rem;
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-links a {
    color: white;
    font-size: 1.5rem;
    transition: color 0.3s ease;
}

.social-links a:hover {
    color: #3498db;
}

/* Loading Indicator */
.loading-indicator {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: white;
    padding: 2rem;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    text-align: center;
    z-index: 1000;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #007bff;
    border-radius: 50%;
    animation: spin 1s linear infinite;
    margin: 0 auto 1rem;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Desktop Optimization */
@media (min-width: 1200px) {
    .app-container {
        max-width: 1000px;
        height: 100vh;
        overflow: hidden;
        display: flex;
        flex-direction: column;
    }

    .app-header {
        padding: 1.5rem 1rem;
        flex-shrink: 0;
    }

    .app-header h1 {
        font-size: 2.2rem;
        margin-bottom: 0.3rem;
    }

    .character-selection {
        padding: 1.5rem 1rem;
        flex: 1;
        overflow-y: auto;
        display: flex;
        flex-direction: column;
    }

    .character-selection h2 {
        font-size: 1.6rem;
        margin-bottom: 1.5rem;
    }

    .character-grid {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 1.2rem;
        max-width: 800px;
        margin: 0 auto;
    }

    .character-card {
        padding: 1.5rem 1rem;
    }

    .character-avatar {
        font-size: 3rem;
        margin-bottom: 0.8rem;
    }

    .character-card h3 {
        font-size: 1.2rem;
        margin-bottom: 0.4rem;
    }

    .character-card p {
        font-size: 0.85rem;
    }

    .app-footer {
        padding: 1.5rem 1rem;
        flex-shrink: 0;
    }

    .chat-container {
        height: 100vh;
        max-height: 100vh;
        border-radius: 0;
        overflow: hidden;
        box-shadow: none;
        margin: 0;
    }

    .chat-header {
        border-radius: 0;
        padding: 0.8rem 1rem;
    }

    .messages-container {
        max-height: calc(100vh - 120px); /* Subtract header and input heights */
    }

    .input-container {
        border-radius: 0;
        padding: 0.8rem 1rem;
    }
}

/* Responsive Design */
@media (max-width: 768px) {
    .app-header h1 {
        font-size: 2rem;
    }
    
    .character-grid {
        grid-template-columns: 1fr;
        gap: 1rem;
    }
    
    .character-card {
        padding: 1.5rem 1rem;
    }
    
    .chat-header {
        padding: 0.8rem;
    }
    
    .character-avatar-small {
        width: 50px;
        height: 50px;
        font-size: 2rem;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .back-button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    .app-container {
        margin: 0;
        border-radius: 0;
    }
    
    .app-header {
        padding: 1.5rem 1rem;
    }
    
    .character-selection {
        padding: 1.5rem 1rem;
    }
    
    .message-content {
        max-width: 90%;
        padding: 0.8rem 1rem;
    }
    
    .input-container {
        padding: 0.8rem;
    }
}
