/* ============================================
   SaaS Membership — Design System
   Baseado no Dynamis Painel de Membros
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --font-sans: 'Inter', system-ui, -apple-system, sans-serif;
  --font-mono: 'DM Mono', 'Fira Code', monospace;
  --font-display: 'Bebas Neue', sans-serif;
  --font-serif: 'Instrument Serif', serif;

  /* Dark theme (default) */
  --bg-primary: #0d0d0f;
  --bg-secondary: #141418;
  --bg-tertiary: #1a1a20;
  --bg-card: #1e1e26;
  --bg-hover: #25252f;

  --text-primary: #ececee;
  --text-secondary: #9a99a0;
  --text-muted: #63626b;

  --border-subtle: rgba(255, 255, 255, 0.06);
  --border-muted: rgba(255, 255, 255, 0.10);
  --border-strong: rgba(255, 255, 255, 0.18);

  --accent: #38bdf8;
  --accent-soft: rgba(56, 189, 248, 0.12);
  --accent-border: rgba(56, 189, 248, 0.40);

  --danger: #dc2626;
  --success: #22c55e;
  --warning: #f59e0b;

  --radius-sm: 6px;
  --radius-md: 10px;
  --radius-lg: 16px;

  --sidebar-width: 240px;
  --sidebar-collapsed: 64px;
}

[data-theme="light"] {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --bg-tertiary: #ebebef;
  --bg-card: #ffffff;
  --bg-hover: #e8e8ed;

  --text-primary: #1a1a20;
  --text-secondary: #63626b;
  --text-muted: #9a99a0;

  --border-subtle: rgba(0, 0, 0, 0.06);
  --border-muted: rgba(0, 0, 0, 0.10);
  --border-strong: rgba(0, 0, 0, 0.18);
}

html, body {
  font-family: var(--font-sans);
  background: var(--bg-primary);
  color: var(--text-primary);
  height: 100%;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--accent); text-decoration: none; }
button { cursor: pointer; font-family: inherit; }
input, select, textarea { font-family: inherit; font-size: inherit; }

/* --- Shell Layout --- */
.painel-shell {
  display: flex;
  height: 100vh;
  overflow: hidden;
}

.painel-main {
  flex: 1;
  overflow-y: auto;
  padding: 32px;
  margin-left: var(--sidebar-width);
  transition: margin-left 0.2s ease;
}

/* --- Sidebar --- */
.sidebar {
  position: fixed;
  left: 0;
  top: 0;
  bottom: 0;
  width: var(--sidebar-width);
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: width 0.2s ease;
}

.sidebar--collapsed {
  width: var(--sidebar-collapsed);
}

.sidebar--collapsed + .painel-main,
.sidebar--collapsed ~ .painel-main {
  margin-left: var(--sidebar-collapsed);
}

.sidebar-header {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 20px 16px;
  border-bottom: 1px solid var(--border-subtle);
}

.sidebar-logo {
  font-size: 28px;
  color: var(--accent);
}

.sidebar-title {
  font-family: var(--font-display);
  font-size: 22px;
  letter-spacing: 0.02em;
}

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

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

.sidebar-item:hover {
  background: var(--bg-hover);
  color: var(--text-primary);
}

.sidebar-item--active {
  background: var(--accent-soft);
  color: var(--accent);
}

.sidebar-item-icon {
  font-size: 20px;
  flex-shrink: 0;
}

.sidebar-item-label {
  white-space: nowrap;
  overflow: hidden;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-subtle);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sidebar-theme {
  display: flex;
  gap: 4px;
  justify-content: center;
}

.sidebar-theme-btn {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  background: none;
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  transition: all 0.15s ease;
}

.sidebar-theme-btn:hover {
  border-color: var(--border-muted);
  color: var(--text-primary);
}

.sidebar-theme-btn--active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

.sidebar-user {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px;
  border-radius: var(--radius-sm);
}

.sidebar-user-info {
  display: flex;
  flex-direction: column;
  min-width: 0;
}

