/* =========================
   open_data.css (to'liq, footer qoidalarsiz)
   ========================= */

/* Global resets (faqat shu sahifa uchun maqsad qilingan qoidalar) */
.open-data-page, .open-data-page * {
  box-sizing: border-box;
}

/* Make page container fill viewport so footer won't leave unexpected gap */
.open-data-page {
  display: flex;
  flex-direction: column;
  min-height: 100vh; /* sahifa balandligini to'liq egallaydi */
  background: transparent;
}

/* Content area grows to fill available space, footer follows after it */
.open-data-page .content-wrap {
  flex: 1 0 auto;
}

/* Katta sarlavha */
.od-title {
  color: #1b8f55;
  font-weight: 700;
  font-size: clamp(20px, 2.5vw, 34px);
  margin-bottom: 16px;
}

/* Kartalar */
.od-card {
  border-radius: 16px;
  display: flex;
  flex-direction: column;
  width: 100%;
  min-height: auto;
  box-shadow: none;
}

/* Sidebar */
.od-sidebar {
  border-radius: 16px;
}

/* Sidebar title */
.od-sidebar-title {
  font-weight: 600;
  font-size: clamp(16px, 2vw, 18px);
  margin: 8px 6px 12px;
}

/* Ro‘yxat */
.od-list {
  list-style: none;
  margin: 0;
  padding: 0;
}
.od-item {
  padding: 10px 8px;
  border-bottom: 1px solid #f1f5f3;
  border-radius: 8px;
  transition: background .15s ease;
  display: flex;
  align-items: center;
  gap: 8px;
  word-break: break-word;
}
.od-item:hover { background: #f5f7f6; }
.od-item:last-child { border-bottom: none; }

/* Hujjat linklari */
.od-link {
  flex: 1;
  text-decoration: none;
  color: #1c1e21;
  font-size: clamp(14px, 1.8vw, 16px);
  word-break: break-word;
}
.od-link:hover { text-decoration: underline; }

/* Sidebar list-group override */
.od-sidebar-list .list-group-item {
  border: none;
  margin: 4px 0;
  border-radius: 10px;
  padding: 8px 12px;
  font-size: clamp(13px, 1.7vw, 15px);
}

/* Active link */
.od-sidebar-link.active,
.od-sidebar-link.active:hover {
  background-color: #58b077;
  color: #fff !important;
}
.od-sidebar-link:hover { background: #eef6f0; }

/* Type matni */
.doc-type-text .doc-type-full {
  background: #fafafa;
  border: 1px solid #eef2f0;
  border-radius: 8px;
  padding: 10px;
  color: #222;
  font-size: clamp(14px, 1.8vw, 16px);
  margin-bottom: 0.5rem; /* jadval va footer orasidagi bo'shliqni kamaytirish */
}

/* Table styling for CKEditor content (responsive by default) */
.doc-type-text .doc-type-full table {
  width: 100%;
  border-collapse: collapse;
  margin: 8px 0;
  table-layout: auto;
}
.doc-type-text .doc-type-full table th,
.doc-type-text .doc-type-full table td {
  border: 1px solid #ddd;
  padding: 6px;
  text-align: left;
  font-size: clamp(13px, 1.7vw, 15px);
  word-break: break-word;
  white-space: normal;
  hyphens: auto;
}
.doc-type-text .doc-type-full table th {
  background-color: #f5f7f6;
  font-weight: 600;
}
.doc-type-text .doc-type-full table tr:nth-child(even) {
  background-color: #fafafa;
}

/* wrapper for horizontal scroll */
.table-responsive {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  margin: 0.5rem 0; /* kichik margin; footer ostidagi bo'sh joyni kamaytiradi */
}

/* ensure table doesn't overflow container */
.doc-type-text .doc-type-full table.od-table {
  width: 100%;
  max-width: 100%;
}

/* images inside cells scale down */
.doc-type-text .doc-type-full table img {
  max-width: 100%;
  height: auto;
  display: block;
}

/* small-screen adjustments for paddings */
@media (max-width: 767.98px) {
  .od-card, .od-sidebar {
    padding: 12px;
  }
  .od-list .od-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
  }
  .doc-type-text .doc-type-full table {
    font-size: 13px;
  }
  .od-title { font-size: 20px; }
}

/* Mobil uchun qo'shimcha responsivlik */
@media (max-width: 1199.98px) {
  .od-sidebar { margin-bottom: 0.75rem; }
  .od-sidebar-list {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    justify-content: flex-start;
  }
  .od-sidebar-list .list-group-item {
    flex: 0 0 auto;
    width: auto;
    margin: 0;
    padding: 6px 10px;
    font-size: 14px;
  }
  .od-title { font-size: 1.4rem; }
  .od-item { padding: 6px 8px; font-size: 14px; }
}

/* ===========================================
   MOBIL: 2-USTUNLI JADVALLAR UCHUN MAXSUS QOIDALAR
   (nom -> link) STACK KO‘RINISHINI TA'MINLAYDI
   =========================================== */

/* Default mobile card-view for od_table */
@media (max-width: 480px) {
  /* Default non-two-col behavior (label:value pairs) */
  .od-table:not(.od-table-two-col) thead { display: none; }
  .od-table:not(.od-table-two-col) tr {
    display: block;
    margin-bottom: 10px;
    border: 1px solid #eef2f0;
    border-radius: 8px;
    padding: 8px;
    background: #fff;
  }
  .od-table:not(.od-table-two-col) td {
    display: flex;
    justify-content: space-between;
    padding: 6px 8px;
    border: none;
    align-items: center;
  }
  .od-table:not(.od-table-two-col) td:before {
    content: attr(data-label);
    font-weight: 600;
    margin-right: 8px;
    color: #555;
    flex: 0 0 40%;
    white-space: normal;
    text-align: left;
  }
  .od-table:not(.od-table-two-col) td > * {
    flex: 1 1 60%;
    text-align: right;
    word-break: break-word;
  }

  /* 2-ustunli jadval uchun maxsus stack qoidalari */
  .od-table.od-table-two-col {
    width: 100%;
    border: none;
  }
  .od-table.od-table-two-col thead {
    display: none;
  }
  .od-table.od-table-two-col tr {
    display: block;
    margin-bottom: 10px;
    border: 1px solid #eef2f0;
    border-radius: 8px;
    padding: 8px;
    background: #fff;
  }
  /* Har bir td to'liq qatorni egallaydi: 1st - nom, 2nd - link */
  .od-table.od-table-two-col td,
  .od-table.od-table-two-col th {
    display: block;
    width: 100%;
    padding: 8px 6px;
    border: none;
    text-align: left; /* MUHIM: link/qator hech qachon o'ngga surilmasin */
    word-break: break-word;
    white-space: normal;
  }
  /* 1-ustun (qaror nomi) vizual jihatdan ajratilsin */
  .od-table.od-table-two-col td:first-child,
  .od-table.od-table-two-col th:first-child {
    font-weight: 700;
    padding-bottom: 6px;
    color: #1b8f55;
  }
  /* 2-ustun (link yoki qo'shimcha) biroz yengilroq ko'rinsin */
  .od-table.od-table-two-col td:nth-child(2) a,
  .od-table.od-table-two-col td:nth-child(2) {
    display: block;
    margin-top: 4px;
    font-weight: 500;
    text-decoration: underline;
    word-break: break-word;
    white-space: normal;
  }

  /* Oldingi :before label ko'rsatish qoidalarini 2-ustunli special holatda o'chirish uchun */
  .od-table.od-table-two-col td:before {
    content: none;
  }

  /* Qo'shimcha: barcha jadval linklarini sozlash (har doim chapga moslash) */
  .doc-type-text .doc-type-full table a {
    color: inherit;
    text-decoration: underline;
    word-break: break-word;
    display: inline;
  }

  /* Agar siz hali ham birinchi ustun qiymati juda uzun bo'lsa — uni normal ravishda word-break qiling */
  .od-table.od-table-two-col td:first-child {
    white-space: normal;
    word-break: break-word;
    overflow-wrap: anywhere;
  }
}

/* =========================
   Qo'shimcha foydali qoidalar
   ========================= */

/* Alohida: kichik ekranlarda jadval sarlavhasini (head) yo'q qilish natijasida
   birinchi qator "sarlavha" bo'lsa, u remove qilinadi. JS da ham tekshirildi. */

/* Reduce risk of stray whitespace under footer (some editors add <br> or empty p) */
/* (Bu qoidalarning ko'pi CKEditor tomonidan kiritilgan bo'sh elementlarni kamaytirish uchun foydali) */
.doc-type-full p, .doc-type-full br {
  margin-bottom: 0;
  padding-bottom: 0;
}

/* Keraksiz katta pastki bo'shliqni oldini olish */
.container, .open-data-page .container {
  padding-bottom: 0;
}

/* Scrollbar ni nozik qilish (ixtiyoriy mobil uchun yaxshiroq UX) */
.table-responsive::-webkit-scrollbar {
  height: 8px;
}
