/* ─────────────────────────────────────────────────────────────
   rtc.css — Styles for RTC / Mutation / Akarband / E-Swathu / E-Khata views
   All scoped under .swarnal-view to avoid collisions with TruDOCS styles.
   Add <link rel="stylesheet" href="/rtc.css" /> in index.html <head>.
   ───────────────────────────────────────────────────────────── */

/* ── View container ───────────────────────────────────────── */
.swarnal-view {
  display: flex;
  flex-direction: column;
  flex: 1;
}

/* ── Topbar ───────────────────────────────────────────────── */
.swarnal-view .topbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 0 0;
  flex-shrink: 0;
  margin-bottom: 4px;
}

.swarnal-view .topbar-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-muted);
}

.swarnal-view .topbar-chip {
  font-size: 12px;
  font-weight: 500;
  color: var(--text);
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 20px;
  padding: 5px 14px;
}

/* ── Page heading ─────────────────────────────────────────── */
.swarnal-view .content {
  flex: 1;
  padding-top: 8px;
}

.swarnal-view .page-heading {
  margin-bottom: 20px;
}

.swarnal-view .page-heading h1 {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -0.02em;
  line-height: 1.2;
  margin-bottom: 6px;
}

.swarnal-view .page-heading p {
  font-size: 13px;
  color: var(--text-muted);
}

/* ── Card ─────────────────────────────────────────────────── */
.swarnal-view .card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  overflow: visible;
  box-shadow: var(--shadow-sm);
}

.swarnal-view .card-full {
  margin-top: 20px;
}

.swarnal-view .card-body {
  padding: 24px 28px 28px;
  display: grid;
  grid-template-columns: 1fr 240px;
  gap: 0 28px;
  align-items: start;
}

.swarnal-view .card-fields {
  display: flex;
  flex-direction: column;
}

.swarnal-view .card-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
  padding-top: 24px;
  border-left: 1px solid var(--border);
  padding-left: 28px;
  height: 100%;
  justify-content: center;
}

/* ── Fields ───────────────────────────────────────────────── */
.swarnal-view .field {
  margin-bottom: 20px;
}

.swarnal-view .field:last-child {
  margin-bottom: 0;
}

.swarnal-view .field-label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: var(--text-muted);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 4px;
}

/* ── Custom select dropdown ───────────────────────────────── */
.swarnal-view .custom-select-wrapper {
  position: relative;
  width: 100%;
}

.swarnal-view .custom-select-trigger {
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-family: var(--font-body);
  color: var(--text);
  background: var(--surface);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  transition: border-color 0.15s, box-shadow 0.15s;
  min-height: 40px;
  gap: 8px;
}

.swarnal-view .custom-select-trigger:hover {
  border-color: var(--border-strong);
}

.swarnal-view .custom-select-trigger.open {
  border-color: var(--primary);
  box-shadow: 0 0 0 3px var(--primary-tint);
  border-bottom-left-radius: 0;
  border-bottom-right-radius: 0;
}

.swarnal-view .custom-select-trigger.disabled-trigger {
  background: var(--surface-2);
  color: var(--text-faint);
  cursor: not-allowed;
  pointer-events: none;
  border-color: var(--border);
}

.swarnal-view .custom-select-trigger svg {
  flex-shrink: 0;
  transition: transform 0.2s;
  color: var(--text-faint);
}

.swarnal-view .custom-select-trigger.open svg {
  transform: rotate(180deg);
}

.swarnal-view .custom-select-dropdown {
  display: none;
  position: absolute;
  top: 100%; left: 0; right: 0;
  background: var(--surface);
  border: 1.5px solid var(--primary);
  border-top: none;
  border-bottom-left-radius: 10px;
  border-bottom-right-radius: 10px;
  z-index: 9999;
  box-shadow: var(--shadow-lg);
}

.swarnal-view .custom-select-dropdown.open {
  display: block;
}

.swarnal-view .custom-select-list {
  max-height: 280px;
  overflow-y: auto;
  scrollbar-width: thin;
  overscroll-behavior: contain;
}

.swarnal-view .custom-select-item {
  padding: 10px 16px;
  font-size: 13px;
  cursor: pointer;
  color: var(--text-muted);
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}

.swarnal-view .custom-select-item:last-child { border-bottom: none; }
.swarnal-view .custom-select-item:hover { background: var(--surface-2); color: var(--text); }
.swarnal-view .custom-select-item.selected { background: var(--primary-tint); color: var(--primary); font-weight: 500; }

