:root {
    --PRIMARY_COLOR: #b458ff
}

/*
------------------------------------------
        MAIN CONTENT
------------------------------------------
*/

html, body {
    height: 100%;
    margin: 0;
    padding: 0;
}

body {
    background-color: #f4f5f7;
    color: #111827;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
    display: flex;
    justify-content: center;
    align-items: center;
}

.content {
    width: 100%;
    max-width: 900px;
    height: 100%;
    box-sizing: border-box;
    overflow-y: auto;
}

/* Character Grid Layout */
.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 1.5rem;
    padding: 0 2rem 2rem 2rem;
}

.character-card {
    background: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.04);
    transition: transform 0.2s, box-shadow 0.2s;
}

.character-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 6px 16px rgba(0, 0, 0, 0.08);
}

.card-banner {
    width: 100%;
    aspect-ratio: 5 / 4;
    background-size: cover;
    background-position: center;
    background-color: #4f46e5;
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    font-size: 2.5rem;
    font-weight: 700;
}

.card-body {
    padding: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    flex: 1;
}

.card-stats {
    display: flex;
    gap: 1rem;
    font-size: 0.85rem;
    color: #6b7280;
}

.card-stats span {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

/* Chat list */

#chatlist-container {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    overflow-y: auto;
    max-height: calc(100vh - 300px);
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.chatlist-card {
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 8px;
    padding: 0.625rem 0.75rem;
    cursor: pointer;
    transition: all 0.2s ease-in-out;
    text-decoration: none;
    display: block;
}

.chatlist-card:hover {
    background-color: #f9fafb;
    border-color: #d1d5db;
    transform: translateX(2px);
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.02);
}

