/* ============================================================
   OtakKiri Admin - Panel Styles
   ============================================================ */

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

:root {
  --white: #ffffff;
  --bg: #f8f9fa;
  --bg-card: #ffffff;
  --text: #1a1a2e;
  --text-secondary: #6b7280;
  --text-muted: #9ca3af;
  --border: #e5e7eb;
  --border-light: #f3f4f6;
  --primary: #2563eb;
  --primary-hover: #1d4ed8;
  --primary-light: #eff6ff;
  --primary-soft: rgba(37, 99, 235, 0.08);
  --success: #10b981;
  --danger: #ef4444;
  --danger-light: #fef2f2;
  --orange: #f59e0b;
  --sidebar-width: 240px;
  --topbar-height: 56px;
  --radius-sm: 8px;
  --radius: 12px;
  --radius-lg: 16px;
  --shadow: 0 1px 3px rgba(0,0,0,0.06), 0 1px 2px rgba(0,0,0,0.04);
  --shadow-md: 0 4px 6px rgba(0,0,0,0.05), 0 2px 4px rgba(0,0,0,0.04);
  --transition: 0.2s ease;
}

html { scroll-behavior: smooth; }

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

a { text-decoration: none; color: inherit; }
button { cursor: pointer; border: none; background: none; font-family: inherit; }

/* ---- Sidebar ---- */
.sidebar {
  position: fixed;
  top: 0;
  left: 0;
  width: var(--sidebar-width);
  height: 100vh;
  background: var(--white);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  z-index: 100;
  transition: transform 0.3s ease;
}

.sidebar-header {
  padding: 20px;
  display: flex;
  align-items: center;
  gap: 10px;
  border-bottom: 1px solid var(--border-light);
}

.sidebar-logo { font-size: 24px; }

.sidebar-brand {
  font-size: 16px;
  font-weight: 700;
  color: var(--text);
}

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

.sidebar-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 14px;
  font-size: 14px;
  font-weight: 500;
  color: var(--text-secondary);
  border-radius: var(--radius-sm);
  transition: all var(--transition);
}

.sidebar-link:hover {
  color: var(--text);
  background: var(--bg);
}

.sidebar-link.active {
  color: var(--primary);
  background: var(--primary-light);
  font-weight: 600;
}

.sidebar-footer {
  padding: 12px;
  border-top: 1px solid var(--border-light);
}

/* ---- Mobile Topbar ---- */
.mobile-topbar {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  height: var(--topbar-height);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  padding: 0 16px;
  align-items: center;
  justify-content: space-between;
  z-index: 99;
}

.menu-btn {
  padding: 4px;
  color: var(--text-secondary);
}

.mobile-title {
  font-size: 16px;
  font-weight: 700;
}

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

/* ---- Views ---- */
.view { display: none; }
.view.active { display: block; }

.view-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 20px;
  margin-bottom: 28px;
  flex-wrap: wrap;
}

.view-title {
  font-size: 24px;
  font-weight: 700;
  letter-spacing: -0.02em;
}

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

.view-actions {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
}

/* ---- Search Box ---- */
.search-box {
  display: flex;
  align-items: center;
  gap: 8px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 8px 14px;
  min-width: 200px;
}

.search-box svg { color: var(--text-muted); flex-shrink: 0; }

.search-box input {
  border: none;
  background: transparent;
  font-size: 14px;
  outline: none;
  width: 100%;
  color: var(--text);
}

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

.filter-select {
  padding: 8px 14px;
  font-size: 14px;
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  color: var(--text-secondary);
  cursor: pointer;
}

.filter-select:focus { border-color: var(--primary); }

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

.stat-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 18px 20px;
}

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

.stat-card-value {
  font-size: 28px;
  font-weight: 700;
  margin-top: 4px;
}

.stat-card-value.primary { color: var(--primary); }
.stat-card-value.success { color: var(--success); }
.stat-card-value.orange { color: var(--orange); }

/* ---- Table ---- */
.product-table-wrap {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  overflow: hidden;
}

.product-table {
  width: 100%;
  border-collapse: collapse;
}

.product-table th {
  padding: 14px 16px;
  font-size: 12px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  text-align: left;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

.product-table td {
  padding: 14px 16px;
  font-size: 14px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
}

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

.product-table tr:hover td { background: var(--bg); }

.table-product {
  display: flex;
  align-items: center;
  gap: 12px;
}

.table-product-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  background: linear-gradient(135deg, var(--bg) 0%, var(--primary-light) 100%);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  flex-shrink: 0;
}

.table-product-name {
  font-weight: 600;
  font-size: 14px;
  line-height: 1.3;
}

.table-product-id {
  font-size: 11px;
  color: var(--text-muted);
}

.table-category {
  display: inline-flex;
  padding: 3px 10px;
  font-size: 12px;
  font-weight: 500;
  border-radius: var(--radius-sm);
  background: var(--primary-soft);
  color: var(--primary);
}

.table-badge {
  display: inline-flex;
  padding: 2px 8px;
  font-size: 11px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  margin-left: 6px;
}

