/* Variables de Color (Paleta solicitada) */
:root {
    --bg-black: #000000;
    --box-gray: #3e3d40;
    --accent-green: #8faf22;
    --text-white: #ffffff;
    --text-gray: #b0b0b0;
    --accent-hover: #9fc12b;
    --border-color: rgba(255, 255, 255, 0.1);
    --bubble-other: #525055;
    --input-bg: #2b2a2c;
}

body.theme-light {
    --bg-black: #f0f2f5;
    --box-gray: #ffffff;
    --text-white: #1c1c1c;
    --text-gray: #666666;
    --border-color: rgba(0, 0, 0, 0.1);
    --bubble-other: #e4e6eb;
    --input-bg: #f0f2f5;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-black);
    color: var(--text-white);
    height: 100dvh;
    margin: 0;
    overflow: hidden;
}

.title-color {
    color: var(--accent-green);
}

.box-bg {
    background-color: var(--box-gray);
    border-radius: 12px;
    box-shadow: 0 8px 24px rgba(0, 0, 0, 0.8);
}

.app-container {
    width: 100%;
    max-width: 600px;
    height: 100%;
    padding-top: 85px; /* Aumentado para evitar solapamiento con el top navbar de 60px */
    padding-bottom: env(safe-area-inset-bottom, 15px); /* Margen inferior de seguridad */
    display: flex;
    flex-direction: column;
    margin: 0 auto;
}

.app-header {
    text-align: center;
    margin-bottom: 20px;
}

.app-title {
    color: var(--accent-green);
    font-size: 1.8rem;
    font-weight: 600;
    letter-spacing: 0.5px;
}

/* Modal Selector de Idioma */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 1000;
}

.modal-content {
    padding: 40px;
    text-align: center;
    max-width: 400px;
    width: 90%;
}

.modal-content h2 {
    margin-bottom: 10px;
}

.modal-content p {
    color: var(--text-gray);
    margin-bottom: 30px;
}

.language-options {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Botones */
button {
    cursor: pointer;
    border: none;
    outline: none;
    font-family: 'Inter', sans-serif;
    transition: all 0.2s ease;
}

.btn-primary {
    background-color: var(--accent-green);
    color: #000;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.btn-primary:hover {
    background-color: var(--accent-hover);
    transform: translateY(-2px);
}

.btn-primary:active {
    transform: scale(0.98);
}

/* --- TAB BUTTONS --- */
.tab-btn {
    background: transparent;
    color: var(--text-gray);
    border: 1px solid var(--text-gray);
    padding: 10px 20px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 1rem;
}

.tab-btn:hover {
    color: var(--text-white);
    border-color: var(--text-white);
}

.tab-btn.active {
    color: var(--accent-green);
    border-color: var(--accent-green);
}

/* --- INPUTS GENERALES --- */
.custom-input {
    padding: 10px;
    border-radius: 6px;
    border: 1px solid var(--border-color);
    background: var(--input-bg);
    color: var(--text-white);
    font-family: 'Inter', sans-serif;
}

.custom-input:focus {
    outline: none;
    border-color: var(--accent-green);
    box-shadow: 0 0 0 2px rgba(143, 175, 34, 0.2);
}

.custom-input::placeholder {
    color: var(--text-gray);
    opacity: 0.8;
}

/* --- TOP NAVBAR --- */
.top-navbar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background-color: #1a1a1a; /* Siempre oscuro como en el referente */
    border-bottom: 2px solid var(--accent-green);
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0 20px;
    z-index: 2000;
    box-shadow: 0 2px 10px rgba(0,0,0,0.5);
}

.top-navbar-left {
    display: flex;
    align-items: center;
    gap: 15px;
}

.top-navbar-right {
    display: flex;
    align-items: center;
    gap: 15px;
}

.navbar-title {
    color: var(--accent-green);
    font-size: 1.2rem;
    font-weight: 600;
    letter-spacing: 1px;
    margin: 0;
    text-transform: uppercase;
}

/* --- LOGO Y MARCA BLANCA --- */
.dynamic-logo-container {
    display: flex;
    align-items: center;
    height: 100%;
}

.dynamic-logo {
    max-height: 35px;
    object-fit: contain;
}

/* --- MODALES --- */
/* Chat Main Area */
.chat-main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    position: relative;
}

