/* assets/css/styles.css - Sistema de Evaluación Visual con Autenticación PHP/MySQL */
@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@400;500;600;700;800&display=swap');

:root {
    --primary: #0284c7;
    --primary-hover: #0369a1;
    --primary-light: #e0f2fe;
    --primary-gradient: linear-gradient(135deg, #0284c7 0%, #0d9488 100%);
    --accent: #10b981;
    
    --bg-color: #f1f5f9;
    --card-bg: #ffffff;
    --card-border: #e2e8f0;
    
    --text-main: #0f172a;
    --text-muted: #64748b;
    --text-subtle: #94a3b8;
    
    --border: #e2e8f0;
    --input-bg: #f8fafc;
    --input-focus-border: #38bdf8;
    
    --success: #10b981;
    --success-bg: #ecfdf5;
    --warning: #f59e0b;
    --warning-bg: #fffbeb;
    --danger: #ef4444;
    --danger-bg: #fef2f2;
    
    --radius-sm: 8px;
    --radius-md: 12px;
    --radius-lg: 18px;
    --radius-full: 9999px;
    
    --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
    --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.07), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
    --shadow-lg: 0 12px 24px -4px rgba(15, 23, 42, 0.08), 0 4px 6px -2px rgba(15, 23, 42, 0.03);
    --shadow-hover: 0 16px 32px -4px rgba(2, 132, 199, 0.12);
}

* {
    box-sizing: border-box;
}

body {
    font-family: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-main);
    line-height: 1.6;
    margin: 0;
    padding: 0;
    -webkit-font-smoothing: antialiased;
}

/* =======================================================
   AUTENTICACIÓN (LOGIN Y REGISTRO)
   ======================================================= */
.auth-body {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    background: radial-gradient(circle at 10% 20%, #e0f2fe 0%, #f1f5f9 60%, #e2e8f0 100%);
    padding: 24px;
}

.auth-wrapper {
    width: 100%;
    max-width: 480px;
    margin: auto;
}

.auth-card {
    background: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-lg);
    padding: 36px 32px;
    box-shadow: var(--shadow-lg);
    backdrop-filter: blur(10px);
    transition: transform 0.2s ease;
}

.auth-header {
    text-align: center;
    margin-bottom: 26px;
}

.auth-logo {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 64px;
    height: 64px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 18px;
    margin-bottom: 14px;
    box-shadow: 0 8px 16px rgba(2, 132, 199, 0.25);
}

.auth-header h2 {
    font-size: 22px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}

.auth-header p {
    font-size: 14px;
    color: var(--text-muted);
    margin: 0;
}

/* Tabs */
.auth-tabs {
    display: flex;
    background: #f1f5f9;
    padding: 4px;
    border-radius: var(--radius-md);
    margin-bottom: 24px;
    gap: 4px;
}

.auth-tab {
    flex: 1;
    background: transparent;
    border: none;
    padding: 10px 14px;
    font-size: 14px;
    font-weight: 600;
    color: var(--text-muted);
    border-radius: var(--radius-sm);
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
}

.auth-tab.active {
    background: white;
    color: var(--primary);
    box-shadow: var(--shadow-sm);
}

/* Formularios y Grupos de Entrada */
.form-row-2 {
    display: flex;
    gap: 12px;
}

.form-row-2 .form-group {
    flex: 1;
}

.form-row-2 .form-group.col-small {
    flex: 0 0 38%;
}

.auth-form .form-group {
    margin-bottom: 18px;
}

.form-group label {
    display: block;
    font-size: 13px;
    font-weight: 600;
    color: var(--text-main);
    margin-bottom: 6px;
}

.input-icon-wrapper {
    position: relative;
    display: flex;
    align-items: center;
}

.input-icon-wrapper .input-icon {
    position: absolute;
    left: 14px;
    color: var(--text-subtle);
    pointer-events: none;
}

.input-icon-wrapper input {
    width: 100%;
    padding: 12px 42px 12px 42px;
    font-family: inherit;
    font-size: 14px;
    background: var(--input-bg);
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    color: var(--text-main);
    transition: all 0.2s ease;
}

.input-icon-wrapper input:focus {
    outline: none;
    border-color: var(--primary);
    background: white;
    box-shadow: 0 0 0 4px rgba(2, 132, 199, 0.12);
}

.btn-toggle-password {
    position: absolute;
    right: 12px;
    background: transparent;
    border: none;
    cursor: pointer;
    font-size: 15px;
    padding: 4px;
    color: var(--text-muted);
    width: auto;
    opacity: 0.7;
    transition: opacity 0.2s;
}

.btn-toggle-password:hover {
    opacity: 1;
    background: transparent;
}

.btn-auth-primary {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    width: 100%;
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 13px 20px;
    font-size: 15px;
    font-weight: 700;
    border-radius: var(--radius-sm);
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(2, 132, 199, 0.25);
    transition: all 0.2s ease;
    margin-top: 24px;
}

.btn-auth-primary:hover {
    transform: translateY(-1px);
    box-shadow: 0 6px 16px rgba(2, 132, 199, 0.35);
}

.btn-auth-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    transform: none;
}

