/* 
 * EmochiAI - Modern Premium UI/UX
 * Dark Theme, Glassmorphism, Fluid Layouts
 */

:root {
    --bg-dark: #0f1117;
    --bg-surface: #1a1d26;
    --bg-surface-glass: rgba(26, 29, 38, 0.7);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --primary: #8b5cf6;
    --primary-hover: #7c3aed;
    --primary-light: #a78bfa;
    --secondary: #ec4899;
    --secondary-light: #f472b6;
    
    --text-main: #f8fafc;
    --text-muted: #94a3b8;
    
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    --radius-lg: 20px;
    --radius-md: 12px;
    --radius-sm: 8px;
    
    --sidebar-width: 260px;
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Inter', sans-serif;
}

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    overflow-x: hidden;
    -webkit-font-smoothing: antialiased;
}

/* Base Utility Classes */
.text-gradient {
    background: linear-gradient(135deg, var(--primary-light), var(--secondary-light));
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    display: inline-block;
}

.glass-panel {
    background: var(--bg-surface-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
}

.mt-4 { margin-top: 1.5rem; }
.mt-5 { margin-top: 3rem; }
.mb-5 { margin-bottom: 3rem; }

/* Layout Grid */
.app-container {
    display: flex;
    height: 100vh;
    overflow: hidden;
}

/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background: var(--bg-surface);
    height: 100%;
    display: flex;
    flex-direction: column;
    border-right: 1px solid var(--border-color);
    z-index: 50;
    transition: transform 0.3s ease;
}

.sidebar-header {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 24px;
    border-bottom: 1px solid var(--border-color);
}

.logo {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    font-size: 20px;
    font-weight: 700;
    color: var(--text-main);
    letter-spacing: -0.5px;
}

.logo i {
    font-size: 24px;
}

.sidebar-content {
    flex: 1;
    overflow-y: auto;
    padding: 24px 16px;
}

.sidebar-content::-webkit-scrollbar { width: 6px; }
.sidebar-content::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.nav-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 16px;
    color: var(--text-muted);
    text-decoration: none;
    border-radius: var(--radius-md);
    font-weight: 500;
    transition: var(--transition);
    margin-bottom: 4px;
}

.nav-item i {
    font-size: 18px;
    width: 20px;
    text-align: center;
}

.nav-item:hover, .nav-item.active {
    background: rgba(139, 92, 246, 0.1);
    color: var(--primary-light);
}

.nav-section-title {
    font-size: 11px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: #64748b;
    margin: 24px 0 12px 16px;
    font-weight: 700;
}

.sidebar-footer {
    padding: 16px;
    border-top: 1px solid var(--border-color);
}

.btn-admin {
    background: rgba(255,255,255,0.05);
    border: 1px solid var(--border-color);
}
.btn-admin:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

/* Main Content Wrapper */
.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

/* Topbar */
.topbar {
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0 32px;
    border-bottom: 1px solid var(--border-color);
    background: rgba(15, 17, 23, 0.8);
    backdrop-filter: blur(12px);
    z-index: 40;
}

.mobile-toggle, .mobile-close {
    display: none;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 20px;
    cursor: pointer;
}

.search-bar {
    display: flex;
    align-items: center;
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 30px;
    padding: 8px 16px;
    width: 100%;
    max-width: 400px;
    transition: var(--transition);
}

.search-bar:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

.search-bar i {
    color: var(--text-muted);
    margin-right: 12px;
}

.search-bar input {
    background: none;
    border: none;
    color: var(--text-main);
    width: 100%;
    outline: none;
    font-size: 14px;
}

.avatar-placeholder {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(236, 72, 153, 0.3);
}

/* Scrollable Content */
.content-wrapper {
    flex: 1;
    overflow-y: auto;
    padding: 32px;
    position: relative;
}
.content-wrapper::-webkit-scrollbar { width: 8px; }
.content-wrapper::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

/* Hero Section */
.hero-section {
    position: relative;
    padding: 60px 40px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    overflow: hidden;
    margin-bottom: 40px;
}

.hero-content {
    max-width: 600px;
    z-index: 2;
}

.hero-title {
    font-size: 48px;
    line-height: 1.1;
    margin-bottom: 24px;
    font-weight: 800;
    letter-spacing: -1px;
}

.hero-subtitle {
    font-size: 18px;
    color: var(--text-muted);
    margin-bottom: 32px;
    line-height: 1.6;
}

.btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 12px 24px;
    border-radius: 30px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    transition: var(--transition);
    border: none;
    font-size: 15px;
}

.btn-lg {
    padding: 16px 32px;
    font-size: 16px;
}

