:root {
    --bg-dark: #09090b;
    --bg-sidebar: #121214;
    --bg-surface: #18181b;
    --bg-glass: rgba(24, 24, 27, 0.65);
    --border-glass: rgba(255, 255, 255, 0.07);
    --primary: #8b5cf6;
    --primary-glow: rgba(139, 92, 246, 0.3);
    --primary-hover: #a78bfa;
    --text-main: #f4f4f5;
    --text-muted: #a1a1aa;
    --text-google: #ea4335;
    --success: #10b981;
    --danger: #ef4444;
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 16px;
    --transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
    --font-outfit: 'Outfit', sans-serif;
    --font-inter: 'Inter', sans-serif;
}

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

body {
    background-color: var(--bg-dark);
    color: var(--text-main);
    font-family: var(--font-inter);
    overflow: hidden;
    height: 100vh;
    width: 100vw;
}

/* Animations */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes pulseGlow {
    0% { box-shadow: 0 0 5px var(--primary-glow); }
    50% { box-shadow: 0 0 15px var(--primary-glow); }
    100% { box-shadow: 0 0 5px var(--primary-glow); }
}

/* Screen Managers */
.screen {
    display: none;
    height: 100vh;
    width: 100vw;
}

.screen.active {
    display: flex;
    animation: fadeIn 0.4s ease-out;
}

/* Auth Cards */
#auth-screen {
    justify-content: center;
    align-items: center;
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.12), transparent 45%),
                radial-gradient(circle at bottom left, rgba(24, 24, 27, 1), var(--bg-dark));
}

.auth-card {
    background-color: var(--bg-glass);
    border: 1px solid var(--border-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border-radius: var(--radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 440px;
    box-shadow: 0 20px 40px rgba(0,0,0,0.4);
    animation: fadeIn 0.5s ease-out;
}

.auth-header {
    text-align: center;
    margin-bottom: 2rem;
}

.logo {
    display: inline-flex;
    align-items: center;
    gap: 0.6rem;
    font-family: var(--font-outfit);
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-main);
    margin-bottom: 1rem;
    text-decoration: none;
}

.logo i {
    color: var(--primary);
    filter: drop-shadow(0 0 8px var(--primary-glow));
}

.auth-header h2 {
    font-family: var(--font-outfit);
    font-size: 1.75rem;
    font-weight: 600;
    margin-bottom: 0.4rem;
}

.auth-header p {
    color: var(--text-muted);
    font-size: 0.9rem;
}

/* Forms */
.auth-form {
    display: none;
}

.auth-form.active {
    display: block;
}

.input-group {
    margin-bottom: 1.25rem;
}

.input-group label {
    display: block;
    font-size: 0.8rem;
    font-weight: 500;
    color: var(--text-muted);
    margin-bottom: 0.5rem;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.input-wrapper {
    position: relative;
}

.input-wrapper i {
    position: absolute;
    left: 1rem;
    top: 50%;
    transform: translateY(-50%);
    color: var(--text-muted);
    font-size: 0.95rem;
    pointer-events: none;
    transition: var(--transition);
}

.input-wrapper input, .input-group input, .input-group select, .input-group textarea {
    width: 100%;
    background-color: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.75rem 1rem 0.75rem 2.5rem;
    color: var(--text-main);
    font-family: var(--font-inter);
    font-size: 0.95rem;
    transition: var(--transition);
}

.input-group select, .input-group input[type="text"] {
    padding-left: 1rem;
}

.input-group textarea {
    padding: 0.75rem 1rem;
    resize: none;
    background-color: rgba(255,255,255,0.02);
}

.input-wrapper input:focus, .input-group select:focus, .input-group textarea:focus {
    outline: none;
    border-color: var(--primary);
    background-color: rgba(255,255,255,0.05);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.15);
}

.input-wrapper input:focus + i {
    color: var(--primary);
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-inter);
    font-weight: 500;
    font-size: 0.95rem;
    padding: 0.75rem 1.25rem;
    border-radius: var(--radius-sm);
    border: none;
    cursor: pointer;
    transition: var(--transition);
    text-decoration: none;
}

.btn-block {
    display: flex;
    width: 100%;
}

.btn-primary {
    background-color: var(--primary);
    color: white;
}

.btn-primary:hover {
    background-color: var(--primary-hover);
    box-shadow: 0 4px 12px var(--primary-glow);
}

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

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.09);
    border-color: rgba(255,255,255,0.15);
}

.btn-sm {
    padding: 0.45rem 0.85rem;
    font-size: 0.8rem;
    border-radius: 6px;
}

