/* Debug panel styles */
#debug-panel {
    position: fixed;
    top: 10px;
    right: 10px;
    width: 350px;
    max-height: 80vh;
    background: #222e35ee;
    color: #e4edef;
    border: 1px solid #384750;
    border-radius: 8px;
    z-index: 9999;
    box-shadow: 0 2px 12px #0008;
    font-size: 13px;
    display: flex;
    flex-direction: column;
}
#debug-panel.hidden {
    display: none;
}
#debug-toggle-btn {
    background: #222e35;
    color: #00a884;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    margin: 8px;
    cursor: pointer;
    font-size: 13px;
}
#debug-log {
    flex: 1;
    overflow-y: auto;
    background: #1a2329;
    padding: 8px;
    border-radius: 6px;
    margin: 0 8px 8px 8px;
    font-family: monospace;
    max-height: 60vh;
}
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    /* Prevenir zoom en inputs en iOS */
    -webkit-text-size-adjust: 100%;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
    height: 100vh;
    height: 100dvh; /* Dynamic viewport height para móviles */
    overflow: hidden;
    background: #111b21;
    touch-action: pan-y;
    -webkit-font-smoothing: antialiased;
}

/* Bloqueo defensivo: oculta overlays fijados del navegador (p.ej. "Add element to chat") */
body *[aria-label*="Add element to chat"],
body *[aria-label*="add element to chat"],
body *[aria-label*="Add element"],
body *[aria-label*="Copilot"],
body *[aria-label*="Assistant"],
body *[id*="copilot"],
body *[id*="edge-"],
body *[id*="assistant"],
body *[class*="copilot"],
body *[class*="edge-"],
body *[class*="assistant"],
/* fallback genérico para widgets fijados con ese texto */
body *[style*="position: fixed"],
body iframe[src*="copilot"],
body iframe[src*="edge"],
body iframe[id*="copilot"],
body iframe[id*="edge"],
body iframe[id*="assistant"] {
    display: none !important;
    visibility: hidden !important;
    pointer-events: none !important;
    opacity: 0 !important;
    width: 0 !important;
    height: 0 !important;
    position: absolute !important;
    left: -9999px !important;
}

/* Si el overlay de opciones aparece, muévelo a la esquina superior derecha y hazlo menos intrusivo */
body *[aria-label*="Add element to chat"],
body *[aria-label*="add element to chat"],
body *[aria-label*="Add element"],
body *[aria-label*="Copilot"],
body *[aria-label*="Assistant"],
body *[id*="copilot"],
body *[id*="edge-"],
body *[id*="assistant"],
body *[class*="copilot"],
body *[class*="edge-"],
body *[class*="assistant"] {
    top: 12px !important;
    right: 12px !important;
    left: auto !important;
    bottom: auto !important;
    z-index: 9999 !important;
    width: 48px !important;
    height: 48px !important;
    opacity: 0.5 !important;
    pointer-events: auto !important;
    border-radius: 50% !important;
    box-shadow: none !important;
}

/* Ocultar sombras y overlays del navegador */
body::after,
body::before {
    content: none !important;
}

/* Modal */
.modal {
    display: flex;
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.8);
    align-items: center;
    justify-content: center;
}

