/**
 * Estilos aislados para IBI Sala de Comunidad y Videollamada
 * Prefijo estricto .ibi- para evitar conflictos con Elementor y JetEngine
 */

.ibi-room-container {
    --ibi-bg-dark: #0f172a;
    --ibi-bg-card: #1e293b;
    --ibi-bg-card-hover: #334155;
    --ibi-primary: #2563eb;
    --ibi-primary-hover: #1d4ed8;
    --ibi-gold: #f59e0b;
    --ibi-success: #10b981;
    --ibi-danger: #ef4444;
    --ibi-text: #f8fafc;
    --ibi-text-muted: #94a3b8;
    --ibi-border: #334155;
    --ibi-radius: 12px;

    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Oxygen-Sans, Ubuntu, Cantarell, "Helvetica Neue", sans-serif;
    color: var(--ibi-text);
    background: var(--ibi-bg-dark);
    border-radius: var(--ibi-radius);
    overflow: hidden;
    box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.4), 0 8px 10px -6px rgba(0, 0, 0, 0.4);
    display: flex;
    flex-direction: column;
    width: 100%;
    min-height: 600px;
    margin: 20px 0;
    box-sizing: border-box;
}

.ibi-room-container * {
    box-sizing: border-box;
}

/* Vista de Invitado / No Autenticado */
.ibi-guest-box {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 60px 20px;
    background: radial-gradient(circle at top, #1e293b 0%, #0f172a 100%);
    text-align: center;
}

.ibi-guest-card {
    max-width: 500px;
    background: rgba(30, 41, 59, 0.8);
    backdrop-filter: blur(10px);
    border: 1px solid var(--ibi-border);
    padding: 40px;
    border-radius: 16px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
}

.ibi-logo-wrapper {
    margin-bottom: 16px;
    display: flex;
    justify-content: center;
    align-items: center;
}

.ibi-custom-logo-large {
    max-height: 95px;
    max-width: 260px;
    width: auto;
    object-fit: contain;
    display: block;
    margin: 0 auto;
    filter: drop-shadow(0 4px 6px rgba(0, 0, 0, 0.4));
}

.ibi-custom-logo-header {
    max-height: 42px;
    max-width: 160px;
    width: auto;
    object-fit: contain;
    display: block;
}

.ibi-logo-badge-lg {
    font-size: 22px;
    padding: 10px 22px;
    margin-bottom: 16px;
    display: inline-block;
}

.ibi-cross-icon {
    font-size: 42px;
    color: var(--ibi-gold);
    margin-bottom: 15px;
    line-height: 1;
}

.ibi-guest-card h2 {
    font-size: 22px;
    color: var(--ibi-gold);
    margin: 0 0 8px 0;
    font-weight: 700;
}

.ibi-guest-card h3 {
    font-size: 18px;
    color: var(--ibi-text);
    margin: 0 0 16px 0;
    font-weight: 500;
}

.ibi-guest-card p {
    font-size: 14px;
    color: var(--ibi-text-muted);
    line-height: 1.6;
    margin-bottom: 25px;
}

/* Botones Comunes */
.ibi-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 12px 24px;
    border-radius: 8px;
    font-size: 15px;
    font-weight: 600;
    text-decoration: none;
    cursor: pointer;
    border: none;
    transition: all 0.2s ease;
}

.ibi-btn-primary {
    background: var(--ibi-primary);
    color: #ffffff !important;
}

.ibi-btn-primary:hover {
    background: var(--ibi-primary-hover);
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
}

.ibi-btn-secondary {
    background: var(--ibi-bg-card-hover);
    color: var(--ibi-text);
}

.ibi-btn-secondary:hover {
    background: #475569;
}

/* Cabecera de la Sala */
.ibi-room-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 14px 20px;
    background: #111827;
    border-bottom: 1px solid var(--ibi-border);
}

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

.ibi-logo-badge {
    background: rgba(245, 158, 11, 0.15);
    color: var(--ibi-gold);
    border: 1px solid rgba(245, 158, 11, 0.3);
    padding: 6px 12px;
    border-radius: 8px;
    font-weight: 700;
    font-size: 13px;
    letter-spacing: 0.5px;
}

.ibi-room-title {
    font-size: 16px;
    font-weight: 600;
    margin: 0;
    color: var(--ibi-text);
}

