/* =========================================================
   PrintHub — design tokens
   ========================================================= */

:root {
  --bg: #F6F5F2;
  --surface: #FFFFFF;
  --surface-soft: #F1EFE9;
  --border: #E6E3DA;
  --border-soft: #EDEBE3;

  --text: #1D1D1F;
  --text-muted: #6B6B70;
  --text-faint: #A4A3A0;

  --accent: #2E5CE6;
  --accent-hover: #2649BE;
  --accent-soft: #E9EFFF;
  --accent-contrast: #FFFFFF;

  --success: #16A34A;
  --success-soft: #E7F7EC;
  --danger: #DC2626;
  --danger-soft: #FBEAEA;

  --sidebar-bg: #17181C;
  --sidebar-border: #26272C;
  --sidebar-text: #C9C9CE;
  --sidebar-text-dim: #85858C;
  --sidebar-active-bg: #24252B;

  --radius-sm: 8px;
  --radius-md: 12px;
  --radius-lg: 18px;
  --radius-full: 999px;

  --shadow-sm: 0 1px 2px rgba(20, 20, 25, 0.05);
  --shadow-md: 0 8px 24px rgba(20, 20, 25, 0.07);
  --shadow-lg: 0 16px 40px rgba(20, 20, 25, 0.12);

  --font: 'Poppins', 'Segoe UI', Arial, sans-serif;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: var(--font);
}

body {
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  -webkit-font-smoothing: antialiased;
}

.hidden {
  display: none !important;
}

::selection {
  background: var(--accent-soft);
  color: var(--accent-hover);
}

/* =========================================================
   ELEMENTOS DE FORMULÁRIO GENÉRICOS
   ========================================================= */

label {
  display: block;
  font-size: 12.5px;
  font-weight: 500;
  color: var(--text-muted);
  margin-top: 16px;
  margin-bottom: 6px;
}

input,
select {
  width: 100%;
  padding: 11px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 400;
  background: var(--surface);
  color: var(--text);
  transition: border-color 0.15s ease, box-shadow 0.15s ease;
}

input::placeholder {
  color: var(--text-faint);
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--accent-soft);
}

select {
  cursor: pointer;
}

button {
  font-family: var(--font);
  cursor: pointer;
}

button[type="submit"] {
  margin-top: 22px;
  width: 100%;
  padding: 12px;
  background: var(--accent);
  color: var(--accent-contrast);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 14px;
  font-weight: 600;
  transition: background 0.15s ease, transform 0.1s ease;
}

button[type="submit"]:hover {
  background: var(--accent-hover);
}

button[type="submit"]:active {
  transform: translateY(1px);
}

.btn-secondary {
  width: auto;
  margin-top: 0;
  padding: 10.5px 18px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  transition: background 0.15s ease, border-color 0.15s ease, color 0.15s ease;
}

.btn-secondary:hover {
  background: var(--surface-soft);
  border-color: var(--text-faint);
  color: var(--text);
}

.btn-small {
  padding: 8px 14px;
  font-size: 12.5px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-row-3 {
  grid-template-columns: 1fr 1fr 1fr;
}

.form-row .form-field label {
  margin-top: 0;
}

.error {
  color: var(--danger);
  font-size: 13px;
  margin-top: 14px;
  padding: 10px 12px;
  background: var(--danger-soft);
  border-radius: var(--radius-sm);
}

.feedback {
  font-size: 13px;
  margin-top: 14px;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
}

.hint {
  color: var(--text-muted);
  font-size: 12.5px;
  line-height: 1.6;
  margin-bottom: 4px;
}

.hint.no-margin {
  margin: 0;
}

.hint code {
  background: var(--surface-soft);
  padding: 1px 5px;
  border-radius: 4px;
  font-size: 11.5px;
}

/* =========================================================
   TELA DE LOGIN
   ========================================================= */

#login-screen {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background:
    radial-gradient(circle at 15% 15%, rgba(46, 92, 230, 0.06), transparent 45%),
    radial-gradient(circle at 85% 85%, rgba(46, 92, 230, 0.05), transparent 45%),
    var(--bg);
  padding: 24px;
}

.login-wrap {
  width: 100%;
  max-width: 380px;
  display: flex;
  flex-direction: column;
  align-items: center;
}

.login-brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 28px;
}

.login-brand .brand-mark {
  width: 38px;
  height: 38px;
  border-radius: var(--radius-sm);
  background: var(--text);
  color: var(--bg);
  display: flex;
  align-items: center;
  justify-content: center;
}

