/* ============================================
   OneTwo v3 — Developer Brief
   Clean documentation theme
   ============================================ */

/* --- Reset & Base --- */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --color-bg: #fafafa;
  --color-surface: #ffffff;
  --color-sidebar: #111827;
  --color-sidebar-text: #d1d5db;
  --color-sidebar-active: #3b82f6;
  --color-sidebar-hover: #1f2937;
  --color-text: #1f2937;
  --color-text-muted: #6b7280;
  --color-heading: #111827;
  --color-border: #e5e7eb;
  --color-accent: #3b82f6;
  --color-accent-light: #eff6ff;
  --color-code-bg: #f3f4f6;
  --color-success: #10b981;
  --color-warning: #f59e0b;
  --color-danger: #ef4444;
  --color-info: #6366f1;
  --font-sans: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  --font-mono: 'SF Mono', 'Fira Code', 'Fira Mono', 'Roboto Mono', monospace;
  --sidebar-width: 260px;
  --max-content: 880px;
}

html { font-size: 15px; scroll-behavior: smooth; }

body {
  font-family: var(--font-sans);
  color: var(--color-text);
  background: var(--color-bg);
  line-height: 1.7;
  display: flex;
  min-height: 100vh;
}

/* --- Sidebar --- */
.sidebar {
  width: var(--sidebar-width);
  background: var(--color-sidebar);
  color: var(--color-sidebar-text);
  position: fixed;
  top: 0;
  left: 0;
  bottom: 0;
  overflow-y: auto;
  padding: 2rem 0;
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.sidebar-brand {
  padding: 0 1.5rem 1.5rem;
  border-bottom: 1px solid rgba(255,255,255,0.08);
  margin-bottom: 1rem;
}

.sidebar-brand h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -0.02em;
}

.sidebar-brand .subtitle {
  font-size: 0.75rem;
  color: var(--color-sidebar-text);
  margin-top: 0.25rem;
  opacity: 0.7;
}

.sidebar nav { flex: 1; }

.sidebar nav a {
  display: flex;
  align-items: center;
  gap: 0.65rem;
  padding: 0.55rem 1.5rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.87rem;
  font-weight: 450;
  transition: background 0.15s, color 0.15s;
  border-left: 3px solid transparent;
}

.sidebar nav a:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
}

.sidebar nav a.active {
  background: rgba(59, 130, 246, 0.1);
  color: var(--color-sidebar-active);
  border-left-color: var(--color-sidebar-active);
  font-weight: 600;
}

.sidebar nav a .nav-icon {
  width: 18px;
  height: 18px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 0.9rem;
  opacity: 0.75;
  flex-shrink: 0;
}

.sidebar nav .nav-section {
  font-size: 0.68rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: rgba(255,255,255,0.35);
  padding: 1.25rem 1.5rem 0.4rem;
}

/* --- Main Content --- */
.main {
  margin-left: var(--sidebar-width);
  flex: 1;
  min-height: 100vh;
}

.content {
  max-width: var(--max-content);
  margin: 0 auto;
  padding: 3rem 2.5rem 5rem;
}

/* --- Page Header --- */
.page-header {
  margin-bottom: 2.5rem;
  padding-bottom: 1.5rem;
  border-bottom: 1px solid var(--color-border);
}

.page-header h1 {
  font-size: 2rem;
  font-weight: 800;
  color: var(--color-heading);
  letter-spacing: -0.03em;
  line-height: 1.2;
}

.page-header .lead {
  font-size: 1.05rem;
  color: var(--color-text-muted);
  margin-top: 0.5rem;
  line-height: 1.6;
}

/* --- Typography --- */
h2 {
  font-size: 1.4rem;
  font-weight: 700;
  color: var(--color-heading);
  margin: 2.5rem 0 1rem;
  letter-spacing: -0.02em;
  padding-bottom: 0.5rem;
  border-bottom: 1px solid var(--color-border);
}

h3 {
  font-size: 1.1rem;
  font-weight: 650;
  color: var(--color-heading);
  margin: 2rem 0 0.75rem;
}

h4 {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.04em;
  margin: 1.75rem 0 0.5rem;
}

p { margin-bottom: 1rem; }

strong { font-weight: 650; color: var(--color-heading); }

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

ul, ol { margin: 0.5rem 0 1.25rem 1.5rem; }
li { margin-bottom: 0.35rem; }

/* --- Tables --- */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  border-radius: 8px;
  border: 1px solid var(--color-border);
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

thead {
  background: var(--color-code-bg);
}

th {
  text-align: left;
  padding: 0.7rem 1rem;
  font-weight: 650;
  color: var(--color-heading);
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  border-bottom: 2px solid var(--color-border);
  white-space: nowrap;
}