.table-badge.hot { background: #fef2f2; color: #dc2626; }
.table-badge.new { background: #f0fdf4; color: #16a34a; }
.table-badge.popular { background: #fffbeb; color: #d97706; }

.table-price {
  font-weight: 600;
  color: var(--primary);
}

.table-rating {
  display: flex;
  align-items: center;
  gap: 4px;
}

.table-rating svg { color: var(--orange); }
.table-rating span { font-size: 13px; font-weight: 500; }

.table-actions {
  display: flex;
  gap: 6px;
}

.btn-icon {
  width: 32px;
  height: 32px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  transition: all var(--transition);
}

.btn-icon:hover {
  background: var(--bg);
  color: var(--text);
}

.btn-icon.edit:hover { color: var(--primary); background: var(--primary-light); }
.btn-icon.delete:hover { color: var(--danger); background: var(--danger-light); }

/* ---- Buttons ---- */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 20px;
  font-size: 14px;
  font-weight: 600;
  border-radius: var(--radius-sm);
  transition: all var(--transition);
  white-space: nowrap;
}

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

.btn-primary:hover {
  background: var(--primary-hover);
  transform: translateY(-1px);
}

.btn-outline {
  background: transparent;
  color: var(--text);
  border: 1.5px solid var(--border);
}

.btn-outline:hover {
  border-color: var(--primary);
  color: var(--primary);
  background: var(--primary-light);
}

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

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

/* ---- Form ---- */
.product-form {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 32px;
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 20px;
  margin-bottom: 28px;
}

.form-group { display: flex; flex-direction: column; gap: 6px; }
.form-group.full { grid-column: 1 / -1; }

.form-group label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text);
}

.form-group input,
.form-group select,
.form-group textarea {
  padding: 10px 14px;
  font-size: 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  transition: border-color var(--transition);
  color: var(--text);
  background: var(--white);
}

.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.1);
}

.form-group textarea {
  resize: vertical;
  font-family: inherit;
}

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

.image-preview {
  margin-top: 10px;
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.image-preview img {
  width: 100px;
  height: 72px;
  border-radius: var(--radius-sm);
  object-fit: contain;
  border: 1px solid var(--border);
  background: var(--bg);
}

.image-preview .placeholder {
  font-size: 40px;
  width: 100px;
  height: 72px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--radius-sm);
  border: 2px dashed var(--border);
  background: var(--bg);
}

.form-actions {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding-top: 20px;
  border-top: 1px solid var(--border-light);
}

/* ---- Export ---- */
.export-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
  gap: 20px;
}

.export-card {
  background: var(--white);
  border: 1px solid var(--border-light);
  border-radius: var(--radius);
  padding: 28px;
}

.export-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--radius);
  background: var(--primary-light);
  color: var(--primary);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 16px;
}

.export-card h3 {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 8px;
}

.export-card p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  line-height: 1.5;
}

.json-editor {
  width: 100%;
  font-family: 'SF Mono', 'Fira Code', 'Consolas', monospace;
  font-size: 12px;
  padding: 14px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  outline: none;
  resize: vertical;
  background: #1e1e2e;
  color: #cdd6f4;
  margin-bottom: 12px;
  line-height: 1.5;
}

.json-editor:focus {
  border-color: var(--primary);
}

.export-actions {
  display: flex;
  gap: 8px;
}

/* ---- Modal ---- */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.5);
  backdrop-filter: blur(4px);
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  visibility: hidden;
  transition: all 0.2s ease;
  padding: 20px;
}

.modal-overlay.active {
  opacity: 1;
  visibility: visible;
}

.modal-confirm {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 36px;
  text-align: center;
  max-width: 400px;
  width: 100%;
  transform: scale(0.9);
  transition: transform 0.2s ease;
}

.modal-overlay.active .modal-confirm {
  transform: scale(1);
}

.modal-confirm-icon {
  color: var(--danger);
  margin-bottom: 16px;
}

.modal-confirm h3 {
  font-size: 18px;
  font-weight: 700;
  margin-bottom: 8px;
}

.modal-confirm p {
  font-size: 14px;
  color: var(--text-secondary);
  margin-bottom: 24px;
}

.modal-confirm-actions {
  display: flex;
  gap: 10px;
  justify-content: center;
}

/* ---- Toast ---- */
.toast {
  position: fixed;
  bottom: 24px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: var(--text);
  color: var(--white);
  padding: 12px 24px;
  border-radius: var(--radius);
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 14px;
  font-weight: 500;
  z-index: 3000;
  transition: transform 0.3s ease;
  box-shadow: 0 8px 24px rgba(0,0,0,0.2);
}

.toast.active {
  transform: translateX(-50%) translateY(0);
}

.toast svg { color: var(--success); flex-shrink: 0; }

/* ---- Responsive ---- */
@media (max-width: 900px) {
  .sidebar {
    transform: translateX(-100%);
  }

  .sidebar.open {
    transform: translateX(0);
    box-shadow: 0 0 40px rgba(0,0,0,0.2);
  }

  .mobile-topbar { display: flex; }

  .main {
    margin-left: 0;
    padding: calc(var(--topbar-height) + 20px) 16px 20px;
  }

  .view-header { flex-direction: column; }
  .view-actions { width: 100%; }
  .search-box { flex: 1; min-width: auto; }

  .form-grid { grid-template-columns: 1fr; }
  .form-group.full { grid-column: auto; }

  .product-table-wrap { overflow-x: auto; }
  .product-table { min-width: 600px; }

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

@media (max-width: 480px) {
  .stats-row { grid-template-columns: 1fr; }
  .product-form { padding: 20px; }
  .export-grid { grid-template-columns: 1fr; }
}
