/* 
 * StoryMals PWA Styles
 * Versión: 1.0.9 - COMPLETO Y OPTIMIZADO
 * Estilos para banners PWA, notificaciones y botones
 */

/* ========================================================================== */
/* 🎯 BANNER ESTILO WASHINGTON POST */
/* ========================================================================== */

.storymals-pwa-banner {
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    z-index: 2147483647;
}

.storymals-pwa-banner.storymals-style-banner {
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
}

.storymals-banner-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 16px;
}

.storymals-banner-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.storymals-banner-icon {
    color: #7c3aed;
    flex-shrink: 0;
}

.storymals-banner-text h4 {
    margin: 0 0 4px 0;
    font-size: 16px;
    font-weight: 600;
    color: #1a1a1a;
}

.storymals-banner-text p {
    margin: 0;
    font-size: 14px;
    color: #666;
}

.storymals-banner-actions {
    display: flex;
    gap: 8px;
    flex-shrink: 0;
}

.storymals-install-btn {
    background: #7c3aed;
    color: white;
    border: none;
    padding: 10px 20px;
    border-radius: 6px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    transition: background-color 0.2s;
}

.storymals-install-btn:hover {
    background: #6d28d9;
}

.storymals-dismiss-btn {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
    padding: 10px 16px;
    border-radius: 6px;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
}

.storymals-dismiss-btn:hover {
    background: #f5f5f5;
}

/* ========================================================================== */
/* 🎯 NOTIFICACIÓN ESTILO POPUP */
/* ========================================================================== */

.storymals-pwa-notification {
    background: #2d3748;
    color: white;
    padding: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    z-index: 2147483647;
}

.storymals-notification-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    gap: 16px;
}

.storymals-notification-text {
    display: flex;
    flex-direction: column;
    gap: 2px;
    flex: 1;
}

.storymals-notification-text strong {
    font-size: 14px;
    font-weight: 600;
}

.storymals-notification-text span {
    font-size: 12px;
    opacity: 0.9;
}

.storymals-notification-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-shrink: 0;
}

.storymals-notification-install {
    background: #7c3aed;
    color: white;
    border: none;
    padding: 8px 16px;
    border-radius: 4px;
    font-weight: 600;
    font-size: 12px;
    cursor: pointer;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    transition: background-color 0.2s;
}

.storymals-notification-install:hover {
    background: #6d28d9;
}

.storymals-notification-dismiss {
    background: transparent;
    color: #a0aec0;
    border: none;
    padding: 4px;
    border-radius: 4px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.storymals-notification-dismiss:hover {
    color: white;
    background: rgba(255,255,255,0.1);
}

.storymals-notification-dismiss svg {
    width: 14px;
    height: 14px;
}

/* ========================================================================== */
/* 🎯 BOTÓN DESCARGAR APP */
/* ========================================================================== */

.storymals-download-btn {
    background: linear-gradient(135deg, #7c3aed, #6d28d9);
    color: white;
    border: none;
    padding: 12px 24px;
    border-radius: 8px;
    font-weight: 600;
    font-size: 14px;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    transition: all 0.3s ease;
    box-shadow: 0 2px 8px rgba(124, 58, 237, 0.3);
    text-decoration: none;
    font-family: inherit;
}

.storymals-download-btn:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(124, 58, 237, 0.4);
    background: linear-gradient(135deg, #6d28d9, #5b21b6);
    color: white;
}

/* VARIANTES DE BOTÓN */
.storymals-download-btn.outline {
    background: transparent;
    color: #7c3aed;
    border: 2px solid #7c3aed;
    box-shadow: none;
}

.storymals-download-btn.outline:hover {
    background: #7c3aed;
    color: white;
}

.storymals-download-btn.small {
    padding: 8px 16px;
    font-size: 12px;
}

.storymals-download-btn.large {
    padding: 16px 32px;
    font-size: 16px;
}

.storymals-download-btn svg {
    margin-right: 8px;
}

/* ========================================================================== */
/* 🎯 BANNER ORIGINAL (compatibilidad) */
/* ========================================================================== */

#storymals-pwa-banner {
    padding: 15px;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 2147483647;
    position: fixed;
    left: 0;
    right: 0;
    display: none;
}

#storymals-pwa-banner > div {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

#storymals-pwa-banner > div > div:first-child {
    flex: 1;
}

