/* BuildFlow design layer — loaded AFTER tailwind.css. Tailwind is
   precompiled (no Node at runtime), so the modern component design lives
   here and overrides the base component classes. Dark mode: html.dark. */

:root {
  /* BuildFlow brend ranglari — logodagi to'q ko'k (#0B3C5D) + yashil (#72C07D) */
  --ap-primary: #0b3c5d;
  --ap-primary-2: #1d6fa5;
  --ap-primary-soft: rgba(11, 60, 93, 0.10);
  --ap-ring: rgba(11, 60, 93, 0.30);
  --ap-success: #72c07d;
  --ap-danger: #ee5d50;
}

/* BuildFlow logo belgisi — qorong'i fonda yorqinroq ko'rinadi */
.ap-logo-mark { flex: none; }
.dark .ap-logo-mark { filter: brightness(2.2) saturate(0.8); }
/* Login/ro'yxatdan o'tish sahifasidagi katta logo — SVG'da width/height
   atributi yo'q, shuning uchun aniq o'lcham bermasak brauzer uni juda
   katta (default ~300px) chizadi. */
.ap-logo-mark-lg { height: 44px; width: auto; }

/* Inter shrifti (base.html da ulanadi) */
body {
  font-family: "Inter", ui-sans-serif, system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
}

/* Yorug' mavzu foni va matni — dizayn tizimiga muvofiq */
html:not(.dark) body { background-color: #f4f7fe; color: #1b2559; }

/* ============ Buttons ============ */
.btn {
  position: relative;
  border-radius: 0.625rem !important;
  font-weight: 600;
  letter-spacing: 0.01em;
  transition: transform .12s ease, box-shadow .15s ease, background-color .15s ease, color .15s ease, border-color .15s ease;
  outline: none;
}
.btn:focus-visible { box-shadow: 0 0 0 3px var(--ap-ring); }
.btn:active { transform: translateY(1px) scale(0.98); }

.btn-primary {
  background-image: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-2)) !important;
  background-color: var(--ap-primary) !important;
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(11, 60, 93, 0.35);
}
.btn-primary:hover {
  box-shadow: 0 6px 16px rgba(11, 60, 93, 0.45);
  transform: translateY(-1px);
  filter: brightness(1.05);
}

