/* =====================================================
   Azul Contable – Sistema de Gestión
   public/css/app.css
   ===================================================== */

/* ── Variables ─────────────────────────────────────── */
:root {
  --navy:       #0a1f44;
  --blue:       #1a4a8a;
  --mid-blue:   #2563c6;
  --sky:        #4a9fd4;
  --pale:       #d6e8f8;
  --ice:        #eef5fc;
  --white:      #ffffff;
  --gray-50:    #f8fafc;
  --gray-100:   #f1f5f9;
  --gray-200:   #e2e8f0;
  --gray-400:   #94a3b8;
  --gray-600:   #475569;
  --gray-800:   #1e293b;
  --green:      #16a34a;
  --green-light:#dcfce7;
  --red:        #dc2626;
  --red-light:  #fee2e2;
  --orange:     #c55a11;
  --orange-light:#fff4e6;
  --yellow:     #ca8a04;
  --yellow-light:#fefce8;
  --gold:       #c9a84c;
  --sidebar-w:  260px;
  --topbar-h:   64px;
  --radius:     10px;
  --shadow:     0 2px 12px rgba(10,31,68,.1);
  --shadow-lg:  0 8px 32px rgba(10,31,68,.15);
  --trans:      all .2s ease;
}

/* ── Reset ─────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { scroll-behavior: smooth; }
body {
  font-family: 'DM Sans', sans-serif;
  font-size: .9rem;
  color: var(--gray-800);
  background: var(--gray-100);
  overflow-x: hidden;
}
a { text-decoration: none; color: inherit; }
ul { list-style: none; }
button { font-family: inherit; cursor: pointer; }
input, select, textarea { font-family: inherit; }

/* ── Login page ────────────────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--navy) 0%, var(--blue) 55%, var(--mid-blue) 100%);
  padding: 1.5rem;
}
.login-wrap { width: 100%; max-width: 420px; }
.login-card {
  background: var(--white);
  border-radius: 20px;
  padding: 2.5rem;
  box-shadow: var(--shadow-lg);
}
.login-brand { text-align: center; margin-bottom: 2rem; }
.login-logo {
  width: 64px; height: 64px;
  background: linear-gradient(135deg, var(--mid-blue), var(--navy));
  border-radius: 16px;
  display: flex; align-items: center; justify-content: center;
  margin: 0 auto .9rem;
}
.login-logo svg { width: 36px; height: 36px; }
.login-brand h1 {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--navy);
  margin-bottom: .3rem;
}
.login-brand p { font-size: .85rem; color: var(--gray-400); }
.btn-login {
  width: 100%;
  display: flex; align-items: center; justify-content: center; gap: .6rem;
  background: linear-gradient(135deg, var(--mid-blue), var(--navy));
  color: white;
  font-weight: 700;
  font-size: .95rem;
  padding: .9rem;
  border-radius: var(--radius);
  border: none;
  transition: var(--trans);
  margin-top: .5rem;
}
.btn-login:hover { opacity: .9; transform: translateY(-1px); box-shadow: 0 6px 20px rgba(37,99,198,.3); }
.btn-login svg { width: 18px; height: 18px; }
.login-footer { text-align: center; margin-top: 1.25rem; font-size: .82rem; color: var(--gray-400); }
.login-footer a { color: var(--mid-blue); font-weight: 500; }

/* ── Layout: sidebar + main ────────────────────────── */
.sidebar {
  position: fixed; top: 0; left: 0;
  width: var(--sidebar-w);
  height: 100vh;
  background: var(--navy);
  display: flex; flex-direction: column;
  z-index: 300;
  transition: transform .3s ease;
  overflow-y: auto;
}
.main-content {
  margin-left: var(--sidebar-w);
  min-height: 100vh;
  display: flex; flex-direction: column;
}