.auth-footer-text {
    text-align: center;
    font-size: 13px;
    color: var(--text-muted);
    margin-top: 20px;
}

.auth-footer-text a {
    color: var(--primary);
    font-weight: 600;
    text-decoration: none;
}

.auth-footer-text a:hover {
    text-decoration: underline;
}

.auth-alert {
    padding: 12px 16px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    margin-bottom: 18px;
    line-height: 1.4;
}

.auth-alert-error {
    background: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #fca5a5;
}

.auth-alert-success {
    background: var(--success-bg);
    color: #065f46;
    border: 1px solid #6ee7b7;
}

.auth-alert-info {
    background: #eff6ff;
    color: #1e40af;
    border: 1px solid #bfdbfe;
}

.btn-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.4);
    border-top-color: white;
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* =======================================================
   HEADER Y PANEL PRINCIPAL (INDEX.PHP)
   ======================================================= */
.main-header {
    background: white;
    border-bottom: 1px solid var(--border);
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.header-content {
    max-width: 960px;
    margin: 0 auto;
    padding: 12px 20px;
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.brand-icon {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 40px;
    height: 40px;
    background: var(--primary-gradient);
    color: white;
    border-radius: 10px;
}

.brand-text {
    display: flex;
    flex-direction: column;
}

.brand-title {
    font-weight: 800;
    font-size: 16px;
    color: var(--text-main);
    line-height: 1.2;
}

.brand-subtitle {
    font-size: 12px;
    font-weight: 600;
    color: var(--primary);
    text-transform: uppercase;
    letter-spacing: 0.05em;
}

.user-nav {
    display: flex;
    align-items: center;
    gap: 14px;
}

.btn-history {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    background: #f8fafc;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 7px 14px;
    border-radius: var(--radius-sm);
    font-size: 13px;
    font-weight: 600;
    cursor: pointer;
    width: auto;
    transition: all 0.2s;
}

.btn-history:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.user-profile-badge {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 4px 10px 4px 4px;
    background: #f8fafc;
    border: 1px solid var(--border);
    border-radius: var(--radius-full);
}

.user-avatar {
    width: 32px;
    height: 32px;
    background: var(--primary-gradient);
    color: white;
    font-weight: 700;
    font-size: 14px;
    display: flex;
    align-items: center;
    justify-content: center;
    border-radius: 50%;
}

.user-info {
    display: flex;
    flex-direction: column;
    text-align: left;
}

.user-name {
    font-size: 13px;
    font-weight: 700;
    color: var(--text-main);
    line-height: 1.2;
}

.user-email {
    font-size: 11px;
    color: var(--text-muted);
}

.btn-logout {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    background: transparent;
    color: #dc2626;
    border: 1px solid #fecaca;
    padding: 6px 12px;
    border-radius: var(--radius-sm);
    font-size: 12px;
    font-weight: 600;
    text-decoration: none;
    transition: all 0.2s;
}

.btn-logout:hover {
    background: #fee2e2;
}

/* Contenedor Principal */
.container {
    max-width: 860px;
    margin: 32px auto 60px auto;
    padding: 0 20px;
}

.welcome-banner {
    background: white;
    border: 1px solid var(--border);
    border-radius: var(--radius-md);
    padding: 24px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
}

.welcome-banner h1 {
    font-size: 24px;
    font-weight: 800;
    color: var(--text-main);
    margin: 0 0 6px 0;
    letter-spacing: -0.02em;
}

.welcome-banner p {
    color: var(--text-muted);
    margin: 0;
    font-size: 15px;
}

/* Tarjetas de Cuestionario */
.card {
    background-color: var(--card-bg);
    border: 1px solid var(--card-border);
    border-radius: var(--radius-md);
    padding: 26px;
    margin-bottom: 24px;
    box-shadow: var(--shadow-sm);
    transition: box-shadow 0.2s ease, border-color 0.2s ease;
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    margin-bottom: 20px;
    padding-bottom: 12px;
    border-bottom: 1px solid var(--border);
}

.card-header h2 {
    font-size: 18px;
    font-weight: 700;
    color: var(--text-main);
    margin: 6px 0 0 0;
}

.section-tag {
    display: inline-block;
    background: var(--primary-light);
    color: var(--primary-hover);
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.05em;
    padding: 3px 8px;
    border-radius: 4px;
}

/* Preguntas */
.question {
    margin-bottom: 20px;
    padding-bottom: 16px;
    border-bottom: 1px solid #f1f5f9;
}

.question:last-child {
    border-bottom: none;
    margin-bottom: 0;
    padding-bottom: 0;
}

.question p {
    font-weight: 600;
    font-size: 14.5px;
    color: var(--text-main);
    margin-top: 0;
    margin-bottom: 12px;
}

.options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.options label {
    display: flex;
    align-items: center;
    gap: 8px;
    cursor: pointer;
    background: var(--input-bg);
    padding: 8px 14px;
    border-radius: var(--radius-sm);
    border: 1px solid var(--border);
    font-size: 13.5px;
    font-weight: 500;
    color: var(--text-main);
    transition: all 0.15s ease;
}

.options label:hover {
    background: #e2e8f0;
    border-color: #cbd5e1;
}

.options input[type="radio"]:checked + span,
.options label:has(input[type="radio"]:checked) {
    background: var(--primary-light);
    border-color: var(--primary);
    color: var(--primary-hover);
    font-weight: 600;
}

/* Botón principal de calcular */
.btn-submit {
    background: var(--primary-gradient);
    color: white;
    border: none;
    padding: 16px 28px;
    border-radius: var(--radius-md);
    font-size: 16px;
    font-weight: 700;
    cursor: pointer;
    width: 100%;
    box-shadow: 0 4px 14px rgba(2, 132, 199, 0.28);
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.btn-submit:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(2, 132, 199, 0.38);
}

/* Resultados */
.result-card {
    border: 2px solid var(--primary);
    background: linear-gradient(180deg, #ffffff 0%, #f8fafc 100%);
}

#resultados {
    display: none;
    margin-top: 32px;
    animation: fadeIn 0.4s ease;
}

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

.alert {
    padding: 18px 20px;
    border-radius: var(--radius-md);
    margin-bottom: 20px;
    font-weight: 700;
    font-size: 16px;
}

.alert.alto {
    background-color: var(--danger-bg);
    color: #991b1b;
    border: 1px solid #f87171;
}

.alert.moderado {
    background-color: var(--warning-bg);
    color: #92400e;
    border: 1px solid #fbbf24;
}

.alert.bajo {
    background-color: var(--success-bg);
    color: #065f46;
    border: 1px solid #34d399;
}

.recomendacion-box {
    background: #f8fafc;
    border-left: 4px solid var(--primary);
    padding: 14px 18px;
    border-radius: 4px;
    font-size: 14.5px;
    color: var(--text-main);
    margin: 18px 0;
}

.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(140px, 1fr));
    gap: 12px;
    margin-top: 24px;
}

