/* ─── auth.css — Login page & User management page ───────────────────────── */

/* ─── Login page layout ─────────────────────────────────────────────────── */
.auth-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
}

.auth-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 2.5rem 2.25rem 2rem;
  width: 100%;
  max-width: 380px;
  box-shadow: 0 8px 40px rgba(0,0,0,.45);
  text-align: center;
}

.auth-logo {
  font-size: 2.4rem;
  margin-bottom: .35rem;
}

.auth-title {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-primary);
  margin-bottom: .2rem;
}

.auth-subtitle {
  color: var(--text-secondary);
  font-size: .9rem;
  margin-bottom: 1.75rem;
}

/* ─── Form ────────────────────────────────────────────────────────────────── */
.auth-form {
  display: flex;
  flex-direction: column;
  gap: .9rem;
  text-align: right;
}

.auth-form .form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.auth-form label {
  font-size: .85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.auth-form input[type="text"],
.auth-form input[type="password"] {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: .65rem .9rem;
  color: var(--text-primary);
  font-size: .95rem;
  direction: ltr;
  transition: border-color .2s;
}

.auth-form input:focus {
  outline: none;
  border-color: var(--border-focus);
}

.auth-btn {
  margin-top: .4rem;
  padding: .7rem;
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .2s, transform .1s;
}

.auth-btn:hover  { background: var(--accent-hover); }
.auth-btn:active { transform: scale(.98); }
.auth-btn:disabled { opacity: .55; cursor: not-allowed; }

.auth-error {
  background: rgba(255,92,92,.12);
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 7px;
  padding: .55rem .8rem;
  font-size: .87rem;
  text-align: center;
}

.auth-footer {
  margin-top: 1.25rem;
  color: var(--text-secondary);
  font-size: .88rem;
}

.auth-footer a {
  color: var(--accent);
  text-decoration: none;
  margin-right: .4rem;
}

.auth-footer a:hover { text-decoration: underline; }

/* ─── Role badges ─────────────────────────────────────────────────────────── */
.role-badge {
  display: inline-block;
  padding: .2em .65em;
  border-radius: 99px;
  font-size: .75rem;
  font-weight: 700;
  letter-spacing: .02em;
  text-transform: uppercase;
}

.role-admin   { background: rgba(255,92,92,.18);  color: #ff7c7c; }
.role-manager { background: rgba(108,99,255,.18); color: #a09af8; }
.role-editor  { background: rgba(76,175,138,.18); color: #5dd9a8; }
.role-user    { background: rgba(153,153,187,.12);color: #9999bb; }
.role-guest   { background: rgba(153,153,187,.07);color: #7777aa; }

/* ─── Status badges ───────────────────────────────────────────────────────── */
.status-badge {
  display: inline-block;
  padding: .2em .65em;
  border-radius: 99px;
  font-size: .73rem;
  font-weight: 600;
}

.status-active   { background: rgba(76,175,138,.15); color: var(--success); }
.status-inactive { background: rgba(255,92,92,.12);  color: var(--error); }

/* ─── Users page layout ───────────────────────────────────────────────────── */
.users-page .container {
  max-width: 1100px;
  margin: 0 auto;
  padding: 1.5rem 1rem 3rem;
}

/* Stats bar */
.stats-bar {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: 1.5rem;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: .75rem 1.25rem;
  flex: 1 1 120px;
  text-align: center;
}

.stat-card .stat-value {
  font-size: 1.6rem;
  font-weight: 700;
  color: var(--accent);
}

.stat-card .stat-label {
  font-size: .78rem;
  color: var(--text-secondary);
  margin-top: .15rem;
}

/* Settings panel */
.settings-panel {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1rem 1.25rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 1.5rem;
  flex-wrap: wrap;
}

.settings-panel h3 {
  font-size: .85rem;
  color: var(--text-secondary);
  text-transform: uppercase;
  letter-spacing: .06em;
  white-space: nowrap;
}

.toggle-row {
  display: flex;
  align-items: center;
  gap: .6rem;
  cursor: pointer;
  font-size: .9rem;
  color: var(--text-primary);
}

.toggle-row input[type="checkbox"] {
  width: 1.1rem;
  height: 1.1rem;
  accent-color: var(--accent);
  cursor: pointer;
}

/* Users table wrapper */
.users-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

.users-table-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.users-table-header h2 {
  font-size: 1.05rem;
  font-weight: 600;
}

/* Table */
#usersTable {
  width: 100%;
  border-collapse: collapse;
}

#usersTable th {
  background: var(--bg-secondary);
  color: var(--text-secondary);
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  padding: .6rem 1rem;
  text-align: right;
}

#usersTable td {
  padding: .75rem 1rem;
  border-top: 1px solid var(--border);
  color: var(--text-primary);
  font-size: .9rem;
  vertical-align: middle;
}

#usersTable tr:hover td { background: var(--bg-card-hover); }

.user-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--accent-light);
  color: var(--accent);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: .8rem;
  border: 1px solid var(--border);
}

.table-actions {
  display: flex;
  gap: .4rem;
}

.icon-btn {
  background: transparent;
  border: 1px solid var(--border);
  border-radius: 6px;
  padding: .3rem .5rem;
  cursor: pointer;
  color: var(--text-secondary);
  font-size: .85rem;
  transition: all .15s;
  line-height: 1;
}

.icon-btn:hover { background: var(--bg-input); color: var(--text-primary); }
.icon-btn.danger:hover { border-color: var(--error); color: var(--error); }

/* ─── Modal ───────────────────────────────────────────────────────────────── */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.65);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-backdrop.open { display: flex; }