.btn-primary {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    color: white;
    box-shadow: 0 10px 25px -5px rgba(139, 92, 246, 0.5);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 15px 35px -5px rgba(139, 92, 246, 0.6);
}

/* Hero Background Animations */
.hero-visual {
    position: absolute;
    right: 0;
    top: 0;
    width: 50%;
    height: 100%;
    opacity: 0.6;
    z-index: 1;
    pointer-events: none;
}

.blob {
    position: absolute;
    border-radius: 50%;
    filter: blur(60px);
}

.blob-1 {
    width: 300px;
    height: 300px;
    background: rgba(139, 92, 246, 0.4);
    top: -50px;
    right: -50px;
    animation: float 8s ease-in-out infinite;
}

.blob-2 {
    width: 250px;
    height: 250px;
    background: rgba(236, 72, 153, 0.3);
    bottom: -50px;
    right: 20%;
    animation: float 10s ease-in-out infinite reverse;
}

.blob-3 {
    width: 200px;
    height: 200px;
    background: rgba(56, 189, 248, 0.2);
    top: 30%;
    left: -50px;
    animation: float 12s ease-in-out infinite;
}

@keyframes float {
    0%, 100% { transform: translate(0, 0) scale(1); }
    50% { transform: translate(-20px, 20px) scale(1.1); }
}

/* Character Grid Section */
.section-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.section-header h2 {
    font-size: 24px;
    font-weight: 700;
}

.view-all {
    color: var(--primary-light);
    text-decoration: none;
    font-size: 14px;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 6px;
    transition: var(--transition);
}
.view-all:hover {
    color: white;
    gap: 10px;
}

.character-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(240px, 1fr));
    gap: 24px;
}

.character-card {
    display: flex;
    flex-direction: column;
    text-decoration: none;
    color: var(--text-main);
    overflow: hidden;
    transition: var(--transition);
}

.character-card.interactive:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.5);
    border-color: rgba(255, 255, 255, 0.15);
}

.char-image {
    height: 280px;
    position: relative;
    overflow: hidden;
}

.char-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
    transition: var(--transition);
}

.character-card:hover .char-bg {
    transform: scale(1.05);
}

.char-badge {
    position: absolute;
    top: 12px;
    left: 12px;
    background: rgba(0,0,0,0.6);
    backdrop-filter: blur(8px);
    padding: 4px 10px;
    border-radius: 20px;
    font-size: 12px;
    font-weight: 600;
    border: 1px solid rgba(255,255,255,0.1);
}

.char-info {
    padding: 20px;
    position: relative;
}

.char-info h3 {
    font-size: 18px;
    font-weight: 700;
    margin-bottom: 8px;
}

.tagline {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 16px;
    height: 42px; /* Fixed height for 2 lines */
    overflow: hidden;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.char-meta {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 13px;
    color: #cbd5e1;
    font-weight: 500;
}

.play-btn {
    opacity: 0;
    transform: translateX(-10px);
    transition: var(--transition);
    color: var(--primary-light);
}

.character-card:hover .play-btn {
    opacity: 1;
    transform: translateX(0);
}

.empty-state {
    grid-column: 1 / -1;
    padding: 60px 20px;
    text-align: center;
    background: var(--bg-surface-glass);
    border: 1px dashed var(--border-color);
    border-radius: var(--radius-lg);
    color: var(--text-muted);
}
.empty-state i {
    font-size: 48px;
    margin-bottom: 16px;
    color: rgba(255,255,255,0.1);
}

/* Responsive */
@media (max-width: 1024px) {
    .hero-title { font-size: 36px; }
}

@media (max-width: 768px) {
    .sidebar {
        position: fixed;
        left: 0;
        top: 0;
        transform: translateX(-100%);
    }
    
    .sidebar.active {
        transform: translateX(0);
        box-shadow: 20px 0 50px rgba(0,0,0,0.5);
    }
    
    .mobile-toggle, .mobile-close {
        display: block;
    }
    
    .topbar { padding: 0 16px; }
    .content-wrapper { padding: 20px; }
    
    .hero-section {
        padding: 40px 24px;
    }
    
    .search-bar { display: none; }
}

/* Sidebar Recent Chats */
.sidebar-recent-chats {
    display: flex;
    flex-direction: column;
    gap: 4px;
    padding: 0 8px;
}

.mini-chat-item {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 8px 12px !important;
    border-radius: var(--radius-md);
    transition: var(--transition);
}

.mini-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    overflow: hidden;
    flex-shrink: 0;
}

.mini-avatar .avatar-bg {
    width: 100%;
    height: 100%;
    background-size: cover;
    background-position: center;
}