#storymals-pwa-banner > div > div:last-child {
    margin-left: 15px;
}

#storymals-pwa-banner button {
    padding: 8px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
}

#storymals-pwa-banner button:last-child {
    margin-left: 8px;
    padding: 8px 12px;
    background: transparent;
    border: 1px solid #ccc;
    border-radius: 4px;
    cursor: pointer;
}

/* ========================================================================== */
/* 🎯 POSICIONES */
/* ========================================================================== */

.storymals-pwa-banner[data-position="top"],
.storymals-pwa-notification[data-position="top"] {
    top: 0;
    bottom: auto;
}

.storymals-pwa-banner[data-position="bottom"],
.storymals-pwa-notification[data-position="bottom"] {
    bottom: 0;
    top: auto;
}

.storymals-pwa-banner[data-position="center"] {
    top: 50%;
    transform: translateY(-50%);
    bottom: auto;
}

#storymals-pwa-banner[style*="top: 0"] {
    top: 0 !important;
}

#storymals-pwa-banner[style*="bottom: 0"] {
    bottom: 0 !important;
}

#storymals-pwa-banner[style*="top: 50%"] {
    top: 50% !important;
    transform: translateY(-50%) !important;
}

/* ========================================================================== */
/* 🎯 RESPONSIVE */
/* ========================================================================== */

@media (max-width: 768px) {
    .storymals-banner-content {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    .storymals-banner-actions {
        justify-content: center;
    }
    
    .storymals-notification-content {
        flex-direction: column;
        gap: 12px;
        text-align: center;
    }
    
    .storymals-notification-actions {
        justify-content: center;
    }
    
    .storymals-banner-info {
        text-align: center;
        flex-direction: column;
    }
    
    #storymals-pwa-banner > div {
        flex-direction: column;
        align-items: stretch;
        gap: 12px;
    }
    
    #storymals-pwa-banner > div > div:last-child {
        margin-left: 0;
        display: flex;
        justify-content: center;
        gap: 8px;
    }
    
    .storymals-download-btn {
        padding: 10px 20px;
        font-size: 13px;
    }
}

/* ========================================================================== */
/* 🎯 ANIMACIONES */
/* ========================================================================== */

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

@keyframes storymalsSlideInDown {
    from {
        transform: translateY(-100%);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.storymals-pwa-banner[data-position="bottom"],
.storymals-pwa-notification[data-position="bottom"] {
    animation: storymalsSlideInUp 0.3s ease-out;
}

.storymals-pwa-banner[data-position="top"],
.storymals-pwa-notification[data-position="top"] {
    animation: storymalsSlideInDown 0.3s ease-out;
}

.storymals-pwa-banner[data-position="center"] {
    animation: storymalsSlideInDown 0.3s ease-out;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA ADMIN */
/* ========================================================================== */

.storymals-chart-container {
    margin: 20px 0;
    padding: 20px;
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
    max-width: 1000px;
}

.storymals-chart-container h2 {
    margin-bottom: 20px;
    color: #1d2327;
    font-size: 18px;
    font-weight: 600;
    border-bottom: 1px solid #e2e4e7;
    padding-bottom: 10px;
}

#storymals_top_cuentos {
    max-width: 100%;
    height: 400px;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px solid #e2e4e7;
    padding: 10px;
}

/* Estilos para mensajes de estado */
#storymals-no-data-message,
#storymals-error-message {
    margin: 20px 0;
    padding: 20px;
    border-radius: 4px;
    max-width: 1000px;
}

#storymals-no-data-message {
    background: #f8f9fa;
    border: 1px solid #e2e4e7;
    color: #666;
    text-align: center;
}

