/* 
   Círculo - Estilos
   Paleta: #FAF0E6 (Fondo), #4A4E69 (Textos), #C9B6A0 (Madera), #8B9A7A (Verde), #D9C5B3 (Arena)
*/

:root {
    --bg-main: #FAF0E6;
    --text-main: #4A4E69;
    --accent-soft: #C9B6A0;
    --btn-primary: #8B9A7A;
    --btn-secondary: #D9C5B3;
    --video-bg: #FFF9F0;
    --video-border: #E5D9D0;
    --shadow-soft: 0 8px 20px rgba(0,0,0,0.03), 0 2px 6px rgba(0,0,0,0.05);
    --radius-lg: 24px;
    --radius-md: 16px;
}

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

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-main);
    color: var(--text-main);
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    justify-content: center;
    align-items: center;
}

.app-container {
    width: 100%;
    max-width: 1200px;
    padding: 20px;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* Tipografía */
h1, h2, .room-code, .participant-name {
    font-family: 'Fraunces', serif;
}

.title {
    font-size: 2.5rem;
    font-weight: 700;
}

.subtitle {
    font-size: 1.1rem;
    opacity: 0.8;
    margin-top: 4px;
}

/* Pantallas */
.screen {
    display: none;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    height: 100%;
    width: 100%;
    animation: fadeIn 0.5s ease;
}

.screen.active {
    display: flex;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

/* Header */
.header {
    text-align: center;
    margin-bottom: 40px;
}

.logo-container {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 12px;
}

/* Tarjetas */
.card {
    background: white;
    padding: 40px;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    width: 100%;
    max-width: 500px;
    border: 1px solid rgba(201, 182, 160, 0.2);
}

.entry-card {
    display: flex;
    flex-direction: column;
    gap: 24px;
}

/* Inputs */
.input-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.input-group label {
    font-weight: 600;
    font-size: 0.9rem;
}

input[type="text"] {
    padding: 14px 20px;
    border-radius: 12px;
    border: 1px solid var(--accent-soft);
    font-family: inherit;
    font-size: 1rem;
    color: var(--text-main);
    background-color: #fff;
    transition: border-color 0.2s;
}

input[type="text"]:focus {
    outline: none;
    border-color: var(--btn-primary);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    padding: 14px 24px;
    border-radius: 16px;
    border: none;
    font-family: inherit;
    font-weight: 600;
    font-size: 1rem;
    cursor: pointer;
    transition: opacity 0.2s, transform 0.1s;
    min-height: 44px;
}

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

.btn:hover {
    opacity: 0.9;
}

.btn-primary {
    background-color: var(--btn-primary);
    color: white;
    width: 100%;
}

.btn-secondary {
    background-color: var(--btn-secondary);
    color: var(--text-main);
}

.btn-sm {
    padding: 8px 16px;
    font-size: 0.85rem;
    border-radius: 10px;
}

.actions {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.join-group {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Sala de Video */
.room-header {
    width: 100%;
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
}

.room-info {
    display: flex;
    align-items: center;
    gap: 16px;
}

.room-code {
    font-size: 1.5rem;
    color: var(--btn-primary);
}

.room-status {
    font-weight: 600;
    font-size: 0.9rem;
    background: white;
    padding: 6px 16px;
    border-radius: 20px;
    box-shadow: var(--shadow-soft);
    display: flex;
    align-items: center;
    gap: 12px;
}

.inactivity-timer {
    color: #e63946;
    font-variant-numeric: tabular-nums;
    padding-right: 12px;
    border-right: 1px solid var(--accent-soft);
}

/* Layout de Sala */
.room-layout {
    display: flex;
    width: 100%;
    height: calc(100% - 100px);
    gap: 20px;
}

.main-content {
    flex: 1;
    display: flex;
    flex-direction: column;
    height: 100%;
}

/* Panel de Chat */
.chat-panel {
    width: 320px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    display: flex;
    flex-direction: column;
    border: 1px solid var(--video-border);
    animation: slideInRight 0.3s ease;
}

@keyframes slideInRight {
    from { transform: translateX(20px); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}

.chat-header {
    padding: 16px 20px;
    border-bottom: 1px solid var(--video-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.chat-header h3 {
    font-family: 'Fraunces', serif;
    font-size: 1.2rem;
}

.close-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    display: flex;
    align-items: center;
    justify-content: center;
}

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

.message {
    background: var(--bg-main);
    padding: 10px 14px;
    border-radius: 14px;
    max-width: 90%;
    position: relative;
    align-self: flex-start;
}

.message.own {
    background: var(--btn-secondary);
    align-self: flex-end;
}

.message-user {
    font-size: 0.75rem;
    font-weight: 700;
    margin-bottom: 2px;
    display: block;
}

.message-text {
    font-size: 0.9rem;
    word-break: break-word;
}

.message-reply-ref {
    font-size: 0.75rem;
    background: rgba(0,0,0,0.05);
    padding: 4px 8px;
    border-radius: 8px;
    margin-bottom: 6px;
    border-left: 3px solid var(--btn-primary);
    opacity: 0.8;
}

.message-actions {
    display: flex;
    gap: 8px;
    margin-top: 4px;
    opacity: 0;
    transition: opacity 0.2s;
}

.message:hover .message-actions {
    opacity: 1;
}

.reply-btn {
    background: none;
    border: none;
    font-size: 0.7rem;
    color: var(--btn-primary);
    cursor: pointer;
    font-weight: 600;
}

/* Reply Preview */
.reply-preview {
    padding: 10px 20px;
    background: #f0f0f0;
    border-top: 1px solid var(--video-border);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.reply-info {
    flex: 1;
    overflow: hidden;
}

.reply-label {
    font-size: 0.7rem;
    font-weight: 700;
    color: var(--btn-primary);
}

.reply-text-truncate {
    font-size: 0.8rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.cancel-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: #e63946;
    display: flex;
    align-items: center;
    justify-content: center;
}

.text-styles-bar {
    padding: 8px 16px;
    display: flex;
    gap: 12px;
    background: #fcfcfc;
    border-top: 1px solid var(--video-border);
}

.style-btn {
    background: none;
    border: none;
    cursor: pointer;
    color: var(--text-main);
    font-size: 0.9rem;
    padding: 4px 8px;
    border-radius: 4px;
    transition: background 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
    min-width: 28px;
}

.style-btn:hover {
    background: var(--bg-main);
}

.divider {
    width: 1px;
    background: var(--accent-soft);
    margin: 4px 4px;
    opacity: 0.5;
}

/* Picker Panels */
.picker-panel {
    background: white;
    border-top: 1px solid var(--video-border);
    max-height: 200px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    animation: slideUp 0.2s ease;
}

@keyframes slideUp {
    from { transform: translateY(10px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

.picker-grid {
    display: grid;
    grid-template-columns: repeat(8, 1fr);
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
}

.picker-grid-scroll {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 12px;
    overflow-y: auto;
    max-height: 160px;
}

.emoji-item {
    font-size: 1.2rem;
    cursor: pointer;
    text-align: center;
    padding: 4px;
    border-radius: 4px;
    transition: background 0.2s;
}

.emoji-item:hover {
    background: var(--bg-main);
}

.gif-item {
    width: 100%;
    aspect-ratio: 16/9;
    object-fit: cover;
    border-radius: 8px;
    cursor: pointer;
    background: #eee;
}

.picker-search {
    padding: 8px 12px;
    border-bottom: 1px solid var(--video-border);
}

.picker-search input {
    width: 100%;
    padding: 8px 12px;
    border-radius: 8px;
    border: 1px solid var(--accent-soft);
    font-size: 0.85rem;
}

/* Media Message */
.message-media {
    margin-top: 8px;
    border-radius: 10px;
    overflow: hidden;
    max-width: 100%;
    display: block;
}

.message-media img {
    width: 100%;
    height: auto;
    display: block;
}

.chat-form {
    padding: 16px;
    display: flex;
    gap: 10px;
    border-top: 1px solid var(--video-border);
}

.chat-form input {
    flex: 1;
    padding: 10px 14px;
    border-radius: 10px;
    border: 1px solid var(--accent-soft);
    font-size: 0.9rem;
}

.send-btn {
    background: var(--btn-primary);
    color: white;
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 10px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Admin Controls */
.admin-badge {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--btn-primary);
    color: white;
    font-size: 0.6rem;
    padding: 2px 6px;
    border-radius: 4px;
    z-index: 10;
}

.mute-admin-btn {
    position: absolute;
    bottom: 10px;
    right: 10px;
    background: rgba(230, 57, 70, 0.9);
    color: white;
    border: none;
    width: 32px;
    height: 32px;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 10;
    transition: transform 0.2s;
}

.mute-admin-btn:hover {
    transform: scale(1.1);
}

/* Badge */
.badge {
    position: absolute;
    top: -5px;
    right: -5px;
    background: #e63946;
    color: white;
    font-size: 0.7rem;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    border: 2px solid white;
}

@media (max-width: 1000px) {
    .chat-panel {
        position: fixed;
        right: 20px;
        top: 20px;
        bottom: 100px;
        z-index: 100;
        width: calc(100% - 40px);
        max-width: 350px;
    }
}

.video-grid {
    flex: 1;
    width: 100%;
    display: grid;
    gap: 16px;
    padding: 10px;
    align-content: stretch;
    justify-content: stretch;
    overflow: hidden;
}

.video-grid.count-1 {
    grid-template-columns: 1fr;
    grid-template-rows: 1fr;
}

.video-grid.count-2 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr;
}

.video-grid.count-3, 
.video-grid.count-4 {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: 1fr 1fr;
}

/* Ajustes para móviles */
@media (max-width: 600px) {
    .video-grid.count-2 {
        grid-template-columns: 1fr;
        grid-template-rows: 1fr 1fr;
    }
    .video-grid.count-3 {
        grid-template-columns: 1fr;
        grid-template-rows: repeat(3, 1fr);
    }
    .video-grid.count-4 {
        grid-template-columns: 1fr 1fr;
        grid-template-rows: 1fr 1fr;
    }
}

.video-card {
    background-color: var(--video-bg);
    border: 1px solid var(--video-border);
    border-radius: var(--radius-md);
    overflow: hidden;
    position: relative;
    display: flex;
    flex-direction: column;
    box-shadow: var(--shadow-soft);
    transition: box-shadow 0.3s ease;
    animation: participantEntry 0.6s cubic-bezier(0.16, 1, 0.3, 1) forwards;
    height: 100%;
    min-height: 0;
}

@keyframes participantEntry {
    from {
        opacity: 0;
        transform: scale(0.92) translateY(15px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

.video-card.speaking {
    box-shadow: 0 0 0 3px rgba(139,154,122,0.3);
}

.video-wrapper {
    flex: 1;
    background: #000;
    position: relative;
}

video {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.participant-info {
    padding: 12px;
    background: white;
    text-align: center;
}

.participant-name {
    font-size: 1.1rem;
    font-weight: 600;
}

/* Controles */
.controls {
    margin-top: 24px;
    display: flex;
    gap: 16px;
    justify-content: center;
}

.control-btn {
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    background: white;
    color: var(--text-main);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: var(--shadow-soft);
    transition: all 0.2s;
}

.control-btn:hover {
    transform: translateY(-2px);
    background-color: #f8f8f8;
}

.control-btn.muted {
    background-color: #ffeded;
    color: #e63946;
}

.control-btn.btn-danger {
    background-color: #ffeded;
    color: #e63946;
}

/* Mensajes */
.empty-msg {
    text-align: center;
    padding: 40px;
    background: white;
    border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft);
    max-width: 400px;
    margin: auto;
}

.error-message {
    color: #e63946;
    font-size: 0.85rem;
    text-align: center;
}

.hidden {
    display: none !important;
}

/* Notificaciones */
.notification-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.notification {
    background-color: var(--btn-primary);
    color: white;
    padding: 12px 24px;
    border-radius: 12px;
    box-shadow: var(--shadow-soft);
    animation: slideIn 0.3s ease;
}

@keyframes slideIn {
    from { transform: translateX(100%); opacity: 0; }
    to { transform: translateX(0); opacity: 1; }
}
