/* ═══════════════════════════════════════════════
   CHAT PAGE STYLES
   ═══════════════════════════════════════════════ */

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

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: #faf8f5;
    color: #2d2a26;
    line-height: 1.6;
    height: 100vh;
    overflow: hidden;
}

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

/* ─── Auth Gate ─── */
.chat-auth {
    flex: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.chat-auth .auth-card {
    text-align: center;
    max-width: 440px;
    background: #fffefa;
    border: 1px solid #e8e4de;
    border-radius: 16px;
    padding: 48px 40px;
}

.auth-icon {
    font-size: 48px;
    display: block;
    margin-bottom: 16px;
}

.chat-auth h2 {
    font-size: 24px;
    font-weight: 800;
    letter-spacing: -0.02em;
    margin-bottom: 8px;
}

.chat-auth p {
    font-size: 14px;
    color: #6b665e;
    margin-bottom: 20px;
    line-height: 1.6;
}

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

.auth-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e8e4de;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    background: #faf8f5;
    outline: none;
    transition: border-color 0.2s;
}

.auth-input:focus {
    border-color: #66bb6a;
    box-shadow: 0 0 0 3px rgba(102, 187, 106, 0.1);
}

.btn-auth {
    padding: 12px 24px;
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    white-space: nowrap;
}

