/* ==============================
   Alanis Central de Vendas
   Design System — Alanis Branded
   ============================== */

/* ---------- Variables ---------- */
:root {
  /* Alanis Colors */
  --bg-primary: #1a1a1a;
  --bg-secondary: #1f1f1f;
  --bg-card: #262626;
  --bg-card-hover: #2e2e2e;
  --bg-input: #222222;
  --bg-sidebar: #1a1a1a;

  --text-primary: #ffffff;
  --text-secondary: #a3a3a3;
  --text-muted: #737373;

  --border-color: #333333;
  --border-light: #404040;

  --accent-primary: #04ffc2;
  --accent-primary-hover: #03dcb5;
  --accent-primary-glow: rgba(4, 255, 194, 0.12);
  --accent-primary-text: #000000;

  --color-green: #04ffc2;
  --color-green-bg: rgba(4, 255, 194, 0.1);
  --color-red: #ff4d6a;
  --color-red-bg: rgba(255, 77, 106, 0.1);
  --color-yellow: #ffbe0b;
  --color-yellow-bg: rgba(255, 190, 11, 0.1);
  --color-blue: #38bdf8;
  --color-blue-bg: rgba(56, 189, 248, 0.1);
  --color-purple: #a78bfa;
  --color-purple-bg: rgba(167, 139, 250, 0.1);
  --color-cyan: #22d3ee;
  --color-cyan-bg: rgba(34, 211, 238, 0.1);
  --color-orange: #fb923c;
  --color-orange-bg: rgba(251, 146, 60, 0.1);

  /* Spacing */
  --sidebar-width: 260px;
  --radius: 10px;
  --radius-sm: 6px;
  --radius-lg: 14px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  background: var(--bg-primary);
  color: var(--text-primary);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  font-size: 14px;
}

a {
  color: var(--accent-primary);
  text-decoration: none;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 8px;
  height: 8px;
}

::-webkit-scrollbar-track {
  background: var(--bg-primary);
}

::-webkit-scrollbar-thumb {
  background: var(--border-color);
  border-radius: 4px;
}

::-webkit-scrollbar-thumb:hover {
  background: var(--accent-primary);
}

/* ---------- App Layout ---------- */
.app-container {
  display: flex;
  min-height: 100vh;
}

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

.sidebar-brand {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 20px;
  border-bottom: 1px solid var(--border-color);
}

.brand-logo {
  width: 80%;
  height: auto;
  object-fit: contain;
  display: block;
}

.brand-logo.large {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: var(--accent-primary);
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 800;
  font-size: 16px;
  color: var(--accent-primary-text);
  flex-shrink: 0;
}

.brand-icon.large {
  width: 56px;
  height: 56px;
  font-size: 24px;
  border-radius: var(--radius);
}

.brand-text {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-weight: 700;
  font-size: 16px;
  color: var(--text-primary);
}

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

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

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

.nav-item.active {
  background: var(--accent-primary-glow);
  color: var(--accent-primary);
}

.nav-item svg {
  flex-shrink: 0;
  stroke-width: 1.5;
}

.sidebar-footer {
  padding: 16px;
  border-top: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.admin-info {
  display: flex;
  align-items: center;
  gap: 10px;
  overflow: hidden;
}

.admin-avatar {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  background: var(--bg-card);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
  color: var(--text-secondary);
}

.admin-email {
  font-size: 12px;
  color: var(--text-muted);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 140px;
}

.logout-btn {
  color: var(--text-muted);
  padding: 6px;
  border-radius: var(--radius-sm);
  transition: all 0.15s;
}

.logout-btn:hover {
  color: var(--color-red);
  background: var(--color-red-bg);
}

/* ---------- Main Content ---------- */
.main-content {
  flex: 1;
  margin-left: var(--sidebar-width);
  padding: 32px;
  min-height: 100vh;
}

/* ---------- Page Header ---------- */
.page-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 28px;
}

.page-header h1 {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

.subtitle {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.page-header-right {
  display: flex;
  gap: 8px;
}

/* ---------- Stats Grid ---------- */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  padding: 20px;
  display: flex;
  align-items: flex-start;
  gap: 16px;
  transition: all 0.2s ease;
}

.stat-card:hover {
  border-color: var(--border-light);
  transform: translateY(-2px);
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.4);
}

