/* ===== Apple-Style Admin CSS ===== */

:root {
  --bg: #f5f5f7;
  --card: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --text-tertiary: #aeaeb2;
  --border: #d2d2d7;
  --blue: #007AFF;
  --green: #34c759;
  --red: #ff3b30;
  --orange: #ff9500;
  --sidebar-bg: #1d1d1f;
  --sidebar-text: #f5f5f7;
  --sidebar-hover: #2c2c2e;
  --sidebar-active: #007AFF;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06);
  --shadow-md: 0 4px 12px rgba(0,0,0,0.08);
}

* { margin: 0; padding: 0; box-sizing: border-box; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'SF Pro Text', 'Helvetica Neue',
    'PingFang SC', 'Microsoft YaHei', sans-serif;
  background: var(--bg);
  color: var(--text-primary);
  line-height: 1.5;
  font-size: 14px;
}

a { color: var(--blue); text-decoration: none; }
a:hover { text-decoration: underline; }

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

.sidebar {
  width: 220px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  padding: 24px 0;
  flex-shrink: 0;
  display: flex;
  flex-direction: column;
}

.sidebar-logo {
  padding: 0 24px 24px;
  font-size: 16px;
  font-weight: 600;
  border-bottom: 1px solid #3a3a3c;
  margin-bottom: 12px;
}

.sidebar-nav { flex: 1; }

.sidebar-nav a {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 24px;
  color: var(--sidebar-text);
  font-size: 14px;
  text-decoration: none;
  border-radius: 0;
  transition: background 0.15s;
}

.sidebar-nav a:hover { background: var(--sidebar-hover); text-decoration: none; }
.sidebar-nav a.active { background: var(--sidebar-active); font-weight: 500; }

.sidebar-footer {
  padding: 16px 24px;
  border-top: 1px solid #3a3a3c;
}

.sidebar-footer a { color: var(--text-tertiary); font-size: 13px; }

.main-content {
  flex: 1;
  padding: 32px;
  max-width: 1200px;
}

/* ===== Cards ===== */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 20px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 17px;
  font-weight: 600;
  color: var(--text-primary);
}

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

.stat-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 20px;
  box-shadow: var(--shadow);
}

.stat-label {
  font-size: 13px;
  color: var(--text-secondary);
  margin-bottom: 6px;
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  color: var(--text-primary);
}

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

.page-title {
  font-size: 24px;
  font-weight: 700;
  color: var(--text-primary);
}

/* ===== Buttons ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  font-weight: 500;
  border: none;
  cursor: pointer;
  transition: opacity 0.15s;
  text-decoration: none;
}

.btn:hover { opacity: 0.85; text-decoration: none; }

.btn-primary { background: var(--blue); color: #fff; }
.btn-secondary { background: #e5e5ea; color: var(--text-primary); }
.btn-danger { background: var(--red); color: #fff; }
.btn-success { background: var(--green); color: #fff; }
.btn-sm { padding: 5px 10px; font-size: 12px; }

/* ===== Table ===== */
.table-wrap { overflow-x: auto; }

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 13px;
}

th {
  text-align: left;
  padding: 10px 12px;
  color: var(--text-secondary);
  font-weight: 500;
  border-bottom: 1px solid var(--border);
  white-space: nowrap;
}

td {
  padding: 12px;
  border-bottom: 1px solid #f0f0f2;
  vertical-align: middle;
}

tr:hover td { background: #fafafa; }

/* ===== Badges ===== */
.badge {
  display: inline-block;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 12px;
  font-weight: 500;
}

.badge-active { background: #e8f9ee; color: var(--green); }
.badge-inactive { background: #fef1f0; color: var(--red); }
.badge-custom { background: #fff3e0; color: var(--orange); }
.badge-type { background: #e8f0fe; color: var(--blue); }

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

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

.form-control {
  width: 100%;
  padding: 9px 12px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 14px;
  color: var(--text-primary);
  background: var(--card);
  outline: none;
  transition: border-color 0.15s;
}

.form-control:focus { border-color: var(--blue); }

select.form-control { appearance: auto; }

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

/* ===== Modal ===== */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 100;
  justify-content: center;
  align-items: center;
}

.modal-overlay.active { display: flex; }

.modal {
  background: var(--card);
  border-radius: var(--radius);
  padding: 28px;
  width: 90%;
  max-width: 520px;
  max-height: 85vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0,0,0,0.2);
}

.modal-title {
  font-size: 17px;
  font-weight: 600;
  margin-bottom: 20px;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  margin-top: 24px;
}

/* ===== Icon Preview ===== */
.icon-preview {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  color: #fff;
  font-weight: bold;
  overflow: hidden;
}

.icon-preview img { width: 100%; height: 100%; object-fit: cover; }

/* ===== Color Swatch ===== */
.color-swatch {
  display: inline-block;
  width: 18px;
  height: 18px;
  border-radius: 4px;
  vertical-align: middle;
  margin-right: 6px;
  border: 1px solid var(--border);
}

/* ===== Chart ===== */
.chart-wrap {
  height: 200px;
  position: relative;
}

/* ===== Grid Layout ===== */
.grid-2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
}

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

.login-card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 40px;
  width: 360px;
  box-shadow: var(--shadow-md);
  text-align: center;
}

.login-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 8px;
}

.login-subtitle {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 28px;
}

.login-error {
  background: #fef1f0;
  color: var(--red);
  padding: 8px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
  margin-bottom: 16px;
}

/* ===== Pagination ===== */
.pagination {
  display: flex;
  gap: 6px;
  margin-top: 20px;
  justify-content: center;
}

.pagination a, .pagination span {
  padding: 6px 12px;
  border-radius: var(--radius-sm);
  font-size: 13px;
}

.pagination a { background: var(--card); color: var(--text-primary); border: 1px solid var(--border); }
.pagination a:hover { background: var(--bg); text-decoration: none; }
.pagination span.current { background: var(--blue); color: #fff; }

/* ===== Misc ===== */
.text-secondary { color: var(--text-secondary); }
.text-sm { font-size: 12px; }
.mt-4 { margin-top: 16px; }
.mb-4 { margin-bottom: 16px; }
.inline-actions { display: flex; gap: 6px; align-items: center; }
