/* ========================================
   ASTROMAMBO - STYLES PARTE 2
   Responsive, Modales, Animaciones
   V3.8 - Optimizado y Coherente
   ======================================== */

/* ============================================
   MODALES
   ============================================ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.7);
    z-index: 9999;
    align-items: center;
    justify-content: center;
}

.modal.show {
    display: flex !important;
}

.modal-content {
    background: white;
    border-radius: 16px;
    padding: 0;
    max-width: 90%;
    max-height: 90vh;
    overflow-y: auto;
    box-shadow: 0 10px 40px rgba(0,0,0,0.3);
    animation: modalSlideIn 0.3s ease;
}

@keyframes modalSlideIn {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

.modal-small { max-width: 500px; }
.modal-large { max-width: 900px; }

.modal-header {
    padding: 20px 30px;
    border-bottom: 1px solid #e5e7eb;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.modal-header h2 {
    margin: 0;
    color: #0a192f;
    font-size: 1.5em;
}

.modal-close {
    background: none;
    border: none;
    font-size: 2em;
    color: #999;
    cursor: pointer;
    padding: 0;
    line-height: 1;
    transition: color 0.2s;
}

.modal-close:hover { color: #333; }

.modal-body { padding: 30px; }

.modal-actions {
    display: flex;
    gap: 10px;
    margin-top: 20px;
}

.modal-actions button { flex: 1; }

/* ============================================
   MODAL MANDALA 3D
   ============================================ */
.modal3d-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.9);
    z-index: 9999;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
}

.modal3d-content {
    position: relative;
    width: 100%;
    max-width: 900px;
    height: 80vh;
    max-height: 700px;
    background: #0a0a15;
    border-radius: 16px;
    overflow: hidden;
}

.modal3d-close {
    position: absolute;
    top: 10px;
    right: 10px;
    width: 36px;
    height: 36px;
    background: rgba(255, 255, 255, 0.1);
    border: none;
    border-radius: 50%;
    color: white;
    font-size: 18px;
    cursor: pointer;
    z-index: 10;
    transition: background 0.2s;
}

.modal3d-close:hover { background: rgba(255, 255, 255, 0.2); }

.modal3d-content .chart3d-container {
    width: 100%;
    height: 100%;
}

/* ============================================
   MENÚ DE USUARIO LOGUEADO
   ============================================ */
.menu-user-info {
    padding: 15px 20px;
    border-bottom: 1px solid rgba(255,255,255,0.1);
    background: rgba(255,255,255,0.05);
}

.menu-user-info strong {
    display: block;
    color: #ffffff !important;
    font-size: 1.1em;
    margin-bottom: 5px;
}

.menu-user-role {
    display: inline-block;
    padding: 4px 12px;
    background: rgba(102, 126, 234, 0.3);
    color: #ffffff !important;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
}

.menu-user-role.admin {
    background: rgba(255, 87, 34, 0.3);
    color: #ffb74d !important;
}

.menu-logout { color: #ff6b6b !important; }

/* ============================================
   TABLA USUARIOS
   ============================================ */
#usuariosTable {
    width: 100%;
    border-collapse: collapse;
    margin-top: 15px;
}

#usuariosTable th,
#usuariosTable td {
    padding: 12px;
    text-align: left;
    border-bottom: 1px solid #e0e0e0;
}

#usuariosTable th {
    background: #0a192f;
    color: white;
    font-weight: 600;
    font-size: 0.9em;
    text-transform: uppercase;
}

#usuariosTable tbody tr:hover { background: #f5f5f5; }

#usuariosTable .role-badge {
    display: inline-block;
    padding: 4px 10px;
    border-radius: 12px;
    font-size: 0.85em;
    font-weight: 600;
    text-transform: uppercase;
}

#usuariosTable .role-badge.admin { background: #ff6b35; color: white; }
#usuariosTable .role-badge.user { background: #e0e0e0; color: #666; }
#usuariosTable .loading { text-align: center; padding: 40px; color: #999; }