.stat-icon {
  width: 44px;
  height: 44px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.stat-icon svg {
  stroke-width: 1.5;
}

.stat-active .stat-icon {
  background: var(--color-green-bg);
  color: var(--color-green);
}

.stat-revenue .stat-icon {
  background: var(--color-purple-bg);
  color: var(--color-purple);
}

.stat-approved .stat-icon {
  background: var(--color-blue-bg);
  color: var(--color-blue);
}

.stat-pix .stat-icon {
  background: var(--color-cyan-bg);
  color: var(--color-cyan);
}

.stat-refused .stat-icon {
  background: var(--color-red-bg);
  color: var(--color-red);
}

.stat-refund .stat-icon {
  background: var(--color-orange-bg);
  color: var(--color-orange);
}

.stat-chargeback .stat-icon {
  background: var(--color-yellow-bg);
  color: var(--color-yellow);
}

.stat-info {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
  line-height: 1.2;
}

.stat-label {
  font-size: 12px;
  color: var(--text-muted);
  font-weight: 500;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  margin-top: 4px;
}

/* ---------- Cards ---------- */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
}

.card-header h2 {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 16px;
  font-weight: 600;
}

.card-body {
  padding: 0;
}

.chart-card .card-body {
  padding: 20px;
}

.settings-card .card-body {
  padding: 22px;
}

/* ---------- Tables ---------- */
.table-responsive {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.data-table thead th {
  text-align: left;
  padding: 12px 18px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.data-table tbody td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

.data-table tbody tr:last-child td {
  border-bottom: none;
}

.data-table tbody tr:hover {
  background: var(--bg-card-hover);
}

.cell-main {
  font-weight: 500;
}

.cell-sub {
  font-size: 12px;
  color: var(--text-muted);
  margin-top: 2px;
}

.empty-state {
  text-align: center;
  color: var(--text-muted);
  padding: 40px 18px !important;
  font-style: italic;
}

/* ---------- Badges ---------- */
.badge {
  display: inline-block;
  padding: 4px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  white-space: nowrap;
}

.badge-compra_aprovada {
  background: var(--color-green-bg);
  color: var(--color-green);
}

.badge-compra_recusada {
  background: var(--color-red-bg);
  color: var(--color-red);
}

.badge-pix_gerado {
  background: var(--color-cyan-bg);
  color: var(--color-cyan);
}

.badge-reembolso {
  background: var(--color-orange-bg);
  color: var(--color-orange);
}

.badge-chargeback {
  background: var(--color-yellow-bg);
  color: var(--color-yellow);
}

.badge-buyer-active {
  background: var(--color-green-bg);
  color: var(--color-green);
}

.badge-buyer-refunded {
  background: var(--color-orange-bg);
  color: var(--color-orange);
}

.badge-buyer-chargeback {
  background: var(--color-red-bg);
  color: var(--color-red);
}

.badge-license-active {
  background: var(--color-green-bg);
  color: var(--color-green);
}

.badge-license-suspended {
  background: var(--color-yellow-bg);
  color: var(--color-yellow);
}

.badge-license-cancelled {
  background: var(--color-red-bg);
  color: var(--color-red);
}

.badge-license-expired {
  background: var(--color-orange-bg);
  color: var(--color-orange);
}

/* ---------- Buttons ---------- */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 18px;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  background: var(--bg-card);
  color: var(--text-primary);
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s ease;
  font-family: inherit;
  text-decoration: none;
}

.btn:hover {
  border-color: var(--border-light);
  background: var(--bg-card-hover);
}

.btn-primary {
  background: var(--accent-primary);
  border-color: var(--accent-primary);
  color: var(--accent-primary-text);
  font-weight: 600;
}

.btn-primary:hover {
  background: var(--accent-primary-hover);
  border-color: var(--accent-primary-hover);
  color: var(--accent-primary-text);
}

.btn-secondary {
  background: transparent;
}

.btn-sm {
  padding: 6px 12px;
  font-size: 13px;
}

.btn-ghost {
  background: transparent;
  border: none;
  padding: 6px;
  color: var(--text-muted);
}

.btn-ghost:hover {
  color: var(--accent-primary);
  background: var(--accent-primary-glow);
}

.btn-full {
  width: 100%;
  justify-content: center;
}

/* ---------- Forms ---------- */
.form-group {
  margin-bottom: 18px;
}

.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.form-input,
.form-select {
  width: 100%;
  padding: 10px 14px;
  background: var(--bg-input);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  color: var(--text-primary);
  font-size: 14px;
  font-family: inherit;
  transition: border-color 0.15s;
}

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

.form-input::placeholder {
  color: var(--text-muted);
}

.form-select {
  cursor: pointer;
  appearance: none;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%23737373' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='M6 8l4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 10px center;
  background-repeat: no-repeat;
  background-size: 18px;
  padding-right: 36px;
}

.form-help {
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

/* ---------- Filters ---------- */
.filters-bar {
  margin-bottom: 18px;
}

.filters-form {
  display: flex;
  gap: 12px;
  align-items: center;
  flex-wrap: wrap;
}

.filter-group {
  flex-shrink: 0;
}

.filter-search {
  display: flex;
  gap: 8px;
  flex: 1;
  min-width: 250px;
}

.filter-search .form-input {
  flex: 1;
}

.results-count {
  margin-bottom: 12px;
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Pagination ---------- */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 20px 0;
}

.page-info {
  font-size: 13px;
  color: var(--text-muted);
}

/* ---------- Alerts ---------- */
.alert {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 12px 16px;
  border-radius: var(--radius-sm);
  font-size: 14px;
  margin-bottom: 18px;
}

.alert-success {
  background: var(--color-green-bg);
  color: var(--color-green);
  border: 1px solid rgba(4, 255, 194, 0.2);
}

.alert-error {
  background: var(--color-red-bg);
  color: var(--color-red);
  border: 1px solid rgba(255, 77, 106, 0.2);
}

/* ---------- Modal ---------- */
.modal {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
}

.modal-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  backdrop-filter: blur(4px);
}

.modal-content {
  position: relative;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  width: 90%;
  max-width: 640px;
  max-height: 80vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.6);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-color);
}