.chatlist-card-body {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.chatlist-avatar {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    background-color: #4f46e5;
    color: #ffffff;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.875rem;
    font-weight: 600;
    flex-shrink: 0;
}

.chatlist-info {
    display: flex;
    flex-direction: column;
    overflow: hidden;
    flex: 1;
}

.chatlist-name {
    font-size: 0.875rem;
    font-weight: 600;
    color: #1f2937;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin: 0;
}

.chatlist-meta {
    font-size: 0.75rem;
    color: #9ca3af;
    margin: 0;
}

/* Welcome header */

.welcome-header {
    padding: 2rem;
}

.user-welcome-card {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.user-avatar {
    width: 48px;
    height: 48px;
    background-color: #4f46e5;
    color: #ffffff;
    font-weight: 600;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    font-size: 1.15rem;
    flex-shrink: 0;
}

.welcome-text {
    display: flex;
    flex-direction: column;
}

.welcome-label {
    font-size: 0.875rem;
    color: #6b7280;
    font-weight: 500;
}

.username-display {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
}

/* --- Empty State / No Bots Box --- */
.empty-bots-container {
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 3rem 2rem;
    text-align: center;
}

.empty-bots-card {
    background-color: #f9fafb;
    border: 2px dashed #e5e7eb;
    border-radius: 12px;
    padding: 2.5rem 2rem;
    width: 100%;
    max-width: 400px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1.25rem;
}

.empty-bots-text {
    font-size: 0.95rem;
    color: #4b5563;
    margin: 0;
    line-height: 1.5;
    font-weight: 500;
}

/* Primary Action Button (Fixed background color added) */
.btn-create-bot {
    color: #ffffff;
    padding: 0.75rem 1.25rem;
    font-size: 0.95rem;
    font-weight: 600;
    text-decoration: none;
    border-radius: 6px;
    border: none;
    cursor: pointer;
    text-align: center;
    transition: background-color 0.2s, transform 0.1s;
}

/*
------------------------------------------
   HORIZONTAL SCROLLABLE CHARACTER ROWS
------------------------------------------
*/

.character-row-section {
    padding: 0 2rem 2rem 2rem;
}

.section-header h2 {
    font-size: 1.25rem;
    font-weight: 700;
    color: #111827;
    margin-bottom: 1rem;
}

.horizontal-scroll-container {
    display: flex;
    gap: 1.25rem;
    overflow-x: auto;
    overflow-y: hidden;
    padding-bottom: 0.75rem;
    scroll-behavior: smooth;
    /* Hide scrollbar for a clean look while maintaining scrollability */
    scrollbar-width: thin;
    scrollbar-color: #d1d5db transparent;
}

.horizontal-scroll-container::-webkit-scrollbar {
    height: 6px;
}

.horizontal-scroll-container::-webkit-scrollbar-thumb {
    background-color: #d1d5db;
    border-radius: 4px;
}

/* Specific overrides for cards inside horizontal sliders */
.horizontal-card {
    flex: 0 0 220px; /* Forces cards to stay a fixed width instead of shrinking */
    width: 220px;
}

.no-chars-text {
    font-size: 0.9rem;
    color: #6b7280;
    font-style: italic;
    margin: 0;
}

/*
-----------------------------------------
            CHARACTER CREATION PAGE
-----------------------------------------
*/

.form-body {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    background-color: #f4f5f7;
    margin: 0;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif;
}

.form-container {
    background-color: #ffffff;
    padding: 2.5rem;
    border-radius: 12px;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.06);
    width: 100%;
    max-width: 520px;
    box-sizing: border-box;
}

.form-container h2 {
    margin-top: 0;
    font-size: 1.5rem;
    color: #111827;
    margin-bottom: 1.5rem;
}

.form-group {
    margin-bottom: 1.25rem;
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
}

.form-group label {
    font-size: 0.875rem;
    font-weight: 600;
    color: #374151;
}

.form-group input[type="text"],
.form-group textarea {
    padding: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    font-size: 0.95rem;
    color: #111827;
    outline: none;
    transition: border-color 0.2s;
    width: 100%;
    box-sizing: border-box;
    font-family: inherit;
}

.form-group textarea {
    resize: none;     
    overflow: hidden; 
    min-height: 90px; 
    line-height: 1.5;
}

.form-group input[type="text"]:focus,
.form-group textarea:focus {
    border-color: #4f46e5;
}

/* Avatar File Upload Custom Layout */
.avatar-upload-wrapper {
    display: flex;
    align-items: center;
    gap: 1rem;
    margin-top: 0.25rem;
}

.file-input {
    display: none; /* Hide native ugly file input */
}

.file-upload-btn {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 600;
    border-radius: 6px;
    cursor: pointer;
    transition: background-color 0.2s, color 0.2s;
}

.file-upload-btn:hover {
    background-color: #e5e7eb;
    color: #111827;
}

.form-container .btn-create-bot {
    width: 100%;
    margin-top: 0.5rem;
    display: block;
}

.back-link {
    text-align: center;
    margin-top: 1.25rem;
    margin-bottom: 0;
}

.back-link a {
    color: #4f46e5;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
}

.back-link a:hover {
    text-decoration: underline;
}

/* Flash error messages styling */
.flash-messages {
    background-color: #fee2e2;
    border: 1px solid #fecaca;
    color: #b91c1c;
    padding: 0.75rem 1rem 0.75rem 2rem;
    border-radius: 6px;
    font-size: 0.875rem;
    margin-bottom: 1.25rem;
}

/*
------------------------------------------
          OTHER CONTENT
------------------------------------------
*/

.clickable-user-handle {
    color: #00000054
}

.clickable-user-handle:hover {
    color: var(--PRIMARY_COLOR)
}

/* --- Sidebar Container --- */
.sidebar {
    position: fixed;
    top: 0;
    left: -280px;
    width: 280px;
    height: 100vh;
    background-color: #ffffff;
    color: #111827;
    display: flex;
    flex-direction: column;
    box-shadow: 4px 0 24px rgba(0, 0, 0, 0.06);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
    z-index: 1000;
}

.sidebar.open {
    transform: translateX(280px);
}

/* --- Sidebar Header & Close Button --- */
.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid #e5e7eb;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
    color: #1f2937;
}

.icon-btn {
    background: transparent;
    border: none;
    font-size: 1.5rem;
    cursor: pointer;
    color: #6b7280;
    padding: 0.25rem 0.5rem;
    border-radius: 6px;
    transition: background 0.2s, color 0.2s;
}

