/* ==========================================================================
   Mundo Papière · Admin · Painel restrito
   ========================================================================== */

:root {
  --admin-bg: #F8F9FB;
  --admin-surface: #FFFFFF;
  --admin-sidebar: #1A1A1A;
  --admin-sidebar-text: rgba(255,255,255,0.75);
  --admin-sidebar-active: #00C9B1;
  --admin-border: #E5E5E5;
  --admin-text: #1A1A1A;
  --admin-muted: #737373;
  --admin-success: #16A34A;
  --admin-warning: #EAB308;
  --admin-danger: #DC2626;
  --admin-info: #3B82F6;
}

body { background: var(--admin-bg); color: var(--admin-text); }

/* ============== LOGIN ============== */
.login-page {
  min-height: 100vh;
  display: grid;
  grid-template-columns: 1fr;
  align-items: center;
  background: linear-gradient(135deg, #00C9B1 0%, #FF6B8A 100%);
  padding: var(--space-md);
}
@media (min-width: 900px) {
  .login-page { grid-template-columns: 1fr 1.1fr; }
  .login-page__art { display: flex; }
}

.login-page__art {
  display: none;
  flex-direction: column;
  justify-content: center;
  padding: var(--space-2xl);
  color: white;
}
.login-page__art img.logo { width: 180px; margin-bottom: var(--space-xl); filter: brightness(0) invert(1); }
.login-page__art h2 { color: white; margin-bottom: var(--space-md); font-size: 2.4rem; }
.login-page__art p { font-size: 1.1rem; opacity: 0.95; max-width: 480px; line-height: 1.6; }
.login-page__art .hand { font-family: var(--font-hand); font-size: 1.4rem; opacity: 0.9; margin-top: var(--space-lg); }

.login-card {
  background: white;
  border-radius: 24px;
  padding: var(--space-2xl);
  width: 100%;
  max-width: 440px;
  margin: var(--space-md) auto;
  box-shadow: 0 24px 64px rgba(0,0,0,0.18);
}
.login-card h1 {
  font-size: 1.8rem;
  margin-bottom: 8px;
}
.login-card .login-sub {
  color: var(--admin-muted);
  margin-bottom: var(--space-lg);
}
.login-card .form-field { margin-bottom: var(--space-md); }
.login-card .login-error {
  background: #FEE2E2;
  color: var(--admin-danger);
  padding: 12px 14px;
  border-radius: 8px;
  font-size: 0.9rem;
  margin-bottom: var(--space-md);
  display: none;
}
.login-card .login-error.is-visible { display: block; }
.login-card .login-meta {
  margin-top: var(--space-md);
  text-align: center;
  font-size: 0.82rem;
  color: var(--admin-muted);
}
.login-card .login-meta a { color: var(--turquesa-dark); font-weight: 600; }
.login-card .provisional-note {
  background: #FEF3C7;
  border-left: 3px solid #EAB308;
  padding: 10px 12px;
  border-radius: 6px;
  font-size: 0.78rem;
  color: #78350F;
  margin-top: var(--space-md);
}

/* ============== FORM ============== */
.form-field { display: flex; flex-direction: column; gap: 6px; }
.form-field label {
  font-size: 0.85rem;
  font-weight: 600;
  color: var(--admin-text);
}
.form-field input,
.form-field select,
.form-field textarea {
  padding: 12px 14px;
  border: 2px solid var(--admin-border);
  border-radius: 10px;
  font-size: 0.95rem;
  background: white;
  transition: border-color 150ms, box-shadow 150ms;
  font-family: inherit;
}
.form-field input:focus,
.form-field select:focus,
.form-field textarea:focus {
  outline: 0;
  border-color: var(--turquesa);
  box-shadow: 0 0 0 4px rgba(0,201,177,0.15);
}
.form-field input::placeholder { color: #BBB; }
.form-field .hint { font-size: 0.78rem; color: var(--admin-muted); }

/* ============== ADMIN LAYOUT ============== */
.admin-app {
  display: grid;
  grid-template-columns: 240px 1fr;
  min-height: 100vh;
}
@media (max-width: 900px) {
  .admin-app { grid-template-columns: 1fr; }
  .admin-sidebar { display: none; }
}

/* ============== SIDEBAR ============== */
.admin-sidebar {
  background: var(--admin-sidebar);
  color: var(--admin-sidebar-text);
  padding: var(--space-lg);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}
.admin-sidebar__brand {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: var(--space-xl);
  padding-bottom: var(--space-md);
  border-bottom: 1px solid rgba(255,255,255,0.1);
}
.admin-sidebar__brand img { width: 36px; height: 36px; filter: brightness(0) invert(1); }
.admin-sidebar__brand strong {
  color: white;
  font-family: var(--font-display);
  font-size: 1rem;
}
.admin-sidebar__brand small {
  display: block;
  font-size: 0.7rem;
  opacity: 0.6;
}

.admin-nav { display: flex; flex-direction: column; gap: 2px; }
.admin-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  border-radius: 10px;
  font-size: 0.92rem;
  font-weight: 500;
  color: var(--admin-sidebar-text);
  transition: all 150ms;
}
.admin-nav a:hover {
  background: rgba(255,255,255,0.06);
  color: white;
}
.admin-nav a.is-active {
  background: var(--admin-sidebar-active);
  color: white;
  font-weight: 600;
}
.admin-nav a svg { width: 18px; height: 18px; flex-shrink: 0; }
.admin-nav__section {
  font-size: 0.7rem;
  text-transform: uppercase;
  letter-spacing: 0.12em;
  opacity: 0.5;
  margin: var(--space-md) 14px 6px;
}

.admin-sidebar__footer {
  margin-top: auto;
  padding-top: var(--space-md);
  border-top: 1px solid rgba(255,255,255,0.1);
  font-size: 0.78rem;
}
.admin-sidebar__footer .user {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 10px;
}
.admin-sidebar__footer .avatar {
  width: 36px; height: 36px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--turquesa), var(--rosa));
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-family: var(--font-display);
  font-size: 0.95rem;
}
.admin-sidebar__footer .user-name { color: white; font-weight: 600; font-size: 0.88rem; }
.admin-sidebar__footer .user-role { opacity: 0.6; font-size: 0.72rem; text-transform: uppercase; letter-spacing: 0.08em; }
.admin-sidebar__logout {
  display: block;
  text-align: center;
  padding: 8px;
  background: rgba(255,255,255,0.06);
  border-radius: 8px;
  font-size: 0.82rem;
  width: 100%;
  color: white;
  transition: background 150ms;
}
.admin-sidebar__logout:hover { background: rgba(255,255,255,0.12); }