.swarnal-view .loc-item {
  padding: 10px 16px;
  cursor: pointer;
  transition: background 0.1s;
  border-bottom: 1px solid var(--border);
}
.swarnal-view .loc-item:last-child { border-bottom: none; }
.swarnal-view .loc-item:hover { background: var(--surface-2); }
.swarnal-view .loc-item.selected { background: var(--primary-tint); }
.swarnal-view .loc-item-village { font-size: 13px; font-weight: 500; color: var(--text); }
.swarnal-view .loc-item.selected .loc-item-village { color: var(--primary); }
.swarnal-view .loc-item-meta { font-size: 11px; color: var(--text-faint); margin-top: 2px; }
.swarnal-view .custom-select-empty { padding: 16px; font-size: 13px; color: var(--text-faint); text-align: center; }

.swarnal-view .survey-input-inner {
  border: none; outline: none; background: transparent;
  width: 100%; font-size: 13px; font-family: var(--font-body); color: var(--text);
}
.swarnal-view .survey-input-inner::placeholder { color: var(--text-faint); }
.swarnal-view .survey-input-inner:disabled { cursor: not-allowed; color: var(--text-faint); }

/* ── Buttons ──────────────────────────────────────────────── */
.swarnal-view .btn-search {
  width: 100%;
  padding: 11px 20px;
  background: var(--primary);
  color: #fff;
  border: none;
  border-radius: 10px;
  font-size: 14px;
  font-weight: 600;
  font-family: var(--font-body);
  cursor: pointer;
  transition: background 0.15s, box-shadow 0.15s;
  white-space: nowrap;
}
.swarnal-view .btn-search:hover:not(:disabled) { background: var(--primary-hover); }
.swarnal-view .btn-search:disabled { opacity: 0.45; cursor: not-allowed; }

.swarnal-view .btn-reset {
  width: 100%;
  padding: 11px 20px;
  background: var(--surface);
  color: var(--text-muted);
  border: 1.5px solid var(--border);
  border-radius: 10px;
  font-size: 13px;
  font-weight: 500;
  font-family: var(--font-body);
  cursor: pointer;
  transition: all 0.15s;
}
.swarnal-view .btn-reset:hover { background: var(--surface-2); border-color: var(--border-strong); }

/* ── Status row ───────────────────────────────────────────── */
.swarnal-view .status-row {
  display: flex;
  align-items: center;
  gap: 8px;
  min-height: 20px;
}

