/* ==============================
   SECURITY - BASE
================================ */

.security-wrapper {
  padding: 16px;
}

.security-header {
  margin-bottom: 16px;
}

.security-title {
  font-size: 20px;
  font-weight: 600;
}

.security-subtitle {
  font-size: 13px;
  color: #6b7280;
}

/* ==============================
   LAYOUT
================================ */

.security-body {
  display: flex;
  gap: 12px;
}

.security-nav {
  width: 160px;
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.security-content {
  flex: 1;
  background: #ffffff;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

/* ==============================
   NAV
================================ */

.security-nav-item {
  border: none;
  background: #f3f4f6;
  color: #374151;
  border-radius: 8px;
  padding: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  cursor: pointer;
}

.security-nav-item i {
  font-size: 14px;
}

.security-nav-item.active {
  background: #e0e7ff;
  color: #1e3a8a;
}

/* ==============================
   LISTS
================================ */

.security-list {
  display: flex;
  flex-direction: column;
}

.security-list-row {
  padding: 10px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.security-list-row:last-child {
  border-bottom: none;
}

.security-list-row.inactive {
  opacity: 0.5;
}

.security-list-title {
  font-size: 14px;
  font-weight: 500;
}

/* ==============================
   ACTIONS
================================ */

.security-actions {
  display: flex;
  gap: 6px;
  margin-bottom: 10px;
}

.security-btn {
  border: none;
  border-radius: 6px;
  padding: 4px 10px;
  font-size: 12px;
  cursor: pointer;
}

.security-btn-add {
  background: #e2ecfe;
  color: #2563eb;
}

.security-btn-edit {
  background: #e5e7eb;
  color: #374151;
}

.security-btn-save {
  background: #dcfce7;
  color: #166534;
}

.security-btn-cancel {
  background: #fee2e2;
  color: #991b1b;
}

.security-btn-delete {
  background: #ff8282;
  color: #7f1d1d;
}

/* ==============================
   SECURITY - FORM
================================ */

.security-form {
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.security-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.security-field label {
  font-size: 12px;
  color: #374151;
}

.security-field input,
.security-field textarea {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 8px;
  font-size: 13px;
}

.security-field textarea {
  resize: vertical;
  min-height: 60px;
}

/* ==============================
   SECURITY - SWITCH (iOS)
================================ */

.security-switch-row {
  flex-direction: row;
  align-items: center;
  justify-content: space-between;
}

.security-switch-label {
  font-size: 13px;
  color: #374151;
}

.security-switch {
  position: relative;
  display: inline-block;
  width: 42px;
  height: 24px;
}

.security-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.security-switch-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background-color: #d1d5db;
  border-radius: 999px;
  transition: 0.2s;
}

.security-switch-slider::before {
  position: absolute;
  content: '';
  height: 18px;
  width: 18px;
  left: 3px;
  bottom: 3px;
  background-color: white;
  border-radius: 50%;
  transition: 0.2s;
}

.security-switch input:checked + .security-switch-slider {
  background-color: #2563eb;
}

.security-switch input:checked + .security-switch-slider::before {
  transform: translateX(18px);
}

/* ==============================
   PERMISSIONS HEADER
================================ */

.security-permissions-header {
  display: flex;
  align-items: baseline; /* 🔑 CLAVE */
  gap: 8px;
}

.security-back-btn {
  border: none;
  background: #e5e7eb;
  color: #374151;
  border-radius: 6px;
  padding: 2px 8px; /* 👈 menos alto */
  font-size: 16px; /* 👈 similar al h1 */
  line-height: 1; /* 👈 evita desfasado */
  cursor: pointer;
}

.security-back-btn:hover {
  background: #d1d5db;
}

/* ==============================
   PERMISSIONS ROLE SELECT
================================ */

.security-actions {
  display: flex;
  align-items: flex-end;
  gap: 12px;
}

.security-actions select {
  border: 1px solid #d1d5db;
  border-radius: 6px;
  padding: 6px 10px;
  font-size: 13px;
  background: #ffffff;
  min-width: 140px;
}

.security-actions {
  justify-content: flex-start;
}

.security-actions .global-btn-save {
  margin-left: auto; /* 🔑 empuja a la derecha */
  height: 30px;
}

/* ==============================
   PERMISSIONS MATRIX
================================ */

.security-permissions-table {
  width: 100%;
  border-collapse: collapse; /* 🔑 líneas limpias */
  font-size: 13px;
}

.security-permissions-table th,
.security-permissions-table td {
  border: 1px solid #e5e7eb; /* líneas suaves */
  padding: 8px;
  text-align: center;
  vertical-align: middle;
}

.security-permissions-table th {
  background: #f9fafb;
  font-weight: 600;
  color: #374151;
  position: sticky;
  top: 0; /* 🔑 header fijo */
  z-index: 2;
}

.security-permissions-table td:first-child,
.security-permissions-table th:first-child {
  text-align: left;
  font-weight: 500;
  background: #ffffff;
  position: sticky;
  left: 0; /* 🔑 columna fija */
  z-index: 1;
}

.security-permissions-table td:first-child {
  white-space: nowrap;
}

/* Zebra rows */
.security-permissions-table tbody tr:nth-child(even) {
  background: #fafafa;
}

.security-permissions-matrix-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: calc(100vh - 220px); /* ajusta según header */
  border: 1px solid #e5e7eb;
  border-radius: 8px;
}

.security-permissions-table .security-switch {
  transform: scale(0.9);
}

@media (orientation: landscape) and (max-width: 900px) {
  .security-permissions-matrix-wrapper {
    max-height: calc(100vh - 160px);
  }

  .security-permissions-table th,
  .security-permissions-table td {
    padding: 6px;
    font-size: 12px;
  }
}

/* =====================================
   SECURITY USERS — LAYOUT
===================================== */

.security-users-page {
  background: #ffffff;
  border-radius: 10px;
  padding: 12px;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.security-users-wrapper {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* HEADER */

.security-users-headerbar {
  display: flex;
  align-items: center;
}

.security-users-header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.security-users-title h2 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
  color: #111827;
}

.security-users-title p {
  margin: 2px 0 0 0;
  font-size: 13px;
  color: #6b7280;
}

/* BACK BUTTON */

.security-users-back {
  border: none;
  background: #f1f5f9;
  padding: 6px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.security-users-back:hover {
  background: #e5e7eb;
}

/* TOOLBAR */

.security-users-toolbar {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 12px;
}

.security-users-search {
  flex: 1;
  min-width: 200px;
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
}

.security-users-select {
  border: 1px solid #d1d5db;
  border-radius: 8px;
  padding: 8px 10px;
  font-size: 13px;
  background: #ffffff;
}

/* =====================================
   SECURITY USERS — LIST
===================================== */

.security-users-list {
  display: flex;
  flex-direction: column;
}

/* CARD */

.security-users-card {
  padding: 14px 18px;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
}

.security-users-card:last-child {
  border-bottom: none;
}

.security-users-card.inactive {
  opacity: 0.45;
}

/* ROWS */

.security-users-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
}

/* NAME */

.security-users-name {
  font-size: 14px;
  font-weight: 600;
  color: #111827;
  line-height: 1.3;
  max-width: 60%;
  word-break: break-word;
}

/* EMAIL */

.security-users-email {
  font-size: 12px;
  color: #6b7280;
}

/* RIGHT TOP AREA */

.security-users-right-top {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* RESET BUTTON */

.security-users-reset {
  font-size: 12px;
  border: none;
  background: #f1f5f9;
  padding: 5px 10px;
  border-radius: 6px;
  cursor: pointer;
}

.security-users-reset:hover {
  background: #e5e7eb;
}

/* STATUS MESSAGES */

.security-users-loading,
.security-users-empty,
.security-users-error {
  padding: 12px;
  font-size: 13px;
  color: #374151;
}

/* =====================================
   SECURITY USERS — ROLE BADGES
===================================== */

.security-users-role {
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 999px;
  font-weight: 600;
}

/* ROLE COLORS */

.security-users-role.administrator {
  background: #dbeafe;
  color: #1d4ed8;
}

.security-users-role.technician {
  background: #dcfce7;
  color: #166534;
}

.security-users-role.client {
  background: #e5e7eb;
  color: #374151;
}

/* =====================================
   SECURITY USERS — SWITCH (iPhone)
===================================== */

.security-users-switch {
  position: relative;
  display: inline-block;
  width: 44px;
  height: 24px;
}

.security-users-switch input {
  opacity: 0;
  width: 0;
  height: 0;
}

.security-users-slider {
  position: absolute;
  cursor: pointer;
  inset: 0;
  background: #d1d5db;
  border-radius: 999px;
  transition: 0.25s;
}

.security-users-slider:before {
  content: '';
  position: absolute;
  height: 18px;
  width: 18px;
  left: 3px;
  top: 3px;
  background: white;
  border-radius: 50%;
  transition: 0.25s;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.25);
}

.security-users-switch input:checked + .security-users-slider {
  background: #22c55e;
}

.security-users-switch input:checked + .security-users-slider:before {
  transform: translateX(20px);
}

/* =====================================
   SECURITY USERS - NEW USER FORM
===================================== */

.security-users-form {
  padding: 16px;
  margin-top: 12px;

  display: flex;
  flex-direction: column;
  gap: 14px;

  max-width: 520px;
}

/* FIELD */

.security-users-field {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.security-users-field label {
  font-size: 12px;
  color: #374151;
}

.security-users-field input,
.security-users-field select {
  width: 100%;

  border: 1px solid #d1d5db;
  border-radius: 8px;

  padding: 9px 10px;
  font-size: 13px;

  background: #ffffff;
}

/* ACTIONS */

.security-users-actions {
  display: flex;
  justify-content: flex-end;
  gap: 8px;

  margin-top: 8px;
}

/* BUTTONS */

.security-users-btn {
  border: none;
  border-radius: 8px;

  padding: 8px 14px;
  font-size: 13px;

  cursor: pointer;
}

.security-users-btn-primary {
  background: #2563eb;
  color: #ffffff;
}

.security-users-btn-primary:hover {
  background: #1d4ed8;
}

.security-users-btn-cancel {
  background: #e5e7eb;
  color: #374151;
}

.security-users-btn-cancel:hover {
  background: #d1d5db;
}

.security-users-btn-danger {
  background: #ef4444;
  color: #ffffff;
}

.security-users-btn-danger:hover {
  background: #dc2626;
}

/* SWITCH ROW */

.security-users-switch-row {
  display: flex;
  justify-content: space-between;
  align-items: center;

  font-size: 13px;
  color: #374151;
}

/* PASSWORD INPUT */

.security-users-password-input {
  position: relative;
  display: flex;
  align-items: center;
}

.security-users-password-input input {
  width: 100%;
  padding-right: 40px;
}

.security-users-eye {
  position: absolute;
  right: 8px;

  border: none;
  background: none;

  cursor: pointer;

  color: #6b7280;
}
