:root {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --danger: #ef4444;
  --success: #10b981;
  --warning: #f59e0b;
  --bg: #0f172a;
  --bg-light: #1e293b;
  --bg-lighter: #334155;
  --text: #f1f5f9;
  --text-secondary: #cbd5e1;
  --border: #475569;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
}

[data-theme="light"] {
  --primary: #6366f1;
  --primary-dark: #4f46e5;
  --secondary: #8b5cf6;
  --danger: #dc2626;
  --success: #059669;
  --warning: #d97706;
  --bg: #ffffff;
  --bg-light: #f8fafc;
  --bg-lighter: #f1f5f9;
  --text: #0f172a;
  --text-secondary: #475569;
  --border: #cbd5e1;
}

* {
  box-sizing: border-box;
}

html, body {
  margin: 0;
  padding: 0;
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  background: var(--bg);
  color: var(--text);
}

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

a:hover {
  text-decoration: underline;
}

/* Layout */
.admin-layout {
  display: flex;
  flex-direction: column;
  min-height: 100vh;
}

.admin-header {
  background: linear-gradient(135deg, var(--primary) 0%, var(--secondary) 100%);
  color: white;
  padding: 1rem 0;
  box-shadow: var(--shadow);
  position: sticky;
  top: 0;
  z-index: 100;
}

.admin-header h1 {
  margin: 0;
  font-size: 1.5rem;
}

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

.admin-header .admin-container {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}

.admin-actions {
  display: flex;
  gap: 0.75rem;
}

.admin-main {
  flex: 1;
  padding: 2rem 1rem;
}

/* Toast */
.admin-toast {
  position: fixed;
  bottom: 1rem;
  right: 1rem;
  background: var(--primary);
  color: white;
  padding: 1rem 1.5rem;
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  z-index: 1000;
  animation: slideIn 0.3s ease;
}

.admin-toast.success {
  background: var(--success);
}

.admin-toast.error {
  background: var(--danger);
}

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

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

.admin-tab {
  padding: 0.75rem 1.5rem;
  background: none;
  border: none;
  color: var(--text-secondary);
  cursor: pointer;
  font-weight: 500;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
  margin-bottom: -2px;
  transition: all 0.2s ease;
}

.admin-tab:hover {
  color: var(--text);
  background: var(--bg-light);
}

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

/* Sections */
.admin-section {
  display: none;
}

.admin-section.active {
  display: block;
  animation: fadeIn 0.3s ease;
}

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

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.section-header h2 {
  margin: 0;
  font-size: 1.5rem;
}

/* Buttons */
.btn {
  padding: 0.625rem 1.25rem;
  border: none;
  border-radius: 0.375rem;
  font-weight: 500;
  font-size: 0.95rem;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  transition: all 0.2s ease;
}

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

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

.btn-secondary {
  background: var(--bg-light);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--bg-lighter);
}

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

.btn-danger:hover {
  background: #dc2626;
  opacity: 0.9;
}

.btn-sm {
  padding: 0.5rem 0.75rem;
  font-size: 0.85rem;
}

.btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

/* Forms */
.admin-form {
  background: var(--bg-light);
  padding: 1.5rem;
  border-radius: 0.5rem;
  margin-bottom: 2rem;
  border: 1px solid var(--border);
}

.admin-form h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  font-size: 1.1rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.375rem;
  font-weight: 500;
  font-size: 0.95rem;
}

.form-group input,
.form-group textarea,
.form-group select {
  width: 100%;
  padding: 0.625rem 0.75rem;
  background: var(--bg);
  color: var(--text);
  border: 1px solid var(--border);
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.95rem;
}

.form-group input:focus,
.form-group textarea:focus,
.form-group select:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(99, 102, 241, 0.1);
}

.form-group checkbox {
  margin-right: 0.5rem;
}

.form-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.form-actions .btn {
  flex: 1;
}

/* Items grid */
.items-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 1rem;
}

.item-card {
  background: var(--bg-light);
  border: 1px solid var(--border);
  border-radius: 0.5rem;
  padding: 1rem;
  transition: all 0.2s ease;
}

.item-card:hover {
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(99, 102, 241, 0.1);
}

.item-card h4 {
  margin: 0 0 0.5rem 0;
  color: var(--primary);
}

.item-card p {
  margin: 0.25rem 0;
  font-size: 0.9rem;
  color: var(--text-secondary);
}

.item-card-actions {
  display: flex;
  gap: 0.5rem;
  margin-top: 1rem;
}

.item-card-actions .btn {
  flex: 1;
  justify-content: center;
}

.item-card-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  margin: 1rem 0;
  padding-top: 1rem;
  border-top: 1px solid var(--border);
  font-size: 0.85rem;
}

.item-card-meta dt {
  font-weight: 600;
  color: var(--text-secondary);
}

.item-card-meta dd {
  color: var(--text);
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 2rem;
  color: var(--text-secondary);
}

.empty-state svg {
  width: 48px;
  height: 48px;
  margin-bottom: 1rem;
  opacity: 0.5;
}

/* Responsive */
@media (max-width: 768px) {
  .admin-container {
    padding: 0 0.75rem;
  }

  .admin-header .admin-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }

  .admin-header h1 {
    font-size: 1.2rem;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.75rem;
  }

  .section-header h2 {
    font-size: 1.2rem;
  }

  .items-grid {
    grid-template-columns: 1fr;
  }

  .admin-tabs {
    margin-bottom: 1rem;
    gap: 0.25rem;
    scrollbar-width: none;
    -webkit-overflow-scrolling: touch;
  }

  .admin-tabs::-webkit-scrollbar {
    display: none;
  }

  .admin-tab {
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
    white-space: nowrap;
    flex-shrink: 0;
  }

  .admin-main {
    padding: 1rem 0.75rem;
  }

  .admin-form {
    padding: 1rem;
  }

  .form-actions {
    flex-direction: column;
  }

  .item-card-meta {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .btn {
    padding: 0.5rem 0.85rem;
    font-size: 0.85rem;
  }
}

@media (max-width: 480px) {
  .admin-header {
    padding: 0.75rem 0;
  }

  .admin-header h1 {
    font-size: 1.05rem;
  }

  .admin-actions {
    gap: 0.4rem;
  }

  .admin-actions .btn {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }

  .admin-tab {
    padding: 0.4rem 0.65rem;
    font-size: 0.8rem;
  }

  .form-group input,
  .form-group textarea,
  .form-group select {
    font-size: 0.9rem;
    padding: 0.5rem 0.6rem;
  }

  .item-card {
    padding: 0.85rem;
  }

  .item-card h4 {
    font-size: 0.95rem;
  }

  .item-card-actions {
    flex-direction: column;
  }
}
