/* --- VARIABLES & TEMA MODERNO --- */
:root {
    /* Paleta de Colores 2026 */
    --primary: #4f46e5;       /* Índigo */
    --primary-hover: #4338ca;
    --secondary: #0ea5e9;     /* Cian */
    --success: #10b981;       /* Verde */
    --danger: #ef4444;        /* Rojo */
    
    /* Fondos */
    --bg-body: #f8fafc;
    --bg-card: #ffffff;
    --bg-input: #fcfdff;
    
    /* Textos y Bordes */
    --text-main: #1e293b;
    --text-muted: #64748b;
    --border-color: #e2e8f0;
    
    /* Sombras y Radios */
    --shadow-md: 0 4px 6px -1px rgba(0,0,0,0.1), 0 2px 4px -1px rgba(0,0,0,0.06);
    --radius-lg: 16px;
    --radius-md: 10px;
    --radius-pill: 999px;
    
    --font-family: 'Inter', system-ui, -apple-system, sans-serif;
}

/* --- RESET BÁSICO --- */
*, *::before, *::after { box-sizing: border-box; }
body {
    margin: 0; background: var(--bg-body); color: var(--text-main);
    font-family: var(--font-family); line-height: 1.5;
    -webkit-font-smoothing: antialiased;
}
h1, h2, h3, p { margin: 0; }

/* --- NAVBAR --- */
.navbar {
    background: var(--bg-card);
    border-bottom: 1px solid var(--border-color);
    padding: 16px 0;
    position: sticky; top: 0; z-index: 100;
    box-shadow: 0 1px 2px rgba(0,0,0,0.05);
}
.nav-container {
    max-width: 1280px; margin: 0 auto; padding: 0 24px;
    display: flex; justify-content: space-between; align-items: center;
}
.nav-left { display: flex; align-items: center; gap: 16px; }
.logo { height: 36px; width: auto; }
.app-title { font-weight: 800; font-size: 1.25rem; letter-spacing: -0.5px; }
.badge {
    background: var(--primary); color: white;
    padding: 4px 12px; border-radius: var(--radius-pill);
    font-size: 0.8rem; font-weight: 600;
}

/* --- LAYOUT PRINCIPAL --- */
.container.main-content { max-width: 1280px; margin: 40px auto; padding: 0 24px; }
.grid-layout {
    display: grid; grid-template-columns: 380px 1fr;
    gap: 32px; align-items: start;
}
@media (max-width: 1024px) { .grid-layout { grid-template-columns: 1fr; } }

/* --- TARJETAS (CARDS) --- */
.card {
    background: var(--bg-card); border-radius: var(--radius-lg);
    padding: 28px; box-shadow: var(--shadow-md);
    border: 1px solid rgba(255,255,255,0.5);
    margin-bottom: 32px;
}
/* Tarjeta Destacada (Paso 1) */
.card-featured {
    background: linear-gradient(145deg, #ffffff, #f8faff);
    border: 1px solid var(--primary);
}
.card-header { display: flex; align-items: center; gap: 12px; margin-bottom: 20px; }
.card-header.no-border { justify-content: space-between; margin-bottom: 16px; }
.step-number {
    background: var(--text-main); color: white; width: 28px; height: 28px;
    display: flex; align-items: center; justify-content: center;
    border-radius: 50%; font-weight: 700; font-size: 0.9rem;
}
.card-featured .step-number { background: var(--primary); }
.card-title { font-size: 1.2rem; font-weight: 700; }
.muted-text { color: var(--text-muted); font-size: 0.95rem; }

/* --- FORMULARIOS E INPUTS --- */
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 16px; }
.field { margin-bottom: 0; }
.field-label {
    display: block; font-size: 0.85rem; margin-bottom: 8px; font-weight: 600;
}
.modern-input, .select-wrapper select {
    width: 100%; padding: 12px 16px;
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
    background: var(--bg-input); font-size: 0.95rem; outline: none;
    font-family: var(--font-family); transition: all 0.2s;
}
.modern-input:focus, .select-wrapper select:focus {
    border-color: var(--primary);
    box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1);
    background: #fff;
}
/* Flecha custom para select */
.select-wrapper { position: relative; }
.select-wrapper::after {
    content: '▼'; font-size: 0.8rem; color: var(--text-muted);
    position: absolute; right: 16px; top: 50%; transform: translateY(-50%);
    pointer-events: none;
}
.select-wrapper select { appearance: none; padding-right: 32px; }

