/*** RcsComponentsSidebar.razor ***/
.components-sidebar {
    background: rgba(255, 255, 255, 0.95);
    backdrop-filter: blur(10px);
    border-radius: 16px;
    height: 100%;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
    overflow: hidden;
}

.widgets-title {
    text-align: center;
    text-transform: uppercase;
    margin: 1rem 0;
    color: #334155;
}

.sidebar-header {
    padding: 1.5rem;
    background: white;
    color: white;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.sidebar-header h3 {
    margin: 0;
    font-size: 1.125rem;
    font-weight: 600;
}

.sidebar-content {
    flex: 1;
    padding: 1.5rem;
    overflow-y: auto;
}

.component-category {
    margin-bottom: 2rem;
}

.category-title {
    font-size: 0.875rem;
    font-weight: 600;
    color: #667eea;
    margin-bottom: 1rem;
    text-transform: uppercase;
    letter-spacing: 0.5px;
}

/* Estilo base del widget (no ponemos reglas de dragging aquí para mantener DRY) */
.widget-item {
    display: flex;
    align-items: center;
    padding: 1rem;
    margin-bottom: 0.75rem;
    background: #f8fafc;
    border: 2px dashed #e2e8f0;
    border-radius: 12px;
    transition: all 0.2s ease; /* respuesta más rápida para el "snapshot" */
    user-select: none;
    position: relative;

    /* Garantiza que el ghost tenga las esquinas redondeadas: */
    overflow: hidden;
    background-clip: padding-box;
    clip-path: inset(0 round 12px);
}

.widget-item:hover:not(.widget-item-disabled) {
    background: #667eea;
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(102, 126, 234, 0.3);
    border-color: #667eea;
}

.widget-item:active:not(.widget-item-disabled) {
    cursor: grabbing;
    transform: scale(0.97);
}

.widget-info { margin-left: 0.75rem; flex: 1; }
.widget-name { display: block; font-weight: 500; font-size: 0.875rem; }
.widget-description { display: block; opacity: 0.7; font-size: 0.75rem; margin-top: 0.25rem; }
/*.widget-icon { font-size: 1.25rem; min-width: 20px; text-align: center; }*/
.widget-icon {
    width: 32px; /* ajusta según necesites */
    height: 32px;
    background-size: contain;
    background-repeat: no-repeat;
    background-position: center;
}

.widget-item-disabled { position: relative; }
.widget-disabled-overlay {
    position: absolute; top: 4px; right: 4px;
    background: rgba(255, 255, 255, 0.9); border-radius: 50%;
    padding: 4px; display: flex; align-items: center; justify-content: center;
}

.sidebar-tips { border-top: 1px solid #e2e8f0; padding-top: 1rem; }

.info-section {
    margin-top: 2rem;
}

.info-card {
    background: linear-gradient(135deg, #f0f9ff 0%, #e0f2fe 100%);
    border: 1px solid #bae6fd;
    border-radius: 16px;
    padding: 1.5rem;
    display: flex;
    gap: 1rem;
    align-items: flex-start;
}

.info-icon {
    font-size: 2rem;
    line-height: 1;
    flex-shrink: 0;
}

.info-content h5 {
    font-size: 1rem;
    font-weight: 600;
    margin: 0 0 0.75rem 0;
    color: #0f172a;
}

.info-content ul {
    margin: 0;
    padding-left: 1.25rem;
    color: #475569;
    line-height: 1.6;
}

.info-content li {
    margin-bottom: 0.5rem;
    font-size: 0.9rem;
}

/* Contenedor principal */
.category-title {
    font-size: 18px;
    font-weight: 600;
    color: #333;
    margin-bottom: 12px;
}

/* Contenedor de los inputs */
.ttl-input-header {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 8px;
}

.ttl-label {
    font-weight: 500;
    color: #333;
}

.tooltip-container {
    position: relative;
    display: inline-block;
}

.info-icon {
    font-size: 14px;
    cursor: help;
    opacity: 0.7;
    transition: opacity 0.2s ease;
}

.info-icon:hover {
    opacity: 1;
}

.tooltip-text {
    visibility: hidden;
    opacity: 0;
    background-color: #272727;
    color: white;
    text-align: left;
    border-radius: 6px;
    padding: 8px 12px;
    font-size: 12px;
    line-height: 1.4;
    width: 250px;

    /* Positioning */
    position: absolute;
    z-index: 1000;
    bottom: 125%;
    left: 50%;
    margin-left: -125px;

    /* Transition */
    transition: opacity 0.3s ease, visibility 0.3s ease;
}

.tooltip-text::after {
    content: "";
    position: absolute;
    top: 100%;
    left: 50%;
    margin-left: -5px;
    border-width: 5px;
    border-style: solid;
    border-color: #333 transparent transparent transparent;
}

.tooltip-container:hover .tooltip-text {
    visibility: visible;
    opacity: 1;
}

/* Estilos para el input - ESTO ES LO QUE FALTA */
.ttl-numeric-field {
    width: 100%;
    padding: 8px 12px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 14px;
    line-height: 1.5;
    background-color: #ffffff;
    transition: border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    outline: none;
}

.ttl-numeric-field:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

.ttl-numeric-field:hover {
    border-color: #9ca3af;
}

.ttl-helper-text {
    font-size: 12px;
    color: #757575;
    margin-top: 4px;
    font-style: italic;
}

.ttl-error-message {
    display: flex;
    align-items: center;
    gap: 4px;
    margin-top: 4px;
    color: #dc2626;
    font-size: 12px;
}

/* Estilo global para todos los inputs dentro de la sección TTL */
.ttl-numeric-field .mud-input-root {
    cursor: text !important;
}

/*** RcsDesignCanvas.razor ***/
.design-canvas {
    background: linear-gradient(135deg, #f8fafc 0%, #e2e8f0 100%);
    border: 2px dashed #cbd5e1;
    border-radius: 16px;
    min-height: 350px;
    width: 100%;         /* Siempre 100% del contenedor */
    max-width: 100%;     /* Nunca más que el viewport */
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    position: relative;
    overflow-x: hidden;  /* 🔒 Bloquea desbordes globales */
    box-sizing: border-box;
}

.design-canvas.drag-active {
    border-color: #667eea;
    background: linear-gradient(135deg, #f0f4ff 0%, #e0e7ff 100%);
}

.design-canvas.drag-over {
    border-color: #4f46e5;
    background: linear-gradient(135deg, #eef2ff 0%, #ddd6fe 100%);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    transform: scale(1.02);
}

.drop-zone {
    width: 100%;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 300px;
    transition: all 0.3s ease;
}

.drop-zone.active {
    background: rgba(79, 70, 229, 0.05);
    border-radius: 12px;
}

.drop-zone-placeholder {
    text-align: center;
    padding: 2rem;
}

.drop-inactive {
    color: #64748b;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
}

.drop-inactive span {
    font-size: 1.125rem;
    font-weight: 500;
}

.drop-active {
    color: #4f46e5;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 1rem;
    animation: pulse 2s infinite;
}

.drop-active span {
    font-size: 1.25rem;
    font-weight: 600;
}

.components-list {
    width: 100%;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    min-height: 100%;
    overflow-x: hidden;
}

.additional-drop-zone {
    margin-top: 1rem;
    padding: 1rem;
    border: 2px dashed #4f46e5;
    border-radius: 8px;
    background: rgba(79, 70, 229, 0.05);
    animation: fadeIn 0.3s ease-in-out;
}

.drop-zone-line {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: #4f46e5;
    font-weight: 500;
}

@keyframes pulse {
    0%, 100% {
        transform: scale(1);
        opacity: 1;
    }
    50% {
        transform: scale(1.05);
        opacity: 0.8;
    }
}

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

/* 📱 Móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
    .design-canvas {
        min-height: 250px;
        width: 100%;
        border-radius: 12px;
        padding: 0.5rem;
    }

    .drop-zone {
        min-height: 200px;
        flex-direction: column;
        gap: 1rem;
    }

    .drop-zone-placeholder {
        padding: 1rem;
        font-size: 0.9rem;
    }

    .drop-inactive span,
    .drop-active span {
        font-size: 0.9rem;
    }
}

/* 📲 Tablets (481px a 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .design-canvas {
        min-height: 300px;
        width: 100%;
        border-radius: 14px;
    }

    .drop-zone {
        min-height: 250px;
    }

    .drop-zone-placeholder {
        padding: 1.25rem;
        font-size: 1rem;
    }

    .drop-inactive span,
    .drop-active span {
        font-size: 1rem;
    }
}

/* 💻 Tablets grandes y laptops pequeñas (769px a 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .design-canvas {
        min-height: 350px;
        width: 100%;
        border-radius: 16px;
        padding: 1rem;
    }

    .drop-zone {
        min-height: 300px;
    }

    .drop-zone-placeholder {
        padding: 1.5rem;
        font-size: 1.1rem;
    }

    .drop-inactive span,
    .drop-active span {
        font-size: 1.1rem;
    }
}

/* 🖥️ Desktop (1025px en adelante) */
@media (min-width: 1025px) {
    .design-canvas {
        min-height: 400px;
        border-radius: 18px;
        padding: 1.5rem;

        width: 100%;        /* Ocupa siempre todo el ancho */
        max-width: 1200px;  /* 🔒 Límite máximo razonable */
        margin: 0 auto;     /* Centrado en pantallas grandes */
    }

    .drop-zone {
        min-height: 350px;
    }

    .drop-zone-placeholder {
        padding: 2rem;
        font-size: 1.25rem;
    }

    .drop-inactive span,
    .drop-active span {
        font-size: 1.25rem;
    }
}

/*** RcsEditorToolbar.razor ***/
.editor-toolbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem;
    background: white;
    border-radius: 12px;
    margin-bottom: 1rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.toolbar-left, .toolbar-right {
    display: flex;
    gap: 0.5rem;
}

/*** BaseComponentRenderer.razor ***/
/* Text component with limited width for readability */
.text-mobile {
    background: #7d7f7f;
    color: #f0f0f0;
    padding: 0.75rem 1rem;
    border-radius: 18px;
    line-height: 1.4;
    word-wrap: break-word;
    margin: 0.5rem 0;
    max-width: 280px;
}

/* URL preview styles - limited width like text messages */
.url-preview-mobile {
    margin-top: 0.5rem;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 280px;
}

.preview-image-mobile img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.preview-content-mobile {
    padding: 0.75rem;
}

.preview-title-mobile {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-description-mobile {
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.preview-url-mobile {
    font-size: 0.75rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.loading-preview-mobile {
    margin-top: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #6b7280;
}

/* Standalone RichCard - takes full available width */
.richcard {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%; /* Full width within its container */
    box-sizing: border-box;
    margin: 0; /* No margins that could interfere with width calculation */
}

/* Vertical Layout - Dynamic heights based on mediaHeight */
.richcard .card-image {
    width: 100%; /* Ensure image container takes full width */
}

.richcard .card-image img {
    width: 100%;
    object-fit: cover;
    display: block;
}

/* Media Height Classes for Vertical Cards */
.richcard.media-height-short .card-image img {
    height: 120px;
}

.richcard.media-height-medium .card-image img {
    height: 160px;
}

.richcard.media-height-tall .card-image img {
    height: 200px;
}

/* Default height if no media-height class */
.richcard .card-image img {
    height: 160px; /* Default medium */
}

.richcard .card-content {
    padding: 1rem;
    word-wrap: break-word;
    width: 100%; /* Full width content */
    box-sizing: border-box;
}

.richcard .card-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.richcard .card-content p {
    margin: 0 0 0.75rem 0;
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Horizontal Layout */
.richcard .card-horizontal-content {
    display: flex;
    align-items: stretch;
    min-height: 120px;
    width: 100%; /* Full width horizontal content */
}

.richcard .card-image-horizontal {
    flex-shrink: 0;
    width: 100px;
    overflow: hidden;
}

.richcard .card-image-horizontal img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.richcard .card-text-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0; /* Allows flex item to shrink below its content size */
}

.richcard .card-text-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #1e293b;
    font-weight: 600;
}

.richcard .card-text-content p {
    margin: 0 0 0.75rem 0;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.4;
    flex-grow: 1;
}

/* Integrated suggestions in standalone cards */
.card-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
    width: 100%;
    box-sizing: border-box;
}

.suggestion-button {
    background: #f8fafc;
    color: #475569;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-weight: 500;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.suggestion-button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Image component - full width */
.image-mobile {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    margin: 0.5rem 0;
}

.image-container-mobile img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* CAROUSEL MOBILE STYLES - Enhanced with Better Size Differentiation */
.carousel-mobile {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0.5rem 0;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
}

.carousel-container-mobile {
    display: flex;
    gap: 1rem;
    overflow-x: auto;     /* Scroll horizontal permitido */
    overflow-y: hidden;   /* Sin scroll vertical */
    padding: 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
    /* 🔑 CLAVE: Establecer ancho explícito para evitar que se expanda */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    /* 🔑 Prevenir que el contenido empuje el contenedor */
    min-width: 0;
}

.carousel-container-mobile::-webkit-scrollbar {
    display: none;
}

/* Carousel Item Base Styles */
.carousel-item-mobile {
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
    box-sizing: border-box;
}

/* CRÍTICO: Card Width Variations - Solo el ancho cambia, el contenido se ajusta proporcionalmente */
.carousel-item-mobile.carousel-card-small {
    min-width: 150px;
    max-width: 150px;
    width: 150px
}

.carousel-item-mobile.carousel-card-medium {
    min-width: 190px;
    max-width: 190px;
    width: 190px;
}

/* Carousel Card Image Container - Mismo comportamiento para ambos tamaños */
.carousel-card-image {
    width: 100%;
    overflow: hidden;
    background: #f8f9fa;
    min-width: 0;
}

.carousel-card-image img {
    width: 100%;
    object-fit: cover;
    display: block;
    max-width: 100%;
    height: auto;
}

/* Media Height Classes - IGUALES para ambos tamaños de card */
.carousel-card-image.carousel-media-short img {
    height: 90px;
}

.carousel-card-image.carousel-media-medium img {
    height: 120px;
}

.carousel-card-image.carousel-media-tall img {
    height: 150px;
}

/* Default height if no media-height class */
.carousel-card-image img {
    height: 120px; /* Default medium */
}

/* Carousel Card Content - Mismo padding y comportamiento para ambos tamaños */
.carousel-card-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 0.5rem;
    min-width: 0;
    word-wrap: break-word;
    overflow-wrap: break-word;
}

/* Título - Mismo tamaño para ambos tipos de card */
.carousel-card-title {
    margin: 0;
    font-size: 0.875rem;
    color: #1e293b;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    hyphens: auto;
}

/* Descripción - Mismo tamaño para ambos tipos de card */
.carousel-card-description {
    margin: 0;
    color: #64748b;
    font-size: 0.8125rem;
    line-height: 1.4;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
    word-break: break-word;
    hyphens: auto;
}

/* Carousel Card Suggestions - Mismo comportamiento para ambos tamaños */
.carousel-card-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
    width: 100%;
    box-sizing: border-box;
    min-width: 0;
}

/* Suggestion buttons - Mismo tamaño para ambos tipos de card */
.carousel-suggestion-button {
    background: #f8fafc;
    color: #475569;
    padding: 0.5rem 0.625rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    min-width: 0;
    max-width: 100%;
}

.carousel-suggestion-button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* PDF Component */
.pdf-container {
    display: flex;
    align-items: flex-start;
    gap: 0.80rem;
    background: #fff;
    border-radius: 8px;
    box-shadow: 0 2px 6px rgba(0,0,0,0.1);
    padding: 0.80rem 1rem;
    max-width: 260px;
}

.pdf-icon {
    flex-shrink: 0;
    display: flex;
}

.pdf-name {
    font-size: 0.85rem;
    font-weight: 500;
    color: #1e293b;
    word-break: break-word;
    line-height: 1.3;
}

.unknown-component {
    margin: 1rem 0;
}

.loading-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #e5e7eb;
    border-top: 2px solid #3b82f6;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Responsive adjustments - Ajustar solo anchura manteniendo consistencia */
@media (max-width: 375px) {
    .carousel-container-mobile {
        padding: 0.75rem; /* Menos padding en móviles pequeños */
        gap: 0.75rem;     /* Menos gap para aprovechar espacio */
    }

    .carousel-item-mobile.carousel-card-small {
        min-width: 130px;  /* Más pequeño en móviles muy pequeños */
        max-width: 130px;
        width: 130px;
    }

    .carousel-item-mobile.carousel-card-medium {
        min-width: 170px;  /* Ajustado proporcionalmente */
        max-width: 170px;
        width: 170px;
    }

    /* Todas las alturas y contenidos siguen siendo iguales en responsive */
    .carousel-card-content {
        padding: 0.625rem;
    }

    .carousel-card-title {
        font-size: 0.8125rem;
    }

    .carousel-card-description {
        font-size: 0.75rem;
    }

    .carousel-suggestion-button {
        padding: 0.4375rem 0.5rem;
        font-size: 0.6875rem;
    }
}

@media (max-width: 320px) {
    .carousel-container-mobile {
        padding: 0.5rem;
        gap: 0.5rem;
    }

    .carousel-item-mobile.carousel-card-small {
        min-width: 120px;
        max-width: 120px;
        width: 120px;
    }

    .carousel-item-mobile.carousel-card-medium {
        min-width: 150px;
        max-width: 150px;
        width: 150px;
    }
}

/* ✅ NUEVO: Media query para tablets en orientación portrait */
@media (min-width: 481px) and (max-width: 768px) {
    .carousel-item-mobile.carousel-card-small {
        min-width: 160px;
        max-width: 160px;
        width: 160px;
    }

    .carousel-item-mobile.carousel-card-medium {
        min-width: 200px;
        max-width: 200px;
        width: 200px;
    }
}

/*** MessageBubble.razor ***/
.message-bubble {
    width: 100%;
    margin-bottom: 0.5rem;
    background: transparent;
    padding: 0;
    box-sizing: border-box;
}

/* Rich Card Styles - Full width within message bubble */
.message-bubble .richcard {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    margin: 0;
}

@media (max-width: 480px) {
    .carousel-item-mobile.carousel-card-small {
        min-width: 130px;
        max-width: 130px;
    }

    .carousel-item-mobile.carousel-card-medium {
        min-width: 160px;
        max-width: 160px;
    }
}

/* Vertical Layout - Image heights based on mediaHeight property */
.message-bubble .richcard .card-image {
    width: 100%;
}

.message-bubble .richcard .card-image img {
    width: 100%;
    object-fit: cover;
    display: block;
}

/* Media Height Classes - Only for VERTICAL orientation */
.message-bubble .richcard.media-height-short .card-image img {
    height: 120px;
}

.message-bubble .richcard.media-height-medium .card-image img {
    height: 160px;
}

.message-bubble .richcard.media-height-tall .card-image img {
    height: 200px;
}

/* Default height if no class is applied */
.message-bubble .richcard .card-image img {
    height: 160px; /* Default to medium */
}

.message-bubble .richcard .card-content {
    padding: 1rem;
    word-wrap: break-word;
    width: 100%;
    box-sizing: border-box;
}

.message-bubble .richcard .card-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 1rem;
    color: #1e293b;
    font-weight: 600;
}

.message-bubble .richcard .card-content p {
    margin: 0 0 0.75rem 0;
    color: #64748b;
    font-size: 0.875rem;
    line-height: 1.4;
}

/* Horizontal Layout */
.message-bubble .richcard .card-horizontal-content {
    display: flex;
    align-items: stretch;
    min-height: 120px;
    width: 100%;
}

.message-bubble .richcard .card-image-horizontal {
    flex-shrink: 0;
    width: 100px;
    overflow: hidden;
}

.message-bubble .richcard .card-image-horizontal img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    display: block;
}

.message-bubble .richcard .card-text-content {
    flex: 1;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    justify-content: flex-start;
    min-width: 0;
}

.message-bubble .richcard .card-text-content h4 {
    margin: 0 0 0.5rem 0;
    font-size: 0.9rem;
    color: #1e293b;
    font-weight: 600;
}

.message-bubble .richcard .card-text-content p {
    margin: 0 0 0.75rem 0;
    color: #64748b;
    font-size: 0.8rem;
    line-height: 1.4;
    flex-grow: 1;
}

/* Integrated Suggestions in Standalone Cards */
.message-bubble .richcard .card-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid #f1f5f9;
    width: 100%;
    box-sizing: border-box;
}

.message-bubble .richcard .suggestion-button {
    background: #f8fafc;
    color: #475569;
    padding: 0.625rem 0.75rem;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-weight: 500;
    font-size: 0.8125rem;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
}

.message-bubble .richcard .suggestion-button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* Text component styles */
.message-bubble .text-mobile {
    background: #7d7f7f;
    color: #f0f0f0;
    padding: 0.75rem 1rem;
    border-radius: 18px 18px 18px 18px;
    line-height: 1.4;
    word-wrap: break-word;
    margin: 0.5rem 0;
    max-width: 280px;
}

/* Image component styles */
.message-bubble .image-mobile {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    width: 100%;
    box-sizing: border-box;
    margin: 0.5rem 0;
}

.message-bubble .image-container-mobile img {
    width: 100%;
    height: auto;
    display: block;
    object-fit: cover;
}

/* Carousel styles - CRÍTICO: Respeta las clases de cardWidth */
.message-bubble .carousel-mobile {
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin: 0.5rem 0;
    width: 100%;
    box-sizing: border-box;
}

.message-bubble .carousel-container-mobile {
    display: flex;
    gap: 1rem;
    overflow-x: auto;
    padding: 1rem;
    scrollbar-width: none;
    -ms-overflow-style: none;
    scroll-behavior: smooth;
}

.message-bubble .carousel-container-mobile::-webkit-scrollbar {
    display: none;
}

/* Carousel Item Base - Sin ancho específico, usa las clases de cardWidth */
.message-bubble .carousel-item-mobile {
    flex-shrink: 0;
    background: white;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
    border: 1px solid #f1f5f9;
    display: flex;
    flex-direction: column;
}

/* CRÍTICO: Card Width Variations - Específicas para MessageBubble */
.message-bubble .carousel-item-mobile.carousel-card-small {
    min-width: 160px;
    max-width: 160px;
}

.message-bubble .carousel-item-mobile.carousel-card-medium {
    min-width: 200px;
    max-width: 200px;
}

/* Carousel Card Image Container */
.message-bubble .carousel-card-image {
    width: 100%;
    overflow: hidden;
    background: #f8f9fa;
}

.message-bubble .carousel-card-image img {
    width: 100%;
    object-fit: cover;
    display: block;
}

/* Media Height Classes - Consistentes con BaseComponentRenderer */
.message-bubble .carousel-card-image.carousel-media-short img {
    height: 90px;
}

.message-bubble .carousel-card-image.carousel-media-medium img {
    height: 120px;
}

.message-bubble .carousel-card-image.carousel-media-tall img {
    height: 150px;
}

/* Default height if no media-height class */
.message-bubble .carousel-card-image img {
    height: 120px; /* Default medium */
}

/* Carousel Card Content */
.message-bubble .carousel-card-content {
    padding: 0.75rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    gap: 0.5rem;
}

.message-bubble .carousel-card-title {
    margin: 0;
    font-size: 0.875rem;
    color: #1e293b;
    font-weight: 600;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-bubble .carousel-card-description {
    margin: 0;
    color: #64748b;
    font-size: 0.8125rem;
    line-height: 1.4;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* Carousel Card Suggestions */
.message-bubble .carousel-card-suggestions {
    display: flex;
    flex-direction: column;
    gap: 0.375rem;
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid #f1f5f9;
    width: 100%;
    box-sizing: border-box;
}

.message-bubble .carousel-suggestion-button {
    background: #f8fafc;
    color: #475569;
    padding: 0.5rem 0.625rem;
    border-radius: 6px;
    border: 1px solid #e2e8f0;
    text-align: center;
    font-weight: 500;
    font-size: 0.75rem;
    transition: all 0.2s ease;
    cursor: pointer;
    width: 100%;
    box-sizing: border-box;
    line-height: 1.3;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.message-bubble .carousel-suggestion-button:hover {
    background: #f1f5f9;
    border-color: #cbd5e1;
}

/* URL Preview styles */
.message-bubble .url-preview-mobile {
    margin-top: 0.5rem;
    background: white;
    border-radius: 12px;
    overflow: hidden;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    max-width: 280px;
}

.message-bubble .preview-image-mobile img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.message-bubble .preview-content-mobile {
    padding: 0.75rem;
}

.message-bubble .preview-title-mobile {
    font-weight: 600;
    font-size: 0.875rem;
    color: #1e293b;
    margin-bottom: 0.25rem;
    line-height: 1.3;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-bubble .preview-description-mobile {
    font-size: 0.8125rem;
    color: #64748b;
    line-height: 1.4;
    margin-bottom: 0.5rem;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

.message-bubble .preview-url-mobile {
    font-size: 0.75rem;
    color: #94a3b8;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.message-bubble .loading-preview-mobile {
    margin-top: 0.5rem;
    background: #f8f9fa;
    border-radius: 8px;
    padding: 0.5rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.8125rem;
    color: #6b7280;
}

/* Responsive adjustments for smaller containers */
@media (max-width: 375px) {
    .message-bubble .richcard .card-horizontal-content {
        min-height: 100px;
    }

    .message-bubble .richcard .card-image-horizontal {
        width: 80px;
    }

    .message-bubble .richcard .card-text-content {
        padding: 0.75rem;
    }

    /* Adjust vertical image heights for smaller screens */
    .message-bubble .richcard.media-height-short .card-image img {
        height: 100px;
    }

    .message-bubble .richcard.media-height-medium .card-image img {
        height: 140px;
    }

    .message-bubble .richcard.media-height-tall .card-image img {
        height: 180px;
    }

    /* Responsive carousel card widths */
    .message-bubble .carousel-item-mobile.carousel-card-small {
        min-width: 140px;
        max-width: 140px;
    }

    .message-bubble .carousel-item-mobile.carousel-card-medium {
        min-width: 200px;
        max-width: 200px;
    }

    /* Mantener contenido igual para ambos tamaños en responsive */
    .message-bubble .carousel-card-content {
        padding: 0.625rem;
    }

    .message-bubble .carousel-card-title {
        font-size: 0.8125rem;
    }

    .message-bubble .carousel-card-description {
        font-size: 0.75rem;
    }

    .message-bubble .carousel-suggestion-button {
        padding: 0.4375rem 0.5rem;
        font-size: 0.6875rem;
    }
}

/*** DragDropWrapper.razor ***/
.drag-drop-wrapper {
    cursor: grab;
    transition: transform 0.12s ease, opacity 0.12s ease;
}

/* Rotación cuando se presiona el mouse (antes de dragstart) */
.drag-drop-wrapper.pre-drag .widget-item,
.drag-drop-wrapper.dragging .widget-item {
    opacity: 0.85;
    transform: rotate(5deg) scale(1.05);
    border-radius: 12px;
    overflow: hidden;
    background-clip: padding-box;
    clip-path: inset(0 round 12px);
}

.drag-drop-wrapper.pre-drag,
.drag-drop-wrapper.dragging {
    transform: translateZ(0); /* evita re-rasterizados raros en algunos navegadores */
}

.drag-drop-wrapper:active {
    cursor: grabbing;
}

/*** DroppedComponent.razor ***/
.dropped-component {
    background: white;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 1rem;
    margin-bottom: 0.5rem;
    transition: all 0.2s ease;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow: hidden;
}

.dropped-component:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    border-color: #c7d2fe;
}

.component-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.component-info {
    display: flex;
    align-items: center;
    gap: 0.5rem;
    flex: 1;
    min-width: 0; /* Permite que el texto se corte */
}

.component-icon {
    font-size: 1.25rem;
    flex-shrink: 0;
}

.component-name {
    font-weight: 600;
    color: #334155;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.component-actions {
    display: flex;
    gap: 0.25rem;
    flex-shrink: 0;
}

/* Contenedor del preview - CORREGIDO */
.component-preview {
    transform: scale(0.9);
    transform-origin: top left;
    width: calc(100% / 0.9); /* Compensar el scale */
    height: auto;
    max-width: none;
    box-sizing: border-box;
    overflow: hidden;
    border-radius: 4px;
}

.component-preview > * {
    max-width: 100%;
    width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* 📱 Móviles pequeños (hasta 480px) */
@media (max-width: 480px) {
    .dropped-component {
        padding: 0.75rem;
        margin-bottom: 0.75rem;
    }

    .component-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 0.75rem;
    }

    .component-info {
        width: 100%;
    }

    .component-actions {
        width: 100%;
        justify-content: flex-end;
    }

    .component-preview {
        transform: scale(0.7);
        width: calc(100% / 0.7);
        margin-left: 0;
    }
}

/* 📲 Tablets en vertical (481px a 768px) */
@media (min-width: 481px) and (max-width: 768px) {
    .dropped-component {
        padding: 1rem;
    }

    .component-header {
        flex-wrap: wrap;
    }

    .component-preview {
        transform: scale(0.8);
        width: calc(100% / 0.8);
    }
}

/* 💻 Tablets horizontales y laptops pequeñas (769px a 1024px) */
@media (min-width: 769px) and (max-width: 1024px) {
    .dropped-component {
        padding: 1.25rem;
    }

    .component-preview {
        transform: scale(0.85);
        width: calc(100% / 0.85);
    }
}

/* 🖥️ Desktop mediano (1025px a 1440px) */
@media (min-width: 1025px) and (max-width: 1440px) {
    .dropped-component {
        padding: 1.5rem;
    }

    .component-preview {
        transform: scale(0.9);
        width: calc(100% / 0.9);
    }
}

/* 🖥️ Desktop grande (más de 1440px) */
@media (min-width: 1441px) {
    .dropped-component {
        padding: 1.5rem;
    }

    .component-preview {
        transform: scale(1);
        width: 100%;
        max-width: 1200px;
        margin: 0 auto;
    }
}

/*** RcsTemplateFormDialog.razor ***/
.custom-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.4);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2000;
}

.modal-container {
    background: white;
    border-radius: 12px;
    padding: 2rem;
    width: 600px;
    max-width: 95%;
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.close-btn {
    background: transparent;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
}

.form-section {
    margin-bottom: 0.5rem;
}

.form-label {
    font-weight: 500;
    margin-bottom: 0.5rem;
    display: block;
}

.text-input {
    width: 100%;
    padding: 0.6rem 0.8rem;
    border: 1px solid #ccc;
    border-radius: 6px;
    font-size: 1rem;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.text-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(124, 58, 237, 0.1);
}

.text-input.valid {
    border-color: #10b981;
}

.text-input.invalid {
    border-color: #ef4444;
}

/* Validación en tiempo real */
.validation-errors {
    margin-top: 0.5rem;
}

.error-message {
    color: #ef4444;
    font-size: 0.85rem;
    margin-bottom: 0.25rem;
}

.char-counter {
    font-size: 0.75rem;
    color: #666;
    text-align: right;
    margin-top: 0.25rem;
    transition: color 0.2s ease;
}

.char-counter.warning {
    color: #f59e0b;
    font-weight: 500;
}

.section-title {
    margin-bottom: 1rem;
}

.options-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 0.75rem;
}

.option-card {
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 2rem 0.75rem 0.75rem 0.75rem;
    text-align: center;
    cursor: pointer;
    transition: all 0.2s ease;
    background: #fafafa;
}

.option-card:hover {
    border-color: var(--primary-color);
    background: #fdfaff;
}

.option-card.selected {
    border: 2px solid var(--primary-color);
    background: #f5f0ff;
}

.option-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 1.5rem;
}

.option-img {
    width: 68px;
    height: 68px;
    object-fit: contain;
}

.option-title {
    font-size: 1rem;
    margin: 0.3rem 0;
}

.option-description {
    font-size: 0.85rem;
    color: #666;
    margin: 0 0 0.25rem 0;
}

.button-container {
    display: flex;
    justify-content: flex-end;
    gap: 1rem;
    margin-top: 2.15rem;
}

.btn {
    padding: 0.6rem 1.2rem;
    border-radius: 6px;
    cursor: pointer;
    font-size: 0.95rem;
    font-weight: 500;
    transition: background 0.2s ease, color 0.2s ease;
}

.btn-cancel {
    background: white;
    color: var(--primary-color);
    border: 1px solid var(--primary-color);
}

.btn-cancel:hover {
    background: #f5f0ff;
}

.btn-primary {
    background: var(--primary-color);
    color: white;
    border: none;
}

.btn-primary:disabled {
    background: #ccc;
    cursor: not-allowed;
}

.btn-primary:hover:not(:disabled) {
    background: #6f2de2;
}

