/* Envato License Manager - Admin UI styles (plain CSS, no Tailwind build required) */

:root {
  --background: #f8fafc;
  --foreground: #0f172a;
  --card: #ffffff;
  --card-foreground: #0f172a;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-foreground: #ffffff;
  --muted: #f1f5f9;
  --muted-foreground: #64748b;
  --border: #e2e8f0;
  --success: #16a34a;
  --success-bg: #dcfce7;
  --success-text: #166534;
  --danger: #dc2626;
  --danger-bg: #fee2e2;
  --danger-text: #991b1b;
  --warning-bg: #fef9c3;
  --warning-text: #854d0e;
  --radius: 0.5rem;
  --shadow: 0 1px 2px 0 rgb(0 0 0 / 0.05);
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--background);
  color: var(--foreground);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

a {
  color: inherit;
  text-decoration: none;
}

/* Layout */
.app-shell {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  width: 16rem;
  background: var(--card);
  border-right: 1px solid var(--border);
  transform: translateX(-100%);
  transition: transform 0.2s ease;
  display: flex;
  flex-direction: column;
}

.sidebar.open {
  transform: translateX(0);
}

@media (min-width: 1024px) {
  .sidebar {
    position: static;
    transform: translateX(0);
  }
}

.sidebar-brand {
  height: 4rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0 1.5rem;
  border-bottom: 1px solid var(--border);
  font-weight: 600;
  font-size: 0.95rem;
}

.sidebar-brand svg {
  color: var(--primary);
  flex-shrink: 0;
}

.sidebar-nav {
  padding: 1rem;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.625rem 0.75rem;
  border-radius: var(--radius);
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  transition: background 0.15s, color 0.15s;
}

.nav-link:hover {
  background: var(--muted);
  color: var(--foreground);
}

.nav-link.active {
  background: var(--primary);
  color: var(--primary-foreground);
}

.nav-link svg {
  width: 1rem;
  height: 1rem;
  flex-shrink: 0;
}

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  z-index: 30;
  background: rgb(0 0 0 / 0.5);
}

.sidebar-overlay.show {
  display: block;
}

@media (min-width: 1024px) {
  .sidebar-overlay {
    display: none !important;
  }
}

.main-column {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  height: 4rem;
  background: var(--card);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 1rem;
}

@media (min-width: 1024px) {
  .topbar {
    padding: 0 1.5rem;
  }
}

.topbar-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.topbar-title {
  font-size: 1.125rem;
  font-weight: 600;
}

.topbar-right {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.user-name {
  display: none;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

@media (min-width: 640px) {
  .user-name {
    display: inline;
  }
}

.main-content {
  flex: 1;
  padding: 1rem;
  overflow: auto;
}

@media (min-width: 1024px) {
  .main-content {
    padding: 1.5rem;
  }
}

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.5rem;
  font-weight: 700;
  letter-spacing: -0.025em;
  margin: 0 0 0.25rem;
}

.page-subtitle {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin: 0;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  height: 2.25rem;
  padding: 0 1rem;
  font-size: 0.875rem;
  font-weight: 500;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  background: var(--card);
  color: var(--foreground);
  cursor: pointer;
  transition: background 0.15s;
}

.btn:hover {
  background: var(--muted);
}

.btn svg,
.menu-btn svg {
  width: 1rem;
  height: 1rem;
}

.btn-primary {
  background: var(--primary);
  border-color: var(--primary);
  color: var(--primary-foreground);
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-icon {
  width: 2.25rem;
  padding: 0;
}

.menu-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.25rem;
  height: 2.25rem;
  border: none;
  background: transparent;
  border-radius: var(--radius);
  cursor: pointer;
  color: var(--foreground);
}

.menu-btn:hover {
  background: var(--muted);
}

@media (min-width: 1024px) {
  .menu-btn {
    display: none;
  }
}

/* Cards */
.card {
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
}

.card-header {
  padding: 1.5rem;
  border-bottom: 1px solid var(--border);
}

.card-header-flex {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

@media (min-width: 640px) {
  .card-header-flex {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.card-title {
  font-size: 1rem;
  font-weight: 600;
  margin: 0;
}

.card-desc {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin: 0.25rem 0 0;
}

.card-body {
  padding: 1.5rem;
}

.card-body-flush {
  padding: 0;
}

/* Stats grid */
.stats-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .stats-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .stats-grid {
    grid-template-columns: repeat(4, 1fr);
  }
}

.stat-card {
  padding: 1.5rem;
}

.stat-card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.5rem;
}

.stat-card-label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--muted-foreground);
  margin: 0;
}

.stat-card-icon {
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
}

.stat-card-value {
  font-size: 1.875rem;
  font-weight: 700;
  line-height: 1;
  margin: 0;
}

.stat-card-value.success { color: var(--success); }
.stat-card-value.danger { color: var(--danger); }

