/* ============================================================
   ICD-10-CM Search Plugin Styles
   ============================================================ */

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

.icd10-app {
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  color: #1a1a2e;
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 16px 60px;
}

/* ── HEADER ── */
.icd10-header {
  background: linear-gradient(135deg, #1a1a2e 0%, #16213e 50%, #0f3460 100%);
  color: #fff;
  border-radius: 16px;
  padding: 36px 32px;
  margin-bottom: 28px;
  box-shadow: 0 8px 32px rgba(15,52,96,.25);
}
.icd10-site-title {
  font-size: 1.9rem;
  font-weight: 700;
  margin: 0 0 8px;
  display: flex;
  align-items: center;
  gap: 12px;
  color: #fff;
}
.icd10-site-subtitle {
  margin: 0;
  font-size: .95rem;
  color: rgba(255,255,255,.7);
}

/* ── SEARCH BOX ── */
.icd10-search-wrap {
  position: relative;
  margin-bottom: 32px;
}
.icd10-search-box {
  position: relative;
  display: flex;
  align-items: center;
}
.icd10-search-icon {
  display: none;
}
.icd10-search-input {
  width: 100%;
  padding: 18px 56px 18px 20px;
  font-size: 1.05rem;
  font-family: inherit;
  border: 2px solid #e5e7eb;
  border-radius: 12px;
  outline: none;
  background: #fff;
  box-shadow: 0 4px 16px rgba(0,0,0,.07);
  transition: border-color .2s, box-shadow .2s;
}
.icd10-search-input:focus {
  border-color: #0f3460;
  box-shadow: 0 4px 24px rgba(15,52,96,.15);
}
.icd10-clear-btn {
  position: absolute;
  right: 16px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px;
  color: #9ca3af;
  display: flex;
  align-items: center;
  border-radius: 50%;
  transition: color .2s, background .2s;
}
.icd10-clear-btn:hover { color: #374151; background: #f3f4f6; }

/* Autocomplete */
.icd10-autocomplete {
  position: absolute;
  top: calc(100% + 4px);
  left: 0; right: 0;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  box-shadow: 0 8px 32px rgba(0,0,0,.12);
  z-index: 999;
  overflow: hidden;
  max-height: 320px;
  overflow-y: auto;
}
.icd10-autocomplete-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 18px;
  cursor: pointer;
  transition: background .15s;
  border-bottom: 1px solid #f3f4f6;
}
.icd10-autocomplete-item:last-child { border-bottom: none; }
.icd10-autocomplete-item:hover,
.icd10-autocomplete-item.active { background: #f0f4ff; }
.icd10-autocomplete-code {
  font-weight: 700;
  color: #0f3460;
  font-size: .85rem;
  background: #e8eef8;
  padding: 3px 8px;
  border-radius: 5px;
  min-width: 70px;
  text-align: center;
}
.icd10-autocomplete-desc {
  font-size: .9rem;
  color: #374151;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Hints */
.icd10-search-hints {
  margin-top: 10px;
  font-size: .85rem;
  color: #6b7280;
  display: flex;
  flex-wrap: wrap;
  gap: 6px 16px;
}
.icd10-hint-link, .icd10-chapter-card {
  color: #0f3460;
  cursor: pointer;
  text-decoration: none;
  transition: color .2s;
}
.icd10-hint-link:hover { text-decoration: underline; }

/* ── MAIN ── */
.icd10-main { min-height: 300px; }

/* Breadcrumb */
.icd10-breadcrumb {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  align-items: center;
  margin-bottom: 16px;
  font-size: .88rem;
  color: #6b7280;
}
.icd10-breadcrumb a {
  color: #0f3460;
  cursor: pointer;
  text-decoration: none;
}
.icd10-breadcrumb a:hover { text-decoration: underline; }
.icd10-breadcrumb-sep { color: #d1d5db; }

/* Loading */
.icd10-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 14px;
  padding: 48px 0;
  color: #6b7280;
}
.icd10-spinner {
  width: 28px; height: 28px;
  border: 3px solid #e5e7eb;
  border-top-color: #0f3460;
  border-radius: 50%;
  animation: icd10-spin .7s linear infinite;
}
@keyframes icd10-spin { to { transform: rotate(360deg); } }

/* ── RESULTS ── */
.icd10-results-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 12px;
  flex-wrap: wrap;
  gap: 8px;
}
.icd10-results-count {
  font-size: .9rem;
  color: #6b7280;
}
.icd10-results-tabs {
  display: flex;
  gap: 4px;
}
.icd10-tab {
  background: none;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  padding: 5px 14px;
  font-size: .85rem;
  font-family: inherit;
  cursor: pointer;
  color: #6b7280;
  transition: all .2s;
}
.icd10-tab.active, .icd10-tab:hover {
  background: #0f3460;
  border-color: #0f3460;
  color: #fff;
}

/* List View */
.icd10-results-list.list-view .icd10-result-card {
  display: flex;
  align-items: flex-start;
  gap: 16px;
  padding: 14px 18px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .15s;
}
.icd10-results-list.list-view .icd10-result-card:hover {
  border-color: #0f3460;
  box-shadow: 0 4px 16px rgba(15,52,96,.12);
  transform: translateY(-1px);
}

/* Grid View */
.icd10-results-list.grid-view {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 12px;
}
.icd10-results-list.grid-view .icd10-result-card {
  padding: 16px;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  cursor: pointer;
  transition: box-shadow .2s, border-color .2s, transform .15s;
}
.icd10-results-list.grid-view .icd10-result-card:hover {
  border-color: #0f3460;
  box-shadow: 0 4px 16px rgba(15,52,96,.12);
  transform: translateY(-2px);
}

.icd10-result-code {
  font-weight: 700;
  font-size: .9rem;
  color: #fff;
  background: #0f3460;
  border-radius: 6px;
  padding: 4px 12px;
  white-space: nowrap;
  min-width: 72px;
  text-align: center;
  flex-shrink: 0;
}
.icd10-result-desc {
  flex: 1;
  font-size: .95rem;
  color: #1a1a2e;
  line-height: 1.4;
}
.icd10-result-badges {
  display: flex;
  flex-wrap: wrap;
  gap: 4px;
  margin-top: 6px;
}
.icd10-badge {
  font-size: .72rem;
  font-weight: 600;
  padding: 2px 7px;
  border-radius: 4px;
  text-transform: uppercase;
  letter-spacing: .04em;
}
.icd10-badge-exc1  { background: #fef3c7; color: #92400e; }
.icd10-badge-exc2  { background: #dbeafe; color: #1e40af; }
.icd10-badge-ua    { background: #d1fae5; color: #065f46; }
.icd10-badge-cf    { background: #fce7f3; color: #9d174d; }
.icd10-badge-ca    { background: #f3e8ff; color: #6b21a8; }
.icd10-badge-inc   { background: #f0fdf4; color: #166534; }

/* Pagination */
.icd10-pagination {
  display: flex;
  justify-content: center;
  gap: 6px;
  margin-top: 24px;
  flex-wrap: wrap;
}
.icd10-page-btn {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 7px;
  padding: 7px 14px;
  font-size: .88rem;
  font-family: inherit;
  cursor: pointer;
  color: #374151;
  transition: all .2s;
}
.icd10-page-btn:hover, .icd10-page-btn.active {
  background: #0f3460;
  border-color: #0f3460;
  color: #fff;
}
.icd10-page-btn:disabled { opacity: .4; cursor: default; }

/* ── CODE DETAIL ── */
.icd10-detail {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 24px rgba(0,0,0,.07);
}
.icd10-detail-hero {
  background: linear-gradient(135deg, #0f3460, #16213e);
  color: #fff;
  padding: 28px 32px;
}
.icd10-detail-code-badge {
  font-size: 1.4rem;
  font-weight: 800;
  letter-spacing: .05em;
  background: rgba(255,255,255,.15);
  display: inline-block;
  padding: 6px 18px;
  border-radius: 8px;
  margin-bottom: 12px;
}
.icd10-detail-title {
  font-size: 1.3rem;
  font-weight: 600;
  line-height: 1.35;
  margin: 0;
}
.icd10-detail-meta {
  margin-top: 10px;
  font-size: .88rem;
  color: rgba(255,255,255,.7);
}
.icd10-detail-back {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  color: #fff;
  border-radius: 7px;
  padding: 7px 16px;
  font-size: .88rem;
  font-family: inherit;
  cursor: pointer;
  margin-bottom: 16px;
  display: inline-flex;
  align-items: center;
  gap: 6px;
  transition: background .2s;
}
.icd10-detail-back:hover { background: rgba(255,255,255,.25); }

.icd10-detail-body { padding: 28px 32px; }

/* Parent / Child hierarchy */
.icd10-hierarchy {
  margin-bottom: 24px;
}
.icd10-hierarchy-label {
  font-size: .8rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .08em;
  color: #9ca3af;
  margin-bottom: 8px;
}
.icd10-hierarchy-items {
  display: flex;
  flex-direction: column;
  gap: 4px;
}
.icd10-hierarchy-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 8px 12px;
  background: #f9fafb;
  border-radius: 7px;
  cursor: pointer;
  transition: background .15s;
  border: 1px solid #f3f4f6;
  text-decoration: none;
}
.icd10-hierarchy-item:hover { background: #f0f4ff; border-color: #c7d2fe; }
.icd10-hierarchy-code {
  font-weight: 700;
  color: #0f3460;
  font-size: .85rem;
  min-width: 70px;
}
.icd10-hierarchy-desc {
  font-size: .88rem;
  color: #374151;
}

/* Annotation sections */
.icd10-section {
  margin-bottom: 20px;
}
.icd10-section-title {
  font-size: .82rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .08em;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.icd10-section-title::after {
  content: '';
  flex: 1;
  height: 1px;
  background: currentColor;
  opacity: .15;
}

.icd10-section-inc   .icd10-section-title { color: #065f46; }
.icd10-section-exc1  .icd10-section-title { color: #92400e; }
.icd10-section-exc2  .icd10-section-title { color: #1e40af; }
.icd10-section-ua    .icd10-section-title { color: #065f46; }
.icd10-section-cf    .icd10-section-title { color: #9d174d; }
.icd10-section-ca    .icd10-section-title { color: #6b21a8; }
.icd10-section-terms .icd10-section-title { color: #374151; }

.icd10-section-box {
  border-radius: 8px;
  padding: 12px 16px;
}
.icd10-section-inc   .icd10-section-box { background: #ecfdf5; border-left: 4px solid #10b981; }
.icd10-section-exc1  .icd10-section-box { background: #fffbeb; border-left: 4px solid #f59e0b; }
.icd10-section-exc2  .icd10-section-box { background: #eff6ff; border-left: 4px solid #3b82f6; }
.icd10-section-ua    .icd10-section-box { background: #f0fdf4; border-left: 4px solid #22c55e; }
.icd10-section-cf    .icd10-section-box { background: #fdf2f8; border-left: 4px solid #ec4899; }
.icd10-section-ca    .icd10-section-box { background: #faf5ff; border-left: 4px solid #a855f7; }
.icd10-section-terms .icd10-section-box { background: #f9fafb; border-left: 4px solid #6b7280; }

.icd10-section-box ul {
  margin: 0;
  padding: 0 0 0 18px;
  list-style: disc;
}
.icd10-section-box ul li {
  font-size: .9rem;
  color: #1f2937;
  line-height: 1.6;
  margin-bottom: 4px;
}
.icd10-section-box p {
  margin: 0;
  font-size: .9rem;
  color: #1f2937;
  line-height: 1.6;
}

/* Children table */
.icd10-children-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 8px;
  margin-top: 8px;
}
.icd10-child-item {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 12px;
  background: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  cursor: pointer;
  transition: all .15s;
  text-decoration: none;
}
.icd10-child-item:hover {
  background: #f0f4ff;
  border-color: #0f3460;
  box-shadow: 0 2px 8px rgba(15,52,96,.1);
}
.icd10-child-code {
  font-weight: 700;
  color: #0f3460;
  font-size: .82rem;
  background: #e8eef8;
  padding: 3px 8px;
  border-radius: 5px;
  min-width: 65px;
  text-align: center;
}
.icd10-child-desc {
  font-size: .85rem;
  color: #374151;
  line-height: 1.3;
}

/* ── WELCOME ── */
.icd10-welcome {
  text-align: center;
  padding: 40px 20px;
}
.icd10-welcome-icon {
  color: #d1d5db;
  margin-bottom: 20px;
}
.icd10-welcome h2 {
  font-size: 1.5rem;
  color: #1a1a2e;
  margin: 0 0 10px;
}
.icd10-welcome > p {
  color: #6b7280;
  font-size: .95rem;
  margin-bottom: 36px;
}
.icd10-welcome-chapters h3 {
  font-size: 1rem;
  color: #374151;
  margin-bottom: 16px;
  text-align: center;
}
.icd10-chapter-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
  gap: 10px;
  max-width: 900px;
  margin: 0 auto;
}
.icd10-chapter-card {
  display: block;
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  padding: 14px 16px;
  text-align: center;
  cursor: pointer;
  font-size: .85rem;
  font-weight: 600;
  color: #0f3460;
  transition: all .2s;
  text-decoration: none;
  line-height: 1.4;
}
.icd10-chapter-card small {
  display: block;
  font-weight: 400;
  color: #6b7280;
  margin-top: 4px;
  font-size: .78rem;
}
.icd10-chapter-card:hover {
  border-color: #0f3460;
  background: #f0f4ff;
  box-shadow: 0 4px 12px rgba(15,52,96,.1);
  transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 640px) {
  .icd10-header { padding: 24px 20px; }
  .icd10-site-title { font-size: 1.4rem; }
  .icd10-search-input { font-size: .95rem; padding: 15px 48px 15px 46px; }
  .icd10-detail-hero { padding: 20px; }
  .icd10-detail-body { padding: 20px; }
  .icd10-results-list.grid-view { grid-template-columns: 1fr; }
  .icd10-chapter-grid { grid-template-columns: repeat(2, 1fr); }
}