.modal-header h3 {
  font-size: 16px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 24px;
  cursor: pointer;
  padding: 4px;
  line-height: 1;
}

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

.modal-body {
  padding: 22px;
  overflow-y: auto;
}

.payload-pre {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 16px;
  font-size: 12px;
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  color: var(--accent-primary);
  overflow-x: auto;
  white-space: pre-wrap;
  word-break: break-all;
}

/* ---------- Settings ---------- */
.settings-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  align-items: start;
}

.settings-form {}

.settings-info {
  margin-bottom: 20px;
}

.settings-info p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.webhook-url-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
}

.webhook-url-box code {
  flex: 1;
  font-size: 13px;
  color: var(--accent-primary);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  word-break: break-all;
}

/* ---------- Login ---------- */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--bg-primary);
  background-image:
    radial-gradient(at 20% 50%, rgba(4, 255, 194, 0.06) 0%, transparent 50%),
    radial-gradient(at 80% 20%, rgba(4, 255, 194, 0.03) 0%, transparent 50%);
}

.login-container {
  width: 100%;
  max-width: 420px;
  padding: 20px;
}

.login-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 36px;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.5);
}

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

.login-brand {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.login-brand h1 {
  font-family: 'Outfit', 'Inter', sans-serif;
  font-size: 22px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.login-logo {
  width: 80%;
  max-width: 320px;
  height: auto;
  object-fit: contain;
  display: block;
  margin: 0 auto 8px;
}

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

.login-form .btn-primary {
  margin-top: 6px;
  padding: 12px;
  font-size: 15px;
}

.login-footer-text {
  text-align: center;
  color: var(--text-muted);
  font-size: 12px;
  margin-top: 24px;
}

/* ---------- Error Page ---------- */
.error-page {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 80px 20px;
  text-align: center;
}

.error-icon {
  color: var(--color-red);
  margin-bottom: 20px;
}

.error-page h1 {
  font-size: 28px;
  margin-bottom: 8px;
}

.error-page p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* ---------- License Recovery ---------- */
.recovery-results {
  margin-bottom: 20px;
  display: flex;
  flex-direction: column;
  gap: 14px;
}

.recovery-card {
  background: var(--bg-primary);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 18px;
}

.recovery-plan {
  font-weight: 600;
  font-size: 15px;
  margin-bottom: 12px;
  color: var(--accent-primary);
}

.recovery-key label {
  display: block;
  font-size: 12px;
  color: var(--text-muted);
  margin-bottom: 6px;
}

.recovery-key-box {
  display: flex;
  align-items: center;
  gap: 10px;
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-sm);
  padding: 10px 14px;
  margin-bottom: 12px;
}

.recovery-key-box code {
  flex: 1;
  font-size: 13px;
  color: var(--accent-primary);
  font-family: 'JetBrains Mono', 'Fira Code', monospace;
  word-break: break-all;
}

.recovery-status {
  margin-top: 8px;
}

.recovery-expires,
.recovery-reason {
  font-size: 13px;
  color: var(--text-secondary);
  margin-top: 6px;
}

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

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

  .main-content {
    margin-left: 0;
    padding: 20px 16px;
  }

  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters-form {
    flex-direction: column;
    align-items: stretch;
  }

  .filter-search {
    min-width: unset;
  }
}

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