@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg: #f8f9fb;
  --surface: #ffffff;
  --sidebar-bg: #1e293b;
  --sidebar-text: #94a3b8;
  --sidebar-active: #f0a030;
  --primary: #2563eb;
  --primary-light: #eff6ff;
  --accent: #f0a030;
  --accent-light: #fef3c7;
  --text: #1e293b;
  --text-secondary: #64748b;
  --border: #e2e8f0;
  --required: #ef4444;
  --green: #10b981;
  --green-light: #ecfdf5;
  --purple: #8b5cf6;
  --purple-light: #f5f3ff;
  --shadow: 0 1px 3px rgba(0,0,0,0.08), 0 1px 2px rgba(0,0,0,0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0,0,0,0.1), 0 4px 6px -2px rgba(0,0,0,0.05);
  --radius: 10px;
}

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

body {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}

/* ===== SIDEBAR ===== */
.sidebar {
  width: 280px;
  background: var(--sidebar-bg);
  color: var(--sidebar-text);
  position: fixed;
  top: 0; left: 0; bottom: 0;
  overflow-y: auto;
  z-index: 100;
  display: flex;
  flex-direction: column;
}
.sidebar-header {
  padding: 24px 20px 16px;
  border-bottom: 1px solid rgba(255,255,255,0.08);
}
.sidebar-header .logo {
  display: flex; align-items: center; gap: 12px;
  text-decoration: none; color: #fff;
}
.sidebar-header .logo-icon {
  width: 40px; height: 40px; border-radius: 10px;
  background: linear-gradient(135deg, var(--accent), #d48a20);
  display: flex; align-items: center; justify-content: center;
  font-size: 20px; font-weight: 700; color: #fff;
  flex-shrink: 0;
}
.sidebar-header .logo-text { font-size: 15px; font-weight: 600; color: #fff; }
.sidebar-header .logo-sub { font-size: 11px; color: var(--sidebar-text); }

.sidebar-section { padding: 16px 12px 8px; }
.sidebar-section-title {
  font-size: 10px; font-weight: 700; text-transform: uppercase;
  letter-spacing: 1.5px; color: rgba(255,255,255,0.3);
  padding: 0 8px 8px;
}
.sidebar-link {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  color: var(--sidebar-text); text-decoration: none;
  font-size: 13px; font-weight: 500;
  transition: all 0.2s; margin-bottom: 2px;
}
.sidebar-link:hover { background: rgba(255,255,255,0.08); color: #e2e8f0; }
.sidebar-link.active { background: rgba(240,160,48,0.15); color: var(--sidebar-active); }
.sidebar-link .icon { font-size: 16px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-link .badge {
  margin-left: auto; font-size: 10px; padding: 2px 6px;
  border-radius: 10px; background: rgba(255,255,255,0.1);
}

/* Collapsible parent-child sidebar */
.sidebar-parent {
  display: flex; align-items: center; gap: 10px;
  padding: 8px 12px; border-radius: 8px;
  color: rgba(255,255,255,0.55); text-decoration: none;
  font-size: 12px; font-weight: 600; text-transform: uppercase;
  letter-spacing: 0.8px; cursor: pointer;
  transition: all 0.2s; margin-bottom: 2px;
  user-select: none;
}
.sidebar-parent:hover { background: rgba(255,255,255,0.06); color: rgba(255,255,255,0.8); }
.sidebar-parent .icon { font-size: 14px; width: 20px; text-align: center; flex-shrink: 0; }
.sidebar-parent .chevron {
  margin-left: auto; font-size: 10px;
  transition: transform 0.25s ease;
  color: rgba(255,255,255,0.25);
}
.sidebar-parent.open .chevron { transform: rotate(90deg); }
.sidebar-parent .parent-count {
  font-size: 9px; padding: 1px 5px; border-radius: 8px;
  background: rgba(255,255,255,0.08); color: rgba(255,255,255,0.4);
  font-weight: 600; letter-spacing: 0;
}

.sidebar-children {
  max-height: 0; overflow: hidden;
  transition: max-height 0.3s ease;
  padding-left: 10px;
}
.sidebar-children.open { max-height: 800px; }
.sidebar-children .sidebar-link {
  padding: 6px 10px 6px 22px;
  font-size: 12.5px;
  border-left: 2px solid rgba(255,255,255,0.06);
  border-radius: 0 8px 8px 0;
  margin-bottom: 0;
}
.sidebar-children .sidebar-link:hover {
  border-left-color: rgba(255,255,255,0.2);
}
.sidebar-children .sidebar-link.active {
  border-left-color: var(--sidebar-active);
}

/* ===== MAIN CONTENT ===== */
.main {
  margin-left: 280px;
  flex: 1;
  min-height: 100vh;
}

/* Top header */
.top-bar {
  position: sticky; top: 0; z-index: 50;
  background: rgba(255,255,255,0.85);
  backdrop-filter: blur(12px);
  border-bottom: 1px solid var(--border);
  padding: 12px 32px;
  display: flex; align-items: center; gap: 16px;
}
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 13px; color: var(--text-secondary); }
.breadcrumb a { color: var(--primary); text-decoration: none; }
.breadcrumb .sep { color: var(--border); }
.breadcrumb .current { color: var(--text); font-weight: 600; }
.search-box {
  margin-left: auto; position: relative;
}
.search-box input {
  padding: 8px 14px 8px 36px; border-radius: 8px;
  border: 1px solid var(--border); background: var(--bg);
  font-size: 13px; width: 240px; outline: none;
  transition: border-color 0.2s;
}
.search-box input:focus { border-color: var(--primary); }
.search-box::before {
  content: '🔍'; position: absolute; left: 12px; top: 50%;
  transform: translateY(-50%); font-size: 13px;
}

/* Content area */
.content { padding: 32px; max-width: 960px; }

/* Page title */
.page-title {
  display: flex; align-items: flex-start; gap: 16px;
  margin-bottom: 32px;
}
.page-title .title-icon {
  width: 52px; height: 52px; border-radius: 14px;
  display: flex; align-items: center; justify-content: center;
  font-size: 24px; flex-shrink: 0;
}
.page-title h1 { font-size: 24px; font-weight: 700; line-height: 1.3; }
.page-title .subtitle { font-size: 14px; color: var(--text-secondary); margin-top: 4px; }

/* Info cards */
.info-grid {
  display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 12px; margin-bottom: 32px;
}
.info-card {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); padding: 16px; box-shadow: var(--shadow);
}
.info-card .label { font-size: 11px; text-transform: uppercase; letter-spacing: 0.5px; color: var(--text-secondary); margin-bottom: 4px; }
.info-card .value { font-size: 15px; font-weight: 600; }

/* Section */
.section {
  background: var(--surface); border: 1px solid var(--border);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 24px; overflow: hidden;
}
.section-header {
  padding: 16px 20px; border-bottom: 1px solid var(--border);
  display: flex; align-items: center; gap: 10px;
}
.section-header h2 { font-size: 16px; font-weight: 600; }
.section-header .count {
  font-size: 11px; padding: 2px 8px; border-radius: 10px;
  background: var(--primary-light); color: var(--primary); font-weight: 600;
}
.section-body { padding: 20px; }

/* Field table */
.field-table { width: 100%; border-collapse: collapse; font-size: 13px; }
.field-table thead th {
  text-align: left; padding: 10px 14px;
  background: var(--bg); font-weight: 600; font-size: 11px;
  text-transform: uppercase; letter-spacing: 0.5px;
  color: var(--text-secondary); border-bottom: 2px solid var(--border);
}
.field-table tbody td {
  padding: 12px 14px; border-bottom: 1px solid var(--border);
  vertical-align: top;
}
.field-table tbody tr:last-child td { border-bottom: none; }
.field-table tbody tr:hover { background: #fafbfc; }

/* Field name styling */
.field-name {
  font-weight: 600; color: var(--text); display: flex;
  align-items: center; gap: 6px; white-space: nowrap;
}
.field-name .req {
  width: 6px; height: 6px; border-radius: 50%;
  background: var(--required); flex-shrink: 0;
}
.field-type {
  display: inline-block; font-size: 10px; font-weight: 600;
  padding: 2px 6px; border-radius: 4px;
  text-transform: uppercase; letter-spacing: 0.3px;
}
.field-type.text { background: var(--primary-light); color: var(--primary); }
.field-type.number { background: var(--green-light); color: var(--green); }
.field-type.combo { background: var(--purple-light); color: var(--purple); }
.field-type.date { background: var(--accent-light); color: #92400e; }
.field-type.check { background: #fce7f3; color: #9d174d; }
.field-type.mask { background: #e0e7ff; color: #4338ca; }
.field-type.link { background: #fee2e2; color: var(--required); }
.field-type.button { background: #f1f5f9; color: #475569; }

.db-col { font-family: 'SF Mono', 'Consolas', monospace; font-size: 12px; color: var(--primary); background: var(--primary-light); padding: 2px 6px; border-radius: 4px; }
.max-len { font-size: 11px; color: var(--text-secondary); }

/* Notes/alerts */
.note {
  padding: 14px 16px; border-radius: 8px;
  font-size: 13px; display: flex; gap: 10px;
  align-items: flex-start; margin-top: 16px;
}
.note.info { background: var(--primary-light); border-left: 3px solid var(--primary); }
.note.warning { background: #fef3c7; border-left: 3px solid #f59e0b; }
.note.tip { background: var(--green-light); border-left: 3px solid var(--green); }
.note .note-icon { font-size: 16px; flex-shrink: 0; }

/* Key badge */
.key {
  display: inline-block; padding: 2px 8px;
  background: var(--bg); border: 1px solid var(--border);
  border-radius: 4px; font-size: 11px; font-weight: 600;
  font-family: 'SF Mono', 'Consolas', monospace;
  box-shadow: 0 1px 0 var(--border);
}

/* Shortcut table */
.shortcut-grid {
  display: grid; grid-template-columns: auto 1fr;
  gap: 8px 16px; font-size: 13px; align-items: center;
}

/* Footer */
.help-footer {
  margin-top: 48px; padding: 24px 0;
  border-top: 1px solid var(--border);
  font-size: 12px; color: var(--text-secondary);
  display: flex; justify-content: space-between;
}

/* Print styles */
@media print {
  .sidebar, .top-bar, .search-box { display: none; }
  .main { margin-left: 0; }
  .content { max-width: 100%; }
  .section { break-inside: avoid; }
}

/* Responsive */
@media (max-width: 1024px) {
  .sidebar { display: none; }
  .main { margin-left: 0; }
}
