/* assets/css/style.css */

:root {
    /* Palette */
    --bg-primary: #FFFFFF;
    --text-primary: #1A1A1A;
    --text-secondary: #666666;
    --action-primary: #0056B3;
    --action-hover: #004494;
    --accent-light: #E6F0FF;
    --border-color: #E0E0E0;
    --error-color: #D32F2F;

    /* Typography */
    --font-stack: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    --font-size-base: 16px;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-stack);
    background-color: var(--bg-primary);
    color: var(--text-primary);
    font-size: var(--font-size-base);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}

a {
    color: var(--action-primary);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: var(--action-hover);
}

/* Auth / Centered Layout */
.auth-container {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 20px;
    background-color: #FAFAFA;
    /* Slight contrast for auth pages */
}

.card {
    background: white;
    padding: 40px;
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    width: 100%;
    max-width: 400px;
    border: 1px solid var(--border-color);
}

.card h1 {
    font-size: 24px;
    margin-bottom: 8px;
    font-weight: 600;
    text-align: center;
}

.card h2 {
    font-size: 14px;
    color: var(--text-secondary);
    margin-bottom: 32px;
    font-weight: 400;
    text-align: center;
}

/* Forms */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 6px;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: var(--action-primary);
    box-shadow: 0 0 0 3px var(--accent-light);
}

.btn {
    display: inline-block;
    width: 100%;
    padding: 12px;
    background-color: var(--action-primary);
    color: white;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s;
}

.btn:hover {
    background-color: var(--action-hover);
}

.btn-secondary {
    background-color: white;
    color: var(--text-primary);
    border: 1px solid var(--border-color);
    margin-top: 10px;
}

.btn-secondary:hover {
    background-color: #f5f5f5;
    color: var(--text-primary);
}

.error-msg {
    color: var(--error-color);
    font-size: 13px;
    margin-bottom: 15px;
    text-align: center;
}

/* Character Selection Grid */
.char-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 24px;
    max-width: 1000px;
    margin: 0 auto;
}

.char-card {
    background: white;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    overflow: hidden;
    transition: transform 0.2s, box-shadow 0.2s;
    cursor: pointer;
}

.char-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.08);
    border-color: var(--action-primary);
}

.char-img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    background-color: var(--accent-light);
}

.char-info {
    padding: 20px;
}

.char-name {
    font-weight: 600;
    font-size: 18px;
    margin-bottom: 8px;
}

.char-desc {
    font-size: 14px;
    color: var(--text-secondary);
    line-height: 1.4;
    margin-bottom: 16px;
}

/* Chat Layout */
.chat-layout {
    display: flex;
    height: 100vh;
    height: 100dvh;
    /* Dynamic Viewport Height for Mobile */
    width: 100%;
    overflow: hidden;
    /* Prevent body scroll */
}

.sidebar {
    width: 260px;
    background: #f9f9f9;
    border-right: 1px solid var(--border-color);
    padding: 20px;
    display: flex;
    flex-direction: column;
}

.main-chat {
    flex: 1;
    display: flex;
    flex-direction: column;
    background: white;
}

.chat-header {
    height: 60px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    align-items: center;
    padding: 0 24px;
    font-weight: 600;
}

.chat-messages {
    flex: 1;
    padding: 24px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.message {
    max-width: 480px;
    line-height: 1.5;
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 15px;
    position: relative;
    word-wrap: break-word;
    /* Ensure long words break */
    overflow-wrap: break-word;
}

.message.user {
    align-self: flex-end;
    background-color: var(--action-primary);
    color: white;
    border-bottom-right-radius: 2px;
}

.message.ai {
    align-self: flex-start;
    background-color: var(--accent-light);
    color: var(--text-primary);
    border-bottom-left-radius: 2px;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    position: relative;
    max-width: 800px;
    margin: 0 auto;
}

.chat-textarea {
    width: 100%;
    padding: 14px 50px 14px 16px;
    border: 1px solid var(--border-color);
    border-radius: 8px;
    resize: none;
    height: 52px;
    font-family: inherit;
    font-size: 15px;
}

.chat-textarea:focus {
    outline: none;
    border-color: var(--action-primary);
}

.send-btn {
    position: absolute;
    right: 8px;
    top: 8px;
    background: none;
    border: none;
    color: var(--action-primary);
    cursor: pointer;
    padding: 8px;
}

/* Typing Indicator */
.typing-indicator {
    display: inline-block;
    padding: 12px 16px;
    background-color: var(--accent-light);
    border-radius: 12px;
    border-bottom-left-radius: 2px;
    font-size: 12px;
    color: var(--text-secondary);
    animation: fadeIn 0.3s;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(5px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* Mobile Responsiveness */
.mobile-menu-btn {
    display: none;
    background: none;
    border: none;
    cursor: pointer;
    padding: 0;
    margin-right: 12px;
    color: var(--text-primary);
}

.mobile-close-btn {
    display: none;
    background: none;
    border: none;
    font-size: 24px;
    cursor: pointer;
    color: var(--text-secondary);
}

.sidebar-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 900;
    opacity: 0;
    transition: opacity 0.3s;
}

.sidebar-overlay.active {
    opacity: 1;
}

@media (max-width: 768px) {
    .chat-layout {
        position: relative;
        overflow: hidden;
    }

    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        bottom: 0;
        width: 280px;
        z-index: 1000;
        transform: translateX(-100%);
        transition: transform 0.3s ease;
        border-right: none;
        box-shadow: 2px 0 8px rgba(0, 0, 0, 0.1);
    }

    .sidebar.active {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
        pointer-events: none;
    }

    .sidebar-overlay.active {
        pointer-events: auto;
    }

    .mobile-menu-btn {
        display: block;
    }

    .mobile-close-btn {
        display: block;
    }

    .main-chat {
        width: 100%;
    }

    .chat-header {
        padding-left: 16px;
    }
}