/* ==========================================================================
   procesos.totalhse.com — Estilos
   Diseño alegre, colorido y juguetón. Glassmorphism + gradientes + animaciones.
   ========================================================================== */

:root {
    --bg1: #6a11cb;
    --bg2: #2575fc;
    --bg3: #ff6a88;
    --card: rgba(255, 255, 255, 0.92);
    --ink: #2d3436;
    --muted: #7a869a;
    --purple: #6c5ce7;
    --pink: #fd79a8;
    --green: #00b894;
    --blue: #0984e3;
    --amber: #e17055;
    --yellow: #fdcb6e;
    --shadow: 0 10px 30px rgba(31, 18, 73, 0.18);
    --radius: 22px;
    --radius-sm: 14px;
    font-family: 'Baloo 2', 'Segoe UI', system-ui, sans-serif;
}

* { box-sizing: border-box; margin: 0; padding: 0; }

body {
    min-height: 100vh;
    color: var(--ink);
    background: linear-gradient(135deg, var(--bg1), var(--bg2) 55%, var(--bg3));
    background-attachment: fixed;
    overflow-x: hidden;
}

/* fondo animado de burbujas */
.bg-bubbles { position: fixed; inset: 0; z-index: 0; overflow: hidden; pointer-events: none; }
.bg-bubbles span {
    position: absolute; bottom: -120px; width: 40px; height: 40px;
    background: rgba(255, 255, 255, 0.12); border-radius: 50%;
    animation: rise 18s infinite ease-in;
}
@keyframes rise {
    to { transform: translateY(-115vh) rotate(360deg); opacity: 0; }
}

button { font-family: inherit; cursor: pointer; border: none; }
input, select, textarea { font-family: inherit; }

.hidden { display: none !important; }

/* ---------------------------------------------------------------- Login */
.login-wrap {
    position: relative; z-index: 2;
    min-height: 100vh; display: grid; place-items: center; padding: 20px;
}
.login-card {
    background: var(--card); border-radius: var(--radius);
    box-shadow: var(--shadow); padding: 42px 38px; width: 100%; max-width: 400px;
    text-align: center; backdrop-filter: blur(10px);
    animation: pop .5s cubic-bezier(.18,.89,.32,1.28);
}
.login-logo { font-size: 3.4rem; animation: bounce 2s infinite; }
@keyframes bounce { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-10px)} }
.login-card h1 { font-size: 1.7rem; margin: 6px 0 2px; }
.login-card .sub { color: var(--muted); margin-bottom: 26px; font-size: .95rem; }

.field { text-align: left; margin-bottom: 16px; }
.field label { display: block; font-size: .82rem; font-weight: 700; color: var(--muted); margin-bottom: 6px; }
.field input, .field select, .field textarea {
    width: 100%; padding: 13px 16px; border: 2px solid #eef0f6; border-radius: var(--radius-sm);
    font-size: 1rem; background: #fafbff; transition: border-color .2s, box-shadow .2s;
}
.field input:focus, .field select:focus, .field textarea:focus {
    outline: none; border-color: var(--purple); box-shadow: 0 0 0 4px rgba(108,92,231,.15);
}