td {
  padding: 0.65rem 1rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

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

tr:hover { background: rgba(59, 130, 246, 0.03); }

/* --- Code --- */
code {
  font-family: var(--font-mono);
  font-size: 0.85em;
  background: var(--color-code-bg);
  padding: 0.15em 0.4em;
  border-radius: 4px;
  color: #e11d48;
}

pre {
  background: #1e293b;
  color: #e2e8f0;
  padding: 1.25rem 1.5rem;
  border-radius: 8px;
  overflow-x: auto;
  margin: 1rem 0 1.5rem;
  font-size: 0.85rem;
  line-height: 1.6;
}

pre code {
  background: none;
  padding: 0;
  color: inherit;
  font-size: inherit;
}

/* Syntax highlighting in pre blocks */
pre .method { color: #38bdf8; font-weight: 600; }
pre .path { color: #a5f3fc; }
pre .comment { color: #64748b; font-style: italic; }
pre .string { color: #a3e635; }
pre .keyword { color: #c084fc; }

/* --- Cards --- */
.card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.25rem 1.5rem;
  margin-bottom: 1rem;
}

.card h3 {
  margin-top: 0;
  margin-bottom: 0.5rem;
}

.card-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 1rem;
  margin: 1rem 0 1.5rem;
}

.card-grid .card { margin-bottom: 0; }

/* --- Badges --- */
.badge {
  display: inline-block;
  font-size: 0.72rem;
  font-weight: 650;
  padding: 0.2em 0.6em;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  vertical-align: middle;
}

.badge-blue { background: #dbeafe; color: #1d4ed8; }
.badge-green { background: #d1fae5; color: #065f46; }
.badge-yellow { background: #fef3c7; color: #92400e; }
.badge-red { background: #fee2e2; color: #991b1b; }
.badge-purple { background: #ede9fe; color: #5b21b6; }
.badge-gray { background: #f3f4f6; color: #374151; }

/* --- Status Machine Diagram --- */
.state-diagram {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 2rem;
  margin: 1.5rem 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  overflow-x: auto;
}

.state-row {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.state-node {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.55rem 1.25rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.85rem;
  white-space: nowrap;
  border: 2px solid;
}

.state-booked { background: #eff6ff; border-color: #3b82f6; color: #1e40af; }
.state-confirmed { background: #f0fdf4; border-color: #22c55e; color: #166534; }
.state-completed { background: #f0fdf4; border-color: #10b981; color: #065f46; }
.state-cancelled { background: #fef2f2; border-color: #ef4444; color: #991b1b; }
.state-noshow { background: #fefce8; border-color: #eab308; color: #854d0e; }

.state-arrow {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  font-weight: 700;
}

.state-arrow-down {
  color: var(--color-text-muted);
  font-size: 1.1rem;
  text-align: center;
}

.state-label {
  font-size: 0.72rem;
  color: var(--color-text-muted);
  text-align: center;
  font-style: italic;
}

/* --- Callout Boxes --- */
.callout {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin: 1rem 0 1.5rem;
  border-left: 4px solid;
  font-size: 0.92rem;
}

.callout-info {
  background: #eff6ff;
  border-left-color: #3b82f6;
  color: #1e40af;
}

.callout-warning {
  background: #fffbeb;
  border-left-color: #f59e0b;
  color: #92400e;
}

.callout-danger {
  background: #fef2f2;
  border-left-color: #ef4444;
  color: #991b1b;
}

.callout-success {
  background: #f0fdf4;
  border-left-color: #10b981;
  color: #065f46;
}

.callout strong { color: inherit; }

/* --- Metric Cards --- */
.metric-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 0.75rem;
  margin: 1rem 0 1.5rem;
}

.metric {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  text-align: center;
}

.metric .value {
  font-size: 1.6rem;
  font-weight: 800;
  color: var(--color-heading);
  letter-spacing: -0.03em;
}

.metric .label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  margin-top: 0.15rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
}

.metric .sub {
  font-size: 0.78rem;
  color: var(--color-accent);
  margin-top: 0.25rem;
}

/* --- Flow Steps --- */
.flow-steps {
  display: flex;
  align-items: center;
  gap: 0.25rem;
  margin: 1rem 0;
  flex-wrap: wrap;
}

.flow-step {
  background: var(--color-accent-light);
  border: 1px solid #bfdbfe;
  color: #1e40af;
  padding: 0.4rem 0.9rem;
  border-radius: 6px;
  font-size: 0.82rem;
  font-weight: 550;
  white-space: nowrap;
}

.flow-arrow {
  color: var(--color-text-muted);
  font-size: 1.1rem;
}

/* --- Service Cards --- */
.service-card {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin-bottom: 1.25rem;
  border-top: 3px solid var(--color-accent);
}

.service-card.priority-high { border-top-color: var(--color-danger); }
.service-card.priority-medium { border-top-color: var(--color-warning); }
.service-card.priority-normal { border-top-color: var(--color-accent); }

.service-card h3 {
  margin: 0 0 0.75rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.service-card ul {
  margin: 0.25rem 0 0 1.25rem;
}

/* --- Endpoint List --- */
.endpoint {
  display: flex;
  align-items: baseline;
  gap: 0.5rem;
  padding: 0.5rem 0;
  border-bottom: 1px solid var(--color-border);
  font-size: 0.88rem;
}

.endpoint:last-child { border-bottom: none; }

.endpoint .http-method {
  font-family: var(--font-mono);
  font-weight: 700;
  font-size: 0.75rem;
  padding: 0.15em 0.5em;
  border-radius: 3px;
  text-align: center;
  min-width: 55px;
  display: inline-block;
}

.method-get { background: #d1fae5; color: #065f46; }
.method-post { background: #dbeafe; color: #1d4ed8; }
.method-patch { background: #fef3c7; color: #92400e; }
.method-delete { background: #fee2e2; color: #991b1b; }

.endpoint .endpoint-path {
  font-family: var(--font-mono);
  font-size: 0.85rem;
  color: var(--color-heading);
}

.endpoint .endpoint-desc {
  color: var(--color-text-muted);
  font-size: 0.82rem;
  margin-left: auto;
}

/* --- Auth Flow Diagram --- */
.auth-flow {
  background: var(--color-surface);
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1.5rem;
  margin: 1.5rem 0;
}

.auth-flow h4 {
  margin-top: 0;
  margin-bottom: 1rem;
}

/* --- Schema Table Groups --- */
.schema-group {
  margin-bottom: 2rem;
}

.schema-group h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

/* --- Responsive --- */
@media (max-width: 900px) {
  .sidebar {
    position: relative;
    width: 100%;
    height: auto;
    padding: 1rem 0;
  }

  .sidebar-brand { padding: 0 1rem 1rem; }
  .sidebar nav a { padding: 0.5rem 1rem; }

  .main { margin-left: 0; }

  .content { padding: 2rem 1.25rem 3rem; }

  .page-header h1 { font-size: 1.6rem; }

  body { flex-direction: column; }

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

  .endpoint { flex-wrap: wrap; }
  .endpoint .endpoint-desc { margin-left: 0; flex-basis: 100%; margin-top: 0.25rem; }
}

/* --- Language Toggle --- */
.lang-toggle {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.08);
  margin-top: auto;
}

.lang-toggle a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: var(--color-sidebar-text);
  text-decoration: none;
  font-size: 0.85rem;
  font-weight: 500;
  padding: 0.5rem 0.75rem;
  border-radius: 6px;
  border: 1px solid rgba(255,255,255,0.12);
  transition: background 0.15s, color 0.15s;
}

.lang-toggle a:hover {
  background: var(--color-sidebar-hover);
  color: #fff;
  text-decoration: none;
}

/* --- RTL Support --- */
html[dir="rtl"] {
  --font-sans: 'Noto Sans Arabic', 'Segoe UI', Tahoma, Arial, sans-serif;
}

html[dir="rtl"] body { direction: rtl; }

html[dir="rtl"] .sidebar {
  left: auto;
  right: 0;
}

html[dir="rtl"] .sidebar nav a {
  border-left: none;
  border-right: 3px solid transparent;
}

html[dir="rtl"] .sidebar nav a.active {
  border-left-color: transparent;
  border-right-color: var(--color-sidebar-active);
}

html[dir="rtl"] .main {
  margin-left: 0;
  margin-right: var(--sidebar-width);
}

html[dir="rtl"] th { text-align: right; }

html[dir="rtl"] ul, html[dir="rtl"] ol {
  margin-left: 0;
  margin-right: 1.5rem;
}

html[dir="rtl"] .callout {
  border-left: none;
  border-right: 4px solid;
}

html[dir="rtl"] .callout-info { border-right-color: #3b82f6; }
html[dir="rtl"] .callout-warning { border-right-color: #f59e0b; }
html[dir="rtl"] .callout-danger { border-right-color: #ef4444; }
html[dir="rtl"] .callout-success { border-right-color: #10b981; }

html[dir="rtl"] .endpoint .endpoint-desc {
  margin-left: 0;
  margin-right: auto;
}

html[dir="rtl"] .service-card ul {
  margin-left: 0;
  margin-right: 1.25rem;
}

html[dir="rtl"] code {
  direction: ltr;
  unicode-bidi: isolate;
}

html[dir="rtl"] pre {
  direction: ltr;
  text-align: left;
}

html[dir="rtl"] .endpoint-path {
  direction: ltr;
  unicode-bidi: isolate;
}

html[dir="rtl"] .http-method {
  direction: ltr;
  unicode-bidi: isolate;
}

html[dir="rtl"] .flow-steps {
  flex-direction: row-reverse;
}

html[dir="rtl"] .state-row {
  flex-direction: row-reverse;
}

@media (max-width: 900px) {
  html[dir="rtl"] .main { margin-right: 0; }
  html[dir="rtl"] .endpoint .endpoint-desc { margin-right: 0; }
}

/* --- Print --- */
@media print {
  .sidebar { display: none; }
  .main { margin-left: 0; }
  html[dir="rtl"] .main { margin-right: 0; }
  .content { max-width: 100%; padding: 1rem; }
  pre { background: #f1f5f9; color: #1e293b; }
}
