:root {
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --secondary: #475569;
  --success: #10b981;
  --success-bg: #ecfdf5;
  --warning: #f59e0b;
  --warning-bg: #fffbeb;
  --danger: #ef4444;
  --danger-bg: #fef2f2;
  --info: #06b6d4;
  --info-bg: #ecfeff;
  --bg-main: #f8fafc;
  --bg-card: #ffffff;
  --border-color: #e2e8f0;
  --text-main: #0f172a;
  --text-muted: #64748b;
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --radius-md: 10px;
  --radius-lg: 16px;
  --transition: all 0.2s ease-in-out;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
  font-family: 'Segoe UI', system-ui, -apple-system, BlinkMacSystemFont, Roboto, sans-serif;
}

body {
  background-color: var(--bg-main);
  color: var(--text-main);
  line-height: 1.5;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

/* Header */
.admin-header {
  background: var(--bg-card);
  border-bottom: 1px solid var(--border-color);
  padding: 1rem 2rem;
  position: sticky;
  top: 0;
  z-index: 40;
  box-shadow: var(--shadow-sm);
}

.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
}

.logo-section {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-badge {
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, #2563eb, #38bdf8);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 1.25rem;
  font-weight: bold;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.logo-subtitle {
  font-size: 0.8rem;
  color: var(--text-muted);
  font-weight: normal;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

/* Container */
.admin-container {
  max-width: 1400px;
  width: 100%;
  margin: 1.5rem auto;
  padding: 0 1.5rem;
  flex: 1;
}

/* Metrics Overview */
.metrics-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(240px, 1fr));
  gap: 1.25rem;
  margin-bottom: 1.5rem;
}

.metric-card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  padding: 1.25rem;
  box-shadow: var(--shadow-sm);
  display: flex;
  align-items: center;
  gap: 1rem;
  transition: var(--transition);
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
}

.metric-icon {
  width: 52px;
  height: 52px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  flex-shrink: 0;
}

.metric-icon.blue { background: #dbeafe; color: #1e40af; }
.metric-icon.green { background: #dcfce7; color: #166534; }
.metric-icon.purple { background: #f3e8ff; color: #6b21a8; }
.metric-icon.amber { background: #fef3c7; color: #92400e; }

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

.metric-label {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 500;
}

.metric-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--text-main);
}

.metric-sub {
  font-size: 0.75rem;
  color: var(--text-muted);
}

/* Tabs Navigation */
.tabs-nav {
  display: flex;
  gap: 0.5rem;
  border-bottom: 2px solid var(--border-color);
  margin-bottom: 1.5rem;
  overflow-x: auto;
}

.tab-btn {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--text-muted);
  cursor: pointer;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  transition: var(--transition);
  white-space: nowrap;
}

.tab-btn:hover {
  color: var(--primary);
  background: rgba(37, 99, 235, 0.04);
  border-radius: 8px 8px 0 0;
}

.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
}

.tab-count {
  font-size: 0.75rem;
  background: #e2e8f0;
  color: #475569;
  padding: 2px 8px;
  border-radius: 999px;
}

.tab-btn.active .tab-count {
  background: var(--primary);
  color: white;
}

/* Card Section */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  padding: 1.25rem 1.5rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  border-bottom: 1px solid var(--border-color);
  background: #fafbfc;
}

.card-title-group h2 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text-main);
}

.card-title-group p {
  font-size: 0.85rem;
  color: var(--text-muted);
}

.card-toolbar {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-wrap: wrap;
}

.search-box {
  position: relative;
  min-width: 220px;
}

.search-box input {
  width: 100%;
  padding: 0.5rem 0.75rem 0.5rem 2rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.875rem;
  outline: none;
  transition: var(--transition);
}

.search-box input:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.search-icon {
  position: absolute;
  left: 0.65rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-muted);
  font-size: 0.9rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  padding: 0.5rem 1rem;
  font-size: 0.875rem;
  font-weight: 600;
  border-radius: var(--radius-md);
  border: 1px solid transparent;
  cursor: pointer;
  transition: var(--transition);
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-hover);
}

.btn-outline {
  background: white;
  border-color: var(--border-color);
  color: var(--text-main);
}

.btn-outline:hover {
  background: #f1f5f9;
  border-color: #cbd5e1;
}

.btn-danger-outline {
  background: white;
  border-color: #fca5a5;
  color: var(--danger);
}

.btn-danger-outline:hover {
  background: var(--danger-bg);
}

.btn-sm {
  padding: 0.35rem 0.65rem;
  font-size: 0.8rem;
}