.login-brand .brand-mark svg {
  width: 20px;
  height: 20px;
}

.login-brand .brand-name {
  font-size: 18px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-md);
  width: 100%;
}

.login-card {
  max-width: 380px;
}

.card h1 {
  font-size: 20px;
  font-weight: 600;
  letter-spacing: -0.01em;
  margin-bottom: 4px;
}

.subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-bottom: 4px;
}

/* =========================================================
   APP SHELL / SIDEBAR
   ========================================================= */

.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: 264px;
  flex-shrink: 0;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  display: flex;
  flex-direction: column;
  padding: 22px 16px;
  position: sticky;
  top: 0;
  height: 100vh;
}

.sidebar-brand {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 6px 8px 26px;
}

.sidebar-brand .brand-mark {
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.sidebar-brand .brand-mark svg {
  width: 19px;
  height: 19px;
}

.brand-text {
  display: flex;
  flex-direction: column;
  line-height: 1.3;
  min-width: 0;
}

.brand-name {
  font-size: 15px;
  font-weight: 600;
  color: #fff;
  letter-spacing: -0.01em;
}

.brand-sub {
  font-size: 11.5px;
  color: var(--sidebar-text-dim);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-nav {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  padding: 11px 12px;
  background: transparent;
  color: var(--sidebar-text);
  border: none;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 500;
  text-align: left;
  transition: background 0.15s ease, color 0.15s ease;
}

.nav-item svg {
  width: 18px;
  height: 18px;
  flex-shrink: 0;
  opacity: 0.85;
}

.nav-item:hover {
  background: var(--sidebar-active-bg);
  color: #fff;
}

.nav-item.active {
  background: var(--accent);
  color: #fff;
}

.nav-item.active svg {
  opacity: 1;
}

.sidebar-footer {
  display: flex;
  align-items: center;
  gap: 8px;
  padding-top: 14px;
  border-top: 1px solid var(--sidebar-border);
}

.profile-card {
  display: flex;
  align-items: center;
  gap: 10px;
  flex: 1;
  min-width: 0;
  background: transparent;
  border: none;
  padding: 8px;
  border-radius: var(--radius-sm);
  transition: background 0.15s ease;
}

.profile-card:hover {
  background: var(--sidebar-active-bg);
}

.profile-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
  text-align: left;
}

.profile-name {
  font-size: 13px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 130px;
}

.profile-role {
  font-size: 11px;
  color: var(--sidebar-text-dim);
}

.logout-btn {
  width: 36px;
  height: 36px;
  flex-shrink: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  background: transparent;
  border: none;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text-dim);
  transition: background 0.15s ease, color 0.15s ease;
}

.logout-btn:hover {
  background: var(--danger-soft);
  color: var(--danger);
}

.logout-btn svg {
  width: 18px;
  height: 18px;
}

.sidebar-toggle {
  display: none;
  position: fixed;
  top: 16px;
  left: 16px;
  z-index: 40;
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-sm);
  color: var(--text);
}

.sidebar-toggle svg {
  width: 20px;
  height: 20px;
}

.sidebar-overlay {
  display: none;
}

/* =========================================================
   AVATAR
   ========================================================= */

.avatar {
  position: relative;
  width: 34px;
  height: 34px;
  border-radius: 50%;
  flex-shrink: 0;
  background: var(--accent-soft);
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
}

.avatar-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.avatar-initials {
  font-size: 13px;
  font-weight: 600;
  color: var(--accent);
}

.avatar-lg {
  width: 64px;
  height: 64px;
}

.avatar-lg .avatar-initials {
  font-size: 20px;
}

.avatar-xl {
  width: 88px;
  height: 88px;
}

.avatar-xl .avatar-initials {
  font-size: 26px;
}

.avatar-placeholder-icon {
  width: 26px;
  height: 26px;
  color: var(--accent);
  opacity: 0.6;
}

.avatar-upload-field {
  display: flex;
  align-items: center;
  gap: 18px;
  padding: 16px;
  background: var(--surface-soft);
  border-radius: var(--radius-md);
  margin-bottom: 4px;
}

.avatar-upload-actions {
  display: flex;
  flex-direction: column;
  gap: 6px;
  align-items: flex-start;
}

.file-label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
}

.file-label svg {
  width: 15px;
  height: 15px;
}

/* =========================================================
   ÁREA PRINCIPAL
   ========================================================= */