.ibi-online-count {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: var(--ibi-text-muted);
}

.ibi-status-dot {
    width: 8px;
    height: 8px;
    background-color: var(--ibi-success);
    border-radius: 50%;
    display: inline-block;
    box-shadow: 0 0 6px var(--ibi-success);
}

.ibi-btn-icon {
    display: flex;
    align-items: center;
    gap: 8px;
    background: rgba(255, 255, 255, 0.05);
    border: 1px solid var(--ibi-border);
    padding: 6px 12px;
    border-radius: 20px;
    color: var(--ibi-text);
    cursor: pointer;
    transition: background 0.2s;
}

.ibi-btn-icon:hover {
    background: rgba(255, 255, 255, 0.1);
}

.ibi-user-top-avatar {
    width: 28px;
    height: 28px;
    border-radius: 50%;
    object-fit: cover;
}

.ibi-user-top-name {
    font-size: 13px;
    font-weight: 500;
}

.ibi-avatar-edit-hint {
    font-size: 11px;
    opacity: 0.7;
}

/* Cuerpo Principal: Main Layout */
.ibi-room-main {
    display: flex;
    flex: 1;
    height: calc(100% - 60px);
    position: relative;
    overflow: hidden;
}

/* Escenario de Video */
.ibi-video-stage {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: 16px;
    background: #090d16;
    position: relative;
    overflow-y: auto;
}

.ibi-video-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    flex: 1;
    align-content: center;
    justify-content: center;
    min-height: 450px;
}

.ibi-video-card {
    background: var(--ibi-bg-card);
    border: 1px solid var(--ibi-border);
    border-radius: 12px;
    position: relative;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 220px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
}

.ibi-video-card video {
    width: 100%;
    height: 100%;
    object-fit: cover;
    background: #000;
}

.ibi-avatar-placeholder {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
    background: #1e293b;
}

.ibi-avatar-placeholder img {
    width: 90px;
    height: 90px;
    border-radius: 50%;
    border: 3px solid var(--ibi-primary);
    object-fit: cover;
}

.ibi-card-meta {
    position: absolute;
    bottom: 10px;
    left: 10px;
    right: 10px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    background: rgba(15, 23, 42, 0.75);
    backdrop-filter: blur(6px);
    padding: 6px 12px;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
}

.ibi-card-indicators {
    display: flex;
    gap: 6px;
    font-size: 13px;
}

.ibi-ind-muted {
    filter: grayscale(1) opacity(0.5);
}

/* Barra Flotante de Controles */
.ibi-controls-bar {
    display: flex;
    justify-content: center;
    align-items: center;
    gap: 12px;
    padding: 12px 20px;
    margin-top: 12px;
    background: rgba(30, 41, 59, 0.85);
    backdrop-filter: blur(12px);
    border: 1px solid var(--ibi-border);
    border-radius: 30px;
    align-self: center;
    z-index: 10;
}

.ibi-ctrl-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    background: rgba(255, 255, 255, 0.08);
    border: 1px solid rgba(255, 255, 255, 0.12);
    border-radius: 12px;
    padding: 8px 14px;
    color: var(--ibi-text);
    cursor: pointer;
    transition: all 0.2s ease;
    min-width: 65px;
}

.ibi-ctrl-btn:hover {
    background: rgba(255, 255, 255, 0.16);
    transform: translateY(-2px);
}

.ibi-ctrl-icon {
    font-size: 20px;
    line-height: 1;
    margin-bottom: 4px;
}

.ibi-ctrl-label {
    font-size: 11px;
    font-weight: 500;
}

.ibi-ctrl-btn.ibi-active-off {
    background: rgba(239, 68, 68, 0.2);
    border-color: var(--ibi-danger);
    color: #fca5a5;
}

.ibi-ctrl-danger {
    background: rgba(239, 68, 68, 0.2);
    border-color: rgba(239, 68, 68, 0.4);
}

.ibi-ctrl-danger:hover {
    background: var(--ibi-danger);
    color: #ffffff;
}

/* Barra Lateral de Chat */
.ibi-chat-sidebar {
    width: 340px;
    background: #111827;
    border-left: 1px solid var(--ibi-border);
    display: flex;
    flex-direction: column;
    height: 100%;
}

.ibi-chat-header {
    padding: 12px 16px;
    border-bottom: 1px solid var(--ibi-border);
    background: #1e293b;
}

