/* ==========================================================================
   DISEÑO PREMIUM GLASSMORPHISM - PRESENCIA DIGITAL IA (ASSEGURA AI - PAQ 2)
   ========================================================================== */

/* Fuentes e Inicialización */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&family=Outfit:wght@400;500;600;700;800&display=swap');

:root {
    --bg-primary: #0b0f19;
    --bg-secondary: #091021;
    --bg-card: rgba(30, 41, 59, 0.45);
    --border-color: rgba(255, 255, 255, 0.08);
    
    --color-primary: #6366f1;
    --color-primary-glow: rgba(99, 102, 241, 0.15);
    --color-secondary: #06b6d4;
    --color-secondary-glow: rgba(6, 182, 212, 0.15);
    
    --color-text-main: #f8fafc;
    --color-text-muted: #94a3b8;
    
    --priority-high: #10b981;
    --priority-medium: #f59e0b;
    --priority-low: #ef4444;
    
    --transition-smooth: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    --border-radius-lg: 16px;
    --border-radius-md: 8px;
    
    --sidebar-width: 290px;
}

/* Modo Claro (Opcional - Activado por clase .light-theme) */
body.light-theme {
    --bg-primary: #f8fafc;
    --bg-secondary: #ffffff;
    --bg-card: rgba(241, 245, 249, 0.8);
    --border-color: rgba(0, 0, 0, 0.08);
    --color-text-main: #0f172a;
    --color-text-muted: #64748b;
    --color-primary-glow: rgba(99, 102, 241, 0.08);
    --color-secondary-glow: rgba(6, 182, 212, 0.08);
}

/* Reset y Base */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: 'Inter', sans-serif;
    background-color: var(--bg-primary);
    color: var(--color-text-main);
    min-height: 100vh;
    display: flex;
    overflow-x: hidden;
    transition: var(--transition-smooth);
}

h1, h2, h3, h4, .brand-title {
    font-family: 'Outfit', sans-serif;
    font-weight: 600;
}

/* Barra Lateral de Progreso (Sidebar) */
aside {
    width: var(--sidebar-width);
    background-color: var(--bg-secondary);
    border-right: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    height: 100vh;
    position: fixed;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition-smooth);
}

.sidebar-header {
    padding: 20px 16px;
    border-bottom: 1px solid var(--border-color);
}

/* Progreso Global */
.progress-container {
    padding: 16px 20px;
    border-bottom: 1px solid var(--border-color);
}

.progress-info {
    display: flex;
    justify-content: space-between;
    font-size: 0.8rem;
    color: var(--color-text-muted);
    margin-bottom: 6px;
}

.progress-bar-bg {
    width: 100%;
    height: 6px;
    background-color: rgba(255, 255, 255, 0.05);
    border-radius: 10px;
    overflow: hidden;
}

body.light-theme .progress-bar-bg {
    background-color: rgba(0, 0, 0, 0.05);
}

.progress-bar-fill {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--color-primary), var(--color-secondary));
    border-radius: 10px;
    transition: width 0.5s ease;
}

/* Menú de Fases */
.menu-fases {
    flex: 1;
    overflow-y: auto;
    padding: 12px 8px;
    list-style: none;
}

.menu-item {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    font-size: 0.85rem;
    color: var(--color-text-muted);
    margin-bottom: 4px;
    transition: var(--transition-smooth);
    position: relative;
    user-select: none;
}

.menu-item:hover:not(.locked) {
    color: var(--color-text-main);
    background-color: rgba(255, 255, 255, 0.03);
}

body.light-theme .menu-item:hover:not(.locked) {
    background-color: rgba(0, 0, 0, 0.02);
}

.menu-item.active {
    color: white;
    background: linear-gradient(90deg, var(--color-primary-glow), transparent);
    font-weight: 500;
}

body.light-theme .menu-item.active {
    color: var(--color-primary);
}

.menu-item.active::before {
    content: '';
    position: absolute;
    left: 0;
    top: 15%;
    height: 70%;
    width: 3px;
    background-color: var(--color-primary);
    border-radius: 0 4px 4px 0;
    box-shadow: 0 0 10px var(--color-primary);
}

.menu-item.completed {
    color: var(--color-secondary);
}

.menu-item.locked {
    opacity: 0.4;
    cursor: not-allowed;
}

.phase-number {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    border: 1px solid currentColor;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 600;
    flex-shrink: 0;
}

.phase-check {
    display: none;
    color: var(--color-secondary);
    flex-shrink: 0;
}

.menu-item.completed .phase-number {
    display: none;
}

.menu-item.completed .phase-check {
    display: flex;
}

.phase-lock {
    margin-left: auto;
    font-size: 0.75rem;
    color: var(--color-text-muted);
}