.main-area {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  padding: 28px 40px 8px;
}

.topbar h1 {
  font-size: 22px;
  font-weight: 600;
  letter-spacing: -0.01em;
}

.page-subtitle {
  color: var(--text-muted);
  font-size: 13.5px;
  margin-top: 3px;
}

main {
  max-width: 980px;
  width: 100%;
  padding: 20px 40px 48px;
}

.tab-content {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

main .card {
  max-width: none;
  padding: 28px;
}

main h2 {
  font-size: 15.5px;
  font-weight: 600;
  margin-bottom: 4px;
  letter-spacing: -0.01em;
}

/* =========================================================
   ÁREA DE UPLOAD
   ========================================================= */

.file-drop {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 8px;
  border: 1.5px dashed var(--border);
  border-radius: var(--radius-md);
  padding: 28px 16px;
  text-align: center;
  color: var(--text-muted);
  font-size: 13px;
  cursor: pointer;
  background: var(--surface-soft);
  transition: border-color 0.15s, background 0.15s, color 0.15s;
}

.file-drop-icon {
  width: 24px;
  height: 24px;
  opacity: 0.6;
}

.file-drop:hover,
.file-drop.dragover {
  border-color: var(--accent);
  background: var(--accent-soft);
  color: var(--accent);
}

.file-drop:hover .file-drop-icon,
.file-drop.dragover .file-drop-icon {
  opacity: 1;
}

.file-drop.has-file {
  border-color: var(--success);
  background: var(--success-soft);
  color: var(--success);
  font-weight: 600;
}

.file-drop.has-file .file-drop-icon {
  opacity: 1;
}

/* =========================================================
   TABELAS
   ========================================================= */

.table-scroll {
  overflow-x: auto;
  margin-top: 16px;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th, td {
  text-align: left;
  padding: 12px 10px;
  border-bottom: 1px solid var(--border-soft);
  white-space: nowrap;
}

th {
  color: var(--text-faint);
  font-weight: 600;
  font-size: 11px;
  letter-spacing: 0.02em;
}

tbody tr:hover {
  background: var(--surface-soft);
}

.user-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.status-badge {
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--success-soft);
  color: var(--success);
}

.status-badge.status-fail {
  background: var(--danger-soft);
  color: var(--danger);
}

.role-badge {
  display: inline-block;
  padding: 4px 11px;
  border-radius: var(--radius-full);
  font-size: 11.5px;
  font-weight: 600;
  background: var(--accent-soft);
  color: var(--accent);
}

.role-badge.user {
  background: var(--surface-soft);
  color: var(--text-muted);
}

.contact-icons {
  display: inline-flex;
  align-items: center;
  gap: 6px;
}

.contact-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  border-radius: var(--radius-sm);
  background: var(--surface-soft);
  color: var(--text-muted);
  transition: background 0.15s ease, color 0.15s ease;
}

.contact-icon svg {
  width: 14px;
  height: 14px;
}

.contact-icon-wa:hover {
  background: #E7F7EC;
  color: #17A34A;
}

.contact-icon-phone:hover,
.contact-icon-email:hover {
  background: var(--accent-soft);
  color: var(--accent);
}

.contact-empty {
  color: var(--text-faint);
  font-size: 12.5px;
}

.empty-state {
  text-align: center;
  color: var(--text-faint);
  padding: 28px 0 !important;
  white-space: normal;
}

td.ip-cell {
  font-family: 'Consolas', 'Courier New', monospace;
  font-size: 12px;
  color: var(--text-muted);
}

.link-btn {
  background: none;
  border: none;
  color: var(--accent);
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
  width: auto;
  margin: 0;
}

.link-btn:hover {
  text-decoration: underline;
}

.link-btn.danger {
  color: var(--danger);
}

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

/* Tabelas com poucas colunas e conteúdo curto (usuários/impressoras) ficavam
   com espaços enormes entre as colunas no layout automático — aqui fixamos
   proporções pra evitar isso, mantendo rolagem horizontal em telas pequenas. */
#users-table {
  table-layout: fixed;
  min-width: 760px;
}

#users-table th:nth-child(1), #users-table td:nth-child(1) { width: 52px; }
#users-table th:nth-child(2), #users-table td:nth-child(2) { width: 18%; }
#users-table th:nth-child(3), #users-table td:nth-child(3) { width: 15%; }
#users-table th:nth-child(4), #users-table td:nth-child(4) { width: 13%; }
#users-table th:nth-child(5), #users-table td:nth-child(5) { width: 15%; }
#users-table th:nth-child(6), #users-table td:nth-child(6) { width: 11%; }
#users-table th:nth-child(7), #users-table td:nth-child(7) { width: 14%; }