/* ============================================
   TABLA MIS CARTAS
   ============================================ */
.cartas-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.9em;
}

.cartas-table thead {
    background: linear-gradient(135deg, #0a192f 0%, #1a365d 100%);
    color: white;
}

.cartas-table th {
    padding: 12px 10px;
    text-align: left;
    font-weight: 600;
}

.cartas-table td {
    padding: 12px 10px;
    border-bottom: 1px solid #e5e7eb;
}

.cartas-table tbody tr:hover { background-color: #f0f7ff; }

.cartas-table .sortable {
    user-select: none;
    transition: background 0.2s;
}

.cartas-table .sortable:hover { background: rgba(255,255,255,0.1); }

.btn-small {
    padding: 6px 12px;
    font-size: 0.85em;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-left: 5px;
}

.btn-small.btn-primary {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
}

.btn-small.btn-danger { background: #fee2e2; color: #dc2626; }

/* ============================================
   BOTONES ASISTENTE IA
   ============================================ */
.asistente-container {
    position: fixed;
    bottom: 20px;
    right: 20px;
    display: flex;
    flex-direction: column;
    gap: 10px;
    z-index: 1000;
}

.asistente-container .chatgpt-btn {
    position: relative;
    bottom: auto;
    right: auto;
}

.chatgpt-btn:disabled {
    opacity: 0.4;
    cursor: not-allowed;
    transform: none !important;
    box-shadow: none !important;
    filter: grayscale(70%);
    pointer-events: none;
}

.chatgpt-btn:disabled:hover {
    transform: none !important;
    box-shadow: none !important;
}

/* ============================================
   ANIMACIONES
   ============================================ */
@keyframes fadeIn {
    from { opacity: 0; transform: translateY(10px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes slideInLeft {
    from { opacity: 0; transform: translateX(-20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideInRight {
    from { opacity: 0; transform: translateX(20px); }
    to { opacity: 1; transform: translateX(0); }
}

@keyframes slideUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

.fade-in { animation: fadeIn 0.3s ease-out; }
.slide-in-left { animation: slideInLeft 0.3s ease-out; }
.slide-in-right { animation: slideInRight 0.3s ease-out; }
.slide-up { animation: slideUp 0.3s ease-out; }

/* ============================================
   TABLAS - BASE (DESKTOP)
   ============================================ */
#modalidadesElementosTable,
#aspectsPyramid,
#aspectosTable,
#notaAspectosCercanos,
#planetasTableContainer {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    max-width: 100%;
}

#modalidadesElementosTable table,
#aspectsPyramid table,
#aspectosTable table,
#notaAspectosCercanos table,
#planetasTableContainer table {
    min-width: 100%;
    width: max-content;
}

/* ============================================
   FOOTER - BASE (DESKTOP)
   ============================================ */
footer {
    background: linear-gradient(135deg, #0a192f 0%, #1a365d 100%);
    padding: 14px 20px;
    margin-top: 30px;
    position: relative;
    border-radius: 0;
    box-shadow: none;
    text-align: center;
}

footer::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    height: 2px;
    background: linear-gradient(90deg, transparent, #34A7C1, #667eea, #34A7C1, transparent);
}

footer p {
    margin: 3px 0;
    font-size: 0.78em;
    color: rgba(255, 255, 255, 0.7);
    line-height: 1.3;
}

footer p:first-child {
    font-size: 0.82em;
    font-weight: 600;
    color: #34A7C1;
}

footer strong { color: #ffffff; font-weight: 700; }

footer a {
    color: #34A7C1;
    text-decoration: none;
    font-weight: 600;
}

footer a:hover {
    color: #ffffff;
    text-decoration: underline;
}

.footer-tech {
    font-size: 0.68em;
    opacity: 0.5;
    margin-top: 2px;
}

/* ============================================
   TOP MENU - BASE
   ============================================ */
.top-menu {
    z-index: 9999 !important;
}

#topMenuUser,
#topMenuAdmin,
#topMenuGuest {
    flex-shrink: 0;
}

/* ============================================
   SCROLL & ACCESIBILIDAD
   ============================================ */
html { scroll-behavior: smooth; }

::-webkit-scrollbar { width: 10px; height: 10px; }
::-webkit-scrollbar-track { background: rgba(0, 0, 0, 0.1); }
::-webkit-scrollbar-thumb { background: #34A7C1; border-radius: 5px; }
::-webkit-scrollbar-thumb:hover { background: #2891a8; }

* {
    scrollbar-color: #34A7C1 rgba(0, 0, 0, 0.1);
    scrollbar-width: thin;
}

@media (prefers-reduced-motion: reduce) {
    *, *::before, *::after {
        animation-duration: 0.01ms !important;
        animation-iteration-count: 1 !important;
        transition-duration: 0.01ms !important;
    }
}

*:focus-visible {
    outline: 2px solid #34A7C1;
    outline-offset: 2px;
}

/* ============================================
   RESPONSIVE - TABLETS (max 1024px)
   ============================================ */
@media (max-width: 1024px) {
    .container { max-width: 90%; }
    .grid { grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); }
    .section { padding: 25px; }
}

/* ============================================
   RESPONSIVE - TABLETS/MÓVILES (max 768px)
   ============================================ */
@media (max-width: 768px) {
    /* Layout general */
    .container { max-width: 95%; margin-top: 80px; padding: 15px; }
    .grid { grid-template-columns: 1fr; gap: 12px; }
    .form-row { flex-direction: column; gap: 8px; }
    .section { padding: 20px; margin-bottom: 20px; }
    .section h2 { font-size: 1.5em; }
    .btn { padding: 12px 18px; font-size: 0.95em; }
    .btn-container { flex-direction: column; }
    
    /* Menú */
    .top-menu { padding: 12px 15px; }
    .hamburger-btn { display: flex; }
    .dropdown-menu { top: 60px; right: 10px; min-width: 180px; }
    
    /* Modal 3D */
    .modal3d-content { height: 90vh; max-height: none; border-radius: 12px; }
    .modal3d-overlay { padding: 10px; }
    
    /* ===== PANEL SOL/LUNA/ASC - COMPACTO ESTÉTICO ===== */
    #chartSection > div:first-child {
        flex-direction: column !important;
        align-items: center !important;
        gap: 10px !important;
    }
    
    #highlightPanel {
        gap: 6px !important;
        flex-wrap: nowrap !important;
        justify-content: center !important;
        padding: 0 5px !important;
        width: 100% !important;
    }
    
    #highlightPanel > div {
        padding: 6px 8px !important;
        border-radius: 8px !important;
        gap: 4px !important;
        min-width: 0 !important;
        flex: 1 !important;
        max-width: none !important;
    }
    
    #highlightPanel > div > span:first-child {
        font-size: 1em !important;
    }
    
    #highlightPanel > div > div > div:first-child {
        font-size: 0.5em !important;
        letter-spacing: 0.3px !important;
        white-space: nowrap !important;
    }
    
    #highlightPanel > div > div > div:last-child {
        font-size: 0.6em !important;
        line-height: 1.1 !important;
        white-space: nowrap !important;
    }
    
    /* ===== TABLA BALANCE ===== */
    #modalidadesElementosTable {
        overflow-x: visible !important;
    }
    
    #modalidadesElementosTable table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
        font-size: 0.8em !important;
        table-layout: fixed !important;
    }
    
    #modalidadesElementosTable table td,
    #modalidadesElementosTable table th {
        padding: 6px 4px !important;
        min-width: unset !important;
        width: auto !important;
    }
    
    #modalidadesElementosTable table td:first-child { width: 40px !important; }
    #modalidadesElementosTable table td:last-child,
    #modalidadesElementosTable table th:last-child { width: 35px !important; }
    
    /* ===== PIRÁMIDE ===== */
    #aspectsPyramid {
        overflow-x: auto !important;
        -webkit-overflow-scrolling: touch;
    }
    
    #aspectsPyramid table { min-width: 340px !important; }
    
    #aspectsPyramid td.piramide-celda {
        width: 34px !important;
        height: 34px !important;
        min-width: 34px !important;
        min-height: 34px !important;
        max-width: 34px !important;
        max-height: 34px !important;
        padding: 1px !important;
    }
    
    #aspectsPyramid td.piramide-celda div:first-child { font-size: 1.1em !important; }
    #aspectsPyramid td.piramide-celda div:last-child { font-size: 0.6em !important; }
    
    #aspectsPyramid td:last-child {
        font-size: 0.9em !important;
        padding: 2px !important;
        width: 28px !important;
    }
    
    #aspectsPyramid::after {
        content: '\2190 Desliza \2192';
        display: block;
        text-align: center;
        font-size: 0.7em;
        color: #667eea;
        padding: 6px 0;
        font-weight: 600;
    }
    
    /* ===== TABLA ASPECTOS ===== */
    #aspectosTable { overflow-x: visible !important; }
    
    #aspectosTable table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
        font-size: 0.75em !important;
        table-layout: fixed !important;
    }
    
    #aspectosTable table td,
    #aspectosTable table th { padding: 8px 4px !important; }
    
    #aspectosTable table td:nth-child(1) { width: 40% !important; }
    #aspectosTable table td:nth-child(2) { width: 20% !important; font-size: 1.5em !important; }
    #aspectosTable table td:nth-child(3),
    #aspectosTable table td:nth-child(4) { width: 20% !important; }
    
    /* ===== ASPECTOS CERCANOS ===== */
    #notaAspectosCercanos { overflow-x: visible !important; }
    
    #notaAspectosCercanos > div {
        padding: 10px !important;
        border-width: 2px !important;
    }
    
    #notaAspectosCercanos h3 { font-size: 0.9em !important; margin-bottom: 6px !important; }
    #notaAspectosCercanos p { font-size: 0.75em !important; margin: 4px 0 !important; }
    
    #notaAspectosCercanos table {
        width: 100% !important;
        max-width: 100% !important;
        min-width: unset !important;
        font-size: 0.7em !important;
        table-layout: fixed !important;
    }
    
    #notaAspectosCercanos table td,
    #notaAspectosCercanos table th { padding: 6px 4px !important; }
    
    #notaAspectosCercanos table td:nth-child(1) { width: 55% !important; }
    #notaAspectosCercanos table td:nth-child(2) { width: 20% !important; font-size: 1.4em !important; }
    #notaAspectosCercanos table td:nth-child(3) { width: 25% !important; }
    
    /* ===== TABLA PLANETAS ===== */
    #planetasTableContainer { overflow-x: auto !important; }
    
    #planetasTableContainer table {
        font-size: 0.8em !important;
        min-width: 500px !important;
    }
    
    #planetasTableContainer table td,
    #planetasTableContainer table th { padding: 5px 3px !important; }
    
    #planetasTableContainer::after {
        content: '\2190 Desliza \2192';
        display: block;
        text-align: center;
        font-size: 0.7em;
        color: #667eea;
        padding: 6px 0;
        font-weight: 600;
    }
    
    /* Footer */
    footer { padding: 10px 15px; margin-top: 20px; }
    footer p { font-size: 0.7em; margin: 2px 0; }
    footer p:first-child { font-size: 0.75em; }
}