.chat-header {
    padding: 15px 20px;
    border-bottom: 1px solid var(--border-color);
    display: flex;
    justify-content: space-between;
    align-items: center;
    font-weight: 500;
}

.status-indicator {
    font-size: 0.85rem;
    color: var(--text-gray);
    display: flex;
    align-items: center;
    gap: 5px;
}

.status-indicator::before {
    content: '';
    display: inline-block;
    width: 8px;
    height: 8px;
    background-color: var(--accent-green);
    border-radius: 50%;
}

.chat-messages {
    flex: 1;
    padding: 20px;
    overflow-y: auto;
    display: flex;
    flex-direction: column;
    gap: 15px;
}

/* Scrollbar styling */
.chat-messages::-webkit-scrollbar {
    width: 6px;
}
.chat-messages::-webkit-scrollbar-thumb {
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 4px;
}

/* Message Bubbles */
.message-wrapper {
    display: flex;
    flex-direction: column;
    max-width: 80%;
}

.message-wrapper.own {
    align-self: flex-end;
}

.message-wrapper.other {
    align-self: flex-start;
}

.message-bubble {
    padding: 12px 16px;
    border-radius: 12px;
    font-size: 0.95rem;
    line-height: 1.4;
    position: relative;
}

.message-wrapper.own .message-bubble {
    background-color: var(--accent-green);
    color: #000;
    border-bottom-right-radius: 2px;
}

.message-wrapper.other .message-bubble {
    background-color: var(--bubble-other);
    color: var(--text-white);
    border-bottom-left-radius: 2px;
}

/* Translation below original text */
.translation-text {
    margin-top: 8px;
    padding-top: 8px;
    border-top: 1px solid rgba(0, 0, 0, 0.15);
    font-style: italic;
    font-size: 0.9rem;
}

.message-wrapper.other .translation-text {
    border-top: 1px solid var(--border-color);
}

.message-meta {
    font-size: 0.7rem;
    color: var(--text-gray);
    margin-top: 5px;
    align-self: flex-end;
}

.message-wrapper.other .message-meta {
    align-self: flex-start;
}

/* Input Area */
.chat-input-area {
    padding: 15px 20px;
    border-top: 1px solid var(--border-color);
    display: flex;
    align-items: flex-end;
    gap: 10px;
    flex-shrink: 0;
}

#message-input {
    flex: 1;
    background-color: var(--input-bg);
    border: 1px solid var(--border-color);
    border-radius: 20px;
    padding: 12px 16px;
    color: var(--text-white);
    font-family: 'Inter', sans-serif;
    font-size: 0.95rem;
    resize: none;
    outline: none;
    max-height: 100px;
    overflow-y: auto;
}

#message-input:focus {
    border-color: var(--accent-green);
}

.btn-icon {
    width: 45px;
    height: 45px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.2rem;
    flex-shrink: 0;
}

#btn-mic {
    background-color: var(--input-bg);
    color: var(--text-gray);
}

#btn-mic:hover {
    color: var(--text-white);
    background-color: var(--border-color);
}

#btn-mic.recording {
    background-color: #ff4757;
    color: white;
    animation: pulse 1.5s infinite;
}

@keyframes pulse {
    0% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0.7); }
    70% { transform: scale(1.1); box-shadow: 0 0 0 10px rgba(255, 71, 87, 0); }
    100% { transform: scale(1); box-shadow: 0 0 0 0 rgba(255, 71, 87, 0); }
}

/* System Loading Indicator */
.typing-indicator {
    padding: 10px 16px;
    background-color: var(--bubble-other);
    border-radius: 12px;
    align-self: flex-start;
    display: none;
    color: var(--text-gray);
    font-size: 0.85rem;
    font-style: italic;
    border-bottom-left-radius: 2px;
}

.typing-dots span {
    display: inline-block;
    width: 6px;
    height: 6px;
    background-color: var(--text-gray);
    border-radius: 50%;
    margin: 0 2px;
    animation: typing 1.4s infinite ease-in-out both;
}

.typing-dots span:nth-child(1) { animation-delay: -0.32s; }
.typing-dots span:nth-child(2) { animation-delay: -0.16s; }

@keyframes typing {
    0%, 80%, 100% { transform: scale(0); }
    40% { transform: scale(1); }
}