/* Dashboard grid */
.dashboard-grid {
  display: grid;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .dashboard-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* Chart */
.chart-bar {
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 0.5rem;
  height: 12rem;
}

.chart-col {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.chart-stack {
  width: 100%;
  height: 10rem;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  gap: 2px;
}

.bar-activated {
  width: 100%;
  background: #22c55e;
  border-radius: 4px 4px 0 0;
  min-height: 0;
  transition: height 0.3s;
}

.bar-failed {
  width: 100%;
  background: #f87171;
  border-radius: 4px 4px 0 0;
  min-height: 0;
  transition: height 0.3s;
}

.chart-label {
  font-size: 0.625rem;
  color: var(--muted-foreground);
}

.chart-legend {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.legend-dot {
  display: inline-block;
  width: 0.75rem;
  height: 0.75rem;
  border-radius: 2px;
  margin-right: 0.25rem;
  vertical-align: middle;
}

.legend-dot.green { background: #22c55e; }
.legend-dot.red { background: #f87171; }

/* Activity list */
.activity-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.activity-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  padding-bottom: 0.75rem;
  border-bottom: 1px solid var(--border);
}

.activity-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

@media (min-width: 640px) {
  .activity-item {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.activity-main p {
  margin: 0;
}

.activity-title {
  font-size: 0.875rem;
  font-weight: 500;
}

.activity-meta {
  font-size: 0.75rem;
  color: var(--muted-foreground);
}

.activity-side {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  flex-shrink: 0;
}

.activity-time {
  font-size: 0.75rem;
  color: var(--muted-foreground);
  white-space: nowrap;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  border-radius: 9999px;
  padding: 0.125rem 0.625rem;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1.25;
}

.badge-success {
  background: var(--success-bg);
  color: var(--success-text);
}

.badge-danger {
  background: var(--danger-bg);
  color: var(--danger-text);
}

.badge-warning {
  background: var(--warning-bg);
  color: var(--warning-text);
}

/* Forms */
.form-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: 1fr;
}

@media (min-width: 640px) {
  .form-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

@media (min-width: 1024px) {
  .form-grid.cols-5 {
    grid-template-columns: repeat(5, 1fr);
  }
}

.form-group label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  margin-bottom: 0.375rem;
}

.input,
.select {
  width: 100%;
  height: 2.5rem;
  padding: 0 0.75rem;
  font-size: 0.875rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  background: var(--card);
  color: var(--foreground);
}

.input:focus,
.select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgb(37 99 235 / 0.15);
}

.search-wrap {
  position: relative;
  width: 100%;
  max-width: 16rem;
}

.search-wrap svg {
  position: absolute;
  left: 0.75rem;
  top: 50%;
  transform: translateY(-50%);
  width: 1rem;
  height: 1rem;
  color: var(--muted-foreground);
  pointer-events: none;
}

.search-wrap .input {
  padding-left: 2.25rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
}

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.875rem;
}

.data-table th {
  text-align: left;
  padding: 0.75rem 1rem;
  border-bottom: 1px solid var(--border);
  font-weight: 500;
  color: var(--muted-foreground);
  white-space: nowrap;
}

.data-table th.text-right,
.data-table td.text-right {
  text-align: right;
}

.data-table td {
  padding: 1rem;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.data-table tbody tr {
  transition: background 0.15s;
}

.data-table tbody tr:hover {
  background: var(--muted);
}

.data-table tbody tr.clickable {
  cursor: pointer;
}

.data-table .mono {
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, monospace;
  font-size: 0.75rem;
}

.data-table .truncate {
  max-width: 200px;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.text-green { color: var(--success); }
.text-red { color: var(--danger); }

/* Pagination */
.pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border);
}

.pagination-info {
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

.pagination-actions {
  display: flex;
  gap: 0.5rem;
}

/* Page actions row */
.page-actions {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

@media (min-width: 640px) {
  .page-actions {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
  }
}

.empty-state {
  text-align: center;
  padding: 2rem 1rem;
  font-size: 0.875rem;
  color: var(--muted-foreground);
}

/* Login page */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  background: var(--background);
}

.login-card {
  width: 100%;
  max-width: 28rem;
  background: var(--card);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  padding: 2rem;
}

.login-header {
  text-align: center;
  margin-bottom: 1.5rem;
}

.login-icon {
  width: 3rem;
  height: 3rem;
  margin: 0 auto 0.75rem;
  display: flex;
  align-items: center;
  justify-content: center;
  background: rgb(37 99 235 / 0.1);
  border-radius: 9999px;
  color: var(--primary);
}

.login-header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  margin: 0 0 0.25rem;
}

.login-header p {
  font-size: 0.875rem;
  color: var(--muted-foreground);
  margin: 0;
}

.alert-error {
  padding: 0.75rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  background: var(--danger-bg);
  color: var(--danger-text);
  border: 1px solid #fecaca;
  border-radius: var(--radius);
}

.login-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.login-form .btn-primary {
  width: 100%;
  height: 2.5rem;
}

@media (max-width: 639px) {
  .topbar-right .btn span,
  .topbar-right .btn {
    font-size: 0;
    gap: 0;
    width: 2.25rem;
    padding: 0;
  }

  .topbar-right .btn svg {
    margin: 0;
  }
}