.auth-toggle {
    text-align: center;
    margin-top: 1rem;
    font-size: 0.85rem;
    color: var(--text-muted);
}

.auth-toggle a {
    color: var(--primary);
    text-decoration: none;
    font-weight: 500;
}

.auth-toggle a:hover {
    text-decoration: underline;
}

.divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 1.5rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.divider::before, .divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-glass);
}

.divider::before {
    margin-right: .75em;
}

.divider::after {
    margin-left: .75em;
}

.sso-buttons {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 0.8rem;
}

.btn-sso {
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-glass);
    color: var(--text-main);
}

.btn-sso:hover {
    background-color: rgba(255, 255, 255, 0.07);
    border-color: rgba(255, 255, 255, 0.15);
}

.text-google {
    color: #ea4335;
}

/* Dashboard Layout */

.sidebar {
    width: 280px;
    background-color: var(--bg-sidebar);
    border-right: 1px solid var(--border-glass);
    display: flex;
    flex-direction: column;
    height: 100vh;
}

.sidebar-header {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.btn-new-chat {
    background-color: rgba(139, 92, 246, 0.1);
    border: 1px dashed rgba(139, 92, 246, 0.3);
    color: var(--primary-hover);
    border-radius: var(--radius-sm);
    padding: 0.7rem 1rem;
    font-size: 0.9rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    cursor: pointer;
    transition: var(--transition);
    width: 100%;
}

.btn-new-chat:hover {
    background-color: rgba(139, 92, 246, 0.16);
    border-color: var(--primary);
}

.conv-list-container {
    flex: 1;
    overflow-y: auto;
    padding: 0 1rem;
}

.conv-list {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.4rem;
}

.conv-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 0.7rem 0.8rem;
    border-radius: var(--radius-sm);
    color: var(--text-muted);
    font-size: 0.9rem;
    cursor: pointer;
    transition: var(--transition);
}

.conv-item:hover, .conv-item.active {
    background-color: rgba(255, 255, 255, 0.04);
    color: var(--text-main);
}

.conv-item .title-wrapper {
    display: flex;
    align-items: center;
    gap: 0.6rem;
    overflow: hidden;
    white-space: nowrap;
    text-overflow: ellipsis;
    flex: 1;
}

.conv-item .delete-conv-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    opacity: 0;
    transition: var(--transition);
    padding: 2px 6px;
}

.conv-item:hover .delete-conv-btn {
    opacity: 1;
}

.conv-item .delete-conv-btn:hover {
    color: var(--danger);
}

