/* ============================================================
   GENERIC ELEMENTS
   ============================================================ */

.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 16px;
}

input[type=text], input[type=password], input[type=email], input[type=date], input[type=time], input[type=number], input[type=url], textarea, select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  padding: 8px 10px;
  width: 100%;
  transition: all 150ms ease;
}
input:focus, textarea:focus, select:focus { border-color: var(--accent-study); outline: none; }
textarea { resize: vertical; line-height: 1.6; }
label { font-size: 12px; color: var(--text-secondary); display: block; margin-bottom: 4px; }

.btn-primary {
  background: var(--accent-study);
  color: #000;
  font-weight: 600;
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: all 150ms ease;
}
.btn-primary:hover { opacity: 0.85; }

.btn-secondary {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: all 150ms ease;
}
.btn-secondary:hover { background: var(--bg-card-hover); color: var(--text-primary); }

.btn-danger {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--danger);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  transition: all 150ms ease;
}
.btn-danger:hover { background: rgba(248,113,113,0.12); }

.btn-icon {
  color: var(--text-muted);
  padding: 4px;
  border-radius: var(--radius-sm);
  transition: all 150ms ease;
  display: inline-flex;
  align-items: center;
}
.btn-icon:hover { color: var(--text-primary); background: var(--bg-card-hover); }

.row { display: flex; gap: 12px; align-items: center; }
.row-wrap { flex-wrap: wrap; }
.spacer { flex: 1; }
.muted { color: var(--text-muted); }
.secondary { color: var(--text-secondary); }
.small { font-size: 12px; }
.mt8 { margin-top: 8px; } .mt12 { margin-top: 12px; } .mt16 { margin-top: 16px; } .mt24 { margin-top: 24px; }
.mb8 { margin-bottom: 8px; } .mb12 { margin-bottom: 12px; } .mb16 { margin-bottom: 16px; } .mb24 { margin-bottom: 24px; }

.tag {
  display: inline-flex; align-items: center; gap: 4px;
  background: var(--bg-input); border: 1px solid var(--border);
  border-radius: 999px; padding: 2px 8px; font-size: 11px; color: var(--text-secondary);
}
.tag .x { cursor: pointer; color: var(--text-muted); }
.tag .x:hover { color: var(--danger); }

.pill { display:inline-block; padding: 2px 8px; border-radius: 999px; font-size: 11px; font-weight: 600; }


/* ============================================================
   TABS / SUBNAV
   ============================================================ */

.subnav { display: flex; gap: 4px; border-bottom: 1px solid var(--border); margin-bottom: 20px; }
.subnav button {
  padding: 8px 14px; color: var(--text-secondary); border-bottom: 2px solid transparent;
  transition: all 150ms ease; font-weight: 500;
}
.subnav button:hover { color: var(--text-primary); }
.subnav button.active { color: var(--text-primary); border-bottom-color: var(--accent-study); }

.tabs { display: flex; gap: 4px; align-items: center; flex-wrap: wrap; margin-bottom: 16px; }
.tab {
  padding: 6px 12px; border-radius: var(--radius-sm); background: var(--bg-card);
  border: 1px solid var(--border); color: var(--text-secondary); display: flex; align-items: center; gap: 8px;
  transition: all 150ms ease;
}
.tab:hover { background: var(--bg-card-hover); }
.tab.active { color: var(--text-primary); border-color: var(--border-hover); }
.tab .x { color: var(--text-muted); font-size: 14px; }
.tab .x:hover { color: var(--danger); }
.tab-rename-input {
  background: transparent; border: none; border-bottom: 1px solid var(--accent-lang);
  color: var(--text-primary); font-size: inherit; font-family: inherit;
  width: 120px; outline: none; padding: 0;
}

/* Saludo del dashboard */
.dashboard-greeting {
  margin-bottom: 24px;
  padding-bottom: 20px;
  border-bottom: 1px solid var(--border);
}
.greeting-text {
  font-size: 22px;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 4px;
}
.greeting-date {
  font-size: 13px;
  color: var(--text-muted);
}