/* --- ANIMACIONES UPLOAD (LATIDO Y REBOTE) --- */
@keyframes pulseGlow {
  0% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0.4);
    border-color: var(--primary);
  }
  70% {
    box-shadow: 0 0 0 15px rgba(79, 70, 229, 0);
    border-color: var(--secondary);
  }
  100% {
    box-shadow: 0 0 0 0 rgba(79, 70, 229, 0);
    border-color: var(--primary);
  }
}
@keyframes bounceHappy {
  0%, 100% { transform: translateY(0) scale(1.1); }
  50% { transform: translateY(-10px) scale(1.2); }
}

/* --- UPLOAD AREA --- */
.modern-upload {
    border: 2px dashed var(--border-color);
    border-radius: var(--radius-lg);
    padding: 30px 20px;
    text-align: center;
    cursor: pointer;
    background: #fdfcff;
    display: block;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}
.modern-upload:hover {
    border-color: var(--primary); background: #f5f7ff; transform: translateY(-2px);
}
.modern-upload input { display: none; }
.upload-icon {
    font-size: 2.5rem; margin-bottom: 10px; transition: .3s;
}
.modern-upload:hover .upload-icon { transform: scale(1.1); }

/* Texto de subida */
.upload-text strong {
    display: block;
    color: var(--primary);
    font-size: 1.1rem;
}
.upload-text span {
    font-size: 0.75rem; 
    color: var(--text-muted);
    display: block; 
    margin-top: 4px;
}

/* Estado Activo al Arrastrar (Drag & Drop) */
.modern-upload.drag-active {
    background: #eef2ff;
    animation: pulseGlow 1.5s infinite;
}
.modern-upload.drag-active .upload-icon {
    animation: bounceHappy 0.6s infinite;
    color: var(--primary);
    filter: none;
}
.modern-upload.drag-active .upload-text strong {
    color: var(--primary); font-weight: 800;
}

.status-pill {
    text-align: center; margin-top: 12px; display: inline-block; width: 100%;
    background: var(--bg-body); padding: 8px; border-radius: var(--radius-pill);
    font-size: 0.85rem; font-weight: 600; color: var(--text-muted);
}

/* --- PANEL DE PRECIOS & EDICIÓN --- */
.info-panel {
    background: var(--bg-body); border-radius: var(--radius-md);
    padding: 16px; display: flex; gap: 16px; margin-top: 24px;
    border: 1px solid var(--border-color);
}
.info-item { flex: 1; }
.info-item label {
    display: block; font-size: 0.75rem; text-transform: uppercase;
    letter-spacing: 1px; color: var(--text-muted); margin-bottom: 6px;
}
.input-display {
    width: 100%; border: none; background: transparent;
    font-size: 1.2rem; font-weight: 500; padding: 0;
    font-family: var(--font-family);
}
.input-display.money { font-weight: 800; color: var(--primary); font-size: 1.4rem; }

/* Resaltado para campos editables */
.editable-highlight {
    border-bottom: 2px dashed #cbd5e1;
    transition: border-color 0.2s;
}
.editable-highlight:focus {
    border-bottom: 2px solid var(--primary);
    outline: none; background: rgba(79, 70, 229, 0.05);
}

/* Separador */
.divider-modern {
    text-align: center; margin: 24px 0; position: relative;
}
.divider-modern::before {
    content: ''; position: absolute; top: 50%; left: 0; right: 0;
    border-top: 1px solid var(--border-color);
}
.divider-modern span {
    background: var(--bg-card); padding: 0 12px; position: relative;
    font-size: 0.8rem; text-transform: uppercase; letter-spacing: 1px;
    color: var(--text-muted); font-weight: 600;
}