.modal-box {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 14px;
  padding: 1.75rem 1.75rem 1.5rem;
  width: 100%;
  max-width: 420px;
  box-shadow: 0 12px 48px rgba(0,0,0,.55);
  position: relative;
}

.modal-box h3 {
  font-size: 1.1rem;
  margin-bottom: 1.25rem;
}

.modal-close {
  position: absolute;
  top: 1rem;
  left: 1rem;
  background: transparent;
  border: none;
  color: var(--text-secondary);
  font-size: 1.3rem;
  cursor: pointer;
  line-height: 1;
}

.modal-close:hover { color: var(--text-primary); }

.modal-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-form .form-group {
  display: flex;
  flex-direction: column;
  gap: .35rem;
}

.modal-form label {
  font-size: .83rem;
  color: var(--text-secondary);
}

.modal-form input,
.modal-form select {
  background: var(--bg-input);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .55rem .8rem;
  color: var(--text-primary);
  font-size: .9rem;
  direction: ltr;
}

.modal-form input:focus,
.modal-form select:focus {
  outline: none;
  border-color: var(--border-focus);
}

.modal-form select option { background: var(--bg-input); }

.modal-hint {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: .1rem;
}

.modal-actions {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  margin-top: .5rem;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
  border: none;
  border-radius: 7px;
  padding: .55rem 1.25rem;
  font-size: .9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background .15s;
}

.btn-primary:hover { background: var(--accent-hover); }
.btn-primary:disabled { opacity: .5; cursor: not-allowed; }

.btn-secondary {
  background: transparent;
  color: var(--text-secondary);
  border: 1px solid var(--border);
  border-radius: 7px;
  padding: .55rem 1.1rem;
  font-size: .9rem;
  cursor: pointer;
  transition: all .15s;
}

.btn-secondary:hover { background: var(--bg-input); color: var(--text-primary); }

.modal-error {
  background: rgba(255,92,92,.1);
  border: 1px solid var(--error);
  color: var(--error);
  border-radius: 7px;
  padding: .5rem .75rem;
  font-size: .85rem;
}

/* ─── Empty state ─────────────────────────────────────────────────────────── */
.empty-row td {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-muted);
  font-style: italic;
}

/* ─── Navbar user info ────────────────────────────────────────────────────── */
.nav-user-info {
  display: flex;
  align-items: center;
  gap: .75rem;
}

.nav-user-name {
  color: var(--text-secondary);
  font-size: .88rem;
}

.nav-logout-btn {
  background: transparent;
  border: 1px solid var(--border);
  color: var(--text-secondary);
  border-radius: 6px;
  padding: .28rem .65rem;
  font-size: .82rem;
  cursor: pointer;
  transition: all .15s;
}

.nav-logout-btn:hover {
  border-color: var(--error);
  color: var(--error);
}

/* ═══════════════════════════════════════════════════════════════════════════ */
/* Phone Portrait — auth & users page responsive styles (≤ 640px)            */
/* ═══════════════════════════════════════════════════════════════════════════ */
@media (max-width: 640px) {

  /* ── Login card ──────────────────────────────────────────────────────── */
  .auth-card {
    max-width: 100%;
    margin: 1rem;
    padding: 1.75rem 1.1rem 1.5rem;
    border-radius: 16px;
  }

  .auth-logo { font-size: 2rem; }
  .auth-title { font-size: 1.25rem; }

  /* ── Users page container ────────────────────────────────────────────── */
  .users-page .container {
    padding: 1rem 0.75rem 2rem;
  }

  /* ── Stats bar: 2×2 grid ─────────────────────────────────────────────── */
  .stats-bar {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 0.6rem;
  }

  .stat-card {
    flex: none;
    padding: 0.6rem 0.9rem;
  }

  .stat-card .stat-value { font-size: 1.3rem; }

  /* ── Settings panel: vertical ────────────────────────────────────────── */
  .settings-panel {
    flex-direction: column;
    gap: 0.7rem;
    padding: 0.75rem 1rem;
  }

  /* ── Users table: horizontal scroll ─────────────────────────────────── */
  .users-table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  #usersTable { min-width: 500px; }

  #usersTable th,
  #usersTable td {
    padding: 0.5rem 0.7rem;
    font-size: 0.82rem;
  }

  .users-table-header {
    padding: 0.75rem;
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  /* ── User modal ──────────────────────────────────────────────────────── */
  .modal-box {
    padding: 1.25rem 1rem 1rem;
    border-radius: 16px;
    max-width: calc(100% - 1.5rem);
  }

  .modal-actions {
    flex-direction: column-reverse;
    gap: 0.5rem;
  }

  .modal-actions .btn-primary,
  .modal-actions .btn-secondary {
    width: 100%;
    text-align: center;
    justify-content: center;
  }
}