/* Sidebar brand */
.sidebar__brand {
  display: flex; align-items: center; gap: .75rem;
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar__logo {
  width: 38px; height: 38px; flex-shrink: 0;
  background: rgba(255,255,255,.1);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.sidebar__logo svg { width: 22px; height: 22px; }
.sidebar__brand-text strong { display: block; color: white; font-size: .95rem; }
.sidebar__brand-text span { font-size: .7rem; color: var(--sky); letter-spacing: .5px; }

/* Sidebar user */
.sidebar__user {
  display: flex; align-items: center; gap: .75rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid rgba(255,255,255,.08);
  flex-shrink: 0;
}
.sidebar__avatar {
  width: 36px; height: 36px; flex-shrink: 0;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky), var(--mid-blue));
  display: flex; align-items: center; justify-content: center;
  font-size: .8rem; font-weight: 700; color: white;
}
.sidebar__user-info strong { display: block; color: white; font-size: .85rem; line-height: 1.2; }
.sidebar__user-info span { font-size: .72rem; }

/* Sidebar nav */
.sidebar__nav { flex: 1; padding: .75rem .75rem 0; }
.sidebar__section {
  font-size: .68rem;
  font-weight: 700;
  letter-spacing: 1.5px;
  text-transform: uppercase;
  color: rgba(255,255,255,.35);
  padding: .75rem .5rem .35rem;
}
.sidebar__link {
  display: flex; align-items: center; gap: .75rem;
  padding: .7rem .85rem;
  border-radius: 8px;
  color: rgba(255,255,255,.65);
  font-size: .88rem;
  font-weight: 500;
  transition: var(--trans);
  margin-bottom: .15rem;
  position: relative;
}
.sidebar__link svg { width: 18px; height: 18px; flex-shrink: 0; }
.sidebar__link:hover { background: rgba(255,255,255,.08); color: white; }
.sidebar__link.active { background: var(--mid-blue); color: white; }
.sidebar__badge {
  margin-left: auto;
  background: var(--red);
  color: white;
  font-size: .7rem;
  font-weight: 700;
  border-radius: 50px;
  padding: .1rem .45rem;
  min-width: 20px;
  text-align: center;
}