/* --- BOTONES --- */
.btn {
    border: none; padding: 14px 24px; border-radius: var(--radius-md);
    font-weight: 700; cursor: pointer; display: inline-flex;
    align-items: center; justify-content: center; gap: 8px;
    transition: all 0.2s; font-family: var(--font-family);
}
.btn:hover:not(:disabled) { transform: translateY(-1px); }
.btn:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-primary { background: var(--primary); color: white; }
.btn-success { background: var(--success); color: white; }
.btn-text { background: transparent; color: var(--text-main); }
.warn-text { color: var(--danger); }
.btn-block { width: 100%; } .btn-lg { padding: 16px; font-size: 1.1rem; }
.btn-pill { border-radius: var(--radius-pill); }

/* --- TABLA --- */
.toolbar-modern { margin-bottom: 16px; }
.search-bar {
    background: var(--bg-body); border-radius: var(--radius-pill);
    border: 1px solid var(--border-color); padding: 4px 16px;
    display: flex; align-items: center;
}
.search-bar input {
    border: none; background: transparent; padding: 8px 0;
    width: 100%; outline: none; font-family: var(--font-family);
}
.counter-pill {
    background: var(--text-main); color: white; padding: 4px 12px;
    border-radius: var(--radius-pill); font-size: 0.75rem;
}
.table-wrap {
    max-height: 350px; overflow-y: auto;
    border: 1px solid var(--border-color); border-radius: var(--radius-md);
}
.modern-scroll::-webkit-scrollbar { width: 6px; }
.modern-scroll::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 10px; }

.tbl-modern { width: 100%; border-collapse: separate; border-spacing: 0; }
.tbl-modern th {
    text-align: left; padding: 16px; position: sticky; top: 0;
    background: #f1f5f9; font-size: 0.75rem; text-transform: uppercase;
    color: var(--text-muted); border-bottom: 2px solid var(--border-color);
}
.tbl-modern td {
    padding: 16px; border-bottom: 1px solid var(--border-color);
    background: #fff;
}
.table-actions {
    display: flex; justify-content: space-between; margin-top: 20px;
    padding-top: 20px; border-top: 1px solid var(--border-color);
}

/* --- VISTA PREVIA --- */
.preview-frame-wrap {
    height: 500px; border-radius: var(--radius-md); overflow: hidden;
    background: #e2e8f0; border: 4px solid var(--bg-body);
}
.preview-frame-wrap iframe { width: 100%; height: 100%; border: none; }
.preview-notes {
    margin-top: 20px; background: #f0f9ff;
    border-left: 4px solid var(--secondary); padding: 16px;
    font-size: 0.9rem;
}
/* Links modernos en notas */
.link-modern {
    display: inline-block; color: var(--primary); text-decoration: none;
    font-weight: 700; margin-right: 16px; border-bottom: 2px solid transparent;
    transition: all 0.2s; font-size: 0.85rem;
}
.link-modern:hover { border-bottom-color: var(--secondary); color: var(--secondary); }