.ibi-chat-header h3 {
    margin: 0 0 8px 0;
    font-size: 14px;
    font-weight: 600;
    color: var(--ibi-text);
}

/* Switch de Traducción Automática */
.ibi-translate-toggle-box {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 12px;
    color: var(--ibi-gold);
    font-weight: 500;
}

.ibi-switch {
    position: relative;
    display: inline-block;
    width: 34px;
    height: 18px;
}

.ibi-switch input {
    opacity: 0;
    width: 0;
    height: 0;
}

.ibi-slider {
    position: absolute;
    cursor: pointer;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: #475569;
    transition: .3s;
    border-radius: 18px;
}

.ibi-slider:before {
    position: absolute;
    content: "";
    height: 12px;
    width: 12px;
    left: 3px;
    bottom: 3px;
    background-color: white;
    transition: .3s;
    border-radius: 50%;
}

input:checked + .ibi-slider {
    background-color: var(--ibi-primary);
}

input:checked + .ibi-slider:before {
    transform: translateX(16px);
}

/* Lista de Mensajes */
.ibi-chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 16px;
    display: flex;
    flex-direction: column;
    gap: 12px;
    max-height: 480px;
}

.ibi-chat-welcome {
    background: rgba(245, 158, 11, 0.1);
    border-left: 3px solid var(--ibi-gold);
    padding: 10px;
    border-radius: 4px;
    font-size: 12px;
    color: #fde68a;
}

.ibi-chat-welcome p {
    margin: 0;
}

.ibi-msg-item {
    display: flex;
    gap: 10px;
    align-items: flex-start;
}

.ibi-msg-avatar {
    width: 32px;
    height: 32px;
    border-radius: 50%;
    object-fit: cover;
    flex-shrink: 0;
}

.ibi-msg-content {
    background: var(--ibi-bg-card);
    border: 1px solid var(--ibi-border);
    border-radius: 10px;
    padding: 8px 12px;
    flex: 1;
    position: relative;
}

.ibi-msg-item.ibi-msg-mine .ibi-msg-content {
    background: #1e3a8a;
    border-color: #3b82f6;
}

.ibi-msg-header {
    display: flex;
    justify-content: space-between;
    margin-bottom: 4px;
}

.ibi-msg-name {
    font-size: 12px;
    font-weight: 600;
    color: var(--ibi-gold);
}

.ibi-msg-item.ibi-msg-mine .ibi-msg-name {
    color: #93c5fd;
}

.ibi-msg-time {
    font-size: 10px;
    color: var(--ibi-text-muted);
}

.ibi-msg-text {
    font-size: 13px;
    line-height: 1.4;
    word-break: break-word;
    color: var(--ibi-text);
}

/* Bloque de traducción */
.ibi-msg-translated-box {
    margin-top: 6px;
    padding-top: 6px;
    border-top: 1px dashed rgba(255, 255, 255, 0.15);
}

.ibi-translated-badge {
    display: inline-block;
    font-size: 10px;
    background: rgba(16, 185, 129, 0.2);
    color: #6ee7b7;
    border-radius: 4px;
    padding: 2px 5px;
    margin-bottom: 3px;
    font-weight: 600;
}

.ibi-translated-text {
    font-size: 12.5px;
    color: #e2e8f0;
    font-style: italic;
}

.ibi-btn-translate-manual {
    display: inline-block;
    margin-top: 4px;
    background: none;
    border: none;
    color: var(--ibi-primary-hover);
    font-size: 11px;
    cursor: pointer;
    padding: 0;
    text-decoration: underline;
}

/* Formulario de Entrada de Chat */
.ibi-chat-form {
    padding: 12px;
    background: #1e293b;
    border-top: 1px solid var(--ibi-border);
}