/* Sidebar footer */
.sidebar__footer { padding: .75rem; flex-shrink: 0; border-top: 1px solid rgba(255,255,255,.08); }
.sidebar__logout {
  display: flex; align-items: center; gap: .75rem;
  width: 100%;
  padding: .7rem .85rem;
  border-radius: 8px;
  background: none; border: none;
  color: rgba(255,255,255,.5);
  font-size: .88rem;
  transition: var(--trans);
}
.sidebar__logout svg { width: 18px; height: 18px; }
.sidebar__logout:hover { background: rgba(220,38,38,.2); color: #fca5a5; }

/* Overlay móvil */
.sidebar-overlay {
  display: none;
  position: fixed; inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 299;
}
.sidebar-overlay.open { display: block; }

/* ── Topbar ────────────────────────────────────────── */
.topbar {
  height: var(--topbar-h);
  background: var(--white);
  border-bottom: 1px solid var(--gray-200);
  display: flex; align-items: center;
  padding: 0 1.5rem;
  gap: 1rem;
  flex-shrink: 0;
  position: sticky; top: 0; z-index: 100;
}
.topbar__menu-btn {
  display: none;
  background: none; border: none;
  padding: .4rem;
  border-radius: 8px;
  color: var(--gray-600);
  transition: var(--trans);
}
.topbar__menu-btn:hover { background: var(--gray-100); }
.topbar__menu-btn svg { width: 22px; height: 22px; }
.topbar__title { font-size: 1.1rem; font-weight: 700; color: var(--navy); flex: 1; }
.topbar__right { margin-left: auto; }
.topbar__date { font-size: .8rem; color: var(--gray-400); }

/* ── Page content ──────────────────────────────────── */
.page-content { padding: 1.5rem; flex: 1; }

/* ── Alerts ────────────────────────────────────────── */
.alert {
  display: flex; align-items: center; gap: .75rem;
  margin: .75rem 1.5rem 0;
  padding: .85rem 1.1rem;
  border-radius: var(--radius);
  font-size: .88rem;
  font-weight: 500;
}
.alert svg { width: 18px; height: 18px; flex-shrink: 0; }
.alert-success { background: var(--green-light); color: #15803d; border: 1px solid #bbf7d0; }
.alert-error   { background: var(--red-light);   color: #991b1b; border: 1px solid #fecaca; }

/* ── Cards ─────────────────────────────────────────── */
.card {
  background: var(--white);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  overflow: hidden;
  margin-bottom: 1.25rem;
}
.card__header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 1.1rem 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}
.card__title { font-size: 1rem; font-weight: 700; color: var(--navy); }
.card__body { padding: 1.25rem 1.5rem; }
.card__body--flush { padding: 0; }
.card__footer {
  padding: .85rem 1.5rem;
  border-top: 1px solid var(--gray-200);
  background: var(--gray-50);
}
.card__footer-link { font-size: .85rem; color: var(--mid-blue); font-weight: 500; }

/* ── Stats grid ────────────────────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(180px, 1fr));
  gap: 1rem;
  margin-bottom: 1.25rem;
}
.stat-card {
  border-radius: var(--radius);
  padding: 1.25rem;
  display: flex; align-items: center; gap: 1rem;
  box-shadow: var(--shadow);
  color: white;
}
.stat-card--blue   { background: linear-gradient(135deg, var(--mid-blue), var(--blue)); }
.stat-card--red    { background: linear-gradient(135deg, #dc2626, #991b1b); }
.stat-card--orange { background: linear-gradient(135deg, #c55a11, #92400e); }
.stat-card--green  { background: linear-gradient(135deg, #16a34a, #166534); }
.stat-card--navy   { background: linear-gradient(135deg, var(--navy), #0f172a); }
.stat-card__icon {
  width: 44px; height: 44px; flex-shrink: 0;
  background: rgba(255,255,255,.15);
  border-radius: 10px;
  display: flex; align-items: center; justify-content: center;
}
.stat-card__icon svg { width: 22px; height: 22px; }
.stat-card__num { font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat-card__label { font-size: .78rem; opacity: .85; margin-top: .2rem; }

.mini-stats { display: flex; gap: .75rem; margin-bottom: 1rem; flex-wrap: wrap; }
.mini-stat {
  display: flex; align-items: center; gap: .5rem;
  padding: .5rem 1rem;
  border-radius: 50px;
  font-size: .85rem; font-weight: 600;
}
.mini-stat__num { font-size: 1.1rem; font-weight: 700; }
.mini-stat--blue   { background: var(--ice);       color: var(--mid-blue); }
.mini-stat--red    { background: var(--red-light);  color: var(--red); }

/* ── Toolbar ───────────────────────────────────────── */
.toolbar {
  display: flex; align-items: center; gap: .75rem;
  flex-wrap: wrap;
  margin-bottom: 1rem;
}
.toolbar__filters { display: flex; align-items: center; gap: .5rem; flex: 1; flex-wrap: wrap; }
.toolbar__count { color: var(--gray-400); font-size: .85rem; }
.filter-input, .filter-select {
  padding: .5rem .75rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .85rem;
  background: var(--white);
  color: var(--gray-800);
  outline: none;
  transition: var(--trans);
}
.filter-input { flex: 1; min-width: 160px; }
.filter-input:focus, .filter-select:focus { border-color: var(--mid-blue); }

/* ── Botones ───────────────────────────────────────── */
.btn {
  display: inline-flex; align-items: center; gap: .4rem;
  padding: .55rem 1.1rem;
  border-radius: 8px;
  font-size: .88rem;
  font-weight: 600;
  border: none;
  transition: var(--trans);
  white-space: nowrap;
  cursor: pointer;
}
.btn-primary { background: var(--mid-blue); color: white; }
.btn-primary:hover { background: var(--blue); }
.btn-secondary { background: var(--gray-100); color: var(--gray-800); border: 1px solid var(--gray-200); }
.btn-secondary:hover { background: var(--gray-200); }
.btn-success { background: var(--green-light); color: #15803d; }
.btn-success:hover { background: #bbf7d0; }
.btn-danger { background: var(--red-light); color: var(--red); }
.btn-danger:hover { background: #fecaca; }
.btn-ghost { background: transparent; color: var(--gray-600); }
.btn-ghost:hover { background: var(--gray-100); color: var(--navy); }
.btn-sm { padding: .4rem .85rem; font-size: .82rem; }
.btn-xs { padding: .3rem .65rem; font-size: .78rem; }

/* ── Task items (lista pendientes) ─────────────────── */
.task-item {
  display: flex; align-items: center; gap: 1rem;
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  transition: background .15s;
  position: relative;
}
.task-item:last-child { border-bottom: none; }
.task-item:hover { background: var(--gray-50); }
.task-item__priority-bar {
  position: absolute; left: 0; top: 0; bottom: 0;
  width: 4px; border-radius: 0;
}
.task-item--alta    .task-item__priority-bar { background: var(--red); }
.task-item--media   .task-item__priority-bar { background: var(--yellow); }
.task-item--baja    .task-item__priority-bar { background: var(--green); }
.task-item--vencido .task-item__priority-bar { background: var(--orange); }
.task-item--completado .task-item__priority-bar { background: var(--gray-200); }
.task-item__body { flex: 1; min-width: 0; }
.task-item__top { display: flex; align-items: flex-start; gap: .5rem; flex-wrap: wrap; margin-bottom: .3rem; }
.task-item__title {
  font-weight: 600; color: var(--navy); font-size: .9rem;
  flex: 1; min-width: 0;
}
.task-item__title--done { text-decoration: line-through; color: var(--gray-400); }
.task-item__badges { display: flex; gap: .35rem; flex-shrink: 0; }
.task-item__meta { font-size: .78rem; color: var(--gray-400); }
.task-item__actions { display: flex; gap: .35rem; flex-shrink: 0; flex-wrap: wrap; }

/* Task row (dashboard) */
.task-row {
  display: flex; align-items: center; justify-content: space-between;
  gap: 1rem;
  padding: .85rem 0;
  border-bottom: 1px solid var(--gray-100);
}
.task-row:last-child { border-bottom: none; }
.task-row__left { display: flex; align-items: flex-start; gap: .75rem; flex: 1; min-width: 0; }
.task-row__desc { font-weight: 600; font-size: .9rem; color: var(--navy); }
.task-row__meta { font-size: .78rem; color: var(--gray-400); margin-top: .2rem; }
.task-row__right { display: flex; align-items: center; gap: .5rem; flex-shrink: 0; }

/* ── Badges ────────────────────────────────────────── */
.priority-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .7rem;
  font-weight: 700;
  flex-shrink: 0;
}
.priority-badge--alta  { background: var(--red-light);    color: var(--red); }
.priority-badge--media { background: var(--yellow-light);  color: var(--yellow); }
.priority-badge--baja  { background: var(--green-light);   color: var(--green); }

.status-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 4px;
  font-size: .7rem; font-weight: 600;
}
.status-badge--pendiente   { background: var(--ice);         color: var(--mid-blue); }
.status-badge--en_progreso { background: var(--yellow-light); color: var(--yellow); }
.status-badge--completado  { background: var(--green-light);  color: var(--green); }

.due-badge {
  display: inline-block;
  padding: .2rem .55rem;
  border-radius: 50px;
  font-size: .75rem; font-weight: 600;
  background: var(--gray-100); color: var(--gray-600);
}
.due-badge--vencido { background: var(--red-light);    color: var(--red); }
.due-badge--hoy     { background: var(--yellow-light);  color: var(--yellow); }
.due-badge--pronto  { background: var(--orange-light);  color: var(--orange); }

.role-badge {
  display: inline-block;
  padding: .2rem .6rem;
  border-radius: 50px;
  font-size: .72rem; font-weight: 700;
}
.role-super_admin { background: #ede9fe; color: #6d28d9; }
.role-admin       { background: var(--ice);      color: var(--mid-blue); }
.role-usuario     { background: var(--gray-100); color: var(--gray-600); }

.status-pill { display: inline-block; padding: .2rem .6rem; border-radius: 50px; font-size: .78rem; font-weight: 600; }
.status-pill--active   { background: var(--green-light); color: var(--green); }
.status-pill--inactive { background: var(--gray-100);    color: var(--gray-400); }
.status-pill--deleted  { background: var(--red-light);   color: var(--red); }

/* ── Tabla de usuarios ─────────────────────────────── */
.data-table { width: 100%; border-collapse: collapse; }
.data-table th {
  text-align: left;
  padding: .75rem 1.25rem;
  font-size: .78rem;
  font-weight: 700;
  color: var(--gray-400);
  text-transform: uppercase;
  letter-spacing: .5px;
  background: var(--gray-50);
  border-bottom: 1px solid var(--gray-200);
}
.data-table td {
  padding: .85rem 1.25rem;
  border-bottom: 1px solid var(--gray-100);
  font-size: .88rem;
  vertical-align: middle;
}
.data-table tr:last-child td { border-bottom: none; }
.data-table tr:hover td { background: var(--gray-50); }
.row--deleted td { opacity: .5; }
.user-cell { display: flex; align-items: center; gap: .65rem; }
.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--sky), var(--mid-blue));
  color: white; font-size: .75rem; font-weight: 700;
  display: flex; align-items: center; justify-content: center;
  flex-shrink: 0;
}
.table-actions { display: flex; gap: .35rem; align-items: center; }

/* ── Formularios ───────────────────────────────────── */
.form-page { max-width: 780px; }
.form-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 1rem; }
.form-group { display: flex; flex-direction: column; gap: .35rem; margin-bottom: .1rem; }
.form-group--full { grid-column: 1 / -1; }
.form-group label { font-size: .82rem; font-weight: 600; color: var(--navy); }
.form-group input,
.form-group select,
.form-group textarea {
  padding: .65rem .9rem;
  border: 1.5px solid var(--gray-200);
  border-radius: 8px;
  font-size: .9rem;
  color: var(--gray-800);
  background: var(--white);
  outline: none;
  transition: var(--trans);
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus { border-color: var(--mid-blue); box-shadow: 0 0 0 3px rgba(37,99,198,.1); }
.form-group textarea { resize: vertical; min-height: 80px; }
.form-error { font-size: .78rem; color: var(--red); }
.form-actions { display: flex; gap: .75rem; margin-top: 1.25rem; padding-top: 1.25rem; border-top: 1px solid var(--gray-200); }
.form-check { flex-direction: row; align-items: center; }
.checkbox-label { display: flex; align-items: center; gap: .5rem; cursor: pointer; font-size: .88rem; }
.checkbox-label input[type="checkbox"] { width: 16px; height: 16px; cursor: pointer; }

.input-password-wrap { position: relative; }
.input-password-wrap input { padding-right: 2.5rem; width: 100%; }
.toggle-password {
  position: absolute; right: .6rem; top: 50%; transform: translateY(-50%);
  background: none; border: none; padding: .2rem;
  color: var(--gray-400); transition: var(--trans);
}
.toggle-password:hover { color: var(--mid-blue); }
.eye-icon { width: 18px; height: 18px; }

/* ── Empty state ───────────────────────────────────── */
.empty-state { text-align: center; padding: 3rem 1.5rem; }
.empty-state__icon { font-size: 3rem; margin-bottom: .75rem; }
.empty-state p { color: var(--gray-400); margin-bottom: 1rem; }

/* ── Text helpers ──────────────────────────────────── */
.text-danger  { color: var(--red); }
.text-warning { color: var(--orange); }
.text-success { color: var(--green); }

/* ── Responsive ────────────────────────────────────── */
@media (max-width: 900px) {
  .sidebar { transform: translateX(-100%); }
  .sidebar.open { transform: translateX(0); }
  .main-content { margin-left: 0; }
  .topbar__menu-btn { display: flex; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-group--full { grid-column: 1; }
}

@media (max-width: 600px) {
  .page-content { padding: 1rem; }
  .topbar { padding: 0 1rem; }
  .topbar__date { display: none; }
  .stats-grid { grid-template-columns: 1fr 1fr; gap: .75rem; }
  .stat-card__num { font-size: 1.4rem; }
  .task-item { flex-wrap: wrap; }
  .task-item__actions { width: 100%; justify-content: flex-start; }
  .toolbar { flex-direction: column; align-items: stretch; }
  .toolbar__filters { flex-direction: column; }
  .filter-input, .filter-select { width: 100%; }
  .data-table { font-size: .82rem; }
  .data-table th, .data-table td { padding: .65rem .75rem; }
}