.btn-icon-only {
  width: 32px;
  height: 32px;
  padding: 0;
  border-radius: 8px;
}

/* Table Styles */
.table-responsive {
  width: 100%;
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
  font-size: 0.875rem;
}

th {
  background: #f8fafc;
  color: var(--text-muted);
  font-weight: 600;
  padding: 0.85rem 1rem;
  border-bottom: 1px solid var(--border-color);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
}

td {
  padding: 0.95rem 1rem;
  border-bottom: 1px solid var(--border-color);
  vertical-align: middle;
}

tbody tr:hover {
  background-color: #f8fafc;
}

/* Badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 0.3rem;
  padding: 0.25rem 0.65rem;
  border-radius: 999px;
  font-size: 0.75rem;
  font-weight: 600;
  line-height: 1;
}

.badge-physical { background: #dcfce7; color: #15803d; border: 1px solid #bbf7d0; }
.badge-digital { background: #f3e8ff; color: #7e22ce; border: 1px solid #e9d5ff; }
.badge-service { background: #dbeafe; color: #1d4ed8; border: 1px solid #bfdbfe; }

.badge-completed { background: #dcfce7; color: #166534; }
.badge-pending { background: #fef3c7; color: #92400e; }
.badge-cancelled { background: #fee2e2; color: #991b1b; }

.stock-pill {
  display: inline-block;
  padding: 0.2rem 0.5rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.8rem;
}

.stock-ok { background: #dcfce7; color: #166534; }
.stock-low { background: #fef3c7; color: #b45309; }
.stock-out { background: #fee2e2; color: #b91c1c; }
.stock-none { color: var(--text-muted); font-style: italic; }

.price-text {
  font-weight: 700;
  color: #0f172a;
}

.action-buttons {
  display: flex;
  align-items: center;
  gap: 0.4rem;
}

/* Modals */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.6);
  backdrop-filter: blur(4px);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease-in-out;
  padding: 1rem;
}

.modal-backdrop.show {
  opacity: 1;
  visibility: visible;
}

.modal-card {
  background: white;
  width: 100%;
  max-width: 550px;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-lg);
  overflow: hidden;
  transform: scale(0.95);
  transition: transform 0.2s ease-in-out;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}

.modal-backdrop.show .modal-card {
  transform: scale(1);
}

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: #f8fafc;
}

.modal-header h3 {
  font-size: 1.15rem;
  font-weight: 700;
}

.close-modal-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--text-muted);
  cursor: pointer;
  line-height: 1;
}

.close-modal-btn:hover {
  color: var(--danger);
}

.modal-body {
  padding: 1.5rem;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.modal-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  background: #f8fafc;
}

/* Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.35rem;
}

.form-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #334155;
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 0.6rem 0.85rem;
  border: 1px solid var(--border-color);
  border-radius: var(--radius-md);
  font-size: 0.9rem;
  outline: none;
  transition: var(--transition);
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
}

.form-hint {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.rule-alert {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-md);
  padding: 0.75rem;
  font-size: 0.8rem;
  color: #1e40af;
  display: flex;
  gap: 0.5rem;
  line-height: 1.4;
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 3rem 1.5rem;
  color: var(--text-muted);
}

.empty-state-icon {
  font-size: 3rem;
  margin-bottom: 0.75rem;
}

/* Toast Notification */
.toast-container {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  z-index: 200;
  pointer-events: none;
}

.toast {
  background: #1e293b;
  color: white;
  padding: 0.85rem 1.25rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-size: 0.875rem;
  animation: slideIn 0.3s ease forwards;
  pointer-events: auto;
}

.toast.success { background: #065f46; border-left: 4px solid #34d399; }
.toast.error { background: #991b1b; border-left: 4px solid #f87171; }
.toast.info { background: #1e3a8a; border-left: 4px solid #60a5fa; }
.toast.warning { background: #92400e; border-left: 4px solid #fbbf24; }

@keyframes slideIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeOut {
  from { opacity: 1; }
  to { opacity: 0; }
}

/* Footer */
.admin-footer {
  margin-top: 2rem;
  border-top: 1px solid var(--border-color);
  padding: 1.25rem;
  text-align: center;
  font-size: 0.8rem;
  color: var(--text-muted);
  background: white;
}

/* Responsive */
@media (max-width: 768px) {
  .header-inner {
    flex-direction: column;
    align-items: stretch;
  }
  .header-actions {
    justify-content: flex-end;
  }
  .card-header {
    flex-direction: column;
    align-items: stretch;
  }
  .card-toolbar {
    width: 100%;
  }
  .search-box {
    width: 100%;
  }
}