/* ============== MAIN ============== */
.admin-main { padding: 0; min-width: 0; }
.admin-topbar {
  background: white;
  border-bottom: 1px solid var(--admin-border);
  padding: var(--space-md) var(--space-xl);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  flex-wrap: wrap;
}
.admin-topbar__title { font-family: var(--font-display); font-size: 1.4rem; font-weight: 700; }
.admin-topbar__sub { font-size: 0.85rem; color: var(--admin-muted); }
.admin-content { padding: var(--space-xl); }

/* ============== Provisional banner ============== */
.provisional-banner {
  background: #FEF3C7;
  border-bottom: 1px solid #FDE68A;
  color: #78350F;
  padding: 8px var(--space-xl);
  font-size: 0.82rem;
  text-align: center;
  font-weight: 500;
}
.provisional-banner strong { color: #78350F; }

/* ============== Cards ============== */
.admin-card {
  background: white;
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  padding: var(--space-lg);
}
.admin-card__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-md);
  margin-bottom: var(--space-md);
  flex-wrap: wrap;
}
.admin-card__title { font-size: 1.1rem; font-weight: 700; font-family: var(--font-display); }

/* Stats grid */
.stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: var(--space-md);
  margin-bottom: var(--space-xl);
}
.stat {
  background: white;
  border: 1px solid var(--admin-border);
  border-radius: 14px;
  padding: var(--space-lg);
  position: relative;
  overflow: hidden;
}
.stat__icon {
  width: 44px; height: 44px;
  border-radius: 12px;
  display: grid; place-items: center;
  margin-bottom: var(--space-sm);
}
.stat__label { font-size: 0.82rem; color: var(--admin-muted); margin-bottom: 4px; font-weight: 500; }
.stat__value { font-family: var(--font-display); font-size: 1.8rem; font-weight: 700; line-height: 1; }
.stat__delta { font-size: 0.78rem; margin-top: 4px; }
.stat__delta.up { color: var(--admin-success); }
.stat__delta.down { color: var(--admin-danger); }

.stat--turquesa .stat__icon { background: rgba(0,201,177,0.12); color: var(--turquesa-dark); }
.stat--rosa .stat__icon { background: rgba(255,107,138,0.12); color: var(--rosa-dark); }
.stat--coragem .stat__icon { background: rgba(255,122,47,0.12); color: var(--coragem); }
.stat--brilha .stat__icon { background: rgba(255,215,0,0.18); color: #B59A00; }

/* ============== Tabela ============== */
.admin-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  border-radius: 12px;
  overflow: hidden;
}
.admin-table thead {
  background: #F8F9FB;
}
.admin-table th {
  text-align: left;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.1em;
  color: var(--admin-muted);
  font-weight: 600;
  padding: 12px 16px;
  border-bottom: 1px solid var(--admin-border);
}
.admin-table td {
  padding: 14px 16px;
  border-bottom: 1px solid var(--admin-border);
  font-size: 0.92rem;
  vertical-align: middle;
}
.admin-table tbody tr:last-child td { border-bottom: 0; }
.admin-table tbody tr:hover { background: #FAFAFA; }
.admin-table .user-cell {
  display: flex; align-items: center; gap: 10px;
}
.admin-table .user-cell .avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--turquesa), var(--rosa));
  color: white;
  display: grid; place-items: center;
  font-weight: 700;
  font-size: 0.85rem;
  font-family: var(--font-display);
}

