/* GPTExpress - ChatGPT Clone with Purple Theme */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700&family=JetBrains+Mono:wght@400;600;700&display=swap');

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

html {
    height: 100%;
    height: -webkit-fill-available;
}

body {
    font-family: 'Inter', -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: #212121;
    color: #ececec;
    height: 100%;
    height: -webkit-fill-available;
    height: 100dvh;
    overflow: hidden;
}

h1, h2, h3, .model-btn, #modelLabel, .auth-panel h1, .empty-state h1 {
    font-family: 'JetBrains Mono', ui-monospace, SFMono-Regular, Menlo, Consolas, monospace;
}

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

.login-container {
    display: flex;
    align-items: safe center;
    justify-content: center;
    min-height: 100vh;
    min-height: 100dvh;
    background: #212121;
    padding: 16px;
    overflow-y: auto;
}

.auth-card {
    width: 100%;
    max-width: 360px;
    transition: max-width 0.25s ease;
}

/* Wider card for signup to fit side-by-side rows */
.auth-card:has(#signupPanel[style*="block"]) {
    max-width: 480px;
}

.auth-panel {
    text-align: center;
    animation: authFadeIn 0.25s ease;
}

@keyframes authFadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to   { opacity: 1; transform: translateY(0); }
}

.login-logo {
    width: 112px;
    height: 112px;
    margin-bottom: 16px;
}

/* Smaller logo + tighter spacing on signup */
.signup-logo {
    width: 64px;
    height: 64px;
    margin-bottom: 10px;
}

.signup-title {
    font-size: 20px !important;
    margin-bottom: 4px !important;
}

.signup-tagline {
    margin-bottom: 16px !important;
}

.auth-panel h1 {
    font-size: 24px;
    margin-bottom: 6px;
    color: #fff;
    font-weight: 600;
}

.tagline {
    color: #8e8e8e;
    margin-bottom: 24px;
    font-size: 14px;
}

.auth-panel input {
    width: 100%;
    padding: 10px 12px;
    margin-bottom: 8px;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    transition: border-color 0.2s;
    box-sizing: border-box;
}

.auth-panel input:focus {
    outline: none;
    border-color: #1c99fd;
}

.auth-panel input::placeholder {
    color: #8e8e8e;
}

.auth-panel button[type="submit"] {
    width: 100%;
    padding: 12px;
    background: #1c99fd;
    border: none;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    margin-top: 4px;
    font-family: inherit;
    box-shadow: 0 0 16px rgba(28, 153, 253, 0.4);
    transition: background 0.2s, box-shadow 0.2s;
}

.auth-panel button[type="submit"]:hover {
    background: #0a82d8;
    box-shadow: 0 0 26px rgba(28, 153, 253, 0.65);
}

/* ==================== FORM SECTIONS ==================== */

.form-section {
    background: rgba(28, 153, 253, 0.03);
    border: 1px solid rgba(28, 153, 253, 0.08);
    border-radius: 10px;
    padding: 14px 14px 8px;
    margin-bottom: 10px;
}

.form-section-title {
    font-size: 10px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 1.5px;
    color: #1c99fd;
    margin-bottom: 8px;
}

.field-wrap {
    margin-bottom: 2px;
}

.field-error {
    color: #ef4444;
    font-size: 12px;
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.25s ease, opacity 0.25s ease, margin 0.25s ease;
    opacity: 0;
    margin: 0;
    line-height: 1.3;
}

.field-error.visible {
    max-height: 32px;
    opacity: 1;
    margin: 2px 0 6px 2px;
}

/* Side-by-side input row */
.input-row {
    display: flex;
    gap: 10px;
}

.input-row input {
    flex: 1;
    min-width: 0;
}

.input-row .field-wrap {
    flex: 1;
    min-width: 0;
}

.input-row .field-wrap .custom-select {
    min-width: 0;
}

.help-text {
    margin-top: 20px;
    font-size: 13px;
    color: #8e8e8e;
}

.help-text a {
    color: #6dc4fe;
    text-decoration: none;
    cursor: pointer;
}

.help-text a:hover {
    text-decoration: underline;
}

.auth-company {
    margin-top: 16px;
    font-size: 11px;
    color: #555;
    letter-spacing: 0.3px;
}

.error-message {
    color: #ef4444;
    margin-top: 12px;
    font-size: 13px;
    min-height: 18px;
}

