/* frontend/pages/usuarios/usuarios.css */
/* =========================================================
   Rasta Pets – Usuarios
   Diseño Veterinario Minimalista / Soft UI
   ========================================================= */

:root {
  /* Fondos */
  --bg-body: #f6f9fc;
  --bg-card: #ffffff;
  --bg-soft: #f4fcfa;
  --bg-input: #f8fbfd;

  /* Textos */
  --text-main: #102a56;
  --text-secondary: #7b8ba8;
  --text-placeholder: #a6b3c9;

  /* Colores */
  --color-primary: #22c7a9;
  --color-primary-hover: #16a88e;
  --color-primary-soft: #e9fbf7;

  --color-blue: #2563eb;
  --color-blue-soft: #eff6ff;

  --color-green: #22c55e;
  --color-green-soft: #ecfdf5;

  --color-orange: #f59e0b;
  --color-orange-soft: #fffbeb;

  --color-purple: #8b5cf6;
  --color-purple-soft: #f3efff;

  --color-red: #ef4444;
  --color-red-soft: #fff1f2;

  /* Bordes */
  --border-soft: #e3eaf3;
  --border-light: #eef3f8;

  /* Sombras */
  --shadow-soft: 0 14px 35px rgba(16, 42, 86, 0.06);
  --shadow-hover: 0 20px 48px rgba(16, 42, 86, 0.10);
  --shadow-focus: 0 0 0 4px rgba(34, 199, 169, 0.16);
  --shadow-primary: 0 12px 26px rgba(34, 199, 169, 0.22);

  /* Radius */
  --radius-xl: 28px;
  --radius-l: 20px;
  --radius-m: 16px;
  --radius-s: 12px;
  --radius-round: 999px;

  /* Tipografía */
  --font-family: "Inter", "DM Sans", system-ui, sans-serif;
}

/* ===== Layout general ===== */
.page-usuarios {
  min-height: 100vh;
  padding: 28px 36px;
  background:
    radial-gradient(circle at top right, rgba(34, 199, 169, 0.10), transparent 32%),
    var(--bg-body);
  color: var(--text-main);
  font-family: var(--font-family);
}

.u-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 26px;
  align-items: start;
}

/* ===== Panel lateral ===== */
.u-panel {
  position: sticky;
  top: 24px;
  display: flex;
  flex-direction: column;
  gap: 20px;
  padding: 24px;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}

/* Encabezado del panel */
.panel-head {
  display: flex;
  align-items: center;
  gap: 16px;
  padding: 18px;
  background: linear-gradient(135deg, #e9fbf7 0%, #f3efff 100%);
  border: 1px solid rgba(34, 199, 169, 0.18);
  border-radius: var(--radius-l);
  box-shadow: 0 12px 28px rgba(16, 42, 86, 0.05);
}

.panel-logo {
  width: 50px;
  height: 50px;
  flex: 0 0 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: #ffffff;
  border: 1px solid rgba(34, 199, 169, 0.22);
  border-radius: var(--radius-m);
  box-shadow: 0 10px 24px rgba(34, 199, 169, 0.14);
}

.panel-logo i {
  width: 24px;
  height: 24px;
  color: var(--color-primary);
}

.panel-head h1 {
  margin: 0;
  color: var(--text-main);
  font-size: 21px;
  font-weight: 800;
  letter-spacing: -0.04em;
}

.muted {
  margin: 5px 0 0;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 600;
}

/* ===== Segmentos ===== */
.u-segs {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 8px;
}

.seg {
  min-height: 38px;
  padding: 9px 12px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-round);
  cursor: pointer;
  user-select: none;
  font-size: 12.5px;
  font-weight: 800;
  text-align: center;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.seg:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  border-color: rgba(34, 199, 169, 0.35);
}

.seg.is-on {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-primary);
}

/* ===== Chips ===== */
.u-stats {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.chip {
  padding: 8px 14px;
  background: var(--bg-input);
  color: var(--text-secondary);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-round);
  font-size: 12px;
  font-weight: 700;
}

.chip b {
  margin-right: 4px;
  color: var(--color-primary-hover);
  font-weight: 900;
}