.btn-auth:hover {
    background: linear-gradient(135deg, #43a047, #2e7d32);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
}

.auth-note {
    font-size: 12px !important;
    color: #9e9890 !important;
    margin-top: 16px !important;
    margin-bottom: 0 !important;
}

.auth-note a {
    color: #558b2f;
    font-weight: 600;
    text-decoration: none;
}

/* ─── Guest Entry ─── */
.btn-guest {
    width: 100%;
    padding: 14px 24px;
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-weight: 700;
    font-size: 15px;
    cursor: pointer;
    transition: all 0.2s;
    margin-bottom: 0;
}

.btn-guest:hover {
    background: linear-gradient(135deg, #43a047, #2e7d32);
    box-shadow: 0 4px 16px rgba(46, 125, 50, 0.3);
    transform: translateY(-1px);
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 12px;
    margin: 18px 0;
    color: #c4bfb8;
    font-size: 12px;
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.08em;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e8e4de;
}

/* ─── Guest Limit Banner ─── */
.guest-limit-banner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 16px;
    padding: 12px 24px;
    background: linear-gradient(135deg, #fff8e1, #fff3e0);
    border: 1px solid #ffe0b2;
    margin: 0 32px;
    border-radius: 10px;
    font-size: 13px;
    color: #5d4037;
    font-weight: 500;
    animation: fadeIn 0.3s ease;
}

.btn-upgrade {
    display: inline-block;
    padding: 8px 18px;
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: #fff;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 700;
    text-decoration: none;
    white-space: nowrap;
    transition: all 0.2s;
}

.btn-upgrade:hover {
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
    transform: translateY(-1px);
}

/* ─── Chat Interface ─── */
.chat-interface {
    flex: 1;
    display: flex;
    overflow: hidden;
}

.chat-container {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

/* ─── Sidebar ─── */
.chat-sidebar {
    width: 260px;
    background: #fffefa;
    border-right: 1px solid #e8e4de;
    display: flex;
    flex-direction: column;
    flex-shrink: 0;
}

.sidebar-header {
    padding: 16px 18px;
    border-bottom: 1px solid #f0ece6;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.sidebar-header h3 {
    font-size: 14px;
    font-weight: 700;
}

.memory-count {
    font-size: 11px;
    color: #9e9890;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
}

.memory-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px;
}

.memory-item {
    padding: 10px 12px;
    border-radius: 8px;
    font-size: 12px;
    color: #5d5850;
    line-height: 1.5;
    margin-bottom: 4px;
    cursor: default;
    transition: background 0.15s;
    position: relative;
}

.memory-item:hover {
    background: #f5f3ee;
}

.memory-item .memory-delete {
    position: absolute;
    top: 6px;
    right: 6px;
    width: 18px;
    height: 18px;
    border: none;
    background: none;
    color: #ccc;
    font-size: 10px;
    cursor: pointer;
    border-radius: 4px;
    display: none;
    align-items: center;
    justify-content: center;
}

.memory-item:hover .memory-delete {
    display: flex;
}

.memory-item .memory-delete:hover {
    color: #c62828;
    background: #ffebee;
}

.memory-type {
    font-size: 10px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #b0a99f;
    margin-bottom: 2px;
}

.btn-memory-refresh {
    margin: 8px;
    padding: 8px;
    border: 1px solid #e8e4de;
    background: #fffefa;
    border-radius: 8px;
    font-size: 12px;
    font-weight: 600;
    color: #8a857d;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-memory-refresh:hover {
    border-color: #66bb6a;
    color: #558b2f;
}

/* ─── Messages ─── */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    min-width: 0;
}

.messages {
    flex: 1;
    overflow-y: auto;
    padding: 24px 32px;
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.welcome-msg {
    text-align: center;
    padding: 60px 20px;
    color: #9e9890;
}

.welcome-icon {
    font-size: 36px;
    color: #558b2f;
    display: block;
    margin-bottom: 12px;
}

.welcome-msg h3 {
    font-size: 20px;
    font-weight: 700;
    color: #2d2a26;
    margin-bottom: 6px;
}

.welcome-msg p {
    font-size: 14px;
    color: #8a857d;
}

.msg {
    max-width: 720px;
    padding: 14px 18px;
    border-radius: 12px;
    font-size: 14px;
    line-height: 1.65;
    animation: fadeIn 0.2s ease;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(6px);
    }

    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.msg.user {
    align-self: flex-end;
    background: #2d2a26;
    color: #f5f3ee;
    border-bottom-right-radius: 4px;
}

.msg.assistant {
    align-self: flex-start;
    background: #fffefa;
    border: 1px solid #e8e4de;
    color: #2d2a26;
    border-bottom-left-radius: 4px;
}

.msg.assistant code {
    background: #f0ece6;
    padding: 2px 6px;
    border-radius: 4px;
    font-size: 13px;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
}

.msg.assistant pre {
    background: #1a1816;
    color: #c8e6c9;
    padding: 14px 16px;
    border-radius: 8px;
    margin: 10px 0;
    overflow-x: auto;
    font-family: 'SFMono-Regular', 'Consolas', monospace;
    font-size: 12px;
    line-height: 1.6;
}

.msg.assistant pre code {
    background: none;
    padding: 0;
    color: inherit;
}

.msg-meta {
    font-size: 10px;
    color: #b0a99f;
    margin-top: 6px;
}

.typing-indicator {
    align-self: flex-start;
    padding: 14px 18px;
    background: #fffefa;
    border: 1px solid #e8e4de;
    border-radius: 12px;
    border-bottom-left-radius: 4px;
    font-size: 14px;
    color: #9e9890;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {

    0%,
    100% {
        opacity: 1;
    }

    50% {
        opacity: 0.5;
    }
}

/* ─── Input ─── */
.input-bar {
    display: flex;
    gap: 8px;
    padding: 12px 32px;
    background: #fffefa;
    border-top: 1px solid #f0ece6;
}

.chat-textarea {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e8e4de;
    border-radius: 10px;
    font-size: 14px;
    font-family: 'Inter', -apple-system, sans-serif;
    background: #faf8f5;
    color: #2d2a26;
    outline: none;
    resize: none;
    max-height: 120px;
    overflow-y: auto;
    transition: border-color 0.2s;
}

.chat-textarea:focus {
    border-color: #66bb6a;
    box-shadow: 0 0 0 3px rgba(102, 187, 106, 0.1);
}

.chat-textarea::placeholder {
    color: #c4bfb8;
}

.btn-send {
    width: 44px;
    height: 44px;
    border: none;
    border-radius: 10px;
    background: linear-gradient(135deg, #66bb6a, #43a047);
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    cursor: pointer;
    transition: all 0.2s;
    flex-shrink: 0;
}

.btn-send:hover {
    background: linear-gradient(135deg, #43a047, #2e7d32);
    box-shadow: 0 4px 12px rgba(46, 125, 50, 0.25);
}

.btn-send:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.input-meta {
    display: flex;
    justify-content: space-between;
    padding: 0 32px 12px;
    font-size: 11px;
    color: #b0a99f;
}

.credit-display {
    font-weight: 600;
}

/* ─── Responsive ─── */
@media (max-width: 768px) {
    .chat-sidebar {
        display: none;
    }

    .messages {
        padding: 16px;
    }

    .input-bar {
        padding: 12px 16px;
    }

    .input-meta {
        padding: 0 16px 8px;
    }
}