/* Footer de Sidebar */
.sidebar-footer {
    padding: 12px 16px;
    border-top: 1px solid var(--border-color);
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.btn-sidebar {
    width: 100%;
    padding: 8px 12px;
    border-radius: var(--border-radius-md);
    background: transparent;
    border: 1px solid var(--border-color);
    color: var(--color-text-main);
    font-size: 0.8rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    transition: var(--transition-smooth);
}

.btn-sidebar:hover {
    border-color: var(--color-primary);
    background-color: var(--color-primary-glow);
}

/* Contenido Principal */
main {
    margin-left: var(--sidebar-width);
    flex: 1;
    min-height: 100vh;
    padding: 30px 40px;
    display: flex;
    flex-direction: column;
    gap: 24px;
    max-width: 1300px;
    width: calc(100% - var(--sidebar-width));
}

/* Cabecera Principal */
.main-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px;
}

.header-title-section h1 {
    font-size: 1.8rem;
    margin-bottom: 4px;
    background: linear-gradient(135deg, #ffffff 30%, #a5b4fc 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

body.light-theme .header-title-section h1 {
    background: linear-gradient(135deg, #0f172a 30%, #4f46e5 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
}

.header-title-section p {
    color: var(--color-text-muted);
    font-size: 0.88rem;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
}

/* Conexión Supabase Status Indicator */
.connection-status {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    font-size: 0.8rem;
    padding: 4px 10px;
    border-radius: 20px;
    background-color: rgba(255, 255, 255, 0.03);
    border: 1px solid var(--border-color);
}

body.light-theme .connection-status {
    background-color: rgba(0, 0, 0, 0.03);
}

.status-dot {
    width: 8px;
    height: 8px;
    border-radius: 50%;
    background-color: var(--priority-low);
}

.status-dot.connected {
    background-color: var(--priority-high);
    box-shadow: 0 0 8px var(--priority-high);
}

/* Tarjeta Principal Glassmorphic */
.glass-panel {
    background-color: var(--bg-card);
    backdrop-filter: blur(16px);
    -webkit-backdrop-filter: blur(16px);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 28px;
    box-shadow: 0 8px 32px 0 rgba(0, 0, 0, 0.2);
    position: relative;
    overflow: hidden;
}

.glass-panel::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 2px;
    background: linear-gradient(90deg, transparent, var(--color-primary), var(--color-secondary), transparent);
    opacity: 0.6;
}

/* Contenido de Fases (Paneles) */
.fase-panel {
    display: none;
    animation: fadeIn 0.4s ease-out;
}

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

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

.fase-header {
    border-bottom: 1px solid var(--border-color);
    padding-bottom: 14px;
    margin-bottom: 20px;
}

.fase-badge {
    display: inline-block;
    padding: 3px 8px;
    background-color: var(--color-primary-glow);
    border: 1px solid rgba(99, 102, 241, 0.3);
    color: #a5b4fc;
    border-radius: 20px;
    font-size: 0.7rem;
    font-weight: 600;
    margin-bottom: 6px;
    text-transform: uppercase;
}

.fase-header h2 {
    font-size: 1.4rem;
    margin-bottom: 4px;
}

.fase-objective {
    color: var(--color-text-muted);
    font-size: 0.9rem;
}

/* Formularios y Campos */
.form-group {
    margin-bottom: 16px;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr;
    gap: 16px;
}

@media (min-width: 768px) {
    .form-row.two-cols {
        grid-template-columns: 1fr 1fr;
    }
    .form-row.three-cols {
        grid-template-columns: 1fr 1fr 1fr;
    }
}

label {
    display: block;
    margin-bottom: 6px;
    font-weight: 500;
    font-size: 0.85rem;
    color: var(--color-text-main);
}

.label-desc {
    font-size: 0.75rem;
    color: var(--color-text-muted);
    font-weight: 400;
    margin-top: 2px;
}

input[type="text"],
input[type="number"],
input[type="url"],
select,
textarea {
    width: 100%;
    padding: 10px 14px;
    background-color: rgba(15, 23, 42, 0.5);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    color: white;
    font-family: inherit;
    font-size: 0.9rem;
    transition: var(--transition-smooth);
}

body.light-theme input[type="text"],
body.light-theme input[type="number"],
body.light-theme input[type="url"],
body.light-theme select,
body.light-theme textarea {
    background-color: #f1f5f9;
    color: #0f172a;
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px var(--color-primary-glow);
}

textarea {
    resize: vertical;
    min-height: 80px;
}

/* Checklist e Items Especiales */
.checklist-container {
    display: flex;
    flex-direction: column;
    gap: 10px;
    margin-top: 8px;
}

.check-item {
    display: flex;
    align-items: flex-start;
    gap: 10px;
    padding: 10px 12px;
    border-radius: var(--border-radius-md);
    background-color: rgba(255, 255, 255, 0.01);
    border: 1px solid var(--border-color);
    cursor: pointer;
    font-size: 0.85rem;
    user-select: none;
    transition: var(--transition-smooth);
}

.check-item:hover {
    background-color: rgba(255, 255, 255, 0.02);
}

.check-item input[type="checkbox"] {
    margin-top: 3px;
    cursor: pointer;
}

.check-item.checked {
    border-color: rgba(6, 182, 212, 0.3);
    background-color: rgba(6, 182, 212, 0.03);
}

/* Botones */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 10px 20px;
    border-radius: var(--border-radius-md);
    font-weight: 600;
    font-size: 0.88rem;
    cursor: pointer;
    border: none;
    transition: var(--transition-smooth);
    text-decoration: none;
}

.btn-primary {
    background: linear-gradient(135deg, var(--color-primary), var(--color-secondary));
    color: white;
    box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
}

.btn-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(99, 102, 241, 0.35);
}