.stat-box {
    background: white;
    padding: 16px;
    border-radius: var(--radius-sm);
    text-align: center;
    border: 1px solid var(--border);
    font-size: 13px;
    color: var(--text-muted);
}

.stat-box strong {
    display: block;
    font-size: 24px;
    font-weight: 800;
    color: var(--primary);
    margin-top: 4px;
}

.result-actions {
    display: flex;
    gap: 12px;
    margin-top: 24px;
    flex-wrap: wrap;
}

.btn-secondary {
    background: white;
    color: var(--text-main);
    border: 1px solid var(--border);
    padding: 10px 18px;
    border-radius: var(--radius-sm);
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    flex: 1;
    min-width: 180px;
    transition: all 0.2s;
}

.btn-secondary:hover {
    background: #f8fafc;
    border-color: #cbd5e1;
}

/* Toast Notification */
.toast-notification {
    position: fixed;
    bottom: 24px;
    right: 24px;
    background: #0f172a;
    color: white;
    padding: 14px 22px;
    border-radius: var(--radius-sm);
    box-shadow: var(--shadow-lg);
    font-size: 14px;
    font-weight: 600;
    z-index: 1000;
    display: flex;
    align-items: center;
    gap: 10px;
    animation: slideUp 0.3s ease;
}

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

/* =======================================================
   MODAL DE HISTORIAL
   ======================================================= */
.modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(15, 23, 42, 0.6);
    backdrop-filter: blur(4px);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 200;
    padding: 20px;
}

.modal-card {
    background: white;
    border-radius: var(--radius-lg);
    width: 100%;
    max-width: 680px;
    max-height: 85vh;
    overflow-y: auto;
    box-shadow: var(--shadow-lg);
    display: flex;
    flex-direction: column;
}

.modal-header {
    padding: 20px 24px;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

.modal-header h3 {
    margin: 0;
    font-size: 18px;
    font-weight: 700;
}

.btn-close-modal {
    background: transparent;
    border: none;
    font-size: 26px;
    color: var(--text-muted);
    cursor: pointer;
    width: auto;
    line-height: 1;
    padding: 0;
}

.btn-close-modal:hover {
    color: var(--text-main);
    background: transparent;
}

.modal-body {
    padding: 24px;
}

.history-item {
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
    padding: 16px;
    margin-bottom: 14px;
    background: #f8fafc;
}

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

.history-date {
    font-size: 12px;
    color: var(--text-muted);
}

.history-badge {
    font-size: 12px;
    font-weight: 700;
    padding: 3px 8px;
    border-radius: 4px;
}

.history-badge.alto {
    background: #fee2e2;
    color: #991b1b;
}

.history-badge.moderado {
    background: #fef3c7;
    color: #92400e;
}

.history-badge.bajo {
    background: #d1fae5;
    color: #065f46;
}

.loading-text {
    text-align: center;
    color: var(--text-muted);
    font-size: 14px;
}

/* Responsive */
@media (max-width: 640px) {
    .header-content {
        flex-direction: column;
        gap: 12px;
        align-items: flex-start;
    }
    .user-nav {
        width: 100%;
        justify-content: space-between;
    }
    .user-email {
        display: none;
    }
    .options {
        flex-direction: column;
    }
}