.icon-btn:hover {
    background-color: #f3f4f6;
    color: #111827;
}

/* --- Sidebar Content & Navigation Links --- */
.sidebar-content {
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    padding: 1rem 0;
}

.sidebar-nav {
    list-style: none;
    padding: 0 0.75rem;
    margin: 0;
}

.sidebar-nav li a {
    display: block;
    padding: 0.75rem 1rem;
    color: #4b5563;
    text-decoration: none;
    font-weight: 500;
    border-radius: 8px;
    transition: background-color 0.2s, color 0.2s;
}

.sidebar-nav li a:hover {
    background-color: #f3f4f6;
    color: #111827;
}

/* --- Bottom User Profile Section --- */
.sidebar-bottom {
    margin-top: auto;
    padding: 1rem;
    border-top: 1px solid #e5e7eb;
    background-color: #fafafa;
}

/* --- User Profile & Dropdown Menu --- */

.sidebar-user-container {
    position: relative;
}

.sidebar-user {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem;
    border-radius: 8px;
    transition: background-color 0.2s;
    cursor: pointer;
    user-select: none;
}

.sidebar-user:hover {
    background-color: #f0f1f3;
}

.sidebar-user .user-avatar {
    width: 38px;
    height: 38px;
    font-size: 0.95rem;
}

.user-chevron {
    margin-left: auto;
    font-size: 0.65rem;
    color: #9ca3af;
    transition: transform 0.2s;
}

.user-info {
    display: flex;
    flex-direction: column;
}

.user-dropdown-menu {
    position: absolute;
    bottom: calc(100% + 8px);
    left: 0;
    width: 100%;
    background-color: #ffffff;
    border: 1px solid #e5e7eb;
    border-radius: 10px;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.1), 0 8px 10px -6px rgba(0, 0, 0, 0.1);
    padding: 0.375rem;
    display: none;
    z-index: 1010;
    animation: fadeIn 0.15s ease-in-out;
}

.username {
    font-size: 0.9rem;
    font-weight: 600;
    color: #1f2937;
}

.user-dropdown-menu.show {
    display: block;
}

.dropdown-item {
    display: block;
    padding: 0.625rem 0.75rem;
    color: #374151;
    text-decoration: none;
    font-size: 0.875rem;
    font-weight: 500;
    border-radius: 6px;
    transition: background-color 0.2s, color 0.2s;
}

.dropdown-item:hover {
    background-color: #f3f4f6;
    color: #111827;
}

.dropdown-divider {
    height: 1px;
    background-color: #e5e7eb;
    margin: 0.25rem 0.5rem;
}

.dropdown-logout {
    color: #dc2626;
}

.dropdown-logout:hover {
    background-color: #fee2e2;
    color: #b91c1c;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(4px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

/* --- Backdrop Overlay --- */
.sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(17, 24, 39, 0.4);
    backdrop-filter: blur(2px);
    opacity: 0;
    visibility: hidden;
    pointer-events: none;
    transition: opacity 0.3s ease-in-out, visibility 0.3s ease-in-out;
    z-index: 999;
}

.sidebar-overlay.active {
    opacity: 1;
    visibility: visible;
    pointer-events: auto;
}

/* --- Auth Buttons Container --- */
.sidebar-auth-buttons {
    display: flex;
    gap: 0.5rem;
    width: 100%;
}

.btn-auth {
    flex: 1;
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
    font-weight: 600;
    text-align: center;
    text-decoration: none;
    border-radius: 6px;
    transition: background-color 0.2s, transform 0.1s;
}

.btn-login {
    border: 1px solid #e5e7eb;
}

/*
---------------------------------------
             COLORS
---------------------------------------
*/

.btn-primary {
    background-color: var(--PRIMARY_COLOR);
    color: white;
}

.btn-primary:hover {
    background-color: #833ebb;
    color: white;
}

.btn-accent {
    background-color: #f3f4f6;
    color: #374151;
}

.btn-accent:hover {
    background-color: #e5e7eb;
    color: #111827;
}

.btn-rounded {
    display: flex;
    justify-content: center;
    align-items: center;
    background-color: #ececec;
    outline: 1px solid #b5bfce;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}