/* Keep old .login-box selectors working */
.login-box { display: none; }

/* ==================== CUSTOM SELECT DROPDOWN ==================== */

.custom-select {
    position: relative;
    margin-bottom: 8px;
}

.custom-select-trigger {
    width: 100%;
    padding: 10px 12px;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    font-family: inherit;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: border-color 0.2s, box-shadow 0.2s;
    text-align: left;
    box-sizing: border-box;
}

.custom-select-trigger:hover {
    border-color: #555;
}

.custom-select.open .custom-select-trigger {
    border-color: #1c99fd;
    box-shadow: 0 0 0 3px rgba(28, 153, 253, 0.12);
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
}

.custom-select-trigger svg {
    margin-left: auto;
    flex-shrink: 0;
    color: #8e8e8e;
    transition: transform 0.2s;
}

.custom-select.open .custom-select-trigger .city-chevron,
.custom-select.open .custom-select-trigger svg:not(.city-spinner) {
    transform: rotate(180deg);
}

.custom-select-value {
    flex: 1;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    display: flex;
    align-items: center;
    gap: 6px;
}

.custom-select-value.placeholder {
    color: #8e8e8e;
    display: block;
}

.custom-select-dropdown {
    display: none;
    position: absolute;
    top: 100%;
    left: 0;
    right: 0;
    background: #2f2f2f;
    border: 1px solid #1c99fd;
    border-top: none;
    border-radius: 0 0 8px 8px;
    z-index: 50;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
    overflow: hidden;
}

.custom-select.open .custom-select-dropdown {
    display: block;
}

.custom-select-search {
    width: 100%;
    padding: 8px 12px;
    background: #252525;
    border: none;
    border-bottom: 1px solid #3a3a3a;
    color: #fff;
    font-size: 13px;
    font-family: inherit;
    outline: none;
    box-sizing: border-box;
}

.custom-select-search::placeholder {
    color: #666;
}

.custom-select-list {
    max-height: 220px;
    overflow-y: auto;
}

.custom-select-list::-webkit-scrollbar {
    width: 5px;
}

.custom-select-list::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 3px;
}

.custom-select-item {
    padding: 9px 12px;
    cursor: pointer;
    font-size: 14px;
    color: #ececec;
    display: flex;
    align-items: center;
    gap: 8px;
    transition: background 0.1s;
}

.custom-select-item:hover {
    background: #3a3a3a;
}

.custom-select-item.selected {
    background: rgba(28, 153, 253, 0.15);
    color: #1c99fd;
}

.custom-select-item .fi,
.custom-select-value .fi,
.phone-code .fi {
    font-size: 16px;
    line-height: 1;
    flex-shrink: 0;
    border-radius: 2px;
}

.custom-select-empty {
    padding: 12px;
    color: #666;
    font-size: 13px;
    text-align: center;
}

/* Disabled state */
.custom-select.disabled .custom-select-trigger {
    opacity: 0.4;
    cursor: not-allowed;
    pointer-events: none;
}

/* City spinner */
.city-spinner {
    display: none;
    animation: spin 0.8s linear infinite;
}

.custom-select.loading .city-chevron {
    display: none;
}

.custom-select.loading .city-spinner {
    display: block;
}

/* ==================== PHONE GROUP ==================== */

.phone-group {
    display: flex;
    margin-bottom: 8px;
    border: 1px solid #424242;
    border-radius: 8px;
    overflow: hidden;
    transition: border-color 0.2s;
}

.phone-group:focus-within {
    border-color: #1c99fd;
}

.phone-code {
    padding: 0 10px;
    background: #3a3a3a;
    color: #ececec;
    font-size: 13px;
    font-weight: 600;
    white-space: nowrap;
    border-right: 1px solid #424242;
    display: flex;
    align-items: center;
    gap: 5px;
    min-width: 48px;
    justify-content: center;
    flex-shrink: 0;
}

.phone-group input {
    flex: 1;
    border: none !important;
    border-radius: 0 !important;
    margin-bottom: 0 !important;
    outline: none !important;
    min-width: 0;
}

/* ==================== PASSWORD STRENGTH (Segmented) ==================== */

.strength-row {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 4px;
}

.strength-segments {
    display: flex;
    gap: 4px;
    flex: 1;
}

.strength-segment {
    flex: 1;
    height: 4px;
    border-radius: 2px;
    background: #424242;
    transition: background 0.3s ease;
}