#storymals-no-data-message h3 {
    color: #666;
    margin-bottom: 10px;
}

#storymals-error-message {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

#storymals-error-message h3 {
    color: #dc2626;
    margin-bottom: 10px;
}

/* Responsive admin */
@media (max-width: 768px) {
    .storymals-chart-container {
        margin: 15px 0;
        padding: 15px;
    }
    
    #storymals_top_cuentos {
        height: 300px;
    }
}

/* ========================================================================== */
/* 🎯 DEBUG Y UTILIDADES */
/* ========================================================================== */

#pwa-debug-info {
    display: none;
    font-size: 10px;
    color: #666;
}

#storymals-ios-instructions {
    display: none;
    font-size: 14px;
    margin-bottom: 10px;
}

.storymals-desc {
    font-size: 14px;
    margin-bottom: 10px;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA LOGIN */
/* ========================================================================== */

.storymals-login {
    max-width: 400px;
    margin: 0 auto;
    padding: 20px;
}

.storymals-login h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #1d2327;
}

.storymals-login .button {
    width: 100%;
    text-align: center;
    margin-bottom: 10px;
}

.storymals-login input[type="email"] {
    width: 100%;
    padding: 8px;
    margin: 6px 0;
    box-sizing: border-box;
}

.storymals-login label {
    display: flex;
    align-items: center;
    gap: 8px;
    margin: 10px 0;
}

#sm_message {
    margin-top: 8px;
    padding: 8px;
    border-radius: 4px;
    text-align: center;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA CONTENIDO PROTEGIDO */
/* ========================================================================== */

#storymals-protected-content {
    display: none;
}

#storymals-login-required {
    text-align: center;
    padding: 40px 20px;
}

#storymals-login-required h2 {
    color: #1d2327;
    margin-bottom: 15px;
}

#storymals-login-required p {
    color: #666;
    margin-bottom: 25px;
}

/* ========================================================================== */
/* 🎯 SOLUCIÓN Z-INDEX PARA STORYMALS - VISIBILIDAD GARANTIZADA */
/* ========================================================================== */

.storymals-pwa-banner,
.storymals-pwa-notification,
#storymals-pwa-banner {
    z-index: 2147483647 !important;
    position: fixed !important;
}

/* Asegurar que los elementos hijos también tengan alto z-index */
.storymals-pwa-banner *,
.storymals-pwa-notification *,
#storymals-pwa-banner * {
    position: relative !important;
    z-index: 2147483647 !important;
}

/* Asegurar que los banners sean clickeables */
.storymals-pwa-banner button,
.storymals-pwa-notification button,
#storymals-pwa-banner button {
    z-index: 2147483647 !important;
    position: relative !important;
    pointer-events: auto !important;
}

/* Contexto de apilamiento separado para banners */
.storymals-pwa-banner,
.storymals-pwa-notification {
    isolation: isolate !important;
}

/* Media queries para la solución */
@media (max-width: 768px) {
    .storymals-pwa-banner,
    .storymals-pwa-notification,
    #storymals-pwa-banner {
        z-index: 2147483647 !important;
    }
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA BANNERS MODERNOS */
/* ========================================================================== */

.storymals-pwa-banner-modern {
    background: #ffffff;
    border-top: 1px solid #e0e0e0;
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    padding: 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    z-index: 2147483647;
}