.ibi-chat-input-wrapper {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ibi-chat-input-wrapper textarea {
    flex: 1;
    background: #0f172a;
    border: 1px solid var(--ibi-border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--ibi-text);
    font-size: 13px;
    resize: none;
    outline: none;
    transition: border-color 0.2s;
    font-family: inherit;
}

.ibi-chat-input-wrapper textarea:focus {
    border-color: var(--ibi-primary);
}

.ibi-btn-send {
    background: var(--ibi-primary);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    width: 38px;
    height: 38px;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: background 0.2s;
}

.ibi-btn-send:hover {
    background: var(--ibi-primary-hover);
}

/* Modal de Personalización de Avatar */
.ibi-modal-backdrop {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(5px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 99999;
}

/* Botón de compartir en cabecera */
.ibi-btn-share-top {
    background: rgba(37, 99, 235, 0.15) !important;
    border-color: rgba(37, 99, 235, 0.35) !important;
    color: #93c5fd !important;
}
.ibi-btn-share-top:hover {
    background: rgba(37, 99, 235, 0.3) !important;
}

/* Campos de compartir */
.ibi-share-field-group {
    margin-bottom: 14px;
}

.ibi-share-field-group label {
    display: block;
    font-size: 12px;
    color: var(--ibi-text-muted);
    margin-bottom: 6px;
    font-weight: 500;
}

.ibi-copy-input-row,
.ibi-join-code-row {
    display: flex;
    gap: 8px;
    align-items: center;
}

.ibi-copy-input-row input,
.ibi-join-code-row input {
    flex: 1;
    background: #0f172a;
    border: 1px solid var(--ibi-border);
    border-radius: 8px;
    padding: 9px 12px;
    color: var(--ibi-text);
    font-size: 13px;
    outline: none;
}

.ibi-token-box {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background: #0f172a;
    border: 1px dashed var(--ibi-gold);
    border-radius: 8px;
    padding: 8px 12px;
}

.ibi-token-code {
    font-size: 15px;
    font-weight: 700;
    color: var(--ibi-gold);
    letter-spacing: 0.5px;
    font-family: monospace;
}

.ibi-divider {
    border: 0;
    height: 1px;
    background: var(--ibi-border);
    margin: 18px 0;
}

.ibi-quick-actions h4 {
    margin: 0 0 10px 0;
    font-size: 13px;
    color: var(--ibi-text);
}

.ibi-btn-link {
    display: inline-block;
    background: none;
    border: none;
    color: #60a5fa;
    font-size: 12px;
    cursor: pointer;
    padding: 8px 0 0 0;
    text-decoration: underline;
    text-align: left;
}

.ibi-btn-link:hover {
    color: #93c5fd;
}

.ibi-copy-feedback {
    font-size: 12px;
    color: #34d399;
    margin-right: auto;
    font-weight: 500;
}


.ibi-modal-dialog {
    background: #1e293b;
    border: 1px solid var(--ibi-border);
    border-radius: 16px;
    width: 90%;
    max-width: 440px;
    box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.5);
    overflow: hidden;
}

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

.ibi-modal-header h3 {
    margin: 0;
    font-size: 16px;
    color: var(--ibi-text);
}

.ibi-modal-close {
    background: none;
    border: none;
    color: var(--ibi-text-muted);
    font-size: 22px;
    cursor: pointer;
    line-height: 1;
}

.ibi-modal-body {
    padding: 20px;
}

.ibi-modal-body p {
    font-size: 13px;
    color: var(--ibi-text-muted);
    margin: 0 0 14px 0;
}

.ibi-avatar-presets {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-bottom: 20px;
}

.ibi-preset-item {
    cursor: pointer;
    border: 2px solid transparent;
    border-radius: 50%;
    padding: 2px;
    transition: all 0.2s;
}

.ibi-preset-item:hover,
.ibi-preset-item.selected {
    border-color: var(--ibi-gold);
    transform: scale(1.1);
}

.ibi-preset-item img {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    display: block;
}

.ibi-custom-url-field label {
    display: block;
    font-size: 12px;
    color: var(--ibi-text-muted);
    margin-bottom: 6px;
}

.ibi-custom-url-field input {
    width: 100%;
    background: #0f172a;
    border: 1px solid var(--ibi-border);
    border-radius: 8px;
    padding: 8px 12px;
    color: var(--ibi-text);
    font-size: 13px;
    outline: none;
}

.ibi-modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 14px 20px;
    background: #111827;
    border-top: 1px solid var(--ibi-border);
}

/* Responsividad (Móviles y Tablets) */
@media (max-width: 860px) {
    .ibi-room-main {
        flex-direction: column;
    }

    .ibi-chat-sidebar {
        width: 100%;
        height: 380px;
        border-left: none;
        border-top: 1px solid var(--ibi-border);
    }

    .ibi-video-stage {
        min-height: 340px;
    }
}