/* Segment colors by level */
.strength-segments[data-level="1"] .strength-segment:nth-child(1) { background: #ef4444; }
.strength-segments[data-level="2"] .strength-segment:nth-child(1),
.strength-segments[data-level="2"] .strength-segment:nth-child(2) { background: #f59e0b; }
.strength-segments[data-level="3"] .strength-segment:nth-child(1),
.strength-segments[data-level="3"] .strength-segment:nth-child(2),
.strength-segments[data-level="3"] .strength-segment:nth-child(3) { background: #1c99fd; }
.strength-segments[data-level="4"] .strength-segment { background: #22c55e; }

.strength-label {
    font-size: 11px;
    font-weight: 600;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    white-space: nowrap;
    min-width: 48px;
    text-align: right;
    transition: color 0.3s;
}

/* ==================== PASSWORD MATCH GLOW ==================== */

#signupPasswordConfirm.match-valid {
    border-color: #22c55e !important;
    box-shadow: 0 0 0 3px rgba(34, 197, 94, 0.15);
}

#signupPasswordConfirm.match-invalid {
    border-color: #ef4444 !important;
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* (select-wrapper removed — using custom-select component) */

/* ==================== SUBMIT BUTTON SPINNER ==================== */

.auth-panel button[type="submit"] {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    position: relative;
}

.btn-spinner {
    display: none;
    width: 18px;
    height: 18px;
    animation: spin 0.8s linear infinite;
}

.auth-panel button[type="submit"].loading .btn-text {
    opacity: 0;
}

.auth-panel button[type="submit"].loading .btn-spinner {
    display: inline-block;
    position: absolute;
}

.auth-panel button[type="submit"].loading {
    pointer-events: none;
    opacity: 0.8;
}

/* ==================== ENHANCED INPUT FOCUS ==================== */

.auth-panel input:focus,
.auth-panel select:focus {
    box-shadow: 0 0 0 3px rgba(28, 153, 253, 0.12);
}

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

.chat-container {
    display: flex;
    height: 100%;
    height: 100dvh;
}

/* ==================== SIDEBAR ==================== */

.sidebar {
    width: 260px;
    min-width: 260px;
    background: #171717;
    display: flex;
    flex-direction: column;
    transition: width 0.2s ease, min-width 0.2s ease;
}

.sidebar.collapsed {
    width: 56px;
    min-width: 56px;
}

.sidebar-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px;
    flex-shrink: 0;
    border-bottom: 1px solid transparent;
}

.sidebar:not(.collapsed) .sidebar-header {
    border-bottom-color: #2f2f2f;
}

.sidebar-logo-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 8px;
}

.sidebar-logo-btn:hover {
    background: #2f2f2f;
}

.sidebar-logo-btn img {
    width: 28px;
    height: 28px;
}

.sidebar-collapse-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 32px;
    height: 32px;
    background: transparent;
    border: none;
    border-radius: 6px;
    color: #8e8e8e;
    cursor: pointer;
}

.sidebar-collapse-btn:hover {
    background: #2f2f2f;
    color: #ececec;
}

.sidebar.collapsed .sidebar-collapse-btn {
    display: none;
}

.sidebar.collapsed .sidebar-header {
    justify-content: center;
    padding: 12px 8px;
}

.sidebar-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.sidebar.collapsed .sidebar-content {
    display: none;
}

.sidebar-logo {
    padding: 12px 16px;
    display: flex;
    align-items: center;
}

.sidebar-logo img {
    width: 28px;
    height: 28px;
}

.sidebar-actions {
    padding: 8px 12px;
}

.btn-new-chat {
    width: 100%;
    padding: 10px 12px;
    background: transparent;
    border: 1px solid #424242;
    border-radius: 8px;
    color: #ececec;
    cursor: pointer;
    font-size: 14px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-family: inherit;
    transition: background 0.2s, border-color 0.2s, box-shadow 0.2s;
}

.btn-new-chat:hover {
    background: #2f2f2f;
    border-color: #1c99fd;
    box-shadow: 0 0 10px rgba(28, 153, 253, 0.25);
}

.btn-new-chat svg {
    opacity: 0.8;
}