.storymals-pwa-notification-modern {
    background: #2d3748;
    color: white;
    padding: 12px 16px;
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
    display: none;
    position: fixed;
    left: 0;
    right: 0;
    z-index: 2147483647;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA FORMULARIOS Y ELEMENTOS DE UI */
/* ========================================================================== */

.storymals-form-group {
    margin-bottom: 15px;
}

.storymals-form-label {
    display: block;
    margin-bottom: 5px;
    font-weight: 600;
    color: #333;
}

.storymals-form-input {
    width: 100%;
    padding: 10px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 14px;
    box-sizing: border-box;
}

.storymals-form-input:focus {
    outline: none;
    border-color: #7c3aed;
    box-shadow: 0 0 0 2px rgba(124, 58, 237, 0.1);
}

.storymals-btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.storymals-btn-primary {
    background: #7c3aed;
    color: white;
}

.storymals-btn-primary:hover {
    background: #6d28d9;
}

.storymals-btn-secondary {
    background: transparent;
    color: #666;
    border: 1px solid #ddd;
}

.storymals-btn-secondary:hover {
    background: #f5f5f5;
}

.storymals-btn-sm {
    padding: 8px 16px;
    font-size: 12px;
}

.storymals-btn-lg {
    padding: 12px 24px;
    font-size: 16px;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA ESTADOS Y MENSAJES */
/* ========================================================================== */

.storymals-alert {
    padding: 12px 16px;
    border-radius: 6px;
    margin-bottom: 15px;
    font-size: 14px;
}

.storymals-alert-success {
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    color: #166534;
}

.storymals-alert-error {
    background: #fef2f2;
    border: 1px solid #fecaca;
    color: #dc2626;
}

.storymals-alert-warning {
    background: #fffbeb;
    border: 1px solid #fed7aa;
    color: #ea580c;
}

.storymals-alert-info {
    background: #f0f9ff;
    border: 1px solid #bae6fd;
    color: #0369a1;
}

/* ========================================================================== */
/* 🎯 UTILIDADES */
/* ========================================================================== */

.storymals-text-center {
    text-align: center;
}

.storymals-text-left {
    text-align: left;
}

.storymals-text-right {
    text-align: right;
}

.storymals-mt-1 { margin-top: 0.25rem !important; }
.storymals-mt-2 { margin-top: 0.5rem !important; }
.storymals-mt-3 { margin-top: 1rem !important; }
.storymals-mt-4 { margin-top: 1.5rem !important; }
.storymals-mt-5 { margin-top: 2rem !important; }

.storymals-mb-1 { margin-bottom: 0.25rem !important; }
.storymals-mb-2 { margin-bottom: 0.5rem !important; }
.storymals-mb-3 { margin-bottom: 1rem !important; }
.storymals-mb-4 { margin-bottom: 1.5rem !important; }
.storymals-mb-5 { margin-bottom: 2rem !important; }

.storymals-hidden {
    display: none !important;
}

.storymals-visible {
    display: block !important;
}

.storymals-flex {
    display: flex !important;
}

.storymals-items-center {
    align-items: center !important;
}

.storymals-justify-between {
    justify-content: space-between !important;
}

.storymals-justify-center {
    justify-content: center !important;
}

/* ========================================================================== */
/* 🎯 RESPONSIVE ADICIONAL */
/* ========================================================================== */

@media (max-width: 480px) {
    .storymals-pwa-banner,
    .storymals-pwa-notification,
    #storymals-pwa-banner {
        padding: 12px;
    }
    
    .storymals-banner-content,
    .storymals-notification-content {
        gap: 12px;
    }
    
    .storymals-install-btn,
    .storymals-dismiss-btn {
        padding: 8px 16px;
        font-size: 13px;
    }
    
    .storymals-download-btn {
        padding: 10px 18px;
        font-size: 13px;
    }
}

@media (max-width: 320px) {
    .storymals-pwa-banner,
    .storymals-pwa-notification,
    #storymals-pwa-banner {
        padding: 10px;
    }
    
    .storymals-banner-text h4 {
        font-size: 14px;
    }
    
    .storymals-banner-text p {
        font-size: 12px;
    }
    
    .storymals-install-btn,
    .storymals-dismiss-btn {
        padding: 6px 12px;
        font-size: 12px;
    }
}

/* ========================================================================== */
/* 🎯 ANIMACIONES ADICIONALES */
/* ========================================================================== */

@keyframes storymalsFadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

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

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

.storymals-fade-in {
    animation: storymalsFadeIn 0.3s ease-out;
}

