/* ===== Variables ===== */
:root {
  --sidebar-width: 270px;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-text-hover: #f1f5f9;
  --sidebar-active-bg: rgba(59,130,246,0.15);
  --sidebar-active-text: #60a5fa;
  --content-bg: #f8fafc;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --primary: #3b82f6;
  --primary-hover: #2563eb;
}

/* ===== Base ===== */
*, *::before, *::after { box-sizing: border-box; }

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

a { color: inherit; }

/* ===== App layout ===== */
#app {
  display: flex;
  min-height: 100vh;
}

/* ===== Sidebar ===== */
#sidebar {
  width: var(--sidebar-width);
  background: var(--sidebar-bg);
  position: fixed;
  top: 0; left: 0;
  height: 100vh;
  overflow-y: auto;
  display: flex;
  flex-direction: column;
  z-index: 200;
  transition: transform .25s ease;
}

.sidebar-brand {
  padding: 1.25rem 1.25rem 1rem;
  border-bottom: 1px solid rgba(255,255,255,.07);
}
.sidebar-brand h1 {
  font-size: 1.05rem;
  font-weight: 700;
  color: #f1f5f9;
  margin: 0;
  display: flex;
  align-items: center;
  gap: .5rem;
}
.sidebar-brand .subtitle {
  font-size: .68rem;
  color: var(--sidebar-text);
  text-transform: uppercase;
  letter-spacing: .06em;
  margin-top: .2rem;
}

.sidebar-search {
  padding: .75rem 1rem;
}
.sidebar-search input {
  width: 100%;
  background: rgba(255,255,255,.08);
  border: 1px solid rgba(255,255,255,.1);
  border-radius: 7px;
  color: #f1f5f9;
  padding: .45rem .75rem;
  font-size: .85rem;
  outline: none;
  transition: border-color .2s;
}
.sidebar-search input:focus { border-color: var(--primary); }
.sidebar-search input::placeholder { color: var(--sidebar-text); }

.sidebar-section { padding: .3rem 0; }

.sidebar-section-title {
  font-size: .64rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: var(--sidebar-text);
  padding: .5rem 1.25rem .2rem;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: .55rem;
  padding: .45rem .75rem;
  color: var(--sidebar-text);
  text-decoration: none;
  font-size: .865rem;
  border-radius: 6px;
  margin: .1rem .5rem;
  cursor: pointer;
  transition: color .15s, background .15s;
}
.sidebar-nav-item:hover {
  color: var(--sidebar-text-hover);
  background: rgba(255,255,255,.06);
  text-decoration: none;
}
.sidebar-nav-item.active {
  color: var(--sidebar-active-text);
  background: var(--sidebar-active-bg);
}
.sidebar-nav-item i { font-size: 1rem; width: 1.1rem; text-align: center; }

.category-dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-footer {
  margin-top: auto;
  padding: 1rem;
  border-top: 1px solid rgba(255,255,255,.07);
}
.user-info {
  display: flex;
  align-items: center;
  gap: .7rem;
  margin-bottom: .75rem;
}
.user-avatar {
  width: 34px; height: 34px;
  border-radius: 50%;
  background: var(--primary);
  display: flex; align-items: center; justify-content: center;
  color: white;
  font-weight: 700;
  font-size: .8rem;
  flex-shrink: 0;
}
.user-name { font-size: .85rem; font-weight: 500; color: #f1f5f9; }
.user-role { font-size: .7rem; color: var(--sidebar-text); }

/* ===== Main content ===== */
#content {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.page-header {
  background: white;
  border-bottom: 1px solid var(--border);
  padding: 1rem 1.75rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  position: sticky;
  top: 0;
  z-index: 100;
}
.page-header h2 {
  font-size: 1.15rem;
  font-weight: 600;
  margin: 0;
}
.page-header .actions { display: flex; gap: .5rem; align-items: center; }

.page-body { padding: 1.75rem; flex: 1; }

/* ===== Hamburger (mobile) ===== */
#menu-toggle {
  display: none;
  background: none;
  border: none;
  font-size: 1.4rem;
  color: var(--text);
  cursor: pointer;
  padding: 0 .5rem 0 0;
}