/* ===== Filtros ===== */
.filters {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.f-item label {
  display: block;
  margin-bottom: 7px;
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 800;
}

.f-item input,
.f-item select {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  font-size: 13.5px;
  font-weight: 600;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.f-item input:focus,
.f-item select:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

/* Buscador */
.input-search {
  position: relative;
  display: flex;
  align-items: center;
}

.input-search input {
  width: 100%;
  padding-left: 44px;
}

.icon-search {
  position: absolute;
  left: 15px;
  top: 50%;
  width: 18px;
  height: 18px;
  transform: translateY(-50%);
  color: var(--text-secondary);
  pointer-events: none;
}

/* ===== Acciones panel ===== */
.panel-actions {
  display: flex;
  gap: 6px;
  margin-top: 8px;
}

.panel-actions .btn {
  flex: 1;
  min-width: 0;
  padding: 11px 4px;
  font-size: 12px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ===== Botones ===== */
.page-usuarios .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  min-height: 44px;
  padding: 11px 16px;
  appearance: none;
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  background: var(--bg-input);
  color: var(--text-main);
  cursor: pointer;
  font-size: 13px;
  font-weight: 800;
  transition:
    background 0.2s ease,
    color 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.page-usuarios .btn:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  border-color: rgba(34, 199, 169, 0.32);
}

.page-usuarios .btn-primary {
  background: var(--color-primary);
  color: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-primary);
}

.page-usuarios .btn-primary:hover {
  background: var(--color-primary-hover);
  color: #ffffff;
  border-color: var(--color-primary-hover);
  transform: translateY(-1px);
}

/* ===== Main ===== */
.u-main {
  display: flex;
  flex-direction: column;
  gap: 24px;
}

/* ===== Card tabla ===== */
.page-usuarios .card {
  overflow: hidden;
  background: var(--bg-card);
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-soft);
}

.table-wrap {
  overflow: auto;
}

/* ===== Tabla usuarios ===== */
.tbl-usuarios {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  background: var(--bg-card);
  font-size: 13.5px;
}

.tbl-usuarios thead th {
  padding: 16px 20px;
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
  text-align: left;
  font-size: 12.5px;
  font-weight: 900;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 1px solid rgba(34, 199, 169, 0.12);
}

.tbl-usuarios tbody td {
  padding: 16px 20px;
  color: var(--text-main);
  font-weight: 600;
  vertical-align: middle;
  border-bottom: 1px solid var(--border-light);
}

.tbl-usuarios tbody tr:hover {
  background: rgba(34, 199, 169, 0.045);
}

/* Usuario */
.cell-user {
  display: flex;
  align-items: center;
  gap: 12px;
}

.u-id {
  display: flex;
  flex-direction: column;
  gap: 3px;
}

.u-id .u-name {
  color: var(--text-main);
  font-weight: 800;
}

.u-id .u-login {
  color: var(--text-secondary);
  font-size: 12.5px;
  font-weight: 600;
}

/* Avatar */
.avatar {
  width: 42px;
  height: 42px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, var(--color-primary) 0%, #42d6bd 100%);
  color: #ffffff;
  border-radius: 50%;
  font-size: 14px;
  font-weight: 900;
  box-shadow: 0 10px 20px rgba(34, 199, 169, 0.22);
}

.avatar::after {
  content: attr(data-initials);
}

/* ===== Tags y badges ===== */
.tag,
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 5px 11px;
  border-radius: var(--radius-round);
  font-size: 11px;
  font-weight: 900;
  line-height: 1;
  text-transform: uppercase;
}

.tag-admin {
  background: var(--color-purple-soft);
  color: var(--color-purple);
}

.tag-op {
  background: var(--color-blue-soft);
  color: var(--color-blue);
}

.tag-trans {
  background: var(--color-orange-soft, #fff2e6);
  color: var(--color-orange, #e67e22);
}

.badge.ok {
  background: var(--color-green-soft);
  color: var(--color-green);
}

.badge.err {
  background: var(--color-red-soft);
  color: var(--color-red);
}

/* ===== Acciones tabla ===== */
.col-actions {
  width: 200px;
}

.row-actions {
  display: flex;
  align-items: center;
  gap: 8px;
}

.icon-btn {
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-input);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-s);
  cursor: pointer;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    transform 0.2s ease;
}

.icon-btn:hover {
  background: var(--color-primary);
  border-color: var(--color-primary);
  transform: translateY(-1px);
  box-shadow: var(--shadow-primary);
}