/* Log de actividad de proyectos: scroll de todo el log, ~6 entradas visibles
   (el alto exacto lo fija JS en runtime; este max-height es el fallback). */
.activity-log-container {
  max-height: 264px;
  overflow-y: auto;
  scrollbar-width: thin;
  scrollbar-color: var(--border) transparent;
}
.activity-log-container::-webkit-scrollbar { width: 4px; }
.activity-log-container::-webkit-scrollbar-track { background: transparent; }
.activity-log-container::-webkit-scrollbar-thumb { background: var(--border); border-radius: 2px; }
.activity-log-container::-webkit-scrollbar-thumb:hover { background: var(--border-hover); }


/* ============================================================
   DASHBOARD
   ============================================================ */

.grid { display: grid; gap: 14px; }
/* Dashboard: uniform paddings & gaps (v1.1) */
#sec-dashboard .grid { gap: 16px; }
#sec-dashboard .card { padding: 20px; }
.habit-chips { display: flex; flex-wrap: wrap; gap: 10px; }
.habit-pill {
  display: inline-flex; align-items: center; gap: 8px; padding: 8px 14px;
  background: var(--bg-input); border: 1px solid var(--border); border-radius: 999px;
  cursor: pointer; transition: all 150ms ease; user-select: none;
}
.habit-pill:hover { border-color: var(--border-hover); }
.habit-pill.done { background: rgba(74,222,128,0.12); border-color: var(--accent-gym); color: var(--accent-gym); }
.habit-pill input[type=checkbox] { width: auto; accent-color: var(--accent-gym); pointer-events: none; }
.habit-pill .hx { color: var(--text-muted); font-size: 13px; margin-left: 2px; }
.habit-pill .hx:hover { color: var(--danger); }
/* Mood selector (Estado del día, v4) */
.mood-row { display: flex; gap: 8px; flex-wrap: wrap; margin-top: 6px; }
.mood-btn { flex: 1; min-width: 84px; display: flex; flex-direction: column; align-items: center; gap: 4px;
  padding: 10px 6px; background: var(--bg-input); border: 1px solid var(--border); border-radius: var(--radius-md);
  color: var(--text-secondary); transition: all 150ms ease; }