.sidebar-user-name {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-user-role {
  font-size: 11px;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 13px;
  transition: all 0.15s ease;
}

.sidebar-logout:hover {
  background: rgba(220, 38, 38, 0.10);
  color: var(--danger);
}

.sidebar-mobile-toggle {
  display: none;
  position: fixed;
  top: 12px;
  left: 12px;
  z-index: 200;
  background: var(--bg-secondary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  width: 40px;
  height: 40px;
  align-items: center;
  justify-content: center;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  z-index: 99;
}

@media (max-width: 768px) {
  .sidebar {
    transform: translateX(-100%);
    transition: transform 0.2s ease;
  }

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

  .sidebar--open ~ .sidebar-overlay {
    display: block;
  }

  .painel-main {
    margin-left: 0 !important;
    padding: 24px 16px;
  }

  .sidebar-mobile-toggle {
    display: flex;
  }

  .sidebar-overlay {
    display: block;
  }
}

/* --- Avatar --- */
.avatar-img {
  border-radius: 50%;
  object-fit: cover;
}

.avatar-fallback {
  border-radius: 50%;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-muted);
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
}

/* --- Buttons --- */
.btn-primary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--accent);
  color: #0d0d0f;
  border: none;
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 600;
  transition: all 0.15s ease;
}

.btn-primary:hover { filter: brightness(1.1); }
.btn-primary:disabled { opacity: 0.5; cursor: not-allowed; }

.btn-secondary {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  background: var(--bg-tertiary);
  color: var(--text-primary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.btn-secondary:hover { background: var(--bg-hover); border-color: var(--border-muted); }

.btn-icon {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 36px;
  height: 36px;
  border-radius: var(--radius-sm);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 18px;
  transition: all 0.15s ease;
}

.btn-icon:hover { background: var(--bg-hover); color: var(--text-primary); }
.btn-icon:disabled { opacity: 0.3; cursor: not-allowed; }

.btn-icon--danger:hover { background: rgba(220, 38, 38, 0.10); color: var(--danger); border-color: rgba(220, 38, 38, 0.30); }

/* --- Page Headers --- */
.admin-page-header, .admin-form-page .admin-page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.admin-page-header h1 {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.02em;
}

/* --- Status Pills --- */
.status-pill {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 600;
}

.status-pill--active {
  background: rgba(34, 197, 94, 0.12);
  color: var(--success);
  border: 1px solid rgba(34, 197, 94, 0.30);
}

.status-pill--inactive {
  background: rgba(138, 136, 148, 0.10);
  color: var(--text-muted);
  border: 1px solid var(--border-subtle);
}

/* --- Admin Members --- */
.admin-role-section {
  margin-bottom: 32px;
}

.admin-role-title {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 12px;
}

.admin-members-table {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  overflow: hidden;
}

.admin-table-header {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 100px 120px;
  gap: 16px;
  padding: 12px 20px;
  background: var(--bg-tertiary);
  border-bottom: 1px solid var(--border-subtle);
  font-size: 12px;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.admin-table-row {
  display: grid;
  grid-template-columns: 2fr 2fr 1fr 100px 120px;
  gap: 16px;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border-subtle);
  align-items: center;
  transition: background 0.1s ease;
}

.admin-table-row:last-child { border-bottom: none; }
.admin-table-row:hover { background: var(--bg-hover); }

.admin-table-row--inactive { opacity: 0.5; }
.admin-table-row--inactive:hover { opacity: 0.7; }

.admin-member-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.admin-member-name { font-weight: 600; font-size: 14px; }
.admin-member-username { font-size: 12px; color: var(--text-muted); font-family: var(--font-mono); }

.admin-member-contact {
  display: flex;
  flex-direction: column;
  gap: 2px;
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-member-phone { color: var(--text-muted); font-size: 12px; }

.admin-member-date {
  font-size: 13px;
  color: var(--text-secondary);
}

.admin-actions {
  display: flex;
  gap: 4px;
}

/* --- Forms --- */
.admin-form-page, .preferences-page {
  max-width: 720px;
}

.admin-form, .preferences-form {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 24px;
}

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

@media (max-width: 600px) {
  .form-grid { grid-template-columns: 1fr; }
}

.form-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.form-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-field input,
.form-field select {
  padding: 10px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  transition: border-color 0.15s ease;
}

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

.form-field--checkbox {
  flex-direction: row;
  align-items: center;
  gap: 8px;
}

.form-field--checkbox label {
  display: flex;
  align-items: center;
  gap: 8px;
  cursor: pointer;
}

.form-field--checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--accent);
}

.form-actions {
  margin-top: 20px;
  display: flex;
  gap: 10px;
}

.form-errors {
  margin-bottom: 16px;
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.20);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.form-error {
  color: var(--danger);
  font-size: 13px;
}

.form-success {
  margin-bottom: 16px;
  background: rgba(34, 197, 94, 0.08);
  border: 1px solid rgba(34, 197, 94, 0.20);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--success);
  font-size: 13px;
}

