/* ============================================
   Chat Interno — Chatwoot Dashboard App
   ============================================ */

:root {
    --bg-primary: #0f1117;
    --bg-secondary: #1a1d27;
    --bg-card: #1e2130;
    --bg-card-hover: #262a3e;
    --bg-input: #1a1d27;
    --border-color: rgba(255, 255, 255, 0.06);
    --border-color-hover: rgba(255, 255, 255, 0.12);

    --text-primary: #e8eaed;
    --text-secondary: #9aa0b0;
    --text-muted: #5c6370;

    --accent: #6c63ff;
    --accent-hover: #7d75ff;
    --accent-soft: rgba(108, 99, 255, 0.15);
    --accent-glow: rgba(108, 99, 255, 0.3);

    --green: #34d399;
    --green-soft: rgba(52, 211, 153, 0.12);
    --pink: #f472b6;
    --pink-soft: rgba(244, 114, 182, 0.12);

    --msg-sent: #6c63ff;
    --msg-received: #252840;

    --radius-sm: 6px;
    --radius-md: 10px;
    --radius-lg: 14px;
    --radius-xl: 20px;

    --shadow-card: 0 2px 12px rgba(0, 0, 0, 0.25);
}

/* Reset */
*,
*::before,
*::after {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html,
body {
    height: 100%;
    overflow: hidden;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
    background: var(--bg-primary);
    color: var(--text-primary);
    line-height: 1.5;
    -webkit-font-smoothing: antialiased;
    display: flex;
    flex-direction: column;
}

/* ============================================
   Header
   ============================================ */
.app-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-bottom: 1px solid var(--border-color);
    flex-shrink: 0;
    z-index: 100;
}

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

.header-info {
    display: flex;
    flex-direction: column;
}

.header-info h1 {
    font-size: 0.9rem;
    font-weight: 600;
    line-height: 1.2;
}

.header-subtitle {
    font-size: 0.7rem;
    color: var(--text-secondary);
    display: none;
}

.header-subtitle.visible {
    display: block;
}

.logo-icon {
    width: 34px;
    height: 34px;
    border-radius: var(--radius-sm);
    background: linear-gradient(135deg, var(--accent), #a78bfa);
    display: flex;
    align-items: center;
    justify-content: center;
    color: white;
    flex-shrink: 0;
}

.btn-back {
    background: none;
    border: none;
    color: var(--text-secondary);
    cursor: pointer;
    padding: 6px;
    border-radius: var(--radius-sm);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.btn-back:hover {
    color: var(--text-primary);
    background: var(--accent-soft);
}

.status-badge {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 0.7rem;
    font-weight: 500;
    color: var(--text-secondary);
    padding: 4px 10px;
    border-radius: 20px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
}

.status-dot {
    width: 6px;
    height: 6px;
    border-radius: 50%;
    background: var(--green);
    box-shadow: 0 0 6px var(--green);
}

/* ============================================
   Screens
   ============================================ */
.screen {
    flex: 1;
    overflow-y: auto;
}

/* ============================================
   User Selection Screen
   ============================================ */
.screen-select {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 24px 16px;
}

.select-container {
    width: 100%;
    max-width: 400px;
}

.select-header {
    text-align: center;
    margin-bottom: 24px;
}

.select-header h2 {
    font-size: 1.05rem;
    font-weight: 600;
    margin-bottom: 6px;
}

.select-header p {
    font-size: 0.8rem;
    color: var(--text-secondary);
}

.user-cards {
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.user-card {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px;
    background: var(--bg-card);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-lg);
    cursor: pointer;
    transition: all 0.25s ease;
}

.user-card:hover {
    background: var(--bg-card-hover);
    border-color: var(--border-color-hover);
    box-shadow: var(--shadow-card);
    transform: translateY(-1px);
}

.user-card:active {
    transform: translateY(0);
}

.user-avatar {
    width: 46px;
    height: 46px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.1rem;
    font-weight: 700;
    color: white;
    flex-shrink: 0;
}

.user-card-info {
    flex: 1;
    min-width: 0;
}

.user-card-name {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--text-primary);
}

.user-card-id {
    font-size: 0.72rem;
    color: var(--text-muted);
}

.user-card-arrow {
    color: var(--text-muted);
    flex-shrink: 0;
    transition: transform 0.2s;
}

.user-card:hover .user-card-arrow {
    color: var(--accent);
    transform: translateX(3px);
}

/* ============================================
   Chat Screen
   ============================================ */
.screen-chat {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

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

.messages-area::-webkit-scrollbar {
    width: 4px;
}

.messages-area::-webkit-scrollbar-thumb {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 4px;
}

.messages-list {
    display: flex;
    flex-direction: column;
    gap: 6px;
    margin-top: auto;
}

/* Empty chat */
.empty-chat {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    flex: 1;
    color: var(--text-muted);
    font-size: 0.82rem;
    text-align: center;
    gap: 8px;
    padding: 40px 20px;
}

.empty-chat svg {
    opacity: 0.3;
}

/* Messages */
.message {
    max-width: 80%;
    padding: 10px 14px;
    border-radius: var(--radius-xl);
    font-size: 0.84rem;
    line-height: 1.45;
    animation: msgIn 0.2s ease;
    position: relative;
    word-wrap: break-word;
}

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

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

.message.sent {
    align-self: flex-end;
    background: var(--msg-sent);
    color: white;
    border-bottom-right-radius: 6px;
}

.message.received {
    align-self: flex-start;
    background: var(--msg-received);
    color: var(--text-primary);
    border-bottom-left-radius: 6px;
}

.message-time {
    font-size: 0.62rem;
    color: rgba(255, 255, 255, 0.45);
    margin-top: 4px;
    text-align: right;
}

.message.received .message-time {
    color: var(--text-muted);
}

/* Date separator */
.date-separator {
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 12px 0;
}

.date-separator span {
    font-size: 0.68rem;
    color: var(--text-muted);
    background: var(--bg-primary);
    padding: 2px 12px;
    border-radius: 10px;
    border: 1px solid var(--border-color);
}

/* ============================================
   Chat Input
   ============================================ */
.chat-input-area {
    padding: 12px 16px;
    background: var(--bg-secondary);
    border-top: 1px solid var(--border-color);
    flex-shrink: 0;
}

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

.chat-input {
    flex: 1;
    background: var(--bg-input);
    border: 1px solid var(--border-color);
    border-radius: var(--radius-xl);
    padding: 10px 16px;
    color: var(--text-primary);
    font-size: 0.84rem;
    font-family: inherit;
    outline: none;
    transition: border-color 0.2s;
}

.chat-input::placeholder {
    color: var(--text-muted);
}

.chat-input:focus {
    border-color: var(--accent);
}

.btn-send {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--accent);
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    transition: all 0.2s;
}

.btn-send:hover {
    background: var(--accent-hover);
    box-shadow: 0 0 12px var(--accent-glow);
}

.btn-send:active {
    transform: scale(0.94);
}

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

/* ============================================
   Responsive
   ============================================ */
@media (max-width: 480px) {
    .screen-select {
        padding: 16px 12px;
    }
}