.modal-content {
    padding: 36px 36px 32px 36px;
    background: #202c33;
    border-radius: 18px;
    box-shadow: 0 6px 32px rgba(0,0,0,0.22);
    min-width: 340px;
    max-width: 370px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.modal-content h2 {
    color: #e9edef;
    margin-bottom: 20px;
    font-size: 22px;
    text-align: center;
}

.modal-content input {
    width: 100%;
    padding: 12px 14px;
    margin-bottom: 15px;
    border: 1.5px solid #2a3942;
    border-radius: 10px;
    background: #2a3942;
    color: #e9edef;
    font-size: 16px; /* Previene zoom automático en iOS */
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}

.modal-content button {
    width: 100%;
    padding: 14px 0;
    background: #00a884;
    color: #fff;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-size: 18px;
    font-weight: 700;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
}
.modal-content .registered-nick-btn {
    background: transparent !important;
    color: #d1d7db;
    border: 1px solid #384750;
    box-shadow: none;
    padding: 10px 12px; /* mantener distinta altura del botón primario */
}
.modal-content .registered-nick-btn:hover {
    background: transparent !important;
    border-color: #4d5f69;
}

.modal-content button:hover {
    background: #06cf9c;
}

/* Login modal mejorado */
.login-row {
    width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 16px;
}
.login-checkbox-label {
    font-size: 17px;
    color: #e9edef;
    display: flex;
    align-items: center;
    gap: 10px;
    cursor: pointer;
    font-weight: 500;
    letter-spacing: 0.1px;
    width: 100%;
    justify-content: center;
}
.login-checkbox {
    accent-color: #00a884;
    width: 22px;
    height: 22px;
    margin-right: 6px;
    border-radius: 6px;
    border: 2px solid #2a3942;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
    vertical-align: middle;
}
.login-checkbox-label span {
    display: inline-block;
    vertical-align: middle;
}
.login-password-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 10px;
    border: 1.5px solid #2a3942;
    background: #111b21;
    color: #e9edef;
    font-size: 16px;
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    margin-top: 2px;
    transition: border 0.2s;
}
.login-password-input:focus {
    border-color: #00a884;
}
.login-connect-btn {
    width: 100%;
    padding: 14px 0;
    background: #00a884;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 10px;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    transition: background 0.2s;
}
.login-connect-btn:disabled {
    background: #2a3942;
    color: #8696a0;
    cursor: not-allowed;
}
.login-loading {
    margin-top: 14px;
    color: #00a884;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
}

.hidden {
    display: none !important;
}

/* Login profesional IRC */
.login-title {
    margin-bottom: 28px;
    font-size: 2rem;
    font-weight: 700;
    color: #fff;
    text-align: center;
}
.login-form {
    width: 100%;
    max-width: 320px;
    display: flex;
    flex-direction: column;
    gap: 18px;
    align-items: center;
}
.login-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1.5px solid #2a3942;
    background: #111b21;
    color: #e9edef;
    font-size: 16px;
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    margin-bottom: 0;
    transition: border 0.2s;
}
.login-input:focus {
    border-color: #00a884;
}
.login-checkbox-row {
    width: 100%;
    display: flex;
    align-items: stretch;
    justify-content: flex-start;
    margin-bottom: 0;
    white-space: nowrap;
}
.login-checkbox-combined {
    width: 100%;
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 12px 14px;
    background: #111b21; /* igual que password/input */
    border: 1.5px solid #2a3942;
    border-radius: 8px;
    cursor: pointer;
    user-select: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    transition: border 0.2s, background 0.2s;
}
.login-checkbox-combined .login-checkbox {
    flex-shrink: 0;
    margin: 0;
}
.login-checkbox-text {
    display: inline-flex;
    align-items: center;
    line-height: 1;
    font-size: 16px;
    color: #e9edef;
    font-weight: 500;
}
.login-checkbox-combined:hover {
    border-color: #00a884;
}
.login-checkbox-combined:active {
    background: #182229;
}
.registered-nick-btn {
    width: 100%;
    padding: 10px 12px;
    background: transparent; /* sin fondo para que parezca opción */
    border: 1px solid #384750; /* borde sutil */
    color: #d1d7db; /* texto ligeramente más claro */
    font-size: 14.5px;
    font-weight: 500;
    border-radius: 10px;
    cursor: pointer;
    text-align: left;
    display: flex;
    align-items: center;
    gap: 10px;
    position: relative;
    transition: background 0.16s ease, border-color 0.16s ease, color 0.16s ease;
}
.registered-nick-btn::before {
    content: '';
    width: 18px;
    height: 18px;
    border: 2px solid #4d5f69;
    border-radius: 5px;
    background: #1a242b;
    display: inline-block;
    transition: background 0.16s ease, border-color 0.16s ease;
}
.registered-nick-btn:hover {
    background: transparent;
    border-color: #4d5f69;
}
.registered-nick-btn.active {
    border-color: #00a884; /* resalta solo el borde */
    background: #28373f; /* mantener neutro, no verde */
    color: #e9edef;
}
.registered-nick-btn.active::before {
    background: #00a884; /* check de color primario, pequeño */
    border-color: #00a884;
}
.registered-nick-btn.active::after {
    content: '\2713';
    position: absolute;
    left: 18px;
    font-size: 12px;
    color: #0b141a; /* contraste dentro del cuadrito verde */
    pointer-events: none;
}
.login-checkbox {
    accent-color: #00a884;
    width: 22px;
    height: 22px;
    border-radius: 6px;
    border: 2px solid #2a3942;
    box-shadow: 0 2px 8px rgba(0,0,0,0.08);
}
.login-checkbox-text {
    font-size: 16px;
    color: #e9edef;
    font-weight: 500;
    letter-spacing: 0.1px;
    user-select: none;
    white-space: nowrap;
}
.login-password-input {
    width: 100%;
    padding: 12px 14px;
    border-radius: 8px;
    border: 1.5px solid #2a3942;
    background: #111b21;
    color: #e9edef;
    font-size: 16px;
    outline: none;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    margin-top: 0;
    transition: border 0.2s;
}
.login-password-input:focus {
    border-color: #00a884;
}
.login-connect-btn {
    width: 100%;
    padding: 14px 0;
    background: #00a884;
    color: #fff;
    font-size: 18px;
    font-weight: 700;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    margin-top: 0;
    box-shadow: 0 2px 8px rgba(0,0,0,0.10);
    transition: background 0.2s;
}
.login-connect-btn:disabled {
    background: #2a3942;
    color: #8696a0;
    cursor: not-allowed;
}
.login-loading {
    margin-top: 8px;
    color: #00a884;
    font-weight: 600;
    font-size: 16px;
    letter-spacing: 0.5px;
    text-align: center;
}
.modal-content {
    padding: 36px 36px 32px 36px;
    background: #202c33;
    border-radius: 18px;
    box-shadow: 0 6px 32px rgba(0,0,0,0.22);
    min-width: 340px;
    max-width: 370px;
    display: flex;
    flex-direction: column;
    align-items: center;
}
@media (max-width: 480px) {
    .modal-content {
        min-width: 95vw;
        max-width: 98vw;
        padding: 18px 8px 18px 8px;
    }
    .login-form {
        max-width: 98vw;
        gap: 14px;
    }
    .login-input, .login-password-input {
        font-size: 15px;
        padding: 10px 10px;
    }
    .login-connect-btn {
        font-size: 16px;
        padding: 12px 0;
    }
    .login-checkbox-text {
        font-size: 15px;
    }
    .login-checkbox {
        width: 18px;
        height: 18px;
    }
}