/* --- VENTANA MODAL (CONFIRMACIÓN) --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(0,0,0,0.5); z-index: 1000;
    display: flex; align-items: center; justify-content: center;
    opacity: 0; pointer-events: none; transition: opacity 0.3s;
}
.modal-overlay.show { opacity: 1; pointer-events: auto; }

.modal-content {
    background: white; padding: 32px; border-radius: 20px;
    width: 90%; max-width: 400px; text-align: center;
    transform: translateY(20px); transition: transform 0.3s;
    box-shadow: 0 20px 25px -5px rgba(0,0,0,0.1);
}
.modal-overlay.show .modal-content { transform: translateY(0); }

.modal-icon { font-size: 3rem; margin-bottom: 16px; }
.modal-title {
    font-size: 1.25rem; font-weight: 800; margin-bottom: 12px;
    color: var(--text-main);
}
.modal-text {
    font-size: 0.95rem; color: var(--text-muted);
    line-height: 1.6; margin-bottom: 16px;
}
.modal-actions { display: flex; gap: 12px; justify-content: center; margin-top: 24px; }
.small-note { font-size: 0.8rem; margin-top: 12px; }

/* LISTA DE CAMBIOS (COMPARACIÓN) */
.changes-container {
    background: #f1f5f9; border-radius: 8px; padding: 12px;
    margin-bottom: 16px; text-align: left; font-size: 0.9rem;
    max-height: 150px; overflow-y: auto; border: 1px solid var(--border-color);
}
.change-item {
    margin-bottom: 8px; padding-bottom: 8px; border-bottom: 1px solid #e2e8f0;
}
.change-item:last-child { margin-bottom: 0; padding-bottom: 0; border-bottom: none; }

.change-label {
    font-weight: 700; color: var(--text-muted); font-size: 0.75rem;
    text-transform: uppercase; display: block; margin-bottom: 2px;
}
.change-values { display: flex; align-items: center; gap: 8px; }
.arrow { color: var(--text-muted); font-weight: bold; }
.old-val { text-decoration: line-through; color: var(--danger); opacity: 0.8; font-size: 0.85rem; }
.new-val { color: var(--success); font-weight: 700; }

/* --- FOOTER --- */
.app-footer {
    text-align: center; padding: 40px 20px; margin-top: 40px;
    border-top: 1px solid var(--border-color);
    color: #94a3b8; /* Gris tenue */
    font-size: 0.75rem;
}
.app-footer p { margin: 4px 0; }
.app-footer strong { font-weight: 600; }

/* --- UTILIDADES & ANIMACIONES --- */
.mt-4 { margin-top: 16px; } .mt-6 { margin-top: 24px; } .mb-4 { margin-bottom: 16px; }
.animate-in { animation: fadeInUp 0.5s ease forwards; opacity: 0; }
.delay-1 { animation-delay: 0.1s; }
.delay-2 { animation-delay: 0.2s; }
.delay-3 { animation-delay: 0.3s; }
@keyframes fadeInUp { to { opacity: 1; transform: translateY(0); } }

/* Responsive */
@media (max-width: 600px) {
    .form-grid, .info-panel, .nav-container { flex-direction: column; }
    .table-actions { flex-direction: column; gap: 16px; }
    .card { padding: 20px; }
}

/* ... [AGREGAR ESTO AL FINAL] ... */

/* --- TRIGGER DE AYUDA (HEADER) --- */
.help-trigger {
    font-size: 0.85rem;
    color: var(--secondary);
    margin-left: 12px;
    cursor: pointer;
    font-weight: 600;
    text-decoration: none;
    background: rgba(14, 165, 233, 0.1);
    padding: 6px 12px;
    border-radius: var(--radius-pill);
    transition: all 0.2s;
}
.help-trigger:hover {
    background: var(--secondary);
    color: white;
}

/* --- ESTILOS MODAL AYUDA --- */
.help-content {
    max-width: 550px; /* Un poco más ancho que el de confirmación */
    text-align: left;
    padding: 0; /* Quitamos padding global para manejarlo interno */
    overflow: hidden;
}

.modal-header-help {
    background: #f8fafc;
    padding: 20px 30px;
    border-bottom: 1px solid var(--border-color);
}
.modal-header-help h2 { margin: 0; color: var(--primary); }

.close-modal {
    position: absolute;
    right: 20px;
    top: 15px;
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--text-muted);
    cursor: pointer;
    line-height: 1;
}
.close-modal:hover { color: var(--danger); }

.help-body {
    padding: 30px;
    max-height: 60vh; /* Scroll si la pantalla es chica */
    overflow-y: auto;
}