.icon-btn:disabled {
  opacity: 0.45;
  cursor: not-allowed;
  background: #e2e8f0;
  border-color: #cbd5e1;
  pointer-events: none;
  box-shadow: none;
  transform: none;
}

.icon-btn:disabled svg {
  color: #94a3b8;
}

.icon-btn svg,
.password-toggle svg {
  width: 18px;
  height: 18px;
  display: block;
  color: var(--text-main);
  stroke: currentColor;
}

.icon-btn:hover svg {
  color: #FFFFFF;
}

/* ===== Modales ===== */
.modal {
  position: fixed;
  inset: 0;
  z-index: 9999;
  display: none !important;
  align-items: center;
  justify-content: center;
  padding: 0;
  background: transparent;
  border: none;
}

.modal[open] {
  display: flex !important;
}

.modal::backdrop {
  background: rgba(16, 42, 86, 0.38);
  backdrop-filter: blur(6px);
}

.modal__content {
  position: relative;
  z-index: 2;
  width: min(90vw, 680px);
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  background: #ffffff;
  border: 1px solid var(--border-light);
  border-radius: var(--radius-xl);
  box-shadow: 0 40px 90px rgba(16, 42, 86, 0.18);
  overflow: visible;
}

.modal__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 28px;
  background: #ffffff;
  border-bottom: 1px solid var(--border-light);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
}

.modal__header h2 {
  margin: 0;
  color: var(--text-main);
  font-size: 20px;
  font-weight: 800;
  letter-spacing: -0.03em;
}

.modal__close {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--bg-input);
  color: var(--text-secondary);
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s, color 0.2s;
}

.modal__close:hover {
  background: var(--color-primary-soft);
  color: var(--color-primary-hover);
}

.modal__body {
  padding: 28px;
  overflow: visible;
  background: #ffffff;
}

.modal__footer {
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  padding: 20px 28px;
  background: #ffffff;
  border-top: 1px solid var(--border-light);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
}

.modal__body input,
.modal__body select,
.modal__body textarea {
  width: 100%;
  min-height: 48px;
  padding: 12px 15px;
  background: var(--bg-input);
  color: var(--text-main);
  border: 1px solid var(--border-soft);
  border-radius: var(--radius-m);
  font-size: 13.5px;
  font-weight: 600;
  transition:
    background 0.2s ease,
    border-color 0.2s ease,
    box-shadow 0.2s ease;
}

.modal__body input:focus,
.modal__body select:focus,
.modal__body textarea:focus {
  outline: none;
  background: #ffffff;
  border-color: var(--color-primary);
  box-shadow: var(--shadow-focus);
}

.modal__body textarea {
  min-height: 110px;
  resize: vertical;
}

/* Grids modal */
.modal .grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

.hint {
  display: block;
  margin-top: 5px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 600;
}

.form-error {
  margin-top: 8px;
  color: var(--color-red);
  font-size: 13px;
  font-weight: 700;
}

.form-error[hidden] {
  display: none;
}

/* Detalle */
.modal .detail {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px 32px;
}

.modal .detail > div {
  padding: 12px 0;
  border-bottom: 1px solid var(--border-light);
}

.modal .detail dt {
  margin: 0 0 5px;
  color: var(--text-secondary);
  font-size: 12px;
  font-weight: 800;
  text-transform: uppercase;
}

.modal .detail dd {
  margin: 0;
  color: var(--text-main);
  font-weight: 700;
}

/* Scrollbar modal */
.modal__body::-webkit-scrollbar {
  width: 7px;
}

.modal__body::-webkit-scrollbar-track {
  background: transparent;
}

.modal__body::-webkit-scrollbar-thumb {
  background: var(--border-soft);
  border-radius: var(--radius-round);
}

.modal__body::-webkit-scrollbar-thumb:hover {
  background: var(--text-secondary);
}

/* Cambiar sucursal / Reset password */
#dlgSucursal .modal__content,
#dlgPassword .modal__content {
  min-width: min(460px, 92vw);
}

#dlgSucursal .modal__body {
  padding: 24px;
  min-height: 160px;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

#dlgPassword .modal__body {
  padding: 24px;
}

#dlgSucursal .modal__footer,
#dlgPassword .modal__footer {
  padding: 16px 24px;
}

/* Input group para passwords con toggler */
.password-input-group {
  position: relative;
  display: flex;
  align-items: center;
}

