/* --- High-Fashion LIGHT Mode Aesthetics --- */
:root {
    --c-bg: #fcfbfa;       /* Very warm, glossy editorial off-white */
    --c-bg-mesh: radial-gradient(at 0% 0%, #fff0f5 0px, transparent 50%), 
                 radial-gradient(at 100% 100%, #ffe4e6 0px, transparent 50%), 
                 #fcfbfa;
    --c-surface: #ffffff;  /* Pure white for elevation */
    --c-surface-hover: #f3f2f1;
    --c-pink: #ff2a75;     /* Vibrant, elegant pink */
    --c-text-main: #1c1917; /* Deep charcoal (almost black) for sharp readability */
    --c-text-muted: #78716c; /* Elegant taupe/gray */
    --c-border: #e7e5e4;
    
    --font-heading: 'Playfair Display', serif;
    --font-ui: 'DM Sans', sans-serif;
    
    --transition-snappy: 0.4s cubic-bezier(0.85, 0, 0.15, 1);
    --shadow-soft: 0 12px 40px rgba(0, 0, 0, 0.04);
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    font-family: var(--font-ui);
    background: var(--c-bg-mesh);
    color: var(--c-text-main);
    height: 100dvh;
    overflow: hidden;
    -webkit-font-smoothing: antialiased;
}

h1, h2, h3, h4 { font-family: var(--font-heading); font-weight: 700; }

/* --- Screens & Layouts --- */
.screen {
    position: absolute; inset: 0; 
    z-index: 100; background: var(--c-bg-mesh);
    transition: opacity 0.5s ease;
}
.screen.hidden { opacity: 0; pointer-events: none; }
.simple-center { display: flex; justify-content: center; align-items: center; }

/* Split Auth Layout (Desktop) */
.split-layout {
    display: grid;
    grid-template-columns: 1fr 1fr;
    height: 100%;
}
.split-left {
    border-right: 1px solid var(--c-border);
    display: flex; flex-direction: column; justify-content: center;
    padding: 4rem; position: relative;
    background: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100" viewBox="0 0 100 100"><rect fill="%23fcfbfa" width="100" height="100"/><circle cx="50" cy="50" r="40" stroke="%23ff2a75" stroke-width="0.5" fill="none" opacity="0.1"/></svg>') center/cover;
}
.brand-massive h1 {
    font-size: clamp(3rem, 6vw, 6rem);
    line-height: 1; letter-spacing: -2px;
    margin: 0; color: var(--c-text-main);
}
.brand-massive .italic { font-style: italic; color: var(--c-text-muted); font-weight: 400; }
.brand-massive .pink { color: var(--c-pink); }
.brand-tagline { margin-top: 2rem; font-size: 1.1rem; color: var(--c-text-muted); max-width: 400px; line-height: 1.6; font-weight: 500;}

.split-right { display: flex; justify-content: center; align-items: center; padding: 2rem; background: var(--c-surface); }
.auth-box { width: 100%; max-width: 380px; }
.auth-mobile-logo { display: none; width: 60px; margin-bottom: 2rem; }
.auth-box h2 { font-size: 2.5rem; margin-bottom: 0.5rem; color: var(--c-text-main); }
.auth-sub { color: var(--c-text-muted); margin-bottom: 2.5rem; }

/* Forms & Inputs (Floating Labels) */
.input-group { position: relative; margin-bottom: 1.5rem; }
.input-group input, .input-group select {
    width: 100%; padding: 1.2rem 1rem 0.6rem;
    background: transparent; border: none;
    border-bottom: 1px solid var(--c-border);
    color: var(--c-text-main); font-family: var(--font-ui);
    font-size: 1rem; outline: none; transition: all 0.3s;
}
.input-group input:focus, .input-group select:focus { border-bottom-color: var(--c-pink); }
.input-group label {
    position: absolute; top: 1rem; left: 1rem;
    color: var(--c-text-muted); font-size: 1rem;
    pointer-events: none; transition: 0.2s ease all; font-weight: 500;
}
.input-group input:focus ~ label, .input-group input:not(:placeholder-shown) ~ label {
    top: 0.2rem; font-size: 0.75rem; color: var(--c-pink); font-weight: 700;
}
.select-group select { padding-top: 1rem; }
.select-group select option { background: var(--c-surface); color: var(--c-text-main); }

/* Buttons */
.btn {
    padding: 1rem 1.5rem; font-family: var(--font-ui); font-size: 0.95rem; font-weight: 700;
    text-transform: uppercase; letter-spacing: 1px; cursor: pointer;
    border-radius: 4px; transition: all 0.3s;
    display: inline-flex; justify-content: center; align-items: center; gap: 10px;
}
.full-width { width: 100%; }
.btn.primary { background: var(--c-text-main); color: #fff; border: 1px solid var(--c-text-main); }
.btn.primary:hover { background: var(--c-pink); border-color: var(--c-pink); box-shadow: 0 4px 15px rgba(255, 42, 117, 0.2); }
.btn.outline { background: var(--c-surface); border: 1px solid var(--c-border); color: var(--c-text-main); }
.btn.outline:hover { border-color: var(--c-text-muted); background: var(--c-bg); }

.auth-providers { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; margin-bottom: 2rem; }
.divider { display: flex; align-items: center; text-align: center; margin-bottom: 2rem; color: var(--c-text-muted); font-size: 0.8rem; letter-spacing: 2px; font-weight: 700; }
.divider::before, .divider::after { content: ''; flex: 1; border-bottom: 1px solid var(--c-border); }
.divider span { padding: 0 1rem; }

/* Status Cards (Verify, Profile) */
.status-card { max-width: 420px; width: 90%; text-align: center; background: var(--c-surface); padding: 3rem; border-radius: 12px; box-shadow: var(--shadow-soft); border: 1px solid var(--c-border); }
.status-card h2 { font-size: 2.2rem; margin-bottom: 1rem; }
.status-card p { color: var(--c-text-muted); margin-bottom: 2rem; line-height: 1.6; }

/* --- App Layout (Chat + Sidebar) --- */
.app-layout { display: flex; height: 100%; width: 100%; max-width: 1600px; margin: 0 auto; background: var(--c-surface); box-shadow: var(--shadow-soft); }
.app-layout.hidden { display: none; }

.sidebar {
    width: 300px; background: var(--c-bg); border-right: 1px solid var(--c-border);
    display: flex; flex-direction: column; z-index: 50;
    transition: transform var(--transition-snappy);
}
.sidebar-top { padding: 2rem 1.5rem; border-bottom: 1px solid var(--c-border); }
.brand-row { display: flex; align-items: center; gap: 12px; margin-bottom: 2rem; }
.sidebar-logo { width: 28px; }
.brand-row h3 { font-family: var(--font-heading); font-weight: 700; letter-spacing: 1px; font-size: 1.1rem; margin: 0; }

.user-card { display: flex; align-items: center; gap: 12px; }
.avatar-placeholder { width: 44px; height: 44px; border-radius: 50%; background: var(--c-border); border: 1px solid #d6d3d1; }
.user-meta { display: flex; flex-direction: column; gap: 4px; }
#user-display-name { font-weight: 700; font-size: 0.95rem; }
.status-chip { font-size: 0.75rem; color: var(--c-text-muted); display: flex; align-items: center; gap: 6px; font-weight: 500; }
.dot { width: 8px; height: 8px; border-radius: 50%; background: #ccc; transition: 0.3s; }
.dot.online { background: #10b981; box-shadow: 0 0 8px rgba(16, 185, 129, 0.4); }

.sidebar-mid { flex: 1; padding: 2rem 1.5rem; overflow-y: auto; }
.settings-block { margin-bottom: 2.5rem; }
.settings-block h4 { font-family: var(--font-ui); font-size: 0.75rem; font-weight: 700; letter-spacing: 1.5px; color: var(--c-text-muted); margin-bottom: 1.5rem; }
.toggle-row, .quota-row { display: flex; justify-content: space-between; align-items: center; font-size: 0.95rem; margin-bottom: 1rem; font-weight: 500; }
.badge { background: var(--c-surface); border: 1px solid var(--c-border); padding: 4px 10px; border-radius: 4px; font-weight: 700; font-family: monospace; font-size: 1rem; color: var(--c-text-main); }

.progress-track { height: 4px; background: var(--c-border); margin-bottom: 1rem; width: 100%; border-radius: 2px; overflow: hidden; }
.progress-fill { height: 100%; background: var(--c-text-main); transition: width 0.3s; }
.premium-teaser { font-size: 0.75rem; font-weight: 700; letter-spacing: 1px; color: var(--c-pink); }

.sidebar-bottom { padding: 1.5rem; border-top: 1px solid var(--c-border); }

/* Main Chat Area */
.chat-main { flex: 1; display: flex; flex-direction: column; position: relative; background: var(--c-surface); }
.chat-header {
    height: 70px; display: flex; justify-content: space-between; align-items: center;
    padding: 0 2rem; border-bottom: 1px solid var(--c-border); background: var(--c-surface); z-index: 10;
}
.header-center h2 { font-family: var(--font-ui); font-size: 0.85rem; letter-spacing: 3px; font-weight: 700; color: var(--c-text-muted); }
.icon-btn { background: none; border: none; color: var(--c-text-main); cursor: pointer; display: flex; align-items: center; }
.mobile-only { display: none; }

.chat-feed { flex: 1; overflow-y: auto; padding: 2rem; display: flex; flex-direction: column; gap: 1.5rem; scroll-behavior: smooth; }

/* Perfect Bubbles & Breaking extremely long text */
.message { display: flex; width: 100%; max-width: 100%; animation: slideIn 0.4s var(--transition-snappy) forwards; }
.message.user { justify-content: flex-end; }
.message.ai { justify-content: flex-start; }

.bubble {
    padding: 1.1rem 1.4rem;
    font-size: 1.05rem; line-height: 1.6;
    max-width: 80%;
    
    /* CRITICAL FIX FOR LONG STRING OVERFLOW (jdshjdsh...) */
    overflow-wrap: anywhere; 
    word-break: break-word; 
    hyphens: auto; 
}
.message.user .bubble {
    background: var(--c-text-main); color: #fff;
    border-radius: 16px 16px 4px 16px; font-weight: 400;
    box-shadow: 0 4px 15px rgba(0,0,0,0.05);
}
.message.ai .bubble {
    background: var(--c-bg); color: var(--c-text-main);
    border-radius: 4px 16px 16px 16px;
    border: 1px solid var(--c-border);
}

.chat-input-wrapper { padding: 1.5rem 2rem 2rem; background: var(--c-surface); border-top: 1px solid var(--c-border); }
#chat-form { display: flex; gap: 1rem; position: relative; max-width: 900px; margin: 0 auto; }
#chat-input {
    flex: 1; background: var(--c-bg); border: 1px solid var(--c-border);
    padding: 1.2rem 4rem 1.2rem 1.5rem; border-radius: 30px;
    color: var(--c-text-main); font-size: 1rem; outline: none; transition: 0.3s;
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.02);
}
#chat-input:focus { border-color: var(--c-pink); background: #fff; box-shadow: 0 0 0 4px rgba(255, 42, 117, 0.1); }
#btn-send {
    position: absolute; right: 6px; top: 50%; transform: translateY(-50%);
    width: 42px; height: 42px; border-radius: 50%; border: none;
    background: var(--c-text-main); color: #fff; cursor: pointer;
    display: flex; justify-content: center; align-items: center; transition: 0.2s;
}
#btn-send:hover { background: var(--c-pink); transform: translateY(-50%) scale(1.05); box-shadow: 0 4px 10px rgba(255, 42, 117, 0.2); }

/* Switch */
.switch { position: relative; display: inline-block; width: 44px; height: 24px; }
.switch input { opacity: 0; width: 0; height: 0; }
.slider { position: absolute; cursor: pointer; inset: 0; background-color: var(--c-border); transition: .3s; border-radius: 24px; }
.slider:before { position: absolute; content: ""; height: 18px; width: 18px; left: 3px; bottom: 3px; background-color: #fff; transition: .3s; border-radius: 50%; box-shadow: 0 2px 4px rgba(0,0,0,0.1); }
input:checked + .slider { background-color: var(--c-text-main); }
input:checked + .slider:before { transform: translateX(20px); }

/* Mobile Logic */
@media (max-width: 900px) {
    .split-layout { grid-template-columns: 1fr; }
    .split-left { display: none; }
    .split-right { background: var(--c-bg-mesh); }
    .auth-mobile-logo { display: block; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.05)); }
    
    .mobile-only { display: block; }
    .sidebar { position: fixed; top: 0; left: 0; transform: translateX(-100%); width: 85%; max-width: 320px; height: 100%; box-shadow: 10px 0 30px rgba(0,0,0,0.05); }
    .sidebar.open { transform: translateX(0); }
    
    .overlay { position: fixed; inset: 0; background: rgba(28, 25, 23, 0.4); backdrop-filter: blur(2px); z-index: 40; opacity: 0; pointer-events: none; transition: 0.3s; }
    .overlay.show { opacity: 1; pointer-events: auto; }
    
    .chat-header { padding: 0 1.5rem; }
    .chat-feed { padding: 1.5rem 1rem; }
    .chat-input-wrapper { padding: 1rem; }
    .bubble { max-width: 92%; font-size: 1rem; }
}

/* Animations */
@keyframes slideIn { from { opacity: 0; transform: translateY(15px); } to { opacity: 1; transform: translateY(0); } }
@keyframes spin { 100% { transform: rotate(360deg); } }
.stagger-in { animation: slideIn 0.6s var(--transition-snappy) forwards; }
.pulse-icon { animation: slideIn 1s infinite alternate; margin-bottom: 1.5rem; display: block; margin-left: auto; margin-right: auto; }

.loader-screen { position: fixed; inset: 0; display: flex; justify-content: center; align-items: center; background: var(--c-bg); z-index: 9999; transition: opacity 0.5s; }
.loader-content { text-align: center; }
.rotating-logo { width: 70px; animation: spin 4s linear infinite; margin-bottom: 2rem; filter: drop-shadow(0 4px 10px rgba(0,0,0,0.05)); }
.loader-title { font-size: 1.5rem; letter-spacing: 4px; color: var(--c-text-main); font-family: var(--font-heading); }

.typing-container { padding: 0 2rem 1.5rem; display: flex; animation: slideIn 0.3s; }
.typing { display: flex; gap: 5px; align-items: center; padding: 1.1rem 1.4rem; background: var(--c-bg); border: 1px solid var(--c-border); border-radius: 4px 16px 16px 16px; }
.typing span { display: block; width: 6px; height: 6px; background: var(--c-text-muted); border-radius: 50%; animation: blink 1.4s infinite both; }
.typing span:nth-child(2) { animation-delay: 0.2s; }
.typing span:nth-child(3) { animation-delay: 0.4s; }
@keyframes blink { 0%, 100% { opacity: 0.2; } 20% { opacity: 1; background: var(--c-pink); } }