/* ============================================
   RESPONSIVE - MÓVILES (max 480px)
   ============================================ */
@media (max-width: 480px) {
    /* Layout */
    .container { margin-top: 80px; padding: 8px; }
    .section { padding: 10px; margin-bottom: 12px; }
    .section h2 { font-size: 1.2em; }
    .btn { padding: 10px 15px; font-size: 0.9em; width: 100%; }
    
    /* Menú compacto */
    .top-menu { padding: 10px 12px; }
    .hamburger-btn span { width: 20px; height: 2px; }
    .hamburger-btn { padding: 6px !important; min-width: 40px; }
    .dropdown-menu { top: 55px; right: 5px; min-width: 160px; }
    .menu-item { padding: 10px 14px; font-size: 0.9em; }
    
    /* Ocultar nombre usuario */
    #userNameDisplay,
    #adminNameDisplay { display: none !important; }
    
    #userInfoDisplay,
    #adminInfoDisplay { gap: 0 !important; }
    
    #topMenuUser,
    #topMenuAdmin { gap: 8px !important; }
    
    .logout-btn {
        width: 36px !important;
        height: 36px !important;
        font-size: 1.1em !important;
        padding: 0 !important;
    }
    
    .menu-logo span { display: none; }
    .menu-logo img { height: 28px !important; }
    
    /* ===== PANEL SOL/LUNA/ASC - MÓVIL ESTÉTICO ===== */
    #chartSection > div:first-child {
        gap: 8px !important;
    }
    
    #highlightPanel {
        gap: 4px !important;
        padding: 0 3px !important;
    }
    
    #highlightPanel > div {
        padding: 5px 6px !important;
        border-radius: 6px !important;
        gap: 3px !important;
    }
    
    #highlightPanel > div > span:first-child {
        font-size: 0.85em !important;
    }
    
    #highlightPanel > div > div > div:first-child {
        font-size: 0.45em !important;
    }
    
    #highlightPanel > div > div > div:last-child {
        font-size: 0.52em !important;
    }
    
    /* ===== PIRÁMIDE ULTRA COMPACTA ===== */
    #aspectsPyramid table { min-width: 280px !important; }
    #aspectsPyramid td.piramide-celda {
        width: 24px !important;
        height: 24px !important;
        min-width: 24px !important;
        min-height: 24px !important;
        max-width: 24px !important;
        max-height: 24px !important;
    }
    
    #aspectsPyramid td.piramide-celda div:first-child { font-size: 0.9em !important; }
    #aspectsPyramid td.piramide-celda div:last-child { font-size: 0.5em !important; }
    
    #aspectsPyramid td:last-child {
        font-size: 0.75em !important;
        padding: 1px !important;
        width: 22px !important;
    }
    
    /* ===== ASPECTOS ULTRA COMPACTO ===== */
    #aspectosTable table { font-size: 0.68em !important; }
    #aspectosTable table td,
    #aspectosTable table th { padding: 6px 3px !important; }
    
    /* ===== CERCANOS ULTRA COMPACTO ===== */
    #notaAspectosCercanos > div { padding: 8px !important; }
    #notaAspectosCercanos h3 { font-size: 0.8em !important; }
    #notaAspectosCercanos table { font-size: 0.65em !important; }
    #notaAspectosCercanos table td,
    #notaAspectosCercanos table th { padding: 5px 3px !important; }
    
    /* Footer */
    footer { padding: 8px 12px; margin-top: 15px; }
    footer p { font-size: 0.65em; }
    .footer-tech { display: none; }
}

/* ============================================
   RESPONSIVE - MÓVILES MUY PEQUEÑOS (max 400px)
   ============================================ */
@media (max-width: 400px) {
    .top-menu { padding: 8px 10px !important; gap: 8px !important; }
    .menu-logo img { height: 24px !important; }
}

/* ============================================
   IMPRESIÓN
   ============================================ */
@media print {
    body { background: white; }
    .header, footer, .top-menu, .chatgpt-btn, .btn-container, .asistente-container { display: none; }
    .container { margin-top: 0; padding: 0; }
    .card, .section { page-break-inside: avoid; box-shadow: none; border: 1px solid #999; background: white; }
    
    .print-balance-table {
        font-size: 9px !important;
        width: auto !important;
        min-width: 150px !important;
    }
    
    .print-balance-table td,
    .print-balance-table th { padding: 3px 6px !important; }
    
    .print-pyramid td {
        width: 45px !important;
        height: 45px !important;
        padding: 4px !important;
        font-size: 0.75em !important;
    }
    
    .print-pyramid td div { font-size: 1.2em !important; }
}