.mood-btn:hover { border-color: var(--border-hover); }
.mood-btn.active { background: var(--accent-dashboard); border-color: var(--accent-dashboard); color: #0e0e10; }
.mood-emoji { font-size: 22px; line-height: 1; }
.mood-label { font-size: 11px; }
/* Habit tiles con icono (v4) */
.habit-tiles { display: flex; flex-wrap: wrap; gap: 10px; }
.habit-tile { position: relative; width: 96px; padding: 12px 8px; display: flex; flex-direction: column;
  align-items: center; gap: 6px; text-align: center; background: var(--bg-card); border: 1px solid var(--border);
  border-radius: var(--radius-md); cursor: pointer; user-select: none;
  transition: background 150ms ease, color 150ms ease, border-color 150ms ease; }
.habit-tile:hover { border-color: var(--border-hover); }
.habit-ico { display: flex; }
.habit-ico svg { width: 24px; height: 24px; }
.habit-tile .htn { font-size: 11px; color: var(--text-secondary); line-height: 1.2; }
.habit-tile .hx { position: absolute; top: 2px; right: 6px; color: var(--text-muted); font-size: 13px; line-height: 1; }
.habit-tile .hx:hover { color: var(--danger); }
.habit-tile .he { position: absolute; top: 2px; left: 6px; color: var(--text-muted); font-size: 12px; line-height: 1; opacity: 0; transition: opacity .12s ease; }
.habit-tile:hover .he { opacity: 1; }
.habit-tile .he:hover { color: var(--accent-dashboard); }
.habit-tile.done { color: #fff; }
.habit-tile.done .htn { color: #fff; }
.habit-tile.done .hx { color: rgba(255,255,255,0.85); }
.habit-tile.done .he { color: rgba(255,255,255,0.85); }
/* Editor inline de hábitos */
.habit-editor { border: 1px solid var(--border); border-radius: var(--radius-sm); padding: 14px; background: var(--bg-card); }
.habit-editor input[type="text"] { margin-top: 6px; }
.habit-tile.acc-gym.done   { background: var(--accent-gym);   border-color: var(--accent-gym); }
.habit-tile.acc-study.done { background: var(--accent-study); border-color: var(--accent-study); }
.habit-tile.acc-lang.done  { background: var(--accent-lang);  border-color: var(--accent-lang); }
.habit-tile.acc-amber.done { background: var(--warning);      border-color: var(--warning); }
/* Vista previa de recurso de idioma (v4) */
.lang-preview { margin-top: 6px; }
.lang-preview iframe, .lang-preview img { display: block; }
/* Tarjeta de recurso de idioma: icono de tipo + botón editar (v4) */
.tcard { position: relative; }
.lang-type-ico { display: inline-flex; vertical-align: middle; margin-right: 6px; color: var(--accent-lang); }
.lang-type-ico svg { width: 16px; height: 16px; }
.lang-edit-btn { position: absolute; top: 8px; right: 8px; padding: 4px; border-radius: var(--radius-sm);
  background: var(--bg-card-hover); border: 1px solid var(--border); color: var(--text-muted); cursor: pointer;
  display: inline-flex; align-items: center; justify-content: center; transition: all 150ms ease; }
.lang-edit-btn:hover { color: var(--text-primary); border-color: var(--border-hover); }
.lang-edit-btn svg { width: 14px; height: 14px; }
.lang-card-top { display: flex; align-items: center; gap: 6px; padding-right: 26px; }
.lang-resource-view { margin-top: 12px; }
/* Diálogo de confirmación in-page (v4) */
.confirm-overlay { position: fixed; inset: 0; z-index: 9998; background: rgba(0,0,0,0.6); backdrop-filter: blur(3px);
  display: flex; align-items: center; justify-content: center; }
.confirm-box { background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-lg);
  padding: 24px; max-width: 360px; width: 90%; box-shadow: 0 20px 60px rgba(0,0,0,0.5); animation: modalIn 150ms ease; }
.confirm-msg { color: var(--text-primary); font-size: 14px; margin-bottom: 20px; line-height: 1.5; }
.confirm-actions { display: flex; gap: 8px; justify-content: flex-end; }
/* Selector de icono de hábito (v4) */
.icon-grid { display: flex; flex-wrap: wrap; gap: 8px; margin-top: 6px; }
.icon-opt { width: 40px; height: 40px; border-radius: var(--radius-sm); border: 1px solid var(--border);
  display: flex; align-items: center; justify-content: center; cursor: pointer; color: var(--text-secondary);
  background: var(--bg-input); transition: all 150ms ease; }
.icon-opt:hover { border-color: var(--border-hover); color: var(--text-primary); }
.icon-opt.sel { border-color: var(--accent-dashboard); background: var(--bg-card-hover); color: var(--text-primary); }
.icon-opt svg { width: 20px; height: 20px; }
.grid-2 { grid-template-columns: repeat(2, 1fr); }
.grid-3 { grid-template-columns: repeat(3, 1fr); }
.grid-4 { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); }
.summary-card .num { font-size: 26px; font-weight: 700; }
.summary-card .lbl { font-size: 12px; color: var(--text-secondary); }
.dash-block-title { font-size: 13px; font-weight: 600; color: var(--text-secondary); text-transform: uppercase; letter-spacing: 0.5px; margin-bottom: 10px; }
.streak-item { display: flex; justify-content: space-between; padding: 6px 0; border-bottom: 1px solid var(--border); }
.streak-item:last-child { border-bottom: none; }
.char-counter { font-size: 11px; text-align: right; margin-top: 4px; }


/* ============================================================
   SCHEDULE
   ============================================================ */

.sched-block {
  background: var(--bg-card); border: 1px solid var(--border); border-radius: var(--radius-md);
  padding: 12px; margin-bottom: 10px; display: flex; gap: 12px; align-items: flex-start;
}
.sched-block.overlap { border-color: var(--danger); }
.sched-time { display: flex; gap: 4px; align-items: center; }
.sched-time input { width: 90px; }
.sched-drag { cursor: grab; color: var(--text-muted); padding-top: 8px; }
.cat-dot { width: 10px; height: 10px; border-radius: 999px; display: inline-block; }


/* ============================================================
   LANGUAGES — STREAK GRID / BADGE / RESOURCES
   ============================================================ */

.streak-grid { display: grid; grid-template-columns: repeat(auto-fill, 15px); gap: 4px; }
.streak-cell { width: 15px; height: 15px; border-radius: 3px; background: #2f2f35; }
.streak-cell.today { box-shadow: 0 0 0 1.5px var(--text-secondary); }
.lvl1 { background: rgba(251,146,60,0.40); }
.lvl2 { background: rgba(251,146,60,0.70); }
.lvl3 { background: #fb923c; }

.streak-badge {
  margin-left: auto; padding: 4px 12px; border-radius: 999px; font-weight: 600; font-size: 13px;
  background: rgba(251,146,60,0.15); border: 1px solid var(--accent-lang); color: var(--accent-lang);
}
.resource-card { display: flex; gap: 12px; align-items: flex-start; }
.resource-type { font-size: 11px; padding: 2px 6px; border-radius: 999px; background: var(--bg-input); color: var(--accent-lang); }


/* ============================================================
   PROJECTS
   ============================================================ */

.project-card { cursor: pointer; transition: all 150ms ease; }
.project-card:hover { background: var(--bg-card-hover); border-color: var(--border-hover); }
.status-idea { background: rgba(161,161,170,0.15); color: var(--text-secondary); }
.status-active { background: rgba(74,222,128,0.15); color: var(--accent-gym); }
.status-paused { background: rgba(251,191,36,0.15); color: var(--warning); }
.status-done { background: rgba(96,165,250,0.15); color: var(--accent-study); }

.timeline-item { display: flex; gap: 10px; padding: 6px 0; font-size: 12px; }
.timeline-item .dot { width: 7px; height: 7px; border-radius: 999px; background: var(--accent-project); margin-top: 6px; flex-shrink: 0; }
.checklist-item { display: flex; gap: 8px; align-items: center; padding: 4px 0; }
.checklist-item input[type=checkbox] { width: auto; accent-color: var(--accent-gym); }
.checklist-item.done span { text-decoration: line-through; color: var(--text-muted); }
.prio-low { color: var(--accent-gym); } .prio-med { color: var(--warning); } .prio-high { color: var(--danger); }


/* ============================================================
   FORM PIECES (field / diary / note / toolbar / md-render)
   ============================================================ */

.field { margin-bottom: 14px; }
.diary-entry, .note-entry { background: var(--bg-input); border-radius: var(--radius-sm); padding: 8px 10px; margin-bottom: 6px; font-size: 13px; }
.diary-entry .ts, .note-entry .ts { font-size: 11px; color: var(--text-muted); margin-bottom: 2px; }
.toolbar { display: flex; gap: 4px; margin-bottom: 6px; }
.toolbar button { padding: 3px 8px; border: 1px solid var(--border); border-radius: var(--radius-sm); color: var(--text-secondary); font-size: 12px; }
.toolbar button:hover { background: var(--bg-card-hover); color: var(--text-primary); }
.md-render { background: var(--bg-input); border-radius: var(--radius-sm); padding: 10px; font-size: 13px; }
.md-render strong { color: var(--text-primary); }
.md-render code { background: var(--bg-base); padding: 1px 5px; border-radius: 4px; font-family: monospace; font-size: 12px; }
.md-render ul { list-style: disc; padding-left: 18px; }