/* --- Preferences --- */
.preferences-page h1 {
  font-family: var(--font-display);
  font-size: 28px;
  letter-spacing: 0.02em;
  margin-bottom: 24px;
}

.preferences-page h3 {
  font-size: 16px;
  font-weight: 600;
  margin: 24px 0 12px;
  color: var(--text-primary);
}

.preferences-avatar-section {
  display: flex;
  align-items: center;
  gap: 16px;
  margin-bottom: 24px;
  padding: 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
}

.preferences-theme {
  display: flex;
  gap: 8px;
}

.preferences-theme-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  border-radius: var(--radius-md);
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  color: var(--text-secondary);
  font-size: 14px;
  font-weight: 500;
  transition: all 0.15s ease;
}

.preferences-theme-btn:hover { border-color: var(--border-muted); color: var(--text-primary); }

.preferences-theme-btn--active {
  background: var(--accent-soft);
  border-color: var(--accent-border);
  color: var(--accent);
}

/* --- Login Page --- */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background: var(--bg-primary);
}

.login-card {
  width: 100%;
  max-width: 400px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  padding: 40px 32px;
}

.login-header {
  text-align: center;
  margin-bottom: 28px;
}

.login-icon {
  font-size: 48px;
  color: var(--accent);
  margin-bottom: 12px;
}

.login-header h1 {
  font-family: var(--font-display);
  font-size: 26px;
  letter-spacing: 0.02em;
  margin-bottom: 4px;
}

.login-header p {
  font-size: 14px;
  color: var(--text-secondary);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.login-field {
  display: flex;
  flex-direction: column;
  gap: 6px;
}

.login-field label {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.login-field input {
  padding: 12px 14px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 15px;
  transition: border-color 0.15s ease;
}

.login-field input:focus {
  outline: none;
  border-color: var(--accent-border);
}

.login-error {
  background: rgba(220, 38, 38, 0.08);
  border: 1px solid rgba(220, 38, 38, 0.20);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  color: var(--danger);
  font-size: 13px;
  text-align: center;
}

.login-btn {
  padding: 12px;
  background: var(--accent);
  color: #0d0d0f;
  border: none;
  border-radius: var(--radius-md);
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: filter 0.15s ease;
  margin-top: 4px;
}

.login-btn:hover { filter: brightness(1.1); }
.login-btn:disabled { opacity: 0.5; cursor: not-allowed; }

/* --- Biblioteca --- */
.biblioteca-page {
  max-width: 960px;
}

.biblioteca-page .admin-page-header {
  margin-bottom: 20px;
}

.biblioteca-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.biblioteca-search span {
  color: var(--text-muted);
  font-size: 20px;
}

.biblioteca-search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.biblioteca-cat-filter {
  padding: 6px 10px;
  background: var(--bg-tertiary);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 13px;
}

.biblioteca-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
  gap: 10px;
}

.biblioteca-card {
  display: flex;
  align-items: flex-start;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  transition: all 0.15s ease;
}

.biblioteca-card:hover {
  border-color: var(--border-muted);
  background: var(--bg-hover);
}

.biblioteca-card-icon {
  font-size: 28px;
  color: var(--accent);
  flex-shrink: 0;
  margin-top: 2px;
}

.biblioteca-card-body {
  display: flex;
  flex-direction: column;
  gap: 3px;
  min-width: 0;
  flex: 1;
}

.biblioteca-card-titulo {
  font-size: 14px;
  font-weight: 600;
}

.biblioteca-card-meta {
  font-size: 11px;
  color: var(--text-muted);
  font-family: var(--font-mono);
}

.biblioteca-card-desc {
  font-size: 12px;
  color: var(--text-secondary);
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.biblioteca-card-tags {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 4px;
}

.biblioteca-tag {
  font-size: 10px;
  padding: 2px 8px;
  background: var(--accent-soft);
  color: var(--accent);
  border-radius: 10px;
  font-weight: 500;
}

.biblioteca-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.biblioteca-preview-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 32px;
}

.biblioteca-preview {
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.biblioteca-preview-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-subtle);
  font-size: 14px;
  font-weight: 600;
}

