:root {
    --bg-color: #f0f2f5;
    --primary-color: #25d366;
    --card-bg: #ffffff;
    --danger: #ef4444;
    --text-muted: #666666;
    --border-color: #dddddd;
}

body {
    background-color: var(--bg-color);
    font-family: system-ui, -apple-system, sans-serif;
    margin: 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    padding-top: 65px; /* Ajustado a la nueva altura de la barra fija */
}

/* ==========================================
   Banda Fija Superior (Optimizada y compacta)
   ========================================== */
.top-bar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 56px; /* Altura compacta */
    background-color: #ffffff;
    box-shadow: 0 2px 5px rgba(0, 0, 0, 0.08);
    display: flex;
    align-items: center;
    justify-content: space-between;
    box-sizing: border-box;
    z-index: 1000;
    padding: 0 15px;
}

/* Logo */
.logo-container {
    display: flex;
    align-items: center;
}

.top-bar .logo-container img {
    height: 32px;
    width: auto;
}

/* Agrupación a la derecha */
.user-profile {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-left: auto;
}

/* Botón de usuario (Icono + texto "Mi cuenta" debajo) */
.user-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
}

.user-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.user-label {
    font-size: 0.65rem;
    color: #444;
    font-weight: 600;
    margin-top: 2px;
    line-height: 1;
}

/* Botón salir */
.btn-logout {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 4px;
}

.btn-logout:hover {
    background: rgba(239, 68, 68, 0.1);
    border-color: var(--danger);
    color: var(--danger);
}

/* ==========================================
   Contenido Principal y Chat
   ========================================== */
#app-container {
    width: 100%;
    max-width: 480px;
    padding: 10px;
    box-sizing: border-box;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.profile-card {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 15px;
    display: flex;
    align-items: center;
    gap: 15px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.05);
}

.profile-avatar {
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background-color: #ddd;
    overflow: hidden;
    flex-shrink: 0;
}

.profile-avatar img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.profile-info {
    flex: 1;
}

.profile-info h3 {
    margin: 0 0 5px 0;
    font-size: 1.1rem;
}

.profile-info p {
    margin: 0;
    font-size: 0.85rem;
    color: #666;
}

.btn-chat {
    background-color: var(--primary-color);
    color: white;
    border: none;
    padding: 10px 15px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
}

.ad-container {
    width: 100%;
    height: 50px;
    background: #e4e6eb;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 8px;
    font-size: 0.8rem;
    color: #777;
}

#chat-window {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 80px);
    max-height: 650px;
    border: 1px solid #ccc;
    border-radius: 12px;
    background: #f9f9f9;
    overflow: hidden;
    box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
}

.chat-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 15px;
    background: #ffffff;
    border-bottom: 1px solid #e0e0e0;
    min-height: 40px;
    flex-shrink: 0;
}

.chat-title {
    font-weight: bold;
    font-size: 1rem;
    color: #333;
}

#messages-display {
    flex: 1;
    overflow-y: auto;
    padding: 15px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    background: #e5ddd5;
}

.chat-controls {
    display: flex;
    align-items: center;
    gap: 5px;
    padding: 10px;
    background: #ffffff;
    border-top: 1px solid #ddd;
    flex-shrink: 0;
}

.chat-controls input[type="text"] {
    flex: 1;
    padding: 8px 12px;
    border: 1px solid #ccc;
    border-radius: 20px;
    outline: none;
}

.chat-controls button {
    background: var(--primary-color);
    color: white;
    border: none;
    padding: 8px 12px;
    border-radius: 20px;
    font-weight: bold;
    cursor: pointer;
}

.msg-bubble {
    display: flex;
    width: 100%;
}

.msg-enviado { justify-content: flex-end; }
.msg-recibido { justify-content: flex-start; }

.msg-body {
    max-width: 75%;
    padding: 8px 12px;
    border-radius: 12px;
    position: relative;
    box-shadow: 0 1px 2px rgba(0,0,0,0.15);
}

.msg-enviado .msg-body {
    background-color: #dcf8c6;
    border-top-right-radius: 2px;
}

.msg-recibido .msg-body {
    background-color: #ffffff;
    border-top-left-radius: 2px;
}

.txt-content {
    margin: 0;
    font-size: 0.95rem;
    color: #333;
    word-break: break-word;
}

.msg-time {
    display: block;
    font-size: 0.65rem;
    color: #888;
    text-align: right;
    margin-top: 4px;
}

/* Agrupación a la derecha (forzado en fila horizontal) */
.user-profile {
    display: flex !important;
    flex-direction: row !important; /* Fuerza que estén lado a lado */
    align-items: center !important;
    gap: 12px;
    margin-left: auto;
}

/* Botón de usuario (Icono + texto "Mi cuenta" vertical dentro de su propia caja) */
.user-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    background: transparent;
    border: none;
    cursor: pointer;
    padding: 0;
    flex-shrink: 0;
}

.user-icon {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
    border: 1px solid var(--border-color);
}

.user-label {
    font-size: 0.65rem;
    color: #444;
    font-weight: 600;
    margin-top: 2px;
    line-height: 1;
    white-space: nowrap;
}

/* Botón salir al lado del bloque de usuario */
.btn-logout {
    background: #ffffff;
    border: 1px solid var(--border-color);
    color: var(--text-muted);
    padding: 5px 10px;
    border-radius: 6px;
    font-size: 0.8rem;
    text-decoration: none;
    font-weight: 600;
    white-space: nowrap;
    display: inline-flex;
    align-items: center;
    flex-shrink: 0;
}
#app-container {
    padding-top: 80px; /* Ajusta este valor según la altura real de tu header */
}
/* Botón de chat con conversación previa existente */
.btn-chat-activo {
    background-color: #fff !important; /* Verde para destacar conversación iniciada */
    font-size: 18px;
    padding: 6px 14px !important;
    border-radius: 20px !important;
}

.btn-chat-activo:hover {
    background-color: #218838 !important;
}