/* ===== Procedure cards ===== */
.procedure-card {
  background: white;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 1.1rem 1.25rem;
  display: flex;
  flex-direction: column;
  height: 100%;
  text-decoration: none;
  color: inherit;
  transition: box-shadow .18s, border-color .18s, transform .1s;
}
.procedure-card:hover {
  box-shadow: 0 6px 24px rgba(0,0,0,.09);
  border-color: var(--primary);
  transform: translateY(-1px);
  color: inherit;
  text-decoration: none;
}
.card-title {
  font-size: .97rem;
  font-weight: 600;
  margin: .4rem 0 .45rem;
  line-height: 1.4;
  color: var(--text);
}
.card-summary {
  font-size: .83rem;
  color: var(--text-muted);
  line-height: 1.5;
  margin-bottom: .65rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
  flex: 1;
}
.card-footer {
  font-size: .73rem;
  color: var(--text-muted);
  margin-top: .5rem;
  padding-top: .5rem;
  border-top: 1px solid var(--border);
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

/* ===== Category badge ===== */
.category-badge {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  font-size: .68rem;
  font-weight: 600;
  padding: 2px 8px;
  border-radius: 20px;
  text-transform: uppercase;
  letter-spacing: .04em;
  white-space: nowrap;
}

/* ===== Tags ===== */
.tag {
  display: inline-block;
  font-size: .7rem;
  padding: 2px 7px;
  border-radius: 4px;
  background: #e2e8f0;
  color: #475569;
  margin: 2px;
}

/* Tags input widget */
.tags-field {
  display: flex;
  flex-wrap: wrap;
  gap: 5px;
  align-items: center;
  border: 1px solid #ced4da;
  border-radius: .375rem;
  padding: .4rem .6rem;
  background: white;
  min-height: 42px;
  cursor: text;
  transition: border-color .15s, box-shadow .15s;
}
.tags-field.focused {
  border-color: #86b7fe;
  box-shadow: 0 0 0 .25rem rgba(13,110,253,.25);
}
.tag-chip {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  background: #e2e8f0;
  color: #374151;
  border-radius: 4px;
  padding: 2px 7px;
  font-size: .8rem;
}
.tag-chip button {
  background: none; border: none; padding: 0;
  cursor: pointer; color: #6b7280; line-height: 1;
  display: flex; align-items: center; font-size: .7rem;
}
.tag-chip button:hover { color: #ef4444; }
.tags-input {
  border: none; outline: none;
  flex: 1; min-width: 80px;
  font-size: .875rem; padding: 0;
  background: transparent;
}

/* ===== Markdown content ===== */
.prose {
  line-height: 1.75;
  color: var(--text);
  max-width: none;
}
.prose h1, .prose h2, .prose h3, .prose h4 {
  font-weight: 600;
  margin-top: 1.6em;
  margin-bottom: .5em;
}
.prose h1 { font-size: 1.7rem; border-bottom: 2px solid var(--border); padding-bottom: .4rem; }
.prose h2 { font-size: 1.3rem; border-bottom: 1px solid var(--border); padding-bottom: .25rem; }
.prose h3 { font-size: 1.05rem; }
.prose p { margin-bottom: 1em; }
.prose ul, .prose ol { padding-left: 1.5rem; margin-bottom: 1em; }
.prose li { margin-bottom: .3em; }
.prose code {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  border-radius: 4px;
  padding: 1px 5px;
  font-size: .875em;
  font-family: 'Fira Code', Consolas, monospace;
  color: #e11d48;
}
.prose pre {
  background: #1e293b;
  border-radius: 8px;
  padding: 1rem 1.25rem;
  overflow-x: auto;
  margin-bottom: 1em;
}
.prose pre code {
  background: none; border: none; padding: 0;
  color: #e2e8f0; font-size: .875rem;
}
.prose blockquote {
  border-left: 4px solid var(--primary);
  margin: 0 0 1em;
  padding: .5rem 1rem;
  background: #f0f9ff;
  border-radius: 0 8px 8px 0;
  color: #0369a1;
}
.prose table { width: 100%; border-collapse: collapse; margin-bottom: 1em; }
.prose th, .prose td { border: 1px solid var(--border); padding: .45rem .7rem; }
.prose th { background: #f8fafc; font-weight: 600; }
.prose hr { border: none; border-top: 2px solid var(--border); margin: 1.5em 0; }
.prose img { max-width: 100%; border-radius: 6px; }
.prose a { color: var(--primary); text-decoration: underline; }

/* ===== Editor ===== */
.editor-wrap {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
  height: 520px;
}
.editor-pane, .preview-pane {
  border: 1px solid var(--border);
  border-radius: 8px;
  overflow: hidden;
  display: flex;
  flex-direction: column;
}
.pane-header {
  background: #f8fafc;
  border-bottom: 1px solid var(--border);
  padding: .4rem 1rem;
  font-size: .72rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: .05em;
}
.editor-textarea {
  flex: 1; width: 100%;
  border: none; outline: none; resize: none;
  padding: 1rem;
  font-family: 'Fira Code', Consolas, monospace;
  font-size: .875rem;
  line-height: 1.6;
}
.preview-body {
  flex: 1; overflow-y: auto;
  padding: 1rem 1.25rem;
}

/* ===== Login ===== */
.login-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: linear-gradient(135deg, #1e293b 0%, #0f172a 100%);
}
.login-card {
  background: white;
  border-radius: 14px;
  padding: 2.5rem 2rem;
  width: 100%; max-width: 400px;
  box-shadow: 0 30px 60px rgba(0,0,0,.35);
}
.login-logo { text-align: center; margin-bottom: 2rem; }
.login-logo i { font-size: 3rem; color: var(--primary); }
.login-logo h1 { font-size: 1.45rem; font-weight: 700; margin-top: .5rem; }
.login-logo p { color: var(--text-muted); font-size: .875rem; margin: 0; }

/* ===== Procedure info bar ===== */
.proc-meta {
  display: flex;
  flex-wrap: wrap;
  gap: .75rem 1.5rem;
  font-size: .82rem;
  color: var(--text-muted);
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}
.proc-meta i { margin-right: 3px; }

/* ===== Empty state ===== */
.empty-state {
  text-align: center;
  padding: 4rem 2rem;
  color: var(--text-muted);
}
.empty-state i { font-size: 4rem; display: block; opacity: .25; margin-bottom: 1rem; }
.empty-state p { font-size: 1rem; }

/* ===== Salon selector ===== */
.salon-selector {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  min-height: 60vh;
  padding: 3rem 1rem;
}
.salon-selector-title {
  font-size: 1.2rem;
  font-weight: 600;
  color: var(--text-muted);
  margin-bottom: 2.5rem;
  text-align: center;
  letter-spacing: .02em;
}
.salon-cards-grid {
  display: flex;
  gap: 2.5rem;
  flex-wrap: wrap;
  justify-content: center;
}
.salon-card {
  background: white;
  border: 2px solid var(--border);
  border-radius: 18px;
  padding: 2.5rem 2.5rem 2rem;
  text-align: center;
  cursor: pointer;
  transition: all .22s ease;
  min-width: 230px;
  max-width: 300px;
  height: 300px;
  display: flex;
  flex-direction: column;
  align-items: center;
  box-shadow: 0 2px 12px rgba(0,0,0,.05);
  user-select: none;
  position: relative;
}
.salon-card-delete {
  position: absolute;
  top: .65rem; right: .65rem;
  background: none; border: none;
  color: #ef4444; font-size: .85rem;
  cursor: pointer; padding: .3rem;
  border-radius: 6px; opacity: 0;
  transition: opacity .18s, background .15s;
  line-height: 1;
}
.salon-card:hover .salon-card-delete { opacity: 1; }
.salon-card-delete:hover { background: #fee2e2; }
.salon-card:hover {
  border-color: var(--primary);
  box-shadow: 0 20px 56px rgba(59,130,246,.18);
  transform: translateY(-7px);
}
.salon-card img {
  max-height: 160px;
  max-width: 210px;
  object-fit: contain;
  flex: 1;
  margin-bottom: 1.25rem;
}
.salon-card-name {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  margin-top: auto;
}
.salon-card-count {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .35rem;
}

/* ===== Site tabs mini ===== */
.site-tab-logo {
  height: 22px;
  object-fit: contain;
  margin-right: 6px;
  vertical-align: middle;
}
#site-tabs .nav-link {
  color: var(--text-muted);
  background: none;
  border: 2px solid transparent;
  border-radius: 8px;
}
#site-tabs .nav-link:hover {
  color: var(--primary);
  border-color: #bfdbfe;
  background: none;
}
#site-tabs .nav-link.active {
  color: var(--primary);
  background: none;
  border-color: var(--primary);
  font-weight: 600;
}

/* ===== Toast ===== */
.toast-container-fixed {
  position: fixed;
  top: 1rem; right: 1rem;
  z-index: 9999;
}

/* ===== Overlay (mobile) ===== */
#sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  z-index: 150;
}
#sidebar-overlay.show { display: block; }

/* ===== Responsive ===== */
@media (max-width: 768px) {
  #sidebar { transform: translateX(-100%); }
  #sidebar.open { transform: translateX(0); }
  #content { margin-left: 0; }
  #menu-toggle { display: block; }
  .editor-wrap { grid-template-columns: 1fr; height: auto; }
  .editor-pane, .preview-pane { height: 300px; }
  .page-body { padding: 1rem; }
  .page-header { padding: .85rem 1rem; }
}