.password-input-group input {
  padding-right: 48px;
}

.password-toggle {
  position: absolute;
  right: 8px;
  top: 50%;
  transform: translateY(-50%);
  width: 34px;
  height: 34px;
  border-radius: var(--radius-s);
  border: none;
  background: transparent;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.2s ease;
}

.password-toggle:hover {
  background: var(--bg-input);
  transform: translateY(-50%) scale(1.03);
}

.password-toggle.visible svg {
  color: var(--color-primary-hover);
}

.req {
  color: var(--color-red);
  font-weight: bold;
}

/* ===== Vista detalle modal custom scroll / colors ===== */
.modal--view .modal__content {
  min-width: min(540px, 92vw);
}

.modal--view .modal__body {
  padding: 24px 32px;
  background: linear-gradient(135deg, rgba(34, 199, 169, 0.05) 0%, rgba(124, 58, 237, 0.03) 100%), #ffffff;
}

.modal--view .modal__footer {
  padding: 18px 32px;
}

/* Animacion avatar iniciales para mas dinamismo */
.avatar::before {
  transition: transform 0.2s ease;
}

.tbl-usuarios tbody tr:hover .avatar {
  transform: scale(1.06) rotate(3deg);
  box-shadow: 0 12px 24px rgba(34, 199, 169, 0.32);
}

/* Extra tags color variation */
.avatar--rose {
  background: linear-gradient(135deg, #f43f5e 0%, #fda4af 100%);
  box-shadow: 0 10px 20px rgba(244, 63, 94, 0.22);
}

.avatar--rose.avatar::after {
  content: attr(data-initials);
}

.tbl-usuarios tbody tr:hover .avatar--rose {
  box-shadow: 0 12px 24px rgba(244, 63, 94, 0.32);
}

.avatar--peach {
  background: linear-gradient(135deg, #f97316 0%, #fed7aa 100%);
  box-shadow: 0 10px 20px rgba(249, 115, 22, 0.22);
}

.avatar--peach.avatar::after {
  content: attr(data-initials);
}

.tbl-usuarios tbody tr:hover .avatar--peach {
  box-shadow: 0 12px 24px rgba(249, 115, 22, 0.32);
}

/* Table Footer & Pager */
.table-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 24px;
  background: var(--bg-card);
  border-top: 1px solid var(--border-light);
}

.rows-info {
  color: var(--text-secondary);
  font-size: 13px;
  font-weight: 700;
}

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

.pager #pgInfo {
  font-size: 13px;
  font-weight: 800;
  color: var(--text-main);
}

.pager .btn {
  min-height: 32px;
  height: 32px;
  width: 32px;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-s);
}

/* Empty State */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 60px 40px;
  text-align: center;
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-soft);
}

.empty-state[hidden],
.card[hidden] {
  display: none !important;
}

.empty-state img {
  width: 120px;
  height: auto;
  margin-bottom: 20px;
  opacity: 0.85;
}

.empty-state h2 {
  color: var(--text-main);
  font-size: 20px;
  font-weight: 800;
  margin-bottom: 8px;
}

.empty-state p {
  color: var(--text-secondary);
  font-size: 14px;
  margin: 0;
}

/* ===== Responsivo ===== */
@media (max-width: 980px) {
  .u-layout {
    grid-template-columns: 1fr;
  }

  .u-panel {
    position: relative;
    top: 0;
  }

  .modal .grid,
  .modal .detail {
    grid-template-columns: 1fr;
  }
}

@media (max-width: 640px) {
  .page-usuarios {
    padding: 18px;
  }

  .panel-actions {
    flex-direction: column;
  }

  .modal__content {
    min-width: 100vw;
    max-width: 100vw;
    border-radius: var(--radius-l) var(--radius-l) 0 0;
  }

  .modal__header {
    border-radius: var(--radius-l) var(--radius-l) 0 0;
  }

  .modal__header,
  .modal__body,
  .modal__footer {
    padding-left: 22px;
    padding-right: 22px;
  }

  .modal__footer {
    flex-direction: column;
    border-radius: 0;
  }

  .modal__footer .btn {
    width: 100%;
  }
}

/* Adjust height of branch change modal to prevent dropdown clipping */
#dlgSucursal .modal__body {
  min-height: 240px;
}