/* Badges */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 9999px;
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.04em;
}
.badge.role-owner { background: #DBEAFE; color: #1E40AF; }
.badge.role-admin { background: #E0E7FF; color: #4338CA; }
.badge.role-employee { background: #F4F4F4; color: #404040; }
.badge.status-active { background: #DCFCE7; color: #15803D; }
.badge.status-inactive { background: #F4F4F4; color: var(--admin-muted); }

/* Botões admin */
.btn-admin {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 16px;
  border-radius: 9px;
  font-weight: 600;
  font-size: 0.88rem;
  cursor: pointer;
  border: 0;
  transition: all 150ms;
  font-family: inherit;
}
.btn-admin.primary {
  background: var(--turquesa-dark);
  color: white;
}
.btn-admin.primary:hover { background: var(--turquesa); }
.btn-admin.ghost {
  background: white;
  color: var(--admin-text);
  border: 1px solid var(--admin-border);
}
.btn-admin.ghost:hover { border-color: var(--admin-text); }
.btn-admin.danger {
  background: #FEE2E2;
  color: var(--admin-danger);
}
.btn-admin.danger:hover { background: var(--admin-danger); color: white; }
.btn-admin.icon { padding: 8px; width: 34px; height: 34px; justify-content: center; }
.btn-admin.icon svg { width: 16px; height: 16px; }

/* ============== Permission grid ============== */
.perm-grid {
  display: grid;
  grid-template-columns: 1.5fr repeat(3, 1fr);
  gap: 1px;
  background: var(--admin-border);
  border: 1px solid var(--admin-border);
  border-radius: 12px;
  overflow: hidden;
  font-size: 0.88rem;
}
.perm-grid > div {
  background: white;
  padding: 12px 14px;
}
.perm-grid > .perm-head {
  background: #F8F9FB;
  font-weight: 600;
  font-size: 0.78rem;
  color: var(--admin-muted);
  text-transform: uppercase;
  letter-spacing: 0.08em;
}
.perm-grid label {
  display: flex;
  align-items: center;
  gap: 6px;
  cursor: pointer;
  font-size: 0.85rem;
}
.perm-grid input[type="radio"] { accent-color: var(--turquesa-dark); }

/* ============== Modal admin ============== */
.admin-modal-back {
  position: fixed; inset: 0;
  background: rgba(0,0,0,0.5);
  display: none;
  align-items: center; justify-content: center;
  z-index: 100;
  padding: var(--space-md);
}
.admin-modal-back.is-open { display: flex; }
.admin-modal {
  background: white;
  border-radius: 16px;
  padding: var(--space-xl);
  max-width: 640px;
  width: 100%;
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
  box-shadow: 0 20px 50px rgba(0,0,0,0.3);
}
.admin-modal__head {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: var(--space-lg);
}
.admin-modal__head h3 { font-family: var(--font-display); font-size: 1.3rem; }
.admin-modal__body { display: flex; flex-direction: column; gap: var(--space-md); }
.admin-modal__footer {
  margin-top: var(--space-lg);
  padding-top: var(--space-md);
  border-top: 1px solid var(--admin-border);
  display: flex;
  gap: var(--space-sm);
  justify-content: flex-end;
}

/* ============== Toast ============== */
.toast {
  position: fixed;
  bottom: 20px; right: 20px;
  background: var(--preto);
  color: white;
  padding: 14px 20px;
  border-radius: 10px;
  font-size: 0.92rem;
  z-index: 200;
  display: flex; align-items: center; gap: 10px;
  box-shadow: 0 10px 30px rgba(0,0,0,0.25);
  transform: translateY(100px);
  opacity: 0;
  transition: all 250ms;
}
.toast.is-visible { transform: translateY(0); opacity: 1; }
.toast.success { background: var(--admin-success); }
.toast.error { background: var(--admin-danger); }

/* ============== Empty state ============== */
.empty {
  text-align: center;
  padding: var(--space-2xl);
  color: var(--admin-muted);
}
.empty svg { width: 64px; height: 64px; margin: 0 auto var(--space-md); opacity: 0.5; }

/* ============== Mobile back ============== */
@media (max-width: 900px) {
  .admin-mobile-bar {
    display: flex;
    background: var(--admin-sidebar);
    color: white;
    padding: 12px var(--space-md);
    align-items: center;
    gap: 10px;
  }
  .admin-mobile-bar img { height: 28px; filter: brightness(0) invert(1); }
}
@media (min-width: 901px) {
  .admin-mobile-bar { display: none; }
}