.chat-section {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.chat-section-title {
    padding: 8px 16px;
    font-size: 12px;
    color: #8e8e8e;
    font-weight: 500;
}

.chat-list {
    padding: 0 8px;
}

.chat-item {
    padding: 10px 12px;
    border-radius: 8px;
    cursor: pointer;
    margin-bottom: 2px;
    position: relative;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-item:hover {
    background: #2f2f2f;
}

.chat-item:hover .chat-actions {
    opacity: 1;
}

.chat-item.active {
    background: #2f2f2f;
}

.chat-item-title {
    font-size: 14px;
    color: #ececec;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    flex: 1;
}

/* In-place edit input */
.chat-item-input {
    flex: 1;
    background: #171717;
    border: 1px solid #1c99fd;
    border-radius: 4px;
    color: #fff;
    font-size: 14px;
    padding: 4px 8px;
    font-family: inherit;
    outline: none;
}

.chat-actions {
    display: flex;
    gap: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.chat-action-btn {
    width: 24px;
    height: 24px;
    background: transparent;
    border: none;
    border-radius: 4px;
    color: #8e8e8e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
}

.chat-action-btn:hover {
    background: #424242;
    color: #ececec;
}

.chat-action-btn svg {
    width: 14px;
    height: 14px;
}

.sidebar-footer {
    padding: 12px;
    border-top: 1px solid #2f2f2f;
}

.user-info {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-bottom: 10px;
    font-size: 14px;
}

.user-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    background: #1c99fd;
    background-size: cover;
    background-position: center;
    flex-shrink: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 12px;
    font-weight: 600;
    color: #fff;
    text-transform: uppercase;
}

.user-avatar.has-image {
    background-color: transparent;
}

.credits {
    margin-left: auto;
    color: #1c99fd;
    font-weight: 600;
}

.btn-logout {
    width: 100%;
    padding: 8px;
    background: transparent;
    border: 1px solid #424242;
    border-radius: 6px;
    color: #8e8e8e;
    cursor: pointer;
    font-size: 13px;
    font-family: inherit;
}

.btn-logout:hover {
    background: #2f2f2f;
    color: #ececec;
}

/* ==================== MAIN CONTENT ==================== */

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

/* Header with model selector */
.chat-header {
    padding: 12px 16px;
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Custom Model Dropdown */
.model-dropdown {
    position: relative;
}

.model-btn {
    display: flex;
    align-items: center;
    gap: 6px;
    padding: 8px 12px;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 8px;
    color: #ececec;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    min-width: 140px;
}

.model-btn:hover {
    background: #3a3a3a;
}

.model-btn svg {
    margin-left: auto;
    opacity: 0.6;
}

.model-menu {
    position: absolute;
    top: 100%;
    left: 0;
    margin-top: 4px;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 8px;
    min-width: 180px;
    padding: 4px;
    z-index: 100;
    display: none;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.model-menu.open {
    display: block;
}

.model-option {
    padding: 10px 12px;
    border-radius: 6px;
    cursor: pointer;
    font-size: 14px;
    color: #ececec;
    transition: all 0.15s;
}

.model-option:hover {
    background: #1c99fd;
    color: #fff;
}

.model-option.selected {
    background: #1c99fd;
    color: #fff;
}

.reasoning-select {
    padding: 8px 12px;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 8px;
    color: #ececec;
    font-size: 14px;
    cursor: pointer;
    font-family: inherit;
}

.reasoning-select:focus {
    outline: none;
    border-color: #1c99fd;
}

.reasoning-select option {
    background: #2f2f2f;
    color: #ececec;
}

/* Messages */
.messages-container {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
}

.empty-state {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

.empty-state h1 {
    font-size: 32px;
    color: #666;
    font-weight: 400;
}

.messages-wrapper {
    max-width: 768px;
    margin: 0 auto;
    padding: 20px 24px;
    width: 100%;
}

.message {
    margin-bottom: 24px;
}

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

.message-user .message-content {
    background: #2f2f2f;
    padding: 12px 16px;
    border-radius: 20px;
    max-width: 70%;
}

.message-assistant .message-content {
    padding: 12px 0;
}

.message-content {
    line-height: 1.6;
    font-size: 15px;
    white-space: pre-wrap;
    word-wrap: break-word;
}

.message-content img {
    max-width: 400px;
    border-radius: 12px;
    margin-top: 8px;
}

.message-meta {
    margin-top: 8px;
    font-size: 12px;
    color: #666;
}

/* ==================== MARKDOWN & CODE BLOCKS ==================== */

.markdown-content {
    line-height: 1.7;
}

.markdown-content p {
    margin: 0 0 12px 0;
}

.markdown-content p:last-child {
    margin-bottom: 0;
}

.markdown-content h1,
.markdown-content h2,
.markdown-content h3,
.markdown-content h4 {
    margin: 16px 0 8px 0;
    font-weight: 600;
}

.markdown-content h1 { font-size: 1.5em; }
.markdown-content h2 { font-size: 1.3em; }
.markdown-content h3 { font-size: 1.1em; }

.markdown-content ul,
.markdown-content ol {
    margin: 8px 0;
    padding-left: 24px;
}

.markdown-content li {
    margin: 4px 0;
}

.markdown-content code {
    font-family: 'Fira Code', 'Consolas', 'Monaco', monospace;
    font-size: 0.9em;
}

/* Inline code */
.markdown-content code:not(pre code) {
    background: #1a1a1a;
    padding: 2px 6px;
    border-radius: 4px;
    color: #e06c75;
}

/* Code blocks */
.markdown-content pre {
    background: #0d1117;
    border: 1px solid #30363d;
    border-radius: 8px;
    margin: 12px 0;
    overflow: hidden;
    position: relative;
}

.markdown-content pre code {
    display: block;
    padding: 16px;
    overflow-x: auto;
    font-size: 13px;
    line-height: 1.5;
    color: #e6edf3;
}

/* Code block header with language */
.markdown-content pre code::before {
    content: attr(class);
    display: block;
    padding: 8px 16px;
    margin: -16px -16px 12px -16px;
    background: #161b22;
    border-bottom: 1px solid #30363d;
    font-size: 12px;
    color: #7d8590;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

.markdown-content pre code.hljs::before {
    content: none;
}

/* Blockquotes */
.markdown-content blockquote {
    border-left: 3px solid #1c99fd;
    margin: 12px 0;
    padding: 8px 16px;
    background: rgba(28, 153, 253, 0.1);
    border-radius: 0 8px 8px 0;
}

.markdown-content blockquote p {
    margin: 0;
}

/* Tables */
.markdown-content table {
    border-collapse: collapse;
    margin: 12px 0;
    width: 100%;
}

.markdown-content th,
.markdown-content td {
    border: 1px solid #30363d;
    padding: 8px 12px;
    text-align: left;
}

.markdown-content th {
    background: #161b22;
    font-weight: 600;
}

.markdown-content tr:nth-child(even) {
    background: rgba(255, 255, 255, 0.02);
}

/* Links */
.markdown-content a {
    color: #1c99fd;
    text-decoration: none;
}

.markdown-content a:hover {
    text-decoration: underline;
}

/* Horizontal rule */
.markdown-content hr {
    border: none;
    border-top: 1px solid #30363d;
    margin: 16px 0;
}

/* ==================== INPUT AREA ==================== */

.input-wrapper {
    flex-shrink: 0;
    padding: 16px 24px 24px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.input-container {
    max-width: 768px;
    width: 100%;
    display: flex;
    align-items: flex-end;
    gap: 0;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 26px;
    transition: border-color 0.2s, box-shadow 0.2s;
    padding: 4px;
}

.btn-attach {
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #8e8e8e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.btn-attach:hover {
    background: #424242;
    color: #ececec;
}

#messageInput {
    flex: 1;
    padding: 10px 4px;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 15px;
    resize: none;
    max-height: 200px;
    font-family: inherit;
    line-height: 1.5;
}

#messageInput:focus {
    outline: none;
}

#messageInput::placeholder {
    color: #8e8e8e;
}

.input-container:focus-within {
    border-color: #1c99fd;
    box-shadow: 0 0 16px rgba(28, 153, 253, 0.2);
}

.btn-send {
    width: 40px;
    height: 40px;
    background: #1c99fd;
    border: none;
    border-radius: 50%;
    color: #fff;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    box-shadow: 0 0 14px rgba(28, 153, 253, 0.5);
    transition: background 0.2s, box-shadow 0.2s;
}

.btn-send:hover {
    background: #0a82d8;
    box-shadow: 0 0 22px rgba(28, 153, 253, 0.75);
}

.btn-send:disabled {
    background: #424242;
    cursor: not-allowed;
}

.btn-send svg {
    transform: rotate(-90deg);
}

/* ==================== FILE CHIP ==================== */

.file-chip {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 12px;
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 20px;
    margin-bottom: 8px;
    max-width: 300px;
}

.file-chip svg {
    color: #8e8e8e;
    flex-shrink: 0;
}

.file-chip-name {
    color: #ececec;
    font-size: 13px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 150px;
}

.file-chip-label {
    color: #666;
    font-size: 12px;
}

.file-chip-remove {
    width: 20px;
    height: 20px;
    background: transparent;
    border: none;
    border-radius: 50%;
    color: #8e8e8e;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 0;
    margin-left: 4px;
}

.file-chip-remove:hover {
    background: #424242;
    color: #fff;
}

/* Spinner animation */
@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

.spinner {
    animation: spin 1s linear infinite;
}

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

.typing-dot {
    width: 8px;
    height: 8px;
    background: #666;
    border-radius: 50%;
    animation: typing 1.4s infinite;
}

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

@keyframes typing {
    0%, 60%, 100% { opacity: 0.4; }
    30% { opacity: 1; }
}

/* ==================== CUSTOM MODAL ==================== */

.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
    opacity: 0;
    visibility: hidden;
    transition: all 0.2s;
}

.modal-overlay.open {
    opacity: 1;
    visibility: visible;
}

.modal-box {
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 12px;
    padding: 24px;
    max-width: 400px;
    width: 90%;
    transform: scale(0.95);
    transition: transform 0.2s;
}

.modal-overlay.open .modal-box {
    transform: scale(1);
}

.modal-title {
    font-size: 18px;
    font-weight: 600;
    color: #fff;
    margin-bottom: 12px;
}

.modal-message {
    font-size: 14px;
    color: #acacac;
    margin-bottom: 20px;
    line-height: 1.5;
}

.modal-input {
    width: 100%;
    padding: 12px;
    background: #212121;
    border: 1px solid #424242;
    border-radius: 8px;
    color: #fff;
    font-size: 14px;
    margin-bottom: 20px;
    font-family: inherit;
}

.modal-input:focus {
    outline: none;
    border-color: #1c99fd;
}

.modal-buttons {
    display: flex;
    gap: 12px;
    justify-content: flex-end;
}

.modal-btn {
    padding: 10px 20px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 500;
    cursor: pointer;
    font-family: inherit;
    border: none;
}

.modal-btn-cancel {
    background: transparent;
    border: 1px solid #424242;
    color: #acacac;
}

.modal-btn-cancel:hover {
    background: #3a3a3a;
    color: #fff;
}

.modal-btn-primary {
    background: #1c99fd;
    color: #fff;
}

.modal-btn-primary:hover {
    background: #0a82d8;
}

.modal-btn-danger {
    background: #ef4444;
    color: #fff;
}

.modal-btn-danger:hover {
    background: #dc2626;
}

/* Toast Notifications */
.toast-container {
    position: fixed;
    bottom: 24px;
    right: 24px;
    z-index: 1001;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.toast {
    background: #2f2f2f;
    border: 1px solid #424242;
    border-radius: 8px;
    padding: 12px 16px;
    color: #ececec;
    font-size: 14px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease;
}

.toast.error {
    border-color: #ef4444;
    background: #3f1f1f;
}

.toast.success {
    border-color: #22c55e;
    background: #1f3f1f;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: transparent;
}

::-webkit-scrollbar-thumb {
    background: #424242;
    border-radius: 3px;
}

/* ==================== SIDEBAR OVERLAY (mobile) ==================== */

.sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 199;
    opacity: 0;
    transition: opacity 0.25s;
    pointer-events: none;
}

.sidebar-overlay.visible {
    opacity: 1;
    pointer-events: all;
}

/* ==================== MOBILE HAMBURGER BUTTON ==================== */

.mobile-menu-btn {
    display: none;
    width: 40px;
    height: 40px;
    background: transparent;
    border: none;
    border-radius: 8px;
    color: #ececec;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
}

.mobile-menu-btn:hover {
    background: #2f2f2f;
}

/* ==================== RESPONSIVE / MOBILE ==================== */

@media (max-width: 768px) {
    /* Sidebar becomes a slide-in drawer */
    .sidebar {
        position: fixed;
        top: 0;
        left: 0;
        height: 100%;
        width: 280px;
        min-width: 280px;
        z-index: 200;
        transform: translateX(-100%);
        transition: transform 0.25s ease;
    }

    .sidebar.mobile-open {
        transform: translateX(0);
    }

    .sidebar-overlay {
        display: block;
    }

    .sidebar-collapse-btn {
        display: none;
    }

    /* Show hamburger in header on mobile */
    .mobile-menu-btn {
        display: flex;
    }

    .main-content {
        width: 100%;
    }

    .messages-wrapper {
        padding: 16px;
    }

    .message-user .message-content {
        max-width: 85%;
    }

    /* Input bar */
    .input-wrapper {
        padding: 12px;
        padding-bottom: calc(12px + env(safe-area-inset-bottom));
        border-top: 1px solid #2f2f2f;
    }

    /* Prevent iOS zoom on input focus */
    #messageInput {
        font-size: 16px;
    }
}



/* ==================== EMAIL-CODE AUTH ==================== */
.auth-step { display: flex; flex-direction: column; gap: 12px; width: 100%; }
.auth-step .help-text { margin-top: 4px; }
.code-sent-text {
    font-size: 14px;
    color: #acacac;
    margin-bottom: 16px;
    line-height: 1.5;
}
.code-sent-text strong { color: #ececec; }
#authCode {
    text-align: center;
    letter-spacing: 8px;
    font-size: 22px;
    font-weight: 600;
}
.help-text a.disabled { opacity: 0.5; pointer-events: none; }

/* ==================== NOTIFICATIONS BELL ==================== */
.notif-btn {
    margin-left: auto;
    position: relative;
    background: transparent;
    border: none;
    color: #ececec;
    cursor: pointer;
    padding: 8px;
    border-radius: 8px;
    display: flex;
    align-items: center;
}
.notif-btn:hover { background: #2f2f2f; }
.notif-badge {
    position: absolute;
    top: 2px;
    right: 2px;
    min-width: 16px;
    height: 16px;
    padding: 0 4px;
    background: #ef4444;
    color: #fff;
    font-size: 10px;
    font-weight: 700;
    border-radius: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    line-height: 1;
}

/* ==================== BUY CREDITS ==================== */
.btn-buy-credits {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    width: 100%;
    padding: 10px;
    margin-top: 8px;
    background: #1c99fd;
    color: #fff;
    border: none;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    font-family: inherit;
}
.btn-buy-credits:hover { background: #0a82d8; }

.buy-modal, .notif-modal { max-width: 440px; }

.credit-packages {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-bottom: 16px;
}
.credit-pack {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 4px;
    padding: 14px 8px;
    background: #212121;
    border: 1px solid #424242;
    border-radius: 10px;
    cursor: pointer;
    color: #ececec;
    font-family: inherit;
    position: relative;
    transition: border-color 0.15s, background 0.15s;
}
.credit-pack:hover { border-color: #1c99fd; }
.credit-pack.selected { border-color: #1c99fd; background: rgba(28,153,253,0.12); }
.credit-pack .pack-amount { font-size: 18px; font-weight: 700; }
.credit-pack .pack-credits { font-size: 11px; color: #acacac; }
.credit-pack.popular::after {
    content: "Popular";
    position: absolute;
    top: -8px;
    left: 50%;
    transform: translateX(-50%);
    background: #1c99fd;
    color: #fff;
    font-size: 9px;
    font-weight: 700;
    padding: 2px 6px;
    border-radius: 6px;
    text-transform: uppercase;
}
.custom-amount {
    display: flex;
    align-items: center;
    background: #212121;
    border: 1px solid #424242;
    border-radius: 8px;
    padding: 0 12px;
    margin-bottom: 20px;
}
.custom-amount:focus-within { border-color: #1c99fd; }
.custom-amount-prefix { color: #acacac; font-size: 15px; }
#customAmount {
    flex: 1;
    background: transparent;
    border: none;
    color: #fff;
    font-size: 15px;
    padding: 12px 8px;
    font-family: inherit;
    outline: none;
}

/* ==================== NOTIFICATIONS LIST ==================== */
.notif-list {
    max-height: 340px;
    overflow-y: auto;
    margin-bottom: 16px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}
.notif-item {
    padding: 12px;
    background: #212121;
    border: 1px solid #424242;
    border-radius: 10px;
}
.notif-item.unread { border-left: 3px solid #1c99fd; }
.notif-item-title { font-size: 14px; font-weight: 600; color: #ececec; margin-bottom: 2px; }
.notif-item-body { font-size: 13px; color: #acacac; line-height: 1.4; }

.muted { color: #8e8e8e; font-size: 14px; text-align: center; padding: 16px; }


/* ==================== ACCOUNT MENU ==================== */
.sidebar-footer { position: relative; }
.user-info { display:flex; align-items:center; gap:10px; width:100%; background:transparent; border:1px solid transparent; border-radius:10px; padding:8px; cursor:pointer; color:inherit; text-align:left; font-family:inherit; }
.user-info:hover { background:#2a2a2a; }
.user-meta { display:flex; flex-direction:column; align-items:flex-start; gap:1px; line-height:1.2; flex:1; min-width:0; }
.user-meta #userUsername { font-size:13.5px; font-weight:600; color:#ececec; max-width:100%; overflow:hidden; text-overflow:ellipsis; white-space:nowrap; }
.user-meta .credits { margin:0; font-size:12px; color:#1c99fd; font-weight:600; }
.user-caret { margin-left:auto; align-self:center; color:#8e8e8e; flex-shrink:0; }
.user-menu { display:none; flex-direction:column; gap:2px; margin-bottom:8px; background:#2a2a2a; border:1px solid #3a3a3a; border-radius:12px; padding:6px; }
.user-menu.open { display:flex; }
.um-item { display:flex; align-items:center; gap:10px; text-align:left; background:transparent; border:none; color:#ececec; padding:10px 12px; border-radius:8px; cursor:pointer; font-size:14px; font-family:inherit; width:100%; }
.um-item:hover { background:#3a3a3a; }
.um-item svg { color:#9aa3b2; flex-shrink:0; }

/* ==================== SETTINGS MODAL ==================== */
.settings-modal { max-width:540px; width:94%; max-height:88vh; overflow-y:auto; text-align:left; padding:28px; }
.settings-modal .modal-title { text-align:left; font-size:20px; margin-bottom:2px; }
.settings-section { padding:20px 0; border-top:1px solid #3a3a3a; }
.settings-section:first-of-type { border-top:none; padding-top:16px; }
.settings-h { font-size:12px; font-weight:600; color:#8e8e8e; text-transform:uppercase; letter-spacing:.6px; margin-bottom:14px; }
.set-field { margin-bottom:14px; }
.set-field label { display:block; font-size:12px; color:#9aa3b2; margin-bottom:6px; }
.set-note { color:#6b7280; text-transform:none; letter-spacing:0; font-weight:400; }
.set-field input, .set-field select { width:100%; padding:11px 13px; background:#212121; border:1px solid #424242; border-radius:9px; color:#fff; font-size:14px; font-family:inherit; }
.set-field input:focus, .set-field select:focus { outline:none; border-color:#1c99fd; }
.set-readonly { padding:11px 13px; background:#1a1a1a; border:1px solid #2f2f2f; border-radius:9px; color:#acacac; font-size:14px; word-break:break-all; }
.set-row { display:flex; gap:12px; }
.set-row .set-field { flex:1; }
#saveProfileBtn, #deleteAccountBtn { width:100%; margin-top:4px; }
.purchase-list { display:flex; flex-direction:column; gap:8px; max-height:220px; overflow-y:auto; }
.purchase-row { display:flex; justify-content:space-between; gap:10px; padding:11px 13px; background:#212121; border:1px solid #2f2f2f; border-radius:9px; font-size:13px; }
.purchase-row .num-accent { color:#1c99fd; font-weight:600; }
.settings-modal .modal-buttons { border-top:1px solid #3a3a3a; padding-top:16px; margin-top:4px; }


/* promo redeem in buy modal */
.promo-redeem { display:flex; gap:8px; margin-bottom:8px; }
.promo-redeem input { flex:1; padding:11px 13px; background:#212121; border:1px solid #424242; border-radius:9px; color:#fff; font-size:14px; font-family:inherit; text-transform:uppercase; }
.promo-redeem input:focus { outline:none; border-color:#1c99fd; }
.promo-redeem #redeemBtn { background:#3a3a3a; color:#fff; border:none; border-radius:9px; padding:0 18px; font-size:14px; font-weight:600; cursor:pointer; font-family:inherit; }
.promo-redeem #redeemBtn:hover { background:#4a4a4a; }
.promo-redeem #redeemBtn:disabled { opacity:.6; cursor:default; }
.promo-msg { display:none; font-size:13px; margin-bottom:14px; }