.sidebar-footer {
    padding: 1.25rem;
    border-top: 1px solid var(--border-glass);
    background-color: rgba(0,0,0,0.15);
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.user-profile {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.user-profile .avatar {
    font-size: 1.75rem;
    color: var(--text-muted);
}

.user-details {
    flex: 1;
    overflow: hidden;
}

.user-details h4 {
    font-size: 0.88rem;
    font-weight: 600;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.user-details p {
    font-size: 0.75rem;
    color: var(--text-muted);
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

#logout-btn {
    background: none;
    border: none;
    color: var(--text-muted);
    cursor: pointer;
    font-size: 1rem;
    transition: var(--transition);
}

#logout-btn:hover {
    color: var(--danger);
}

.plan-card {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.85rem;
}

.plan-info {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.75rem;
}

.plan-badge {
    background-color: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255,255,255,0.1);
    color: var(--text-main);
    font-family: var(--font-outfit);
    font-size: 0.7rem;
    font-weight: 700;
    text-transform: uppercase;
    padding: 0.2rem 0.5rem;
    border-radius: 4px;
    letter-spacing: 0.05em;
}

.plan-badge.starter { background-color: rgba(139, 92, 246, 0.15); border-color: rgba(139, 92, 246, 0.3); color: var(--primary-hover); }
.plan-badge.pro { background-color: rgba(16, 185, 129, 0.15); border-color: rgba(16, 185, 129, 0.3); color: #34d399; }
.plan-badge.developer { background-color: rgba(245, 158, 11, 0.15); border-color: rgba(245, 158, 11, 0.3); color: #fbbf24; }

.tokens-info {
    font-size: 0.78rem;
    color: var(--text-muted);
}

.tokens-info span {
    font-weight: 600;
    color: var(--text-main);
}

/* Chat container */
.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100vh;
    background-color: var(--bg-dark);
}

.chat-header {
    height: 60px;
    border-bottom: 1px solid var(--border-glass);
    padding: 0 1.5rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.chat-title-info {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    color: var(--text-muted);
}

.chat-title-info h3 {
    font-family: var(--font-outfit);
    font-size: 1.05rem;
    font-weight: 500;
    color: var(--text-main);
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    gap: 1.25rem;
}

.welcome-screen {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    padding: 2rem;
    color: var(--text-muted);
}

.welcome-icon {
    font-size: 3.5rem;
    color: var(--primary);
    margin-bottom: 1.5rem;
    filter: drop-shadow(0 0 12px var(--primary-glow));
}

.welcome-screen h2 {
    font-family: var(--font-outfit);
    font-size: 1.75rem;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 0.5rem;
}

.welcome-screen p {
    font-size: 0.95rem;
    max-width: 460px;
    line-height: 1.5;
}

.message-bubble {
    display: flex;
    gap: 1rem;
    max-width: 80%;
    animation: fadeIn 0.3s ease-out;
}

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

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

.message-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    background-color: rgba(255,255,255,0.03);
    border: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.88rem;
    flex-shrink: 0;
}

.message-bubble.user .message-avatar {
    background-color: rgba(139, 92, 246, 0.15);
    border-color: rgba(139, 92, 246, 0.3);
    color: var(--primary-hover);
}

.message-bubble.assistant .message-avatar {
    color: var(--text-muted);
}

.message-content-wrapper {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.message-text {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    padding: 0.85rem 1.1rem;
    border-radius: var(--radius-md);
    font-size: 0.92rem;
    line-height: 1.5;
}

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

.message-bubble.assistant .message-text {
    border-bottom-left-radius: 4px;
}

.message-meta {
    font-size: 0.72rem;
    color: var(--text-muted);
    align-self: flex-start;
}

.message-bubble.user .message-meta {
    align-self: flex-end;
}

.chat-input-area {
    padding: 1.5rem;
    border-top: 1px solid var(--border-glass);
    background-color: rgba(0,0,0,0.1);
}

#chat-input-form {
    display: flex;
    gap: 0.75rem;
    background-color: rgba(255, 255, 255, 0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 0.4rem 0.5rem 0.4rem 1rem;
    transition: var(--transition);
}

#chat-input-form:focus-within {
    border-color: var(--primary);
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.12);
}

#chat-prompt-input {
    flex: 1;
    background: none;
    border: none;
    color: var(--text-main);
    font-size: 0.95rem;
    font-family: var(--font-inter);
}

#chat-prompt-input:focus {
    outline: none;
}

#chat-send-btn {
    width: 36px;
    height: 36px;
    border-radius: 8px;
    background-color: var(--primary);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: var(--transition);
}

#chat-send-btn:hover {
    background-color: var(--primary-hover);
}

#chat-send-btn:disabled, #chat-prompt-input:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}

/* Modals */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0,0,0,0.7);
    backdrop-filter: blur(8px);
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 100;
}

.modal-overlay.active {
    display: flex;
}

.modal-card {
    background-color: var(--bg-surface);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-lg);
    width: 90%;
    max-width: 960px;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 25px 50px rgba(0,0,0,0.5);
    animation: fadeIn 0.3s ease-out;
}

.modal-card.modal-sm {
    max-width: 480px;
}

.modal-header {
    padding: 1.25rem 1.5rem;
    border-bottom: 1px solid var(--border-glass);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    font-family: var(--font-outfit);
    font-size: 1.2rem;
    font-weight: 600;
}

.modal-close {
    background: none;
    border: none;
    color: var(--text-muted);
    font-size: 1.25rem;
    cursor: pointer;
    transition: var(--transition);
}

.modal-close:hover {
    color: var(--text-main);
}

.modal-body {
    padding: 1.5rem;
}

/* Plan grid inside billing modal */
.plan-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(260px, 1fr));
    gap: 1.25rem;
    margin-bottom: 2rem;
}

.pricing-card {
    background-color: rgba(255,255,255,0.02);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    position: relative;
    transition: var(--transition);
}

.pricing-card:hover {
    transform: translateY(-4px);
    border-color: rgba(255,255,255,0.12);
}

.pricing-card.popular {
    border-color: var(--primary);
    background: radial-gradient(circle at top right, rgba(139, 92, 246, 0.08), transparent 60%), rgba(255,255,255,0.02);
    box-shadow: 0 8px 24px rgba(139, 92, 246, 0.12);
}

.card-badge {
    position: absolute;
    top: -10px;
    right: 1.5rem;
    background-color: var(--primary);
    color: white;
    font-size: 0.72rem;
    font-weight: 600;
    padding: 0.25rem 0.65rem;
    border-radius: 20px;
    letter-spacing: 0.05em;
    text-transform: uppercase;
}