#printers-table {
  table-layout: fixed;
  min-width: 620px;
}

#printers-table th:nth-child(1), #printers-table td:nth-child(1) { width: 32%; }
#printers-table th:nth-child(2), #printers-table td:nth-child(2) { width: 18%; }
#printers-table th:nth-child(3), #printers-table td:nth-child(3) { width: 26%; }
#printers-table th:nth-child(4), #printers-table td:nth-child(4) { width: 12%; }
#printers-table th:nth-child(5), #printers-table td:nth-child(5) { width: 12%; }

#users-table td,
#printers-table td {
  white-space: normal;
  word-break: break-word;
}

/* =========================================================
   FILTROS
   ========================================================= */

.filters {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
  gap: 14px;
  margin-top: 18px;
  padding: 20px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
}

.filter-field {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.filter-name {
  grid-column: span 2;
}

.filter-field label {
  margin-top: 0;
  margin-bottom: 6px;
  font-size: 11px;
  font-weight: 600;
  color: var(--text-faint);
}

.filter-field input,
.filter-field select {
  padding: 9px 11px;
  font-size: 13px;
  background: var(--surface);
}

.filter-actions {
  grid-column: 1 / -1;
  display: flex;
  gap: 10px;
  margin-top: 4px;
  padding-top: 16px;
  border-top: 1px solid var(--border-soft);
}

.filter-actions button {
  width: auto;
  margin-top: 0;
  padding: 10px 20px;
  font-size: 13px;
}

/* =========================================================
   MODAL: MEU PERFIL
   ========================================================= */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(23, 24, 28, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  padding: 20px;
}

.modal-card {
  position: relative;
  width: 100%;
  max-width: 380px;
  background: var(--surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  padding: 32px 28px 28px;
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
}

.modal-close {
  position: absolute;
  top: 14px;
  right: 14px;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--surface-soft);
  border: none;
  border-radius: var(--radius-full);
  color: var(--text-muted);
}

.modal-close svg {
  width: 16px;
  height: 16px;
}

.modal-close:hover {
  background: var(--border-soft);
  color: var(--text);
}

.modal-avatar-block {
  position: relative;
  margin-bottom: 14px;
}

.avatar-edit-btn {
  position: absolute;
  bottom: -2px;
  right: -2px;
  width: 28px;
  height: 28px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--accent);
  color: #fff;
  border-radius: 50%;
  border: 2px solid var(--surface);
  cursor: pointer;
}

.avatar-edit-btn svg {
  width: 13px;
  height: 13px;
}

.modal-name {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 8px;
}

.modal-info-grid {
  width: 100%;
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 10px;
  margin-top: 22px;
}

.modal-info-item {
  display: flex;
  flex-direction: column;
  gap: 3px;
  padding: 12px;
  background: var(--surface-soft);
  border-radius: var(--radius-sm);
  text-align: left;
}

.modal-info-label {
  font-size: 10.5px;
  font-weight: 600;
  color: var(--text-faint);
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.modal-info-value {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text);
  word-break: break-word;
}

.modal-info-value a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 600;
}

.modal-info-value a:hover {
  text-decoration: underline;
}

#modal-avatar-feedback {
  width: 100%;
}

/* =========================================================
   RESPONSIVO
   ========================================================= */

@media (max-width: 900px) {
  .sidebar-toggle {
    display: flex;
  }

  .sidebar {
    position: fixed;
    left: 0;
    top: 0;
    z-index: 50;
    transform: translateX(-100%);
    transition: transform 0.2s ease;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  .sidebar-overlay {
    display: block;
    position: fixed;
    inset: 0;
    background: rgba(15, 15, 18, 0.45);
    z-index: 45;
  }

  .topbar {
    padding: 76px 20px 8px;
  }

  main {
    padding: 16px 20px 40px;
  }

  .filter-name {
    grid-column: 1 / -1;
  }

  .form-row,
  .form-row-3 {
    grid-template-columns: 1fr;
  }

  main .card {
    padding: 20px;
  }
}

@media (max-width: 560px) {
  .avatar-upload-field {
    flex-direction: column;
    align-items: flex-start;
  }

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