.storymals-slide-in-left {
    animation: storymalsSlideInLeft 0.3s ease-out;
}

.storymals-slide-in-right {
    animation: storymalsSlideInRight 0.3s ease-out;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA LOADING Y ESTADOS DE CARGA */
/* ========================================================================== */

.storymals-loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 2px solid #f3f3f3;
    border-top: 2px solid #7c3aed;
    border-radius: 50%;
    animation: storymalsSpin 1s linear infinite;
}

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

.storymals-loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 2147483647;
}

.storymals-loading-spinner {
    width: 40px;
    height: 40px;
    border: 4px solid #f3f3f3;
    border-top: 4px solid #7c3aed;
    border-radius: 50%;
    animation: storymalsSpin 1s linear infinite;
}

/* ========================================================================== */
/* 🎯 ESTILOS PARA ACCESIBILIDAD */
/* ========================================================================== */

@media (prefers-reduced-motion: reduce) {
    .storymals-pwa-banner,
    .storymals-pwa-notification,
    #storymals-pwa-banner {
        animation: none;
    }
    
    .storymals-loading {
        animation: none;
    }
}

/* Alto contraste */
@media (prefers-contrast: high) {
    .storymals-pwa-banner {
        border: 2px solid #000;
    }
    
    .storymals-pwa-notification {
        border: 2px solid #fff;
    }
    
    .storymals-install-btn {
        border: 2px solid #000;
    }
}

/* Modo oscuro */
@media (prefers-color-scheme: dark) {
    .storymals-pwa-banner {
        background: #1a1a1a;
        color: #ffffff;
        border-top: 1px solid #333;
    }
    
    .storymals-banner-text h4 {
        color: #ffffff;
    }
    
    .storymals-banner-text p {
        color: #cccccc;
    }
    
    .storymals-dismiss-btn {
        background: transparent;
        color: #cccccc;
        border: 1px solid #555;
    }
    
    .storymals-dismiss-btn:hover {
        background: #333;
    }
}

/* ========================================================================== */
/* 🎯 ESTILOS MEJORADOS PARA ADMINISTRACIÓN DE USUARIOS */
/* ========================================================================== */

.storymals-admin-container {
    max-width: 100%;
    margin: 20px 0;
}

.storymals-user-search {
    background: #fff;
    padding: 20px;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    margin-bottom: 20px;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.storymals-user-results {
    background: #fff;
    border: 1px solid #ccd0d4;
    border-radius: 4px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.wp-list-table input[type="text"],
.wp-list-table input[type="email"],
.wp-list-table select {
    width: 100%;
    max-width: 200px;
    padding: 6px 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 13px;
}

.wp-list-table input:focus,
.wp-list-table select:focus {
    border-color: #007cba;
    box-shadow: 0 0 0 1px #007cba;
    outline: none;
}

.button-link-delete {
    color: #d63638;
    border-color: #d63638;
    background: transparent;
}

.button-link-delete:hover {
    background: #d63638;
    color: white;
}

.storymals-saving {
    background-color: #fff8e5 !important;
    transition: background-color 0.3s ease;
}

.storymals-saved {
    background-color: #f0f9f0 !important;
    transition: background-color 0.3s ease;
}

/* Estilos para la tabla responsive */
@media (max-width: 1200px) {
    .storymals-admin-container {
        overflow-x: auto;
    }
    
    .wp-list-table {
        min-width: 1000px;
    }
}

/* Estilos para el formulario de creación */
.storymals-create-form table {
    width: 100%;
    border-collapse: collapse;
}

.storymals-create-form th {
    text-align: left;
    padding: 10px;
    background: #f9f9f9;
}

.storymals-create-form td {
    padding: 10px;
}

.storymals-create-form input[type="text"],
.storymals-create-form input[type="email"],
.storymals-create-form select {
    width: 100%;
    padding: 8px;
    border: 1px solid #ddd;
    border-radius: 4px;
}