.card-header h4 {
    font-family: var(--font-outfit);
    font-size: 1.15rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.card-header .price {
    font-family: var(--font-outfit);
    font-size: 2.25rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}

.card-header .price span {
    font-size: 1rem;
    font-weight: 400;
    color: var(--text-muted);
}

.card-header p {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1.25rem;
}

.card-features {
    flex: 1;
    margin-bottom: 1.5rem;
}

.card-features ul {
    list-style: none;
    display: flex;
    flex-direction: column;
    gap: 0.6rem;
}

.card-features li {
    font-size: 0.85rem;
    display: flex;
    align-items: center;
    gap: 0.6rem;
}

.card-features li i {
    color: var(--success);
    font-size: 0.8rem;
}

/* Apple IAP Simulator styling */
.iap-divider {
    display: flex;
    align-items: center;
    text-align: center;
    margin: 2rem 0 1.25rem 0;
    color: var(--text-muted);
    font-size: 0.8rem;
}

.iap-divider::before, .iap-divider::after {
    content: '';
    flex: 1;
    border-bottom: 1px solid var(--border-glass);
}

.iap-divider::before { margin-right: .75em; }
.iap-divider::after { margin-left: .75em; }

.iap-simulator {
    background-color: rgba(0,0,0,0.18);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 1.25rem;
}

.iap-help {
    font-size: 0.8rem;
    color: var(--text-muted);
    margin-bottom: 1rem;
}

.iap-inputs {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.token-helper {
    display: block;
    margin-top: 0.4rem;
    font-size: 0.72rem;
    color: var(--text-muted);
    line-height: 1.3;
}

/* Landing Screen Layout */
#landing-screen {
    flex-direction: column;
    overflow-y: auto;
    padding: 2rem;
    align-items: center;
}

.landing-header {
    width: 100%;
    max-width: 1200px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-glass);
}

.header-nav {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.btn-text {
    color: var(--text-muted);
    text-decoration: none;
    font-weight: 500;
    transition: var(--transition);
}

.btn-text:hover {
    color: var(--text-main);
}

.landing-hero {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    max-width: 1000px;
    width: 100%;
    text-align: center;
    padding: 4rem 1rem;
}

.hero-title {
    font-family: var(--font-outfit);
    font-size: 3.5rem;
    font-weight: 800;
    line-height: 1.15;
    background: linear-gradient(135deg, #ffffff 30%, #a78bfa 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    margin-bottom: 1.5rem;
}

.hero-subtitle {
    font-size: 1.2rem;
    color: var(--text-muted);
    max-width: 700px;
    line-height: 1.6;
    margin-bottom: 3rem;
}

.hero-actions {
    display: flex;
    gap: 1rem;
    margin-bottom: 5rem;
}

.features-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.5rem;
    width: 100%;
    max-width: 1200px;
}

.feature-card {
    background: var(--bg-glass);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-md);
    padding: 2rem 1.5rem;
    text-align: left;
    transition: var(--transition);
}

.feature-card:hover {
    transform: translateY(-5px);
    border-color: var(--primary);
    box-shadow: 0 10px 20px var(--primary-glow);
}

.feature-icon {
    font-size: 1.8rem;
    color: var(--primary);
    margin-bottom: 1.25rem;
}

.feature-card h3 {
    font-family: var(--font-outfit);
    font-size: 1.25rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
}

.feature-card p {
    font-size: 0.9rem;
    color: var(--text-muted);
    line-height: 1.5;
}

/* Chat Model Selector Styling */
.chat-model-select {
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.chat-model-select label {
    font-size: 0.8rem;
    color: var(--text-muted);
}

.chat-model-select select {
    background: var(--bg-surface);
    color: var(--text-main);
    border: 1px solid var(--border-glass);
    border-radius: var(--radius-sm);
    padding: 0.35rem 0.6rem;
    font-size: 0.85rem;
    cursor: pointer;
    transition: var(--transition);
}

.chat-model-select select:focus {
    outline: none;
    border-color: var(--primary);
}

/* Conversation Sidebar Grouping Styling */
.conv-group-header {
    font-size: 0.72rem;
    font-weight: 700;
    text-transform: uppercase;
    color: var(--text-muted);
    padding: 1rem 0.8rem 0.4rem 0.8rem;
    letter-spacing: 0.05em;
    list-style: none;
    user-select: none;
}

.no-chats-placeholder {
    font-size: 0.85rem;
    color: var(--text-muted);
    text-align: center;
    padding: 2rem 1rem;
    list-style: none;
}