.btn-primary:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
}

.btn-secondary {
    background-color: rgba(255, 255, 255, 0.04);
    border: 1px solid var(--border-color);
    color: var(--color-text-main);
}

.btn-secondary:hover {
    background-color: rgba(255, 255, 255, 0.08);
}

body.light-theme .btn-secondary {
    background-color: #e2e8f0;
}

body.light-theme .btn-secondary:hover {
    background-color: #cbd5e1;
}

.btn-secondary:disabled {
    opacity: 0.4;
    cursor: not-allowed;
}

.panel-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 24px;
    border-top: 1px solid var(--border-color);
    padding-top: 20px;
}

/* Tablas */
.process-table-container {
    overflow-x: auto;
    margin-bottom: 16px;
    border-radius: var(--border-radius-md);
    border: 1px solid var(--border-color);
}

.process-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
    text-align: left;
}

.process-table th {
    background-color: rgba(255, 255, 255, 0.02);
    border-bottom: 2px solid var(--border-color);
    padding: 10px 14px;
    font-weight: 600;
    color: var(--color-text-main);
}

.process-table td {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-color);
}

.process-table tr:last-child td {
    border-bottom: none;
}

.process-table tr:hover {
    background-color: rgba(255, 255, 255, 0.01);
}

/* Cuadro de Alertas */
.alert-box {
    padding: 12px 16px;
    border-radius: var(--border-radius-md);
    margin-bottom: 16px;
    display: flex;
    gap: 10px;
    align-items: flex-start;
    font-size: 0.85rem;
}

.alert-info {
    background-color: rgba(6, 182, 212, 0.06);
    border: 1px solid rgba(6, 182, 212, 0.15);
    color: #e0f2fe;
}

body.light-theme .alert-info {
    background-color: #ecfeff;
    color: #0369a1;
}

.alert-warning {
    background-color: rgba(245, 158, 11, 0.06);
    border: 1px solid rgba(245, 158, 11, 0.15);
    color: #fef3c7;
}

body.light-theme .alert-warning {
    background-color: #fffbeb;
    color: #b45309;
}

.alert-icon {
    font-size: 1.1rem;
    flex-shrink: 0;
}

/* Modales */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(8px);
    z-index: 1000;
    align-items: center;
    justify-content: center;
}

.modal-overlay.active {
    display: flex;
}

.modal-content {
    background-color: var(--bg-secondary);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 550px;
    padding: 24px;
    position: relative;
    max-height: 90vh;
    overflow-y: auto;
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 16px;
}

.close-btn {
    background: transparent;
    border: none;
    color: var(--color-text-muted);
    font-size: 1.3rem;
    cursor: pointer;
}

/* Previsualización del Informe */
.preview-pane {
    background-color: #ffffff;
    color: #1e293b;
    border-radius: var(--border-radius-md);
    padding: 30px;
    margin-top: 16px;
    box-shadow: 0 4px 16px rgba(0,0,0,0.1);
    max-height: 500px;
    overflow-y: auto;
    font-family: 'Inter', sans-serif;
    line-height: 1.5;
    border: 1px solid #e2e8f0;
}

.preview-pane h1 {
    color: #0f172a;
    font-size: 1.6rem;
    border-bottom: 2px solid #6366f1;
    padding-bottom: 6px;
    margin-bottom: 14px;
}

.preview-pane h2 {
    color: #1e293b;
    font-size: 1.15rem;
    margin-top: 16px;
    margin-bottom: 8px;
    border-bottom: 1px solid #e2e8f0;
    padding-bottom: 4px;
}

.preview-pane h3 {
    color: #334155;
    font-size: 0.95rem;
    margin-top: 12px;
    margin-bottom: 6px;
}

.preview-pane p {
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.preview-pane ul {
    margin-left: 18px;
    font-size: 0.85rem;
    margin-bottom: 8px;
}

.preview-pane table {
    width: 100%;
    border-collapse: collapse;
    margin: 12px 0;
    font-size: 0.8rem;
}

.preview-pane th, .preview-pane td {
    border: 1px solid #cbd5e1;
    padding: 8px 10px;
}

.preview-pane th {
    background-color: #f8fafc;
    font-weight: 600;
}

/* Estilos de impresión para PDF */
@media print {
    body * {
        visibility: hidden;
    }
    #pdf-preview-area, #pdf-preview-area * {
        visibility: visible;
    }
    #pdf-preview-area {
        position: absolute;
        left: 0;
        top: 0;
        width: 100%;
        max-height: none;
        overflow: visible;
        padding: 0;
        box-shadow: none;
        border: none;
    }
}