.btn-secondary {
  background: #fff !important;
  color: #334155 !important;
  border: 1px solid #e2e8f0;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.05);
}
.btn-secondary:hover { border-color: #c7d2fe; color: var(--ap-primary) !important; background: #f5f6ff !important; }
.dark .btn-secondary { background: #1f2937 !important; color: #d1d5db !important; border-color: #374151; }
.dark .btn-secondary:hover { border-color: #1d6fa5; color: #a5b4fc !important; background: #0b1e3f !important; }

.btn-ghost:hover { color: var(--ap-primary); background: var(--ap-primary-soft) !important; }
.dark .btn-ghost:hover { color: #a5b4fc; }

.btn-danger {
  background-image: linear-gradient(135deg, #ef4444, #dc2626) !important;
  color: #fff !important;
  box-shadow: 0 2px 6px rgba(239, 68, 68, 0.35);
}
.btn-danger:hover { box-shadow: 0 6px 16px rgba(239, 68, 68, 0.45); transform: translateY(-1px); }

/* ============ Checkboxes & radios ============ */
input[type="checkbox"], input[type="radio"] {
  -webkit-appearance: none;
  appearance: none;
  width: 1.125rem;
  height: 1.125rem;
  flex: none;
  margin: 0;
  border: 2px solid #cbd5e1;
  background: #fff;
  cursor: pointer;
  display: inline-grid;
  place-content: center;
  transition: border-color .15s ease, background .15s ease, box-shadow .15s ease;
  vertical-align: middle;
}
input[type="checkbox"] { border-radius: 0.375rem; }
input[type="radio"] { border-radius: 9999px; }
.dark input[type="checkbox"], .dark input[type="radio"] { border-color: #4b5563; background: #1f2937; }

input[type="checkbox"]:hover, input[type="radio"]:hover { border-color: #818cf8; }
input[type="checkbox"]:focus-visible, input[type="radio"]:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px var(--ap-ring);
}

input[type="checkbox"]::before {
  content: "";
  width: 0.625rem;
  height: 0.625rem;
  transform: scale(0);
  transition: transform .12s ease-in-out;
  background: #fff;
  clip-path: polygon(14% 44%, 0 65%, 50% 100%, 100% 16%, 80% 0%, 43% 62%);
}
input[type="checkbox"]:checked {
  border-color: transparent;
  background-image: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-2));
  box-shadow: 0 1px 4px rgba(11, 60, 93, 0.4);
}
input[type="checkbox"]:checked::before { transform: scale(1); }

input[type="radio"]::before {
  content: "";
  width: 0.5rem;
  height: 0.5rem;
  border-radius: 9999px;
  transform: scale(0);
  transition: transform .12s ease-in-out;
  background: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-2));
}
input[type="radio"]:checked { border-color: var(--ap-primary); }
input[type="radio"]:checked::before { transform: scale(1); }

/* ============ Inputs & selects ============ */
.field-input {
  border-radius: 0.625rem !important;
  transition: border-color .15s ease, box-shadow .15s ease;
}
.field-input:hover { border-color: #a5b4fc; }
.field-input:focus {
  outline: none;
  border-color: var(--ap-primary) !important;
  box-shadow: 0 0 0 3px var(--ap-ring) !important;
}

/* ============ Cards ============ */
.card {
  border-radius: 1rem !important;
  box-shadow: 0 1px 3px rgba(15, 23, 42, 0.06);
  transition: box-shadow .15s ease, transform .15s ease, border-color .15s ease;
}
a.card:hover, .card.card-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 24px rgba(15, 23, 42, 0.10);
  border-color: #c7d2fe !important;
}
.dark a.card:hover, .dark .card.card-hover:hover {
  box-shadow: 0 10px 24px rgba(0, 0, 0, 0.45);
  border-color: #4338ca !important;
}

/* ============ Tables ============ */
table thead th {
  font-size: 0.6875rem;
  text-transform: uppercase;
  letter-spacing: 0.06em;
  font-weight: 600;
}
table tbody tr { transition: background-color .12s ease; }

/* ============ Sidebar ============ */
aside nav a { position: relative; transition: background-color .15s ease, color .15s ease; }
aside nav a[class*="bg-blue-50"] {
  background: var(--ap-primary-soft) !important;
  color: var(--ap-primary) !important;
}
.dark aside nav a[class*="bg-blue-50"] { background: rgba(29, 111, 165, 0.25) !important; color: #a5b4fc !important; }
aside nav a[class*="bg-blue-50"]::before {
  content: "";
  position: absolute;
  left: -0.5rem;
  top: 20%;
  bottom: 20%;
  width: 3px;
  border-radius: 9999px;
  background: linear-gradient(180deg, var(--ap-primary), var(--ap-primary-2));
}

/* ============ Scrollbars ============ */
::-webkit-scrollbar { width: 8px; height: 8px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 9999px; }
::-webkit-scrollbar-thumb:hover { background: #94a3b8; }
.dark ::-webkit-scrollbar-thumb { background: #374151; }
.dark ::-webkit-scrollbar-thumb:hover { background: #4b5563; }

/* ============ Stat cards ============ */
.ap-stat {
  display: flex;
  align-items: center;
  gap: 0.875rem;
  padding: 1rem 1.125rem;
}
.ap-stat-icon {
  width: 42px; height: 42px;
  flex: none;
  border-radius: 0.75rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  background: linear-gradient(135deg, var(--ap-primary), var(--ap-primary-2));
  box-shadow: 0 4px 10px rgba(11, 60, 93, 0.30);
}
.ap-stat-icon.is-blue    { background: linear-gradient(135deg, #3b82f6, #2563eb); box-shadow: 0 4px 10px rgba(59,130,246,.30); }
.ap-stat-icon.is-green   { background: linear-gradient(135deg, #10b981, #059669); box-shadow: 0 4px 10px rgba(16,185,129,.30); }
.ap-stat-icon.is-amber   { background: linear-gradient(135deg, #f59e0b, #d97706); box-shadow: 0 4px 10px rgba(245,158,11,.30); }
.ap-stat-label { font-size: 0.6875rem; color: #64748b; font-weight: 500; text-transform: uppercase; letter-spacing: .04em; }
.dark .ap-stat-label { color: #9ca3af; }
.ap-stat-value { font-size: 1.375rem; font-weight: 700; line-height: 1.2; }

/* ============ Charts ============ */
.ap-donut-wrap { display: flex; align-items: center; gap: 1.25rem; flex-wrap: wrap; }
.ap-donut {
  position: relative;
  width: 160px; height: 160px;
  border-radius: 9999px;
  flex: none;
  background: #eef2f7;
}
.dark .ap-donut { background: #1f2937; }
.ap-donut::after {
  content: "";
  position: absolute;
  inset: 26px;
  border-radius: 9999px;
  background: #fff;
}
.dark .ap-donut::after { background: #1f2937; }
.dark .card .ap-donut::after { background: #1f2937; }
.ap-donut-center {
  position: absolute;
  inset: 0;
  z-index: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}
.ap-donut-center b { font-size: 1.5rem; line-height: 1.1; }
.ap-donut-center span { font-size: 0.6875rem; color: #64748b; }
.dark .ap-donut-center span { color: #9ca3af; }

.ap-legend { display: flex; flex-direction: column; gap: 0.375rem; min-width: 150px; flex: 1; }
.ap-legend-item {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.75rem;
  color: #475569;
}
.dark .ap-legend-item { color: #d1d5db; }
.ap-legend-dot { width: 10px; height: 10px; border-radius: 3px; flex: none; }
.ap-legend-item b { margin-left: auto; font-weight: 600; }

/* Horizontal bar rows */
.ap-hbar-row { margin-bottom: 0.625rem; }
.ap-hbar-top {
  display: flex;
  justify-content: space-between;
  font-size: 0.75rem;
  margin-bottom: 0.25rem;
  color: #475569;
}
.dark .ap-hbar-top { color: #d1d5db; }
.ap-hbar {
  height: 0.5rem;
  border-radius: 9999px;
  background: #eef2f7;
  overflow: hidden;
}
.dark .ap-hbar { background: #111827; }
.ap-hbar > div {
  height: 100%;
  border-radius: 9999px;
  width: 0;
  transition: width .7s cubic-bezier(.22,.61,.36,1);
}

/* ============ Badges ============ */
.badge { font-weight: 600; letter-spacing: 0.01em; }

/* ============ Modal ============
   tailwind.css is precompiled offline (no Node at runtime), so utility
   classes not already used elsewhere in the templates (fixed/inset-0/z-50/
   bg-black opacity, etc.) aren't in the bundle. Hand-rolled here instead —
   same reasoning as .switch and .field-info above. */
.ap-modal-backdrop {
  position: fixed;
  inset: 0;
  z-index: 50;
  display: none;
  align-items: flex-start;
  justify-content: center;
  overflow-y: auto;
  padding: 2.5rem 1rem;
  background: rgba(15, 23, 42, 0.6);
}
.ap-modal-backdrop.is-open { display: flex; }
.ap-modal-card { width: 100%; max-width: 36rem; }

/* ============ Responsive (mobil) ============ */
/* Hamburger tugma — faqat mobilda ko'rinadi */
.ap-menu-btn { display: none; }

/* Header o'ng bloki doim o'ngda turadi (hamburger desktopda yashiringanida
   justify-between uni chapga surib yubormasligi uchun) */
.ap-header-right { margin-left: auto; }

/* ============ Tablar ============ */
.ap-tabs {
  display: flex;
  flex-wrap: wrap;
  gap: 0.25rem;
  border-bottom: 1px solid #e2e8f0;
}
.dark .ap-tabs { border-color: #374151; }
.ap-tab {
  padding: 0.5rem 0.875rem;
  font-size: 0.875rem;
  font-weight: 500;
  color: #64748b;
  border: none;
  background: none;
  cursor: pointer;
  border-bottom: 2px solid transparent;
  margin-bottom: -1px;
  transition: color .15s ease, border-color .15s ease;
}
.dark .ap-tab { color: #9ca3af; }
.ap-tab:hover { color: var(--ap-primary); }
.ap-tab.is-active {
  color: var(--ap-primary);
  border-bottom-color: var(--ap-primary);
  font-weight: 600;
}

/* Global qidiruv maydoni */
.ap-search { flex: 0 1 20rem; min-width: 0; }
@media (max-width: 639.98px) {
  .ap-search { display: none; } /* tor ekranda joy yetmaydi — qidiruv sahifasi baribir ochiq */
}

/* Yuklangan avatar rasmi — bosh harfli doira bilan bir xil ko'rinishda */
.ap-avatar-img {
  border-radius: 9999px;
  object-fit: cover;
  flex: none;
}

@media (max-width: 767.98px) {
  .ap-menu-btn { display: inline-flex; font-size: 1.125rem; }

  /* Sidebar mobilda off-canvas drawer bo'ladi: `hidden` klassini bekor
     qilib, chapdan surilib chiqadigan fixed panelga aylantiramiz. */
  #ap-sidebar {
    display: flex !important;
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    z-index: 40;
    width: 16rem;
    transform: translateX(-100%);
    transition: transform 0.25s ease;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.25);
  }
  #ap-sidebar.is-open { transform: translateX(0); }

  #ap-sidebar-overlay {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 30;
    background: rgba(15, 23, 42, 0.5);
  }
  #ap-sidebar-overlay.is-open { display: block; }
}

/* Juda tor ekranlarda ikkinchi darajali tugmalarni yashirish
   (profil sidebar pastida baribir bor) */
@media (max-width: 479.98px) {
  .ap-hide-sm { display: none !important; }
}

/* Kalendar (7 ustunli grid) tor ekranda siqilib ketmasligi uchun
   gorizontal scroll ichiga olinadi */
.ap-cal-scroll { overflow-x: auto; }
.ap-cal-scroll > .grid { min-width: 560px; }

/* ============ Toggle switch (Uiverse.io by alexruix) ============ */
/* Asl koddan farqlar: o'lcham em'ga o'tkazildi (knopka rem'da edi —
   font-size o'zgarsa buzilardi) va qorong'i rejim ranglari qo'shildi. */
.switch {
  font-size: 14px;
  position: relative;
  display: inline-block;
  width: 3.5em;
  height: 2em;
  flex: none;
}

/* Standart checkboxni yashiramiz (globaldagi appearance uslublarini ham bekor qiladi) */
.switch input {
  opacity: 0;
  width: 0;
  height: 0;
  position: absolute;
  border: none;
}

.slider {
  position: absolute;
  cursor: pointer;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: #B0B0B0;
  border: 1px solid #B0B0B0;
  transition: .4s;
  border-radius: 32px;
  outline: none;
}

.slider:before {
  position: absolute;
  content: "";
  height: 2em;
  width: 2em;
  border-radius: 50%;
  outline: 2px solid #B0B0B0;
  left: -1px;
  bottom: -1px;
  background-color: #fff;
  transition: transform .25s ease-in-out 0s;
}

.slider-icon {
  opacity: 0;
  height: 12px;
  width: 12px;
  stroke-width: 8;
  position: absolute;
  z-index: 999;
  stroke: #222222;
  right: 60%;
  top: 30%;
  transition: right ease-in-out .3s, opacity ease-in-out .15s;
}

.switch input:checked + .slider {
  background-color: #222222;
  border-color: #222222;
}

.switch input:checked + .slider .slider-icon {
  opacity: 1;
  right: 20%;
}

.switch input:checked + .slider:before {
  transform: translateX(1.5em);
  outline-color: #181818;
}

/* Qorong'i rejimda #222 fon kartada ko'rinmay qoladi — primary rangga o'tamiz */
.dark .switch input:checked + .slider {
  background-color: var(--ap-primary);
  border-color: var(--ap-primary);
}
.dark .switch input:checked + .slider:before { outline-color: var(--ap-primary); }
.dark .slider-icon { stroke: var(--ap-primary); }

.switch input:focus-visible + .slider { box-shadow: 0 0 0 3px var(--ap-ring); }

/* Kichik switch — bildirishnomalar matritsasi uchun */
.switch-sm { font-size: 10px; }

/* Bildirishnoma sozlamalari matritsasi: yorliq + 3 kanal ustuni */
.ap-prefs-row {
  display: grid;
  grid-template-columns: 1fr auto auto auto;
  align-items: center;
  column-gap: 1rem;
}

/* Forma maydonlari yonidagi "i" info tugmasi va uning tooltip'i.
   position:relative + z-index o'zining "stacking context"ini hosil qiladi —
   shu sababli popup formadagi keyingi (static) div'lar ostiga kirib
   qolmay, ular ustida chiqadi. */
.field-info { position: relative; display: inline-flex; vertical-align: middle; z-index: 1; }
.field-info:hover, .field-info:focus-within { z-index: 60; }
.field-info-btn {
  display: inline-flex; align-items: center; justify-content: center;
  width: 16px; height: 16px; margin-left: 4px; border-radius: 9999px; border: none;
  background: #e5e7eb; color: #4b5563; font-size: 10px; font-weight: 700;
  line-height: 1; cursor: help; padding: 0;
}
.field-info-btn:hover, .field-info-btn:focus { background: #d1d5db; outline: none; }
.dark .field-info-btn { background: #374151; color: #d1d5db; }
.dark .field-info-btn:hover, .dark .field-info-btn:focus { background: #4b5563; }
.field-info-popup {
  /* Tugma tagida markazlashtirish o'rniga chapdan boshlab o'ngga o'sadi —
     shunda ekranning chap chetiga yaqin maydonlarda popup asosiy oyna
     tashqarisiga (yon panel ustiga) chiqib, kesilib qolmaydi. */
  position: absolute; left: 0; top: 100%;
  margin-top: 6px; width: 220px; max-width: calc(100vw - 2.5rem); background: #111827; color: #fff;
  font-size: 11px; font-weight: 400; line-height: 1.4; padding: 8px 10px; border-radius: 6px;
  box-shadow: 0 4px 12px rgba(0,0,0,.25); opacity: 0; pointer-events: none;
  transition: opacity .15s ease; z-index: 60; text-align: left;
}
.field-info-btn:hover + .field-info-popup,
.field-info-btn:focus + .field-info-popup { opacity: 1; pointer-events: auto; }
