/* ==========================================
   1. CONFIGURACIÓN BASE 
   ========================================== */
:root {
    --fb-blue: #1877f2;
    --fb-bg: #f0f2f5;
    --white: #ffffff;
    --text-main: #1c1e21;
    --text-gray: #65676b;
    --border: #dddfe2;
    --shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

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

body {
    font-family: 'Segoe UI', Helvetica, Arial, sans-serif;
    background-color: var(--fb-bg);
    color: var(--text-main);
    display: flex;
    justify-content: center;
    padding: 40px 15px;
}

.app-container {
    width: 100%;
    max-width: 650px; /* Tamaño compacto para evitar espacio muerto */
}

/* ==========================================
   2. HEADER 
   ========================================== */
.app-header {
    text-align: center;
    margin-bottom: 25px;
}

.app-header h1 {
    color: var(--fb-blue);
    font-size: 2.2rem;
}

.app-header p {
    color: var(--text-gray);
    font-weight: 500;
}

/* ==========================================
   3. TARJETA DEL EDITOR (ESTÁTICA Y CORREGIDA)
   ========================================== */
.main-card {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    margin-bottom: 20px;
}

.card-header {
    padding: 12px;
    border-bottom: 1px solid var(--border);
    font-weight: 600;
    text-align: center;
}

/* Se unificaron las dos propiedades repetidas en una sola regla estable */
#emojiComposer {
    width: 100%;
    height: 150px; /* Altura fija optimizada para evitar saltos */
    border: none;
    padding: 15px;
    font-size: 1.1rem;
    outline: none;
    resize: none; /* Bloquea el redimensionado manual */
    font-family: inherit;
    line-height: 1.5;
    overflow-y: auto;
    background: var(--white);
}

.editor-footer {
    text-align: right;
    padding: 8px 15px;
    border-top: 1px solid #f5f5f5;
    font-size: 0.8rem;
    color: var(--text-gray);
}

/* ==========================================
   4. BARRA DE HERRAMIENTAS 
   ========================================== */
.toolbar {
    display: flex;
    justify-content: space-between;
    padding: 10px 15px;
    background: #f9f9f9;
    border-top: 1px solid var(--border);
    border-radius: 0 0 8px 8px;
}

.format-buttons {
    display: flex;
    gap: 8px;
}

.format-buttons button, #fontSelector {
    border: 1px solid var(--border);
    background: var(--white);
    border-radius: 4px;
    cursor: pointer;
    transition: 0.2s;
}

.format-buttons button {
    width: 34px;
    height: 34px;
    font-size: 1rem;
}

#fontSelector {
    padding: 0 10px;
    font-size: 0.9rem;
    outline: none;
}

.format-buttons button:hover, #fontSelector:hover {
    background: #f0f2f5;
}

.btn-blue {
    background: var(--fb-blue);
    color: var(--white);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-gray {
    background: #e4e6eb;
    color: var(--text-main);
    border: none;
    padding: 8px 16px;
    border-radius: 6px;
    font-weight: 600;
    cursor: pointer;
}

.btn-blue:hover { background: #166fe5; }
.btn-gray:hover { background: #d8dadf; }

/* ==========================================
   5. CONTENEDOR DE EMOJIS COMPACTO 
   ========================================== */
.emoji-container {
    background: var(--white);
    border-radius: 8px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border);
    padding: 15px;
}

.search-bar input {
    width: 100%;
    padding: 10px 15px;
    border-radius: 20px;
    border: 1px solid var(--border);
    background: #f0f2f5;
    outline: none;
    margin-bottom: 12px;
}

.category-nav {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
    justify-content: center;
    padding-bottom: 12px;
    border-bottom: 1px solid #f0f0f0;
    margin-bottom: 12px;
}

.category-nav button {
    background: #f0f2f5;
    border: none;
    padding: 6px 12px;
    border-radius: 15px;
    cursor: pointer;
    font-size: 0.85rem;
    font-weight: 500;
    transition: 0.2s;
}

.category-nav button:hover { background: #e4e6eb; }
.category-nav button.active {
    background: var(--fb-blue);
    color: var(--white);
}

.emoji-grid-compact {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(38px, 1fr));
    gap: 4px;
    height: 175px; /* Reducido ligeramente para evitar que la página principal scrollee */
    overflow-y: auto;
    padding-right: 5px;
}

/* Estilo del scrollbar para que sea fino */
.emoji-grid-compact::-webkit-scrollbar { width: 6px; }
.emoji-grid-compact::-webkit-scrollbar-thumb { background: #ccc; border-radius: 10px; }

.emoji-item {
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    justify-content: center;
    aspect-ratio: 1;
    cursor: pointer;
    border-radius: 4px;
    transition: transform 0.1s ease;
    user-select: none;
}

.emoji-item:hover {
    background: #f0f2f5;
    transform: scale(1.15);
}

/* ==========================================
   6. COMPONENTES EXTRA 
   ========================================== */
.toast {
    position: fixed;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0,0,0,0.8);
    color: white;
    padding: 8px 18px;
    border-radius: 20px;
    font-size: 0.85rem;
    z-index: 1000;
}

.hidden { display: none; }
