/* ====================================
   HISTORIAS REALES - CARRUSEL DE CASOS
   ==================================== */

/* Sección Principal */
.historias-section {
    background: var(--bg-primary, #0a0e27);
    padding: 3.5rem 0;
    position: relative;
    overflow: hidden;
}

[data-theme="light"] .historias-section {
    background: #f8fafc;
}

.historias-section::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: radial-gradient(circle at 20% 50%, rgba(0, 123, 255, 0.05), transparent 50%),
                radial-gradient(circle at 80% 50%, rgba(0, 123, 255, 0.05), transparent 50%);
    pointer-events: none;
}

[data-theme="light"] .historias-section::before {
    background: radial-gradient(circle at 20% 50%, rgba(0, 123, 255, 0.03), transparent 50%),
                radial-gradient(circle at 80% 50%, rgba(34, 197, 94, 0.03), transparent 50%);
}

.historias-section .section-header {
    text-align: center;
    margin-bottom: 3rem;
    position: relative;
    z-index: 1;
}

.historias-section .section-title {
    font-size: clamp(2rem, 5vw, 3rem);
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    margin-bottom: 1rem;
    letter-spacing: -0.02em;
}

[data-theme="light"] .historias-section .section-title {
    color: #0b1220;
}

.historias-section .section-subtitle {
    font-size: clamp(1rem, 2vw, 1.25rem);
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    max-width: 600px;
    margin: 0 auto;
}

[data-theme="light"] .historias-section .section-subtitle {
    color: #5f6876;
}

/* Enlaces del Ecosistema en el Subtítulo */
.ecosystem-link {
    text-decoration: none;
    font-weight: 600;
    transition: all 0.3s ease;
    border-bottom: 2px solid transparent;
}