/* App principal */
#app {
    display: flex;
    height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 100%;
    background: #111b21;
    border-right: 1px solid #2a3942;
    display: flex;
    flex-direction: column;
}

/* Escritorio: sidebar fijo */
@media (min-width: 768px) {
    .sidebar {
        width: 350px;
        max-width: 350px;
    }
}

.sidebar-header {
    background: #202c33;
    padding: 16px 16px;
    border-bottom: 1px solid #2a3942;
}

.sidebar-header h2 {
    color: #e9edef;
    font-size: 20px;
    margin-bottom: 5px;
    font-weight: 600;
}

.user-info span {
    color: #8696a0;
    font-size: 14px;
}

.add-channel {
    display: flex;
    padding: 12px;
    background: #202c33;
    border-bottom: 1px solid #2a3942;
}

.add-channel input {
    flex: 1;
    padding: 12px;
    border: none;
    border-radius: 8px;
    background: #2a3942;
    color: #e9edef;
    margin-right: 10px;
    font-size: 16px; /* Previene zoom en iOS */
}

.add-channel button {
    min-width: 44px; /* Tamaño mínimo táctil */
    height: 44px;
    background: #00a884;
    color: white;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-size: 22px;
    font-weight: bold;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

.add-channel button:hover {
    background: #06cf9c;
}

.chat-list {
    flex: 1;
    overflow-y: auto;
}

.chat-item {
    padding: 12px 16px;
    background: #111b21;
    border-bottom: 1px solid #2a3942;
    cursor: pointer;
    transition: background 0.2s;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    min-height: 60px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
}

.chat-item:hover {
    background: #202c33;
}

.chat-item.active {
    background: #2a3942;
}

.chat-item-content {
    flex: 1;
    min-width: 0;
}

.chat-item-name {
    color: #e9edef;
    font-weight: 500;
    margin-bottom: 5px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.chat-item-preview {
    color: #8696a0;
    font-size: 13px;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.chat-item-unread {
    background: #00a884;
    color: white;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 11px;
}

.chat-item-close {
    background: transparent;
    border: none;
    color: #8696a0;
    font-size: 24px;
    line-height: 1;
    cursor: pointer;
    padding: 4px 8px;
    border-radius: 4px;
    transition: all 0.2s;
    flex-shrink: 0;
    opacity: 0;
    width: 0;
    overflow: hidden;
}

.chat-item:hover .chat-item-close {
    opacity: 1;
    width: auto;
}

.chat-item-close:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #ff4444;
}

@media screen and (max-width: 768px) {
    .chat-item-close {
        opacity: 1;
        width: auto;
    }
}

/* Área de chat */
.chat-area {
    flex: 1;
    display: none; /* Oculto por defecto en móvil */
    flex-direction: column;
    background: #0b141a;
}

/* Mostrar área de chat cuando hay un chat activo en móvil */
.chat-area.active {
    display: flex;
}

/* En escritorio siempre visible */
@media (min-width: 768px) {
    .chat-area {
        display: flex;
    }
    
    .sidebar {
        display: flex !important;
    }
}

.chat-header {
    background: #202c33;
    padding: 16px;
    border-bottom: 1px solid #2a3942;
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
}

.chat-header h3 {
    color: #e9edef;
    font-size: 18px;
    font-weight: 600;
    flex: 1;
}

/* Botón de volver (solo visible en móvil) */
.back-btn {
    background: transparent;
    border: none;
    color: #e9edef;
    font-size: 32px;
    padding: 0;
    width: 44px;
    height: 44px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
    line-height: 1;
    margin-left: -8px;
}

.back-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    border-radius: 50%;
}

/* Ocultar botón de volver en escritorio */
@media (min-width: 768px) {
    .back-btn {
        display: none;
    }
}

.messages {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 16px;
    background-image: url('data:image/svg+xml;utf8,<svg xmlns="http://www.w3.org/2000/svg" width="100" height="100"><rect fill="%230b141a" width="100" height="100"/></svg>');
    -webkit-overflow-scrolling: touch; /* Scroll suave en iOS */
}

@media (min-width: 768px) {
    .messages {
        padding: 20px;
    }
}

.message {
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.message-sent {
    align-items: flex-end;
}

.message-received {
    align-items: flex-start;
}

.message-bubble {
    max-width: 80%;
    padding: 10px 12px;
    border-radius: 8px;
    word-wrap: break-word;
    word-break: break-word;
}

@media (min-width: 768px) {
    .message-bubble {
        max-width: 65%;
    }
}

.message-sent .message-bubble {
    background: #005c4b;
    color: #e9edef;
}

.message-received .message-bubble {
    background: #202c33;
    color: #e9edef;
}

.message-sender {
    font-weight: 600;
    color: #06cf9c;
    margin-bottom: 3px;
    font-size: 13px;
}

.message-text {
    font-size: 14px;
    line-height: 1.4;
}
.message-text.message-action {
    font-style: italic;
    opacity: 0.92;
}

.message-time {
    font-size: 11px;
    color: #8696a0;
    margin-top: 3px;
    text-align: right;
}

.system-message {
    text-align: center;
    color: #8696a0;
    font-size: 12px;
    margin: 10px 0;
}

/* Input de mensaje */
.message-input {
    background: #202c33;
    padding: 12px;
    display: flex;
    border-top: 1px solid #2a3942;
    gap: 8px;
}

.message-input input {
    flex: 1;
    padding: 12px 14px;
    border: none;
    border-radius: 24px;
    background: #2a3942;
    color: #e9edef;
    font-size: 16px; /* Previene zoom en iOS */
}

.message-input button {
    min-width: 44px;
    height: 44px;
    padding: 0 20px;
    background: #00a884;
    color: white;
    border: none;
    border-radius: 24px;
    cursor: pointer;
    font-weight: 600;
    font-size: 15px;
    -webkit-tap-highlight-color: transparent;
    touch-action: manipulation;
}

@media (min-width: 768px) {
    .message-input {
        padding: 15px 20px;
    }
    
    .message-input input {
        border-radius: 8px;
    }
    
    .message-input button {
        border-radius: 8px;
        padding: 12px 25px;
    }
}

.message-input button:hover {
    background: #06cf9c;
}

.message-input button:disabled {
    background: #2a3942;
    cursor: not-allowed;
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 6px;
}

::-webkit-scrollbar-track {
    background: #111b21;
}

::-webkit-scrollbar-thumb {
    background: #374045;
    border-radius: 3px;
}

::-webkit-scrollbar-thumb:hover {
    background: #4a5559;
}

@media (max-width: 767px) {
    .chat-area.active {
        height: 100dvh;
    }
    .messages {
        padding-bottom: 80px; /* espacio para la barra fija */
    }
    .message-input {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        padding: 10px 12px;
        background: #202c33ee; /* semitransparente */
        backdrop-filter: blur(6px);
        -webkit-backdrop-filter: blur(6px);
        z-index: 500;
    }
    .message-input input {
        font-size: 16px;
    }
    .message-input button {
        height: 44px;
    }
}
/* message-input-mobile-fix */


:root { --vvh: 100svh; }
@media (max-width: 767px) {
  .chat-area.active { height: var(--vvh, 100svh); }
  .messages { overscroll-behavior-y: contain; padding-bottom: calc(env(safe-area-inset-bottom) + 80px); }
  .message-input { bottom: env(safe-area-inset-bottom); }
}

/* Radio Player */
.radio-player {
    display: flex;
    align-items: center;
    gap: 6px;
    margin-left: auto;
    margin-right: 8px;
}

.radio-btn {
    background: transparent;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 6px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.radio-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d7db;
}

.radio-btn:active {
    transform: scale(0.95);
}

.radio-btn svg {
    width: 16px;
    height: 16px;
}

.hidden {
    display: none !important;
}

.volume-slider {
    width: 60px;
    height: 4px;
    -webkit-appearance: none;
    appearance: none;
    background: #2a3942;
    border-radius: 2px;
    outline: none;
}

.volume-slider::-webkit-slider-thumb {
    -webkit-appearance: none;
    appearance: none;
    width: 12px;
    height: 12px;
    background: #00a884;
    border-radius: 50%;
    cursor: pointer;
}

.volume-slider::-moz-range-thumb {
    width: 12px;
    height: 12px;
    background: #00a884;
    border-radius: 50%;
    cursor: pointer;
    border: none;
}

/* Users Button */
.users-btn {
    background: transparent;
    border: none;
    color: #8696a0;
    cursor: pointer;
    padding: 8px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.users-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d7db;
}

.users-btn:active {
    transform: scale(0.95);
}

/* Users Panel */
.users-panel {
    position: fixed;
    top: 0;
    right: -100%;
    width: 280px;
    max-width: 80%;
    height: calc(100% - 75px);
    background: #111b21;
    border-left: 1px solid #2a3942;
    z-index: 1001;
    transition: right 0.3s ease;
    display: flex;
    flex-direction: column;
}

.users-panel.active {
    right: 0;
}

.users-panel-header {
    background: #202c33;
    padding: 20px 16px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    border-bottom: 1px solid #2a3942;
}

.users-panel-header h4 {
    color: #d1d7db;
    margin: 0;
    font-size: 18px;
    font-weight: 500;
}

.close-btn {
    background: transparent;
    border: none;
    color: #8696a0;
    font-size: 32px;
    line-height: 1;
    cursor: pointer;
    padding: 0;
    width: 32px;
    height: 32px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
    transition: all 0.2s;
}

.close-btn:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #d1d7db;
}

.users-list {
    flex: 1;
    overflow-y: auto;
    padding: 8px 0;
}

.user-item {
    padding: 12px 16px;
    color: #d1d7db;
    display: flex;
    align-items: center;
    gap: 12px;
    transition: background 0.2s;
}

.user-item:hover {
    background: rgba(255, 255, 255, 0.05);
}

.user-prefix {
    font-weight: 700;
    min-width: 20px;
}

.user-prefix.op {
    color: #00a884;
}

.user-prefix.voice {
    color: #53bdeb;
}

.user-nick {
    flex: 1;
    font-size: 14px;
}

@media screen and (max-width: 768px) {
    .volume-slider {
        width: 50px;
    }
    
    .users-panel {
        max-width: 85%;
        height: calc(100% - 60px - env(safe-area-inset-bottom));
    }
}

/* ========== Rich Links (Enlaces enriquecidos) ========== */

/* Enlaces normales con estilo */
.rich-link-url {
    color: #53bdeb;
    text-decoration: underline;
    word-break: break-all;
    cursor: pointer;
    transition: color 0.2s;
}

.rich-link-url:hover {
    color: #8ecef5;
}

/* Contenedor de preview */
.rich-link-preview {
    margin-top: 8px;
    border-radius: 8px;
    overflow: hidden;
    max-width: 100%;
}

/* Vista previa de imágenes */
.rich-link-image {
    background: rgba(0, 0, 0, 0.3);
    padding: 4px;
    cursor: pointer;
    position: relative;
}

.rich-link-image img {
    width: 100%;
    max-width: 400px;
    max-height: 300px;
    object-fit: contain;
    border-radius: 6px;
    display: block;
    cursor: pointer;
    transition: opacity 0.2s;
}

/* Blur effect para imágenes */
.rich-link-image.blurred img.blur-image {
    filter: blur(20px);
    -webkit-filter: blur(20px);
}

.blur-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    background: rgba(0, 0, 0, 0.5);
    border-radius: 6px;
    cursor: pointer;
    transition: background 0.2s;
}

