/* OrthoRef - Admin UI Styles */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg: #f9fafb;
  --surface: #ffffff;
  --text: #1a1a2e;
  --text-muted: #6b7280;
  --accent: #2563eb;
  --accent-hover: #1d4ed8;
  --danger: #ef4444;
  --danger-hover: #dc2626;
  --border: #e5e7eb;
  --radius: 8px;
  --font: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  display: flex;
  height: 100vh;
  overflow: hidden;
}

/* --- Sidebar --- */
.sidebar {
  width: 300px;
  min-width: 300px;
  background: var(--surface);
  border-right: 1px solid var(--border);
  display: flex;
  flex-direction: column;
  height: 100vh;
}

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

.sidebar-header h1 {
  font-size: 1.1rem;
  font-weight: 700;
}

.sidebar-header h1 a {
  color: inherit;
  text-decoration: none;
}

.sidebar-header h1 a:hover {
  color: var(--accent);
}

.btn-add {
  width: 32px;
  height: 32px;
  border-radius: 50%;
  border: none;
  background: var(--accent);
  color: white;
  font-size: 1.2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background 0.15s;
}

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

.sidebar-list {
  flex: 1;
  overflow-y: auto;
  padding: 8px;
}

.region-group {
  margin-bottom: 8px;
}

.region-label {
  font-size: 0.7rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: var(--text-muted);
  padding: 8px 12px 4px;
}

.condition-item {
  padding: 10px 12px;
  border-radius: var(--radius);
  cursor: pointer;
  font-size: 0.9rem;
  transition: background 0.1s;
  display: flex;
  align-items: center;
  gap: 8px;
}

.condition-item:hover { background: #f3f4f6; }
.condition-item.active { background: #dbeafe; color: var(--accent); font-weight: 600; }

.condition-item .img-count {
  margin-left: auto;
  font-size: 0.75rem;
  color: var(--text-muted);
  background: #f3f4f6;
  padding: 1px 7px;
  border-radius: 10px;
}

.condition-item.active .img-count { background: rgba(37,99,235,0.15); color: var(--accent); }

/* --- Main Content --- */
.main {
  flex: 1;
  overflow-y: auto;
  padding: 32px 40px;
}

.placeholder-main {
  display: flex;
  align-items: center;
  justify-content: center;
  height: 100%;
  color: var(--text-muted);
  font-size: 1rem;
}

/* --- Form --- */
.form-section {
  max-width: 720px;
}

.form-section h2 {
  font-size: 1.3rem;
  font-weight: 700;
  margin-bottom: 24px;
}

.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  font-size: 0.8rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 6px;
  text-transform: uppercase;
  letter-spacing: 0.03em;
}

.form-group input,
.form-group select {
  width: 100%;
  padding: 10px 14px;
  font-size: 0.95rem;
  font-family: var(--font);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  transition: border-color 0.15s;
}

.form-group input:focus,
.form-group select:focus {
  border-color: var(--accent);
}

.form-actions {
  display: flex;
  gap: 12px;
  margin-top: 24px;
  margin-bottom: 40px;
}

.btn {
  padding: 10px 20px;
  border-radius: var(--radius);
  border: none;
  font-size: 0.9rem;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.15s;
  font-family: var(--font);
}

.btn-primary { background: var(--accent); color: white; }
.btn-primary:hover { background: var(--accent-hover); }
.btn-danger { background: var(--danger); color: white; }
.btn-danger:hover { background: var(--danger-hover); }
.btn-secondary { background: #f3f4f6; color: var(--text); }
.btn-secondary:hover { background: #e5e7eb; }

/* --- Images Section --- */
.images-section {
  max-width: 720px;
  margin-top: 32px;
}

.images-section h3 {
  font-size: 1rem;
  font-weight: 700;
  margin-bottom: 16px;
}

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius);
  padding: 32px;
  text-align: center;
  cursor: pointer;
  transition: border-color 0.2s, background 0.2s;
  margin-bottom: 20px;
}

.upload-zone:hover,
.upload-zone.dragover {
  border-color: var(--accent);
  background: #f0f4ff;
}

.upload-zone p {
  color: var(--text-muted);
  font-size: 0.9rem;
}

.upload-zone input[type="file"] {
  display: none;
}

.upload-view-label {
  display: flex;
  gap: 12px;
  align-items: center;
  margin-bottom: 12px;
}

.upload-view-label input {
  flex: 1;
  padding: 8px 12px;
  font-size: 0.9rem;
  border: 1px solid var(--border);
  border-radius: var(--radius);
  outline: none;
  font-family: var(--font);
}

.image-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 16px;
}

.image-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  overflow: hidden;
  position: relative;
}

.image-card img {
  width: 100%;
  aspect-ratio: 4/3;
  object-fit: cover;
  display: block;
}

.image-card .image-info {
  padding: 8px 10px;
  font-size: 0.8rem;
}

.image-card .image-info input {
  width: 100%;
  padding: 4px 8px;
  font-size: 0.8rem;
  border: 1px solid var(--border);
  border-radius: 4px;
  outline: none;
  font-family: var(--font);
}

.image-card .image-actions {
  display: flex;
  gap: 4px;
  margin-top: 6px;
}

.image-card .btn-sm {
  padding: 4px 10px;
  font-size: 0.75rem;
  border-radius: 4px;
  border: none;
  cursor: pointer;
  font-weight: 600;
  font-family: var(--font);
}

.btn-sm.save { background: #dbeafe; color: var(--accent); }
.btn-sm.save:hover { background: #bfdbfe; }
.btn-sm.delete { background: #fee2e2; color: var(--danger); }
.btn-sm.delete:hover { background: #fecaca; }

/* --- Toast --- */
.toast {
  position: fixed;
  bottom: 24px;
  right: 24px;
  background: var(--text);
  color: white;
  padding: 12px 20px;
  border-radius: var(--radius);
  font-size: 0.9rem;
  opacity: 0;
  transform: translateY(10px);
  transition: opacity 0.3s, transform 0.3s;
  z-index: 9999;
  pointer-events: none;
}

.toast.show {
  opacity: 1;
  transform: translateY(0);
}