/* Pasos de la guía */
.help-step {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
}
.step-badge {
    background: var(--primary);
    color: white;
    width: 32px; height: 32px;
    border-radius: 50%;
    display: flex; align-items: center; justify-content: center;
    font-weight: 800;
    flex-shrink: 0;
}
.step-info h4 { margin: 0 0 4px 0; color: var(--text-main); font-size: 1rem; }
.step-info p { margin: 0; font-size: 0.9rem; color: var(--text-muted); }

.help-divider {
    height: 1px; background: var(--border-color);
    margin: 10px 0 20px 0;
}

.help-extra h4 { color: var(--primary); font-size: 0.95rem; margin-bottom: 10px; }
.help-extra ul { padding-left: 20px; margin: 0; }
.help-extra li {
    font-size: 0.9rem; color: var(--text-main); margin-bottom: 6px;
}
/* =========================================
   ESTILOS NUEVOS: MODO DIOS (Admin Panel)
   Agregados al final para no romper el diseño original
   ========================================= */

/* Botón Candado y Botones de Icono */
.icon-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 5px;
    border-radius: 5px;
    transition: background 0.2s;
}
.icon-btn:hover { background: rgba(0,0,0,0.05); }

/* Barra de Herramientas Admin (Aparece al loguearse) */
.admin-toolbar {
    background: #e0e7ff; /* Fondo Azul suave */
    border: 1px solid #c7d2fe;
    padding: 10px 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    justify-content: space-between;
    align-items: center;
    /* Animación suave al aparecer */
    animation: fadeIn 0.3s ease-out;
}

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

.admin-badge {
    font-size: 0.7rem;
    font-weight: 800;
    color: #4338ca;
    letter-spacing: 1px;
    text-transform: uppercase;
}

.btn-mini-admin {
    background: #4f46e5;
    color: white;
    border: none;
    padding: 6px 12px;
    border-radius: 6px;
    font-size: 0.8rem;
    font-weight: 600;
    cursor: pointer;
    transition: background 0.2s;
}
.btn-mini-admin:hover { background: #4338ca; }

/* Botón Lápiz (Editar) */
.btn-icon-action {
    background: #f1f5f9;
    border: 1px solid #cbd5e1;
    border-radius: 6px;
    cursor: pointer;
    width: 40px;
    height: 40px; /* Asegura que sea cuadrado */
    font-size: 1.1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}
.btn-icon-action:hover { background: #e2e8f0; border-color: #94a3b8; }
.btn-icon-action.hidden { display: none !important; }

/* --- FORMULARIO DE BASE DE DATOS (Dentro del Modal) --- */

.modal-header-db {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 20px;
    border-bottom: 1px solid #f1f5f9;
    padding-bottom: 15px;
}
.modal-header-db h3 { margin: 0; color: #1e293b; }

.db-form-grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
    margin: 10px 0;
}
/* Clases de utilidad para el grid */
.full-row { grid-column: span 2; }
.half-row { grid-column: span 1; }

.db-form-grid label {
    display: block;
    font-size: 0.8rem;
    font-weight: 700;
    color: #64748b;
    margin-bottom: 5px;
}
.db-form-grid input {
    width: 100%;
    padding: 10px;
    border: 1px solid #cbd5e1;
    border-radius: 8px;
    font-size: 0.95rem;
    background: #fff;
}
.db-form-grid input:focus {
    border-color: #0ea5e9;
    box-shadow: 0 0 0 3px rgba(14, 165, 233, 0.1);
    outline: none;
}

.modal-footer-db {
    display: flex;
    gap: 10px;
    margin-top: 25px;
    padding-top: 20px;
    border-top: 1px solid #e2e8f0;
}

/* Botones de acción específicos */
.btn-danger {
    background-color: #ef4444;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-danger:hover { background-color: #dc2626; }

.btn-success {
    background-color: #10b981;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 8px;
    cursor: pointer;
    font-weight: 600;
}
.btn-success:hover { background-color: #059669; }

/* Modal Pequeño para el PIN */
.small-modal {
    max-width: 300px !important;
    text-align: center;
}