.rich-link-image.blurred:hover .blur-overlay {
    background: rgba(0, 0, 0, 0.6);
}

.blur-text {
    color: #fff;
    font-size: 16px;
    font-weight: 600;
    text-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
    padding: 12px 20px;
    background: rgba(0, 168, 132, 0.9);
    border-radius: 24px;
    user-select: none;
}

.rich-link-image img:hover {
    opacity: 0.9;
}

.rich-link-image img:active {
    opacity: 0.8;
}

/* Link Preview Card (Open Graph) */
.rich-link-card {
    margin-top: 8px;
    max-width: 400px;
}

.link-preview-card {
    display: block;
    background: rgba(32, 44, 51, 0.8);
    border: 1px solid #2a3942;
    border-radius: 8px;
    overflow: hidden;
    text-decoration: none;
    color: inherit;
    transition: all 0.2s;
    cursor: pointer;
}

.link-preview-card:hover {
    background: rgba(42, 57, 66, 0.9);
    border-color: #384750;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

.link-preview-image {
    width: 100%;
    height: 200px;
    background-size: cover;
    background-position: center;
    background-repeat: no-repeat;
}

.link-preview-content {
    padding: 12px;
}

.link-preview-title {
    font-size: 15px;
    font-weight: 600;
    color: #e9edef;
    margin-bottom: 6px;
    line-height: 1.3;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    line-clamp: 2;
    -webkit-box-orient: vertical;
}
.link-preview-description {
    font-size: 13px;
    color: #8696a0;
    margin-bottom: 8px;
    line-height: 1.4;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    line-clamp: 3;
    -webkit-box-orient: vertical;
}

.link-preview-domain {
    font-size: 12px;
    color: #53bdeb;
    text-transform: lowercase;
}

.rich-link-loading {
    margin-top: 8px;
}

@media (max-width: 767px) {
    .rich-link-image img {
        max-width: 100%;
        max-height: 250px;
    }
    
    .link-preview-card {
        max-width: 100%;
    }
    
    .link-preview-image {
        height: 160px;
    }
}

/* Vista previa de videos */
.rich-link-video {
    background: rgba(0, 0, 0, 0.5);
    padding: 4px;
}

.rich-link-video video {
    width: 100%;
    max-width: 400px;
    max-height: 300px;
    border-radius: 6px;
    display: block;
    cursor: pointer;
}

@media (max-width: 767px) {
    .rich-link-video video {
        max-width: 100%;
        max-height: 250px;
    }
}

/* Embeds de plataformas (YouTube, Vimeo, etc.) */
.rich-link-embed {
    background: rgba(0, 0, 0, 0.5);
    padding: 4px;
    position: relative;
    width: 100%;
    max-width: 400px;
}

.rich-link-embed iframe {
    width: 100%;
    height: 225px;
    border-radius: 6px;
    display: block;
}

@media (max-width: 767px) {
    .rich-link-embed {
        max-width: 100%;
    }
    
    .rich-link-embed iframe {
        height: 200px;
    }
}

/* Mensajes enviados con rich links */
.message-sent .rich-link-preview {
    background: rgba(0, 92, 75, 0.3);
}

.message-sent .rich-link-url {
    color: #8ecef5;
}

/* Mensajes recibidos con rich links */
.message-received .rich-link-preview {
    background: rgba(32, 44, 51, 0.5);
}
