/* ============= RESET / BASE ============= */
*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: system-ui, -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
    background: #020617;
    color: #e5e7eb;
}

/* ============= LAYOUT ============= */

.app-shell {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Header */

.app-header {
    padding: 10px 14px;
    border-bottom: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: rgba(15, 23, 42, 0.98);
    backdrop-filter: blur(12px);
    position: sticky;
    top: 0;
    z-index: 20;
}

.brand {
    display: flex;
    align-items: center;
    gap: 8px;
}

.brand-logo {
    width: 32px;
    height: 32px;
    border-radius: 999px;
    background: radial-gradient(circle at 30% 0%, #38bdf8, #6366f1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 18px;
    font-weight: 700;
    color: white;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-text span:first-child {
    font-weight: 600;
    font-size: 14px;
}

.brand-text span:last-child {
    font-size: 11px;
    color: #9ca3af;
}

.nav-links a {
    font-size: 12px;
    color: #9ca3af;
    margin-left: 10px;
    text-decoration: none;
}
.nav-links a:hover {
    color: #e5e7eb;
}

/* Main layout */

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

/* Sidebar */

.sidebar {
    width: 100%;
    border-bottom: 1px solid rgba(148, 163, 184, 0.25);
    padding: 10px;
    background: radial-gradient(circle at top left, rgba(37, 99, 235, 0.25), transparent);
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.sidebar-section-title {
    font-size: 11px;
    text-transform: uppercase;
    color: #9ca3af;
    letter-spacing: 0.08em;
    margin-bottom: 4px;
}

.session-list {
    max-height: 180px;
    overflow-y: auto;
    padding-right: 2px;
}

.session-item {
    padding: 8px;
    margin-bottom: 4px;
    border-radius: 10px;
    font-size: 13px;
    cursor: pointer;
    border: 1px solid transparent;
}
.session-item.active {
    background: rgba(15, 23, 42, 0.9);
    border-color: rgba(129, 140, 248, 0.8);
}
.session-item:hover {
    background: rgba(15, 23, 42, 0.85);
}

/* Profile card */

.profile-card {
    margin-top: 6px;
    padding: 10px;
    border-radius: 14px;
    background: linear-gradient(135deg, rgba(30, 64, 175, 0.95), rgba(8, 47, 73, 0.98));
    font-size: 12px;
}

.profile-name {
    font-weight: 600;
    margin-bottom: 2px;
}

.profile-email {
    font-size: 11px;
    color: #cbd5f5;
}

.profile-actions {
    display: flex;
    gap: 6px;
    margin-top: 8px;
}

/* Buttons */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    border-radius: 999px;
    border: none;
    outline: none;
    padding: 6px 12px;
    font-size: 11px;
    cursor: pointer;
    background: linear-gradient(135deg, #6366f1, #22c55e);
    color: white;
    font-weight: 500;
    box-shadow: 0 10px 25px rgba(79, 70, 229, 0.6);
}

.btn-secondary {
    background: transparent;
    color: #e5e7eb;
    border: 1px solid rgba(148, 163, 184, 0.7);
    box-shadow: none;
}

.btn-block {
    width: 100%;
}

.btn-sm {
    padding: 4px 8px;
    font-size: 10px;
}

/* Chat area */

.chat-area {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.chat-stream {
    flex: 1;
    overflow-y: auto;
    padding: 14px;
}

.chat-message {
    display: flex;
    margin-bottom: 8px;
}

.chat-message.assistant .bubble {
    background: rgba(15, 23, 42, 0.95);
    border-radius: 16px;
    border: 1px solid rgba(148, 163, 184, 0.4);
}

.chat-message.user {
    justify-content: flex-end;
}

.chat-message.user .bubble {
    background: linear-gradient(135deg, #6366f1, #22c55e);
    border-radius: 16px;
    color: white;
}

.bubble {
    max-width: 80%;
    padding: 8px 11px;
    font-size: 14px;
    line-height: 1.4;
}

/* Chat input */

.chat-input-bar {
    padding: 10px;
    border-top: 1px solid rgba(148, 163, 184, 0.3);
    display: flex;
    flex-direction: column;
    gap: 8px;
    background: rgba(15, 23, 42, 0.98);
}

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

.chat-input-row textarea {
    flex: 1;
    min-height: 40px;
    max-height: 110px;
    resize: vertical;
    border-radius: 12px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    background: rgba(15, 23, 42, 0.96);
    color: #e5e7eb;
    padding: 7px 9px;
    font-size: 13px;
}
.chat-input-row textarea:focus {
    outline: none;
    border-color: #6366f1;
}

.icon-button {
    width: 36px;
    height: 36px;
    border-radius: 999px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    background: rgba(15, 23, 42, 0.96);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    font-size: 18px;
}

.chat-input-row input[type="file"] {
    display: none;
}

.sub-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-size: 10px;
    color: #9ca3af;
}

/* Footer */

.footer-links {
    padding: 10px 14px;
    border-top: 1px solid rgba(148, 163, 184, 0.25);
    font-size: 10px;
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
    background: rgba(15, 23, 42, 0.99);
}
.footer-links a {
    color: #9ca3af;
    text-decoration: none;
}
.footer-links a:hover {
    color: #e5e7eb;
}

/* ============= AUTH OVERLAY ============= */

.auth-overlay {
    position: fixed;
    inset: 0;
    background: radial-gradient(circle at top, rgba(56, 189, 248, 0.18), rgba(15, 23, 42, 0.98));
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 40;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.5);
    background: rgba(15, 23, 42, 0.98);
    padding: 20px 18px 18px;
    box-shadow: 0 24px 80px rgba(15, 23, 42, 0.9);
    font-size: 13px;
}

.auth-card h2 {
    margin: 0 0 6px;
    font-size: 19px;
}

.auth-card p {
    margin: 0 0 14px;
    font-size: 12px;
    color: #9ca3af;
}

.field {
    margin-bottom: 9px;
}

.field label {
    display: block;
    font-size: 11px;
    margin-bottom: 3px;
    color: #cbd5f5;
}

.field input {
    width: 100%;
    border-radius: 10px;
    border: 1px solid rgba(148, 163, 184, 0.7);
    padding: 7px 9px;
    font-size: 13px;
    background: rgba(15, 23, 42, 0.96);
    color: #e5e7eb;
}
.field input:focus {
    outline: none;
    border-color: #6366f1;
}

.auth-footer {
    margin-top: 8px;
    font-size: 11px;
    color: #9ca3af;
    text-align: center;
}

.link {
    color: #a5b4fc;
    cursor: pointer;
}
.link:hover {
    text-decoration: underline;
}

/* ============= PROFILE PANEL OVERLAY ============= */

.profile-panel {
    position: fixed;
    inset: 0;
    display: none;
    align-items: center;
    justify-content: center;
    background: rgba(15, 23, 42, 0.85);
    backdrop-filter: blur(5px);
    z-index: 50;
}

.profile-panel.open {
    display: flex;
}

.profile-panel-card {
    max-width: 420px;
    width: 100%;
    margin: 0 16px;
    background: rgba(15, 23, 42, 0.98);
    border-radius: 18px;
    border: 1px solid rgba(148, 163, 184, 0.6);
    padding: 18px 16px 14px;
    box-shadow: 0 22px 60px rgba(15, 23, 42, 0.9);
    font-size: 13px;
    max-height: 80vh;
    overflow-y: auto;
}

.profile-panel-card h3 {
    margin: 0 0 4px;
    font-size: 18px;
}

.profile-panel-card h4 {
    margin: 14px 0 6px;
    font-size: 14px;
}

.profile-panel-card p {
    margin: 0 0 12px;
    font-size: 12px;
    color: #9ca3af;
}

/* Subscription info */

.sub-info-card {
    background: rgba(30, 41, 59, 0.7);
    padding: 10px;
    border: 1px solid rgba(148, 163, 184, 0.3);
    border-radius: 12px;
    font-size: 13px;
    margin-top: 6px;
}
.sub-info-card p {
    margin: 5px 0;
}
.sub-info-card strong {
    color: #e2e8f0;
}

/* Hide cancel by default, shown only when active via JS */
#cancelSubBtn {
    display: none;
}

/* ============= RESPONSIVE (DESKTOP) ============= */

@media (min-width: 900px) {
    .main-content {
        flex-direction: row;
    }

    .sidebar {
        width: 260px;
        border-right: 1px solid rgba(148, 163, 184, 0.25);
        border-bottom: none;
        flex-direction: column;
    }

    .session-list {
        max-height: 50vh;
    }

    .profile-card {
        margin-top: auto;
        max-width: 100%;
    }
}

@media (max-width: 640px) {
    .profile-panel {
        align-items: flex-start;
        padding-top: 70px;
    }
}