.biblioteca-preview-frame {
  flex: 1;
  min-height: 500px;
  border: none;
}

@media (max-width: 768px) {
  .biblioteca-grid {
    grid-template-columns: 1fr;
  }
  .biblioteca-card-actions {
    display: none;
  }
  .biblioteca-card:hover .biblioteca-card-actions {
    display: flex;
  }
}
.links-page {
  max-width: 960px;
}

.links-page .admin-page-header {
  margin-bottom: 20px;
}

.links-search {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  margin-bottom: 24px;
}

.links-search span {
  color: var(--text-muted);
  font-size: 20px;
}

.links-search input {
  flex: 1;
  background: none;
  border: none;
  color: var(--text-primary);
  font-size: 14px;
  outline: none;
}

.links-categoria {
  margin-bottom: 32px;
}

.links-categoria-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 14px;
}

.links-categoria-icon {
  font-size: 24px;
  color: var(--accent);
}

.links-categoria-nome {
  font-size: 18px;
  font-weight: 600;
  flex: 1;
}

.links-actions {
  display: flex;
  gap: 4px;
}

.links-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 10px;
}

.links-card {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 14px 16px;
  background: var(--bg-card);
  border: 1px solid var(--border-subtle);
  border-radius: var(--radius-md);
  text-decoration: none;
  color: var(--text-primary);
  transition: all 0.15s ease;
}

.links-card:hover {
  border-color: var(--accent-border);
  background: var(--bg-hover);
}

.links-card-icon {
  font-size: 24px;
  color: var(--accent);
  flex-shrink: 0;
}

.links-card-body {
  display: flex;
  flex-direction: column;
  gap: 2px;
  min-width: 0;
  flex: 1;
}

.links-card-titulo {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.links-card-desc {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.links-card-actions {
  display: flex;
  gap: 2px;
  flex-shrink: 0;
}

.links-form {
  background: var(--bg-card);
  border: 1px solid var(--accent-border);
  border-radius: var(--radius-lg);
  padding: 24px;
  margin-bottom: 24px;
}

.links-form h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 16px;
}

.links-empty,
.links-empty-cat {
  color: var(--text-muted);
  font-size: 14px;
  padding: 12px 0;
}

.links-empty-cat {
  padding: 6px 0 12px;
}

/* --- Responsive tweaks --- */
@media (max-width: 768px) {
  .links-grid {
    grid-template-columns: 1fr;
  }

  .links-card-actions {
    display: none;
  }

  .links-card:hover .links-card-actions {
    display: flex;
  }
}
::-webkit-scrollbar { width: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--border-muted); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: var(--border-strong); }