.swarnal-view .status-dot {
  width: 7px; height: 7px; border-radius: 50%;
  background: var(--text-faint); flex-shrink: 0;
}
.swarnal-view .status-dot.ok   { background: #16a34a; }
.swarnal-view .status-dot.err  { background: var(--danger-text); }
.swarnal-view .status-dot.info { background: #2563eb; animation: rtc-pulse 1.5s infinite; }
@keyframes rtc-pulse { 0%,100%{ opacity:1 } 50%{ opacity:0.35 } }

.swarnal-view .status-text      { font-size: 12px; color: var(--text-muted); }
.swarnal-view .status-text.ok   { color: #16a34a; }
.swarnal-view .status-text.err  { color: var(--danger-text); }
.swarnal-view .status-text.info { color: #2563eb; }

/* ── Result card ──────────────────────────────────────────── */
.swarnal-view .result-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 20px;
  border-bottom: 1px solid var(--border);
}
.swarnal-view .result-header-left { font-size: 13px; font-weight: 600; color: var(--text); }
.swarnal-view .result-header .result-actions {
  display: flex; align-items: center; gap: 8px;
  margin: 0; padding: 0; background: none; border: none; border-radius: 0;
  animation: none; flex-wrap: nowrap; justify-content: flex-end;
}

.swarnal-view .dl-btn {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; font-weight: 500; font-family: var(--font-body);
  color: var(--text-muted); background: var(--surface);
  border: 1.5px solid var(--border);
  border-radius: 8px; padding: 6px 14px; cursor: pointer; transition: all 0.15s;
}
.swarnal-view .dl-btn:hover:not(:disabled) { border-color: var(--primary); color: var(--primary); }
.swarnal-view .dl-btn:disabled { opacity: 0.4; cursor: not-allowed; }

.swarnal-view .result-body {
  position: relative;
  background: var(--surface-2);
  min-height: 200px;
}

.swarnal-view iframe {
  width: 100%; height: auto; min-height: 400px;
  border: none; display: none; background: #fff;
}

.swarnal-view .placeholder {
  position: absolute; inset: 0;
  display: flex; flex-direction: column;
  align-items: center; justify-content: center; gap: 12px;
}
.swarnal-view .placeholder-icon {
  width: 60px; height: 60px;
  border: 1.5px solid var(--border); border-radius: 16px;
  background: var(--surface);
  display: flex; align-items: center; justify-content: center; font-size: 26px;
}
.swarnal-view .placeholder p { font-size: 13px; color: var(--text-faint); }

.swarnal-view .spinner {
  width: 28px; height: 28px;
  border: 2.5px solid var(--border); border-top-color: var(--primary);
  border-radius: 50%; animation: rtc-spin 0.7s linear infinite;
}
@keyframes rtc-spin { to { transform: rotate(360deg); } }

.swarnal-view .combo-badge {
  font-size: 10px; font-weight: 600;
  background: var(--primary-tint); color: var(--primary);
  border: 1px solid rgba(22,58,46,0.2);
  border-radius: 20px; padding: 2px 8px;
  margin-left: 6px;
  display: none;
}

/* ── iOS prevent zoom ─────────────────────────────────────── */
@media (max-width: 700px) {
  .swarnal-view .survey-input-inner { font-size: 16px; }
}

/* ── Mobile: stack card-body vertically ───────────────────── */
@media (max-width: 767px) {
  .swarnal-view .topbar { padding: 0 0 8px; }
  .swarnal-view .content { padding-top: 4px; }
  .swarnal-view .card-body {
    grid-template-columns: 1fr;
    padding: 16px;
  }
  .swarnal-view .card-actions {
    border-left: none;
    border-top: 1px solid var(--border);
    padding-left: 0;
    padding-top: 16px;
    margin-top: 4px;
  }
  .swarnal-view .page-heading h1 { font-size: 22px; }
}

/* ── Mobile tab bar: scrollable when many tabs ─────────────── */
@media (max-width: 767px) {
  .mobile-tab-bar {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scroll-behavior: smooth;
    scrollbar-width: none;
  }
  .mobile-tab-bar::-webkit-scrollbar { display: none; }
  .mobile-tab {
    min-width: 60px;
    flex: 0 0 auto;
  }
}

/* ── Critical: override hidden attribute so views stay hidden ─── */
.swarnal-view[hidden] { display: none !important; }

/* ══════════════════════════════════════════════════════════
   MOBILE DRAWER — replaces bottom tab bar
   ════════════════════════════════════════════════════════ */

@media (max-width: 767px) {
  .mobile-tab-bar      { display: none !important; }
  .main                { padding-bottom: 200px !important; }
  .mobile-download-bar {
    bottom: 0 !important;
    padding-bottom: calc(16px + env(safe-area-inset-bottom)) !important;
  }
}

/* Hamburger button */
.hamburger-btn {
  display: none;
  width: 40px;
  height: 40px;
  background: none;
  border: none;
  cursor: pointer;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  gap: 6px;
  padding: 8px;
  flex-shrink: 0;
  border-radius: 8px;
  transition: background 0.15s;
}
.hamburger-btn:hover { background: rgba(255,255,255,0.1); }

@media (max-width: 767px) {
  .hamburger-btn { display: flex; }
}

.hamburger-btn span {
  display: block;
  width: 20px;
  height: 2px;
  background: #fff;
  border-radius: 2px;
  transition: transform 0.3s cubic-bezier(0.4,0,0.2,1),
              opacity   0.2s ease,
              width     0.3s ease;
  transform-origin: center;
}

.hamburger-btn.open span:nth-child(1) { transform: translateY(8px) rotate(45deg); }
.hamburger-btn.open span:nth-child(2) { opacity: 0; transform: scaleX(0); }
.hamburger-btn.open span:nth-child(3) { transform: translateY(-8px) rotate(-45deg); }

/* Backdrop */
#drawer-backdrop {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.55);
  z-index: 299;
  backdrop-filter: blur(2px);
  -webkit-backdrop-filter: blur(2px);
  animation: fadeInBd 0.2s ease;
}
#drawer-backdrop.open { display: block; }
@keyframes fadeInBd { from { opacity: 0; } to { opacity: 1; } }

/* Close button only visible on mobile */
.drawer-close-btn { display: none; }

/* Sidebar drawer on mobile */
@media (max-width: 767px) {
  .sidebar {
    display: block !important;
    position: fixed !important;
    top: 0;
    left: -290px;
    width: 275px;
    height: 100vh;
    z-index: 300;
    transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    overflow-y: auto;
    padding: 24px 20px 40px !important;
    box-shadow: none;
    background: rgba(18, 46, 36, 0.72) !important;
    backdrop-filter: blur(24px);
    -webkit-backdrop-filter: blur(24px);
  }

  .sidebar.drawer-open {
    left: 0;
    box-shadow: 8px 0 40px rgba(0,0,0,0.45);
  }

  .sidebar .nav-section-title,
  .sidebar .nav-item,
  .sidebar .nav-item-sub { color: var(--sidebar-text, #F4F0E7) !important; }

  .sidebar .nav-item-sub.active-sub {
    background: rgba(255,255,255,0.14) !important;
    color: #fff !important;
  }

  .sidebar .logo { margin-bottom: 28px; }

  .drawer-close-btn {
    display: flex;
    position: absolute;
    top: 16px;
    right: 16px;
    width: 29px;
    height: 29px;
    border-radius: 6px;
    border: none;
    background: rgba(255,255,255,0.08);
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 15px;
    transition: background 0.15s;
  }
  .drawer-close-btn:hover { background: rgba(255,255,255,0.18); }
}

/* Topbar hide on scroll */
.mobile-topbar { transition: transform 0.3s ease; }
.mobile-topbar.topbar-hidden { transform: translateY(-100%); }

/* Nav item spacing */
@media (max-width: 767px) {
  .sidebar .nav-list { gap: 4px !important; }

  .sidebar .nav-item-sub {
    padding: 12px 14px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
    letter-spacing: 0.01em;
    border-bottom: 1px solid rgba(255,255,255,0.06);
    margin-bottom: 2px;
  }
  .sidebar .nav-item-sub:last-child { border-bottom: none; }

  .sidebar .nav-section + .nav-section {
    margin-top: 20px !important;
    padding-top: 16px;
    border-top: 1px solid rgba(255,255,255,0.12);
  }

  .sidebar .nav-item {
    padding: 10px 14px !important;
    border-radius: 10px !important;
    font-size: 14px !important;
  }

  .sidebar .nav-item-sub .dot {
    width: 8px !important;
    height: 8px !important;
    margin-right: 12px !important;
    flex-shrink: 0;
  }
}

/* Mobile download bar opaque */
@media (max-width: 767px) {
  .mobile-download-bar {
    background: rgba(255, 255, 255, 0.97) !important;
    backdrop-filter: blur(12px) !important;
    -webkit-backdrop-filter: blur(12px) !important;
    border-top: 1.5px solid var(--border) !important;
  }
}

/* ══════════════════════════════════════════════════════════
   MOBILE PDF FIX — iframes can't show PDFs on mobile
   Replace iframe with open/download button on mobile
   ════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  /* Hide PDF iframes on mobile — use open button instead */
  #akb-resultFrame,
  #rtc-resultFrame,
  #mut-resultFrame {
    display: none !important;
  }

  /* Show a mobile-friendly open button when PDF is loaded */
  .mobile-pdf-open-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
    width: 100%;
    padding: 16px;
    background: var(--primary);
    color: #fff;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 600;
    font-family: var(--font-body);
    cursor: pointer;
    margin: 16px 0;
    transition: background 0.15s;
  }
  .mobile-pdf-open-btn:hover { background: var(--primary-hover); }

  /* Result body padding on mobile */
  .swarnal-view .result-body { min-height: 80px; padding: 16px; }
}

/* Hide mobile-pdf-open-btn on desktop */
.mobile-pdf-open-btn { display: none; }

/* ══════════════════════════════════════════════════════════
   E-KHATA TABLE — mobile column pruning
   Keep: ePID | Owner Name | Certificate (hide: # | SAS Tax ID | Address)
   ════════════════════════════════════════════════════════ */
@media (max-width: 767px) {
  #ekh-table th:nth-child(1), #ekh-table td:nth-child(1),
  #ekh-table th:nth-child(3), #ekh-table td:nth-child(3),
  #ekh-table th:nth-child(5), #ekh-table td:nth-child(5) {
    display: none;
  }
  #ekh-table { font-size: 12px; }
  #ekh-table th, #ekh-table td { padding: 8px 10px; }
  #ekh-table td:nth-child(2) { font-weight: 600; word-break: break-all; }
  #ekh-table td:nth-child(6) { text-align: center; }

  /* E-Swathu: keep Panchayat | Property ID | Owner | Certificate */
  #esw-table th:nth-child(1), #esw-table td:nth-child(1),
  #esw-table th:nth-child(3), #esw-table td:nth-child(3),
  #esw-table th:nth-child(5), #esw-table td:nth-child(5),
  #esw-table th:nth-child(7), #esw-table td:nth-child(7) {
    display: none;
  }
  #esw-table { font-size: 12px; }
  #esw-table th, #esw-table td { padding: 8px 10px; }
}