.chat-name {
    font-size: 14px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    color: var(--text-muted);
}

.mini-chat-item:hover .chat-name, 
.mini-chat-item.active .chat-name {
    color: var(--text-main);
}

/* Chat Page Layout */
.chat-container {
    display: flex;
    gap: 24px;
    height: 100%;
    max-width: 1400px;
    margin: 0 auto;
}

.chat-window {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    height: calc(100vh - 130px);
}

.chat-header {
    padding: 16px 24px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid var(--border-color);
}

.chat-character-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.main-avatar {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    border: 2px solid var(--primary);
}

.header-text h2 {
    font-size: 18px;
    font-weight: 700;
}

.status {
    font-size: 12px;
    color: var(--text-muted);
    display: flex;
    align-items: center;
    gap: 6px;
}

.dot {
    width: 8px;
    height: 8px;
    background: #10b981;
    border-radius: 50%;
    box-shadow: 0 0 8px #10b981;
}

.chat-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border-radius: 50%;
    border: 1px solid var(--border-color);
    background: rgba(255,255,255,0.05);
    color: var(--text-muted);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: var(--transition);
}

.icon-btn:hover {
    background: rgba(255,255,255,0.1);
    color: var(--text-main);
}

/* Messages Area */
.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.chat-messages::-webkit-scrollbar { width: 6px; }
.chat-messages::-webkit-scrollbar-thumb { background: rgba(255,255,255,0.1); border-radius: 10px; }

.message-wrapper {
    display: flex;
    gap: 12px;
    max-width: 80%;
}

.message-wrapper.user {
    align-self: flex-end;
    flex-direction: row-reverse;
}

.message-wrapper.assistant {
    align-self: flex-start;
}

.small-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    margin-top: 4px;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 18px;
    position: relative;
    font-size: 15px;
    line-height: 1.5;
}

.user .message-bubble {
    background: var(--primary);
    color: white;
    border-bottom-right-radius: 4px;
}

.assistant .message-bubble {
    background: var(--bg-surface);
    color: var(--text-main);
    border-bottom-left-radius: 4px;
    border: 1px solid var(--border-color);
}

.message-time {
    font-size: 10px;
    opacity: 0.6;
    margin-top: 4px;
    text-align: right;
}

/* Input Area */
.chat-input-area {
    padding: 20px 24px;
    border-top: 1px solid var(--border-color);
}

.input-wrapper {
    background: var(--bg-surface);
    border: 1px solid var(--border-color);
    border-radius: 24px;
    padding: 8px 16px;
    transition: var(--transition);
}

.input-wrapper:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.2);
}

#chatForm {
    display: flex;
    align-items: flex-end;
    gap: 12px;
}

#messageInput {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-main);
    padding: 8px 0;
    resize: none;
    outline: none;
    font-size: 15px;
    max-height: 150px;
}

.input-actions {
    display: flex;
    align-items: center;
    gap: 8px;
    padding-bottom: 4px;
}

.btn-icon {
    width: 36px;
    height: 36px;
    padding: 0;
    justify-content: center;
}

/* Character Details Sidebar */
.character-details {
    width: 320px;
    padding: 32px 24px;
    height: fit-content;
}

.detail-header {
    text-align: center;
    margin-bottom: 32px;
}

.detail-avatar {
    width: 120px;
    height: 120px;
    border-radius: 24px;
    margin: 0 auto 16px;
    background-size: cover;
    background-position: center;
    box-shadow: 0 20px 40px -10px rgba(0,0,0,0.5);
}

.character-tagline {
    font-size: 14px;
    color: var(--text-muted);
    margin-top: 8px;
}

.detail-section h4 {
    font-size: 14px;
    text-transform: uppercase;
    letter-spacing: 1px;
    color: var(--primary-light);
    margin-bottom: 12px;
}

.detail-section p {
    font-size: 14px;
    color: var(--text-muted);
    line-height: 1.6;
}

/* Typing Indicator */
.typing-dots {
    display: flex;
    gap: 4px;
    padding: 4px 0;
}

.typing-dots span {
    width: 6px;
    height: 6px;
    background: var(--text-muted);
    border-radius: 50%;
    animation: typing 1s infinite ease-in-out;
}

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

@keyframes typing {
    0%, 100% { transform: translateY(0); opacity: 0.4; }
    50% { transform: translateY(-4px); opacity: 1; }
}

@media (max-width: 1200px) {
    .character-details { display: none; }
}

@media (max-width: 768px) {
    .chat-window { height: calc(100vh - 100px); }
    .chat-container { gap: 0; }
    .message-wrapper { max-width: 90%; }
}