.ecosystem-link-smart2u {
    color: var(--s2u-blue, #1d4ed8);
}

.ecosystem-link-smart2u:hover {
    color: var(--s2u-blue-600, #1e40af);
    border-bottom-color: var(--s2u-blue, #1d4ed8);
}

.ecosystem-link-verumx {
    color: #9333ea;
}

.ecosystem-link-verumx:hover {
    color: #a855f7;
    border-bottom-color: #9333ea;
}

[data-theme="light"] .ecosystem-link-smart2u {
    color: #1d4ed8;
}

[data-theme="light"] .ecosystem-link-smart2u:hover {
    color: #1e40af;
}

[data-theme="light"] .ecosystem-link-verumx {
    color: #7c3aed;
}

[data-theme="light"] .ecosystem-link-verumx:hover {
    color: #6d28d9;
}

/* Contenedor del Carrusel */
.carrusel-container {
    position: relative;
    width: 100%;
    overflow: hidden;
    padding: 2rem 0;
    margin: 0 auto;
    max-width: 1200px;
}

.carrusel-track {
    display: flex;
    gap: 2rem;
    transition: transform 0.5s cubic-bezier(0.4, 0, 0.2, 1);
    padding: 0 1rem;
    width: fit-content;
}

/* Card de Historia */
.historia-card {
    flex: 0 0 auto;
    width: 360px;
    background: var(--bg-secondary, #151b3d);
    border-radius: 16px;
    padding: 2rem;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.05);
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    cursor: pointer;
    display: flex;
    flex-direction: column;
    gap: 1rem;
    position: relative;
    overflow: hidden;
}

.historia-card::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 4px;
    background: linear-gradient(90deg, var(--primary-color, #007bff), var(--accent-color, #00d4ff));
    transform: scaleX(0);
    transform-origin: left;
    transition: transform 0.3s ease;
}

.historia-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 12px 40px rgba(0, 123, 255, 0.2);
    border-color: var(--primary-color, #007bff);
}

[data-theme="light"] .historia-card {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.08);
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

[data-theme="light"] .historia-card:hover {
    box-shadow: 0 8px 24px rgba(0, 123, 255, 0.15);
    border-color: #007bff;
}

.historia-card:hover::before {
    transform: scaleX(1);
}

.historia-card-sector {
    font-size: 0.875rem;
    color: var(--primary-color, #007bff);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

[data-theme="light"] .historia-card-sector {
    color: #1d4ed8;
}

.historia-card-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    line-height: 1.3;
    margin: 0;
}

[data-theme="light"] .historia-card-title {
    color: #0b1220;
}

.historia-card-extracto {
    font-size: 1rem;
    color: var(--text-secondary, rgba(255, 255, 255, 0.7));
    line-height: 1.6;
    flex-grow: 1;
    display: -webkit-box;
    -webkit-line-clamp: 3;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

[data-theme="light"] .historia-card-extracto {
    color: #5f6876;
}

.historia-card-btn {
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    padding: 0.75rem 1.5rem;
    background: var(--primary-color, #007bff);
    color: #ffffff;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    font-size: 0.95rem;
    transition: all 0.3s ease;
    cursor: pointer;
    align-self: flex-start;
}

.historia-card-btn:hover {
    background: var(--s14u-accent, #22c55e);
    transform: translateX(4px);
    box-shadow: 0 4px 12px rgba(34, 197, 94, 0.3);
}

[data-theme="light"] .historia-card-btn {
    background: #007bff;
}

[data-theme="light"] .historia-card-btn:hover {
    background: #16a34a;
    box-shadow: 0 4px 12px rgba(22, 163, 74, 0.3);
}

.historia-card-btn i {
    transition: transform 0.3s ease;
}

.historia-card-btn:hover i {
    transform: translateX(4px);
}

/* Navegación del Carrusel */
.carrusel-navigation {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

.carrusel-nav-btn {
    width: 48px;
    height: 48px;
    border-radius: 50%;
    background: var(--bg-secondary, #151b3d);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: var(--text-primary, #ffffff);
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 1.25rem;
}

.carrusel-nav-btn:hover:not(:disabled) {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    transform: scale(1.1);
}

.carrusel-nav-btn:disabled {
    opacity: 0.3;
    cursor: not-allowed;
}

/* Indicadores (Dots) */
.carrusel-dots {
    display: flex;
    justify-content: center;
    gap: 0.5rem;
    margin-top: 2rem;
}

.carrusel-dot {
    width: 10px;
    height: 10px;
    border-radius: 50%;
    background: rgba(100, 100, 100, 0.4);
    border: 1px solid rgba(0, 123, 255, 0.3);
    cursor: pointer;
    transition: all 0.3s ease;
}

/* Modo claro */
[data-theme="light"] .carrusel-dot {
    background: rgba(0, 123, 255, 0.2);
    border: 1px solid rgba(0, 123, 255, 0.4);
}

.carrusel-dot.active {
    background: var(--primary-color, #007bff);
    border-color: var(--primary-color, #007bff);
    width: 32px;
    border-radius: 5px;
}

[data-theme="light"] .carrusel-dot.active {
    background: #007bff;
    border-color: #007bff;
}

/* CTA de la Sección */
.historias-cta {
    text-align: center;
    margin-top: 3rem;
}

.historias-cta .btn-large {
    font-size: 1.125rem;
    padding: 1rem 2.5rem;
    background: var(--primary-color, #007bff);
    transition: all 0.3s ease;
}

.historias-cta .btn-large:hover {
    background: var(--s14u-accent, #22c55e);
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(34, 197, 94, 0.3);
}

[data-theme="light"] .historias-cta .btn-large {
    background: #007bff;
}

[data-theme="light"] .historias-cta .btn-large:hover {
    background: #16a34a;
    box-shadow: 0 8px 20px rgba(22, 163, 74, 0.3);
}

/* ====================================
   MODAL DE HISTORIA COMPLETA
   ==================================== */

.historia-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 9999;
    display: none;
    align-items: center;
    justify-content: center;
    padding: 1rem;
}

.historia-modal.active {
    display: flex;
}

.historia-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.85);
    backdrop-filter: blur(8px);
    animation: fadeIn 0.3s ease;
}

.historia-modal-content {
    position: relative;
    background: var(--bg-secondary, #151b3d);
    border-radius: 20px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
    border: 1px solid rgba(255, 255, 255, 0.1);
    animation: modalSlideIn 0.4s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 1;
}

[data-theme="light"] .historia-modal-content {
    background: #ffffff;
    border: 1px solid rgba(0, 0, 0, 0.1);
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.15);
}

.historia-modal-close {
    position: absolute;
    top: 1.5rem;
    right: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    color: var(--text-primary, #ffffff);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
    z-index: 2;
}

.historia-modal-close:hover {
    background: rgba(255, 0, 0, 0.8);
    transform: rotate(90deg);
}

.historia-modal-body {
    padding: 3rem 2.5rem;
}

.historia-modal-header {
    margin-bottom: 2rem;
}

.historia-modal-sector {
    display: inline-block;
    font-size: 0.875rem;
    color: var(--primary-color, #007bff);
    font-weight: 600;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    margin-bottom: 0.5rem;
}

[data-theme="light"] .historia-modal-sector {
    color: #1d4ed8;
}

.historia-modal-title {
    font-size: clamp(1.75rem, 4vw, 2.25rem);
    font-weight: 700;
    color: var(--text-primary, #ffffff);
    line-height: 1.2;
    margin: 0;
}

[data-theme="light"] .historia-modal-title {
    color: #0b1220;
}

.historia-modal-story {
    margin-bottom: 2rem;
}

.historia-modal-story p {
    font-size: 1.0625rem;
    line-height: 1.8;
    color: var(--text-secondary, rgba(255, 255, 255, 0.85));
    margin: 0;
}

[data-theme="light"] .historia-modal-story p {
    color: #1a2233;
}

.historia-modal-tools {
    background: rgba(0, 123, 255, 0.05);
    border-left: 4px solid var(--primary-color, #007bff);
    padding: 1.5rem;
    border-radius: 8px;
    margin-bottom: 2rem;
}

[data-theme="light"] .historia-modal-tools {
    background: rgba(29, 78, 216, 0.05);
    border-left-color: #1d4ed8;
}

.historia-modal-tools h4 {
    font-size: 1.125rem;
    font-weight: 600;
    color: var(--text-primary, #ffffff);
    margin: 0 0 1rem 0;
}

[data-theme="light"] .historia-modal-tools h4 {
    color: #0b1220;
}

.herramientas-list {
    list-style: none;
    padding: 0;
    margin: 0;
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.herramientas-list li {
    font-size: 0.9375rem;
    color: var(--text-secondary, rgba(255, 255, 255, 0.85));
    line-height: 1.6;
    padding-left: 1.5rem;
    position: relative;
}

[data-theme="light"] .herramientas-list li {
    color: #1a2233;
}

.herramientas-list li::before {
    content: '✓';
    position: absolute;
    left: 0;
    color: var(--primary-color, #007bff);
    font-weight: 700;
    font-size: 1.125rem;
}

[data-theme="light"] .herramientas-list li::before {
    color: #16a34a;
}

.historia-modal-footer {
    text-align: center;
}

.historia-modal-footer .btn-large {
    font-size: 1.0625rem;
    padding: 1rem 2rem;
    width: 100%;
    max-width: 400px;
    background: var(--primary-color, #007bff);
    transition: all 0.3s ease;
}

.historia-modal-footer .btn-large:hover {
    background: var(--s14u-accent, #22c55e);
    transform: scale(1.02);
    box-shadow: 0 6px 16px rgba(34, 197, 94, 0.3);
}

[data-theme="light"] .historia-modal-footer .btn-large {
    background: #007bff;
}

[data-theme="light"] .historia-modal-footer .btn-large:hover {
    background: #16a34a;
    box-shadow: 0 6px 16px rgba(22, 163, 74, 0.3);
}

/* Animaciones */
@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: scale(0.9) translateY(20px);
    }
    to {
        opacity: 1;
        transform: scale(1) translateY(0);
    }
}

/* ====================================
   RESPONSIVE
   ==================================== */

@media (min-width: 1201px) {
    /* No aplicar justify-content en desktop para que todas las cards se muestren */
}

/* iPad Pro y tablets grandes (1024px - 1200px) */
@media (max-width: 1200px) and (min-width: 1025px) {
    .carrusel-container {
        max-width: 900px;
    }

    .historia-card {
        width: 340px;
    }
    
    .carrusel-nav-btn {
        width: 44px;
        height: 44px;
    }
}

/* iPad estándar y tablets medianas (768px - 1024px) */
@media (max-width: 1024px) and (min-width: 769px) {
    .carrusel-container {
        max-width: 720px;
    }

    .historia-card {
        width: 320px;
    }
    
    .carrusel-track {
        gap: 1.5rem;
    }
    
    .carrusel-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }
}

@media (max-width: 1200px) {
    .carrusel-container {
        max-width: 800px;
    }

    .historia-card {
        width: 360px;
    }
}

@media (max-width: 768px) {
    .historias-section {
        padding: 4rem 0;
    }

    .carrusel-container {
        max-width: 100%;
    }

    .historia-card {
        width: calc(100vw - 4rem);
        max-width: 500px;
        margin: 0 auto;
    }

    .carrusel-track {
        padding: 0 2rem;
        gap: 1rem;
    }

    .carrusel-navigation {
        margin-bottom: 1rem;
    }

    .carrusel-nav-btn {
        width: 44px;
        height: 44px;
        font-size: 1.1rem;
    }

    .historia-modal-body {
        padding: 2rem 1.5rem;
    }

    .historia-modal-close {
        top: 1rem;
        right: 1rem;
        width: 44px;
        height: 44px;
        font-size: 1.2rem;
    }

    .historias-cta .btn-large {
        font-size: 1rem;
        padding: 0.875rem 2rem;
    }
}

@media (max-width: 480px) {
    .historia-card {
        width: calc(100vw - 3rem);
        max-width: 400px;
    }

    .carrusel-track {
        padding: 0 1.5rem;
    }

    .historia-card-title {
        font-size: 1.25rem;
    }

    .historias-section .section-title {
        font-size: 1.75rem;
    }

    .historias-section .section-subtitle {
        font-size: 0.9375rem;
    }
}

/* Scrollbar para el modal */
.historia-modal-content::-webkit-scrollbar {
    width: 8px;
}

.historia-modal-content::-webkit-scrollbar-track {
    background: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
}

.historia-modal-content::-webkit-scrollbar-thumb {
    background: var(--primary-color, #007bff);
    border-radius: 10px;
}

.historia-modal-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-hover, #0056b3);
}

/* Accesibilidad */
.historia-modal[aria-hidden="true"] {
    pointer-events: none;
}

.historia-modal[aria-hidden="false"] {
    pointer-events: all;
}

/* Mejora para pantallas táctiles */
@media (hover: none) and (pointer: coarse) {
    .historia-card:active {
        transform: translateY(-4px);
    }
    
    .carrusel-track {
        overflow-x: auto;
        scroll-snap-type: x mandatory;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: none;
    }
    
    .carrusel-track::-webkit-scrollbar {
        display: none;
    }
    
    .historia-card {
        scroll-snap-align: center;
    }
}