.btn {
    display: inline-flex; align-items: center; justify-content: center; gap: 8px;
    padding: 13px 22px; border-radius: var(--radius-sm); font-weight: 800; font-size: 1rem;
    color: #fff; background: linear-gradient(135deg, var(--purple), var(--pink));
    box-shadow: 0 8px 18px rgba(108,92,231,.35); transition: transform .12s, box-shadow .2s;
    width: 100%;
}
.btn:hover { transform: translateY(-2px); box-shadow: 0 12px 24px rgba(108,92,231,.45); }
.btn:active { transform: translateY(0) scale(.98); }
.btn.secondary { background: #f1f2f9; color: var(--ink); box-shadow: none; }
.btn.ghost { background: transparent; color: var(--purple); box-shadow: none; }
.btn.small { width: auto; padding: 9px 16px; font-size: .9rem; }
.btn.danger { background: linear-gradient(135deg, #ff7675, #d63031); box-shadow: 0 8px 18px rgba(214,48,49,.3); }

.err-msg { color: #d63031; font-size: .88rem; margin-top: 10px; min-height: 18px; font-weight: 600; }

/* ---------------------------------------------------------------- App shell */
.app { position: relative; z-index: 2; max-width: 1180px; margin: 0 auto; padding: 18px 18px 80px; }

.topbar {
    display: flex; align-items: center; gap: 14px; margin-bottom: 22px;
    background: var(--card); border-radius: var(--radius); padding: 14px 20px; box-shadow: var(--shadow);
    backdrop-filter: blur(10px); position: sticky; top: 12px; z-index: 20;
}
.topbar .brand { font-size: 1.3rem; font-weight: 800; display: flex; align-items: center; gap: 8px; }
.topbar .brand .logo { font-size: 1.6rem; }
.topbar .spacer { flex: 1; }
.chip {
    display: inline-flex; align-items: center; gap: 6px; padding: 7px 13px; border-radius: 999px;
    font-weight: 800; font-size: .85rem; background: #f1f2f9; color: var(--ink);
}
.chip.level { background: linear-gradient(135deg, var(--yellow), #ffeaa7); color: #6b4f00; }
.chip.streak { background: linear-gradient(135deg, #ffd3a5, #fd6585); color: #fff; }
.chip.points { background: linear-gradient(135deg, #a8edea, #74b9ff); color: #04364a; }

.avatar {
    width: 42px; height: 42px; border-radius: 50%; display: grid; place-items: center;
    font-size: 1.3rem; color: #fff; font-weight: 800; cursor: pointer; flex-shrink: 0;
    box-shadow: 0 4px 12px rgba(0,0,0,.18);
}

/* Tabs */
.tabs { display: flex; gap: 8px; margin-bottom: 20px; flex-wrap: wrap; }
.tab {
    padding: 10px 18px; border-radius: 999px; font-weight: 800; font-size: .92rem;
    background: rgba(255,255,255,.55); color: #fff; backdrop-filter: blur(6px); transition: all .2s;
}
.tab.active { background: #fff; color: var(--purple); box-shadow: var(--shadow); }

/* ---------------------------------------------------------------- Dashboard */
.stats-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(150px, 1fr)); gap: 14px; margin-bottom: 22px; }
.stat-card {
    background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    backdrop-filter: blur(10px); position: relative; overflow: hidden; transition: transform .15s;
}
.stat-card:hover { transform: translateY(-3px); }
.stat-card .ico { font-size: 1.9rem; }
.stat-card .num { font-size: 2rem; font-weight: 800; line-height: 1.1; margin-top: 4px; }
.stat-card .lbl { color: var(--muted); font-size: .82rem; font-weight: 700; }

.level-bar { height: 12px; background: #eef0f6; border-radius: 999px; overflow: hidden; margin-top: 10px; }
.level-bar > i { display: block; height: 100%; border-radius: 999px;
    background: linear-gradient(90deg, var(--yellow), var(--pink)); transition: width .8s cubic-bezier(.18,.89,.32,1.28); }

/* ---------------------------------------------------------------- Task cards */
.section-head { display: flex; align-items: center; gap: 12px; margin: 4px 0 16px; }
.section-head h2 { color: #fff; font-size: 1.35rem; text-shadow: 0 2px 8px rgba(0,0,0,.15); }
.section-head .spacer { flex: 1; }

.cards { display: grid; grid-template-columns: repeat(auto-fill, minmax(290px, 1fr)); gap: 16px; }

.task-card {
    background: var(--card); border-radius: var(--radius); padding: 18px; box-shadow: var(--shadow);
    backdrop-filter: blur(10px); position: relative; transition: transform .15s, box-shadow .2s;
    border-top: 6px solid var(--purple); display: flex; flex-direction: column; gap: 12px;
    animation: pop .4s cubic-bezier(.18,.89,.32,1.28);
}
.task-card:hover { transform: translateY(-4px); box-shadow: 0 16px 36px rgba(31,18,73,.22); }
.task-card .tc-top { display: flex; align-items: flex-start; gap: 10px; }
.task-card .tc-emoji { font-size: 2rem; line-height: 1; }
.task-card .tc-title { font-weight: 800; font-size: 1.08rem; }
.task-card .tc-meta { color: var(--muted); font-size: .82rem; font-weight: 600; }
.task-card .tc-menu { margin-left: auto; color: var(--muted); font-size: 1.3rem; background: none; padding: 0 4px; border-radius: 8px; }

.badge-pill { display: inline-flex; align-items: center; gap: 5px; padding: 4px 11px; border-radius: 999px;
    font-size: .76rem; font-weight: 800; }
.bp-prio-alta { background: #ffe3e3; color: #d63031; }
.bp-prio-media { background: #fff3d6; color: #b8860b; }
.bp-prio-baja { background: #e3f7ee; color: #00b894; }
.bp-out-superado { background: #d6f7ec; color: #00876a; }
.bp-out-cumplido { background: #d9ecff; color: #0652a3; }
.bp-out-por_debajo { background: #ffe0d6; color: #c0392b; }

/* anillo de progreso */
.ring { --p: 0; --c: var(--purple); width: 64px; height: 64px; border-radius: 50%; flex-shrink: 0;
    background: conic-gradient(var(--c) calc(var(--p) * 1%), #eef0f6 0);
    display: grid; place-items: center; position: relative; }
.ring::before { content: ''; position: absolute; inset: 7px; background: #fff; border-radius: 50%; }
.ring > b { position: relative; font-size: .82rem; font-weight: 800; }

.tc-progress { display: flex; align-items: center; gap: 14px; }
.tc-progress .info { flex: 1; }
.tc-progress .info .big { font-size: 1.5rem; font-weight: 800; }
.tc-progress .info .small { color: var(--muted); font-size: .8rem; font-weight: 600; }

.tc-actions { display: flex; gap: 8px; flex-wrap: wrap; }
.tc-actions .btn { width: auto; flex: 1; }

.spark { display: flex; align-items: flex-end; gap: 3px; height: 34px; margin-top: 2px; }
.spark > i { flex: 1; background: linear-gradient(180deg, var(--purple), var(--pink)); border-radius: 3px 3px 0 0;
    min-height: 3px; transition: height .4s; }

.today-pill { font-size: .76rem; font-weight: 800; padding: 4px 10px; border-radius: 999px; }
.today-yes { background: #d6f7ec; color: #00876a; }
.today-no { background: #ffe9e0; color: #c0392b; animation: pulse 1.6s infinite; }
@keyframes pulse { 0%,100%{opacity:1} 50%{opacity:.55} }

.empty {
    background: var(--card); border-radius: var(--radius); padding: 50px 24px; text-align: center;
    box-shadow: var(--shadow); backdrop-filter: blur(10px); color: var(--muted); grid-column: 1/-1;
}
.empty .big { font-size: 3.2rem; }
.empty h3 { color: var(--ink); margin: 8px 0; }

/* ---------------------------------------------------------------- Modal */
.modal-overlay {
    position: fixed; inset: 0; background: rgba(20,10,50,.55); backdrop-filter: blur(4px);
    display: grid; place-items: center; z-index: 100; padding: 18px; animation: fade .2s;
}
@keyframes fade { from { opacity: 0; } }
.modal {
    background: #fff; border-radius: var(--radius); padding: 26px; width: 100%; max-width: 480px;
    box-shadow: 0 24px 60px rgba(0,0,0,.3); max-height: 90vh; overflow-y: auto;
    animation: pop .35s cubic-bezier(.18,.89,.32,1.28);
}
.modal.wide { max-width: 620px; }
.modal h3 { font-size: 1.3rem; margin-bottom: 4px; display: flex; align-items: center; gap: 8px; }
.modal .modal-sub { color: var(--muted); font-size: .9rem; margin-bottom: 18px; }
.modal-row { display: flex; gap: 12px; }
.modal-row .field { flex: 1; }
.modal-actions { display: flex; gap: 10px; margin-top: 18px; }

/* cabecera del modal con icono seleccionable a la derecha */
.modal-head { display: flex; align-items: flex-start; justify-content: space-between; gap: 12px; }
.emoji-trigger {
    flex: none; width: 56px; height: 56px; border-radius: 16px; background: #f4f5fb;
    font-size: 1.9rem; display: grid; place-items: center; cursor: pointer;
    border: 2px solid transparent; transition: all .15s; line-height: 1;
}
.emoji-trigger:hover { border-color: var(--purple); transform: scale(1.05); }
.emoji-panel {
    display: flex; gap: 6px; flex-wrap: wrap; margin: 0 0 16px;
    background: #f7f7fc; border-radius: 14px; padding: 12px; animation: fade .15s;
}
.emoji-panel.hidden { display: none; }
.emoji-panel button { font-size: 1.3rem; background: #fff; border-radius: 10px; padding: 6px 9px; transition: transform .1s; }
.emoji-panel button:hover { transform: scale(1.2); }
.emoji-panel button.sel { background: var(--purple); }

@keyframes pop { from { transform: scale(.85); opacity: 0; } }

/* selector de emoji rápido */
.emoji-pick { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 6px; }
.emoji-pick button { font-size: 1.3rem; background: #f4f5fb; border-radius: 10px; padding: 6px 9px; transition: transform .1s; }
.emoji-pick button:hover { transform: scale(1.2); }
.emoji-pick button.sel { background: var(--purple); }

.unit-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(92px, 1fr)); gap: 8px; margin-top: 6px; }
.unit-grid button { padding: 9px; border-radius: 12px; background: #f4f5fb; font-weight: 700; font-size: .85rem; transition: all .15s; }
.unit-grid button.sel { background: linear-gradient(135deg, var(--purple), var(--pink)); color: #fff; }

/* resumen de medias en el historial */
.hist-summary { display: flex; gap: 12px; flex-wrap: wrap; margin: 0 0 16px; }
.hist-summary > div {
    flex: 1; min-width: 120px; background: #f7f7fc; border-radius: 14px; padding: 12px 14px;
    display: flex; flex-direction: column; gap: 4px;
}
.hist-summary span { font-size: .78rem; color: var(--muted); }
.hist-summary b { font-size: 1.05rem; }

/* ---------------------------------------------------------------- Chat IA */
.ai-fab {
    position: fixed; right: 22px; bottom: 22px; z-index: 60; width: 64px; height: 64px; border-radius: 50%;
    background: linear-gradient(135deg, #a18cd1, #fbc2eb); box-shadow: 0 10px 26px rgba(108,92,231,.5);
    font-size: 1.9rem; color: #fff; display: grid; place-items: center; transition: transform .15s;
    animation: floaty 3s ease-in-out infinite;
}
.ai-fab:hover { transform: scale(1.1) rotate(8deg); }
@keyframes floaty { 0%,100%{transform:translateY(0)} 50%{transform:translateY(-8px)} }

.chat-msgs { display: flex; flex-direction: column; gap: 10px; max-height: 340px; overflow-y: auto; padding: 6px 2px; margin-bottom: 12px; }
.msg { padding: 11px 15px; border-radius: 16px; font-size: .92rem; line-height: 1.4; max-width: 85%; }
.msg.user { background: linear-gradient(135deg, var(--purple), var(--pink)); color: #fff; align-self: flex-end; border-bottom-right-radius: 4px; }
.msg.ai { background: #f1f2f9; color: var(--ink); align-self: flex-start; border-bottom-left-radius: 4px; }
.msg.ai.typing { color: var(--muted); font-style: italic; }
.chat-input-row { display: flex; gap: 8px; }
.chat-input-row input { flex: 1; }

.ai-preview { background: #f8f9ff; border: 2px dashed var(--purple); border-radius: var(--radius-sm); padding: 14px; margin: 8px 0; }
.ai-preview .pv-title { font-weight: 800; display: flex; align-items: center; gap: 8px; }
.ai-preview .pv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 6px 14px; margin-top: 8px; font-size: .85rem; }
.ai-preview .pv-grid b { color: var(--muted); font-weight: 700; }
.missing-tag { color: #c0392b; font-weight: 700; }

/* ---------------------------------------------------------------- Toast & confetti */
.toast-wrap { position: fixed; top: 18px; left: 50%; transform: translateX(-50%); z-index: 200; display: flex; flex-direction: column; gap: 8px; align-items: center; }
.toast {
    background: #fff; padding: 14px 22px; border-radius: 999px; box-shadow: 0 12px 30px rgba(0,0,0,.25);
    font-weight: 800; display: flex; align-items: center; gap: 10px; animation: drop .4s cubic-bezier(.18,.89,.32,1.28);
}
.toast.ok { color: var(--green); }
.toast.err { color: #d63031; }
.toast.info { color: var(--blue); }
@keyframes drop { from { transform: translateY(-30px); opacity: 0; } }

.confetti { position: fixed; top: -10px; width: 10px; height: 14px; z-index: 300; pointer-events: none; border-radius: 2px; }
@keyframes confall { to { transform: translateY(105vh) rotate(720deg); opacity: .9; } }

/* ---------------------------------------------------------------- Admin table */
.table-card { background: var(--card); border-radius: var(--radius); padding: 8px; box-shadow: var(--shadow); backdrop-filter: blur(10px); overflow: hidden; }
table { width: 100%; border-collapse: collapse; }
th, td { padding: 13px 14px; text-align: left; }
th { color: var(--muted); font-size: .78rem; text-transform: uppercase; letter-spacing: .04em; }
tbody tr { border-top: 1px solid #f0f1f7; }
tbody tr:hover { background: #fafbff; }

.reminder-banner {
    background: linear-gradient(135deg, #fff6e0, #ffe9e0); border-radius: var(--radius); padding: 16px 20px;
    box-shadow: var(--shadow); margin-bottom: 18px; display: flex; align-items: center; gap: 14px; flex-wrap: wrap;
    border-left: 6px solid var(--amber);
}
.reminder-banner .rb-emoji { font-size: 1.8rem; animation: shake 1.2s infinite; }
@keyframes shake { 0%,100%{transform:rotate(0)} 25%{transform:rotate(-12deg)} 75%{transform:rotate(12deg)} }
.reminder-banner .rb-text { flex: 1; font-weight: 700; }
.reminder-banner .rb-text small { display: block; color: var(--muted); font-weight: 600; }

@media (max-width: 640px) {
    .topbar .brand .txt { display: none; }
    .modal-row { flex-direction: column; }
    .chip span.lbltext { display: none; }
}
