/* ================================
   SISTEMA DE INSTRUCCIONES - KLINAFY
   ================================ */

/* Modal Overlay */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    opacity: 0;
    transition: all 0.3s ease;
}

.modal-overlay.modal-show {
    opacity: 1;
}

/* Container del Modal */
.modal-container {
    background: var(--card-bg, #ffffff);
    border-radius: 20px;
    box-shadow: 0 25px 50px rgba(0, 0, 0, 0.25);
    width: 90%;
    max-width: 900px;
    max-height: 90vh;
    overflow: hidden;
    transform: scale(0.8) translateY(50px);
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

.modal-overlay.modal-show .modal-container {
    transform: scale(1) translateY(0);
}

/* Header del Modal */
.modal-header {
    background: linear-gradient(135deg, #3a5a8a 0%, #1b2d51 100%);
    color: white;
    padding: 25px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.modal-header h2 {
    margin: 0;
    font-size: 1.5rem;
    font-weight: 600;
    display: flex;
    align-items: center;
    gap: 12px;
}

.modal-close {
    background: rgba(255, 255, 255, 0.2);
    border: none;
    color: white;
    font-size: 1.5rem;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s ease;
}

.modal-close:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: rotate(90deg);
}

/* Body del Modal */
.modal-body {
    display: flex;
    height: 500px;
}

/* Navegación de Instrucciones */
.instrucciones-nav {
    width: 250px;
    background: var(--sidebar-bg, #f8fafc);
    border-right: 1px solid var(--border-color, #e5e7eb);
    padding: 0;
    display: flex;
    flex-direction: column;
}

.instruccion-tab {
    background: none;
    border: none;
    padding: 18px 25px;
    text-align: left;
    cursor: pointer;
    transition: all 0.3s ease;
    border-bottom: 1px solid var(--border-color, #e5e7eb);
    color: var(--text-color, #374151);
    font-size: 0.95rem;
    font-weight: 500;
    display: flex;
    align-items: center;
    gap: 12px;
    position: relative;
}

.instruccion-tab:hover {
    background: var(--hover-bg, #f1f5f9);
    color: #3a5a8a;
    transform: translateX(5px);
}

.instruccion-tab.active {
    background: linear-gradient(135deg, #3a5a8a 0%, #1b2d51 100%);
    color: white;
    font-weight: 600;
}

.instruccion-tab.active::after {
    content: '';
    position: absolute;
    right: 0;
    top: 0;
    bottom: 0;
    width: 4px;
    background: #fbbf24;
}

.instruccion-tab i {
    font-size: 1.1rem;
    width: 20px;
}

/* Contenido de Instrucciones */
.instrucciones-content {
    flex: 1;
    padding: 0;
    position: relative;
    overflow: hidden;
}

.instruccion-panel {
    display: none;
    padding: 30px;
    height: 100%;
    overflow-y: auto;
    animation: fadeInUp 0.3s ease;
}

.instruccion-panel.active {
    display: block;
}

@keyframes fadeInUp {
    from {
        opacity: 0;
        transform: translateY(20px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.instruccion-panel h3 {
    color: var(--primary-color, #3a5a8a);
    font-size: 1.4rem;
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 600;
}

.instruccion-panel h4 {
    color: var(--text-color, #374151);
    font-size: 1.1rem;
    margin: 25px 0 15px 0;
    font-weight: 600;
}

.instruccion-panel p, 
.instruccion-panel li {
    color: var(--text-color-light, #6b7280);
    line-height: 1.6;
    margin-bottom: 12px;
}

.instruccion-panel ul, 
.instruccion-panel ol {
    padding-left: 20px;
}

.instruccion-panel li {
    margin-bottom: 10px;
}

/* Elementos especiales */
.instruccion-tip {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    color: white;
    padding: 20px;
    border-radius: 12px;
    margin: 25px 0;
    display: flex;
    align-items: flex-start;
    gap: 15px;
    font-weight: 500;
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.3);
}

.instruccion-ejemplo {
    background: var(--success-bg, #ecfdf5);
    border: 2px solid var(--success-border, #10b981);
    border-left: 5px solid var(--success-border, #10b981);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    color: var(--success-text, #065f46);
    font-style: italic;
}

.instruccion-warning {
    background: var(--warning-bg, #fef3c7);
    border: 2px solid var(--warning-border, #f59e0b);
    border-left: 5px solid var(--warning-border, #f59e0b);
    padding: 20px;
    border-radius: 8px;
    margin: 20px 0;
    color: var(--warning-text, #92400e);
    display: flex;
    align-items: flex-start;
    gap: 15px;
}

/* Footer del Modal */
.modal-footer {
    background: var(--card-bg, #ffffff);
    border-top: 1px solid var(--border-color, #e5e7eb);
    padding: 20px 30px;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 8px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    font-size: 0.95rem;
}

.btn-secondary {
    background: var(--gray-100, #f3f4f6);
    color: var(--gray-700, #374151);
    border: 2px solid var(--gray-300, #d1d5db);
}

.btn-secondary:hover {
    background: var(--gray-200, #e5e7eb);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.btn-primary {
    background: linear-gradient(135deg, #3a5a8a 0%, #1b2d51 100%);
    color: white;
    border: 2px solid transparent;
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.5);
}

/* ================================
   BOTONES MEJORADOS - HEADER
   ================================ */

/* Container para los botones del header */
.header-buttons {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-left: auto;
}

/* Botón base mejorado */
.header-btn {
    position: relative;
    width: 50px;
    height: 50px;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    overflow: hidden;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.header-btn::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    border-radius: 50%;
    background: linear-gradient(45deg, transparent, rgba(255, 255, 255, 0.3));
    opacity: 0;
    transition: opacity 0.3s ease;
}

.header-btn:hover::before {
    opacity: 1;
}

.header-btn:hover {
    transform: translateY(-3px) scale(1.05);
}

.header-btn:active {
    transform: translateY(-1px) scale(0.98);
}

/* Botón Modo Nocturno */
.night-mode-btn {
    background: linear-gradient(135deg, #4c1d95 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(76, 29, 149, 0.4);
}

.night-mode-btn:hover {
    box-shadow: 0 8px 30px rgba(76, 29, 149, 0.6);
}

.night-mode-btn.active {
    background: linear-gradient(135deg, #fbbf24 0%, #f59e0b 100%);
    box-shadow: 0 4px 20px rgba(251, 191, 36, 0.4);
}

.night-mode-btn.active:hover {
    box-shadow: 0 8px 30px rgba(251, 191, 36, 0.6);
}

/* Botón Chat AI */
.ai-chat-btn {
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    animation: pulse-glow 3s infinite;
}

.ai-chat-btn:hover {
    box-shadow: 0 8px 30px rgba(16, 185, 129, 0.6);
    animation: none;
}

@keyframes pulse-glow {
    0%, 100% {
        box-shadow: 0 4px 20px rgba(16, 185, 129, 0.4);
    }
    50% {
        box-shadow: 0 4px 30px rgba(16, 185, 129, 0.7);
    }
}

/* Botón Instrucciones */
.help-btn {
    background: linear-gradient(135deg, #3a5a8a 0%, #1b2d51 100%);
    color: white;
    box-shadow: 0 4px 20px rgba(102, 126, 234, 0.4);
}

.help-btn:hover {
    box-shadow: 0 8px 30px rgba(102, 126, 234, 0.6);
}

/* Tooltip para botones */
.header-btn[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: -45px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.9);
    color: white;
    padding: 8px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 500;
    white-space: nowrap;
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.header-btn[data-tooltip]::before {
    content: '';
    position: absolute;
    bottom: -25px;
    left: 50%;
    transform: translateX(-50%);
    border: 6px solid transparent;
    border-bottom-color: rgba(0, 0, 0, 0.9);
    opacity: 0;
    visibility: hidden;
    transition: all 0.3s ease;
    z-index: 1000;
}

.header-btn[data-tooltip]:hover::after,
.header-btn[data-tooltip]:hover::before {
    opacity: 1;
    visibility: visible;
}

/* ================================
   RESPONSIVE DESIGN
   ================================ */

@media (max-width: 768px) {
    .modal-container {
        width: 95%;
        max-height: 95vh;
    }
    
    .modal-body {
        flex-direction: column;
        height: auto;
        max-height: 60vh;
    }
    
    .instrucciones-nav {
        width: 100%;
        flex-direction: row;
        overflow-x: auto;
        border-right: none;
        border-bottom: 1px solid var(--border-color, #e5e7eb);
    }
    
    .instruccion-tab {
        white-space: nowrap;
        padding: 15px 20px;
        border-bottom: none;
        border-right: 1px solid var(--border-color, #e5e7eb);
    }
    
    .instruccion-panel {
        padding: 20px;
    }
    
    .header-buttons {
        gap: 10px;
    }
    
    .header-btn {
        width: 45px;
        height: 45px;
        font-size: 1.1rem;
    }
    
    .modal-footer {
        flex-direction: column;
        gap: 15px;
    }
    
    .modal-footer .btn {
        width: 100%;
        justify-content: center;
    }
}

@media (max-width: 480px) {
    .modal-header {
        padding: 20px;
    }
    
    .modal-header h2 {
        font-size: 1.2rem;
    }
    
    .instruccion-panel {
        padding: 15px;
    }
    
    .header-btn {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ================================
   TEMA OSCURO
   ================================ */

[data-theme="dark"] {
    --card-bg: #1f2937;
    --sidebar-bg: #111827;
    --border-color: #374151;
    --text-color: #f9fafb;
    --text-color-light: #d1d5db;
    --hover-bg: #374151;
    --success-bg: #064e3b;
    --success-border: #10b981;
    --success-text: #a7f3d0;
    --warning-bg: #451a03;
    --warning-border: #f59e0b;
    --warning-text: #fed7aa;
    --gray-100: #374151;
    --gray-200: #4b5563;
    --gray-300: #6b7280;
    --gray-700: #f9fafb;
}

[data-theme="dark"] .modal-overlay {
    background: rgba(0, 0, 0, 0.9);
}

[data-theme="dark"] .instruccion-tip {
    box-shadow: 0 8px 25px rgba(251, 191, 36, 0.2);
}

[data-theme="dark"] .btn-primary {
    box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
}

[data-theme="dark"] .btn-primary:hover {
    box-shadow: 0 8px 25px rgba(102, 126, 234, 0.4);
}
