/* ============================================
   BASE & RESET
   ============================================ */
* { -webkit-tap-highlight-color: transparent; }

html { scroll-behavior: smooth; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto,
               'Helvetica Neue', Arial, sans-serif;
  font-size: 16px;
  line-height: 1.5;
  padding-bottom: env(safe-area-inset-bottom);
  overflow-x: hidden;
}

/* Touch target minimal 44px — kecuali tombol close & toggler */
.btn:not(.btn-close):not(.navbar-toggler),
button:not(.btn-close):not(.navbar-toggler):not(.dropdown-toggle) {
  min-height: 44px;
}
a.btn {
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.btn-close {
  min-height: auto !important;
  width: 1em;
  height: 1em;
  padding: .25em .25em;
}

input, select, textarea {
  font-size: 16px !important; /* Cegah zoom otomatis di iOS */
}

/* ============================================
   HEADER RESPONSIF
   ============================================ */
.header-section {
  padding: 1.5rem 1rem 1rem;
  text-align: center;
}
.header-section h1 { font-size: 1.4rem; }
.header-section p { font-size: .9rem; }

@media (min-width: 768px) {
  .header-section { padding: 2.5rem 1rem 1rem; }
  .header-section h1 { font-size: 2rem; }
  .header-section p { font-size: 1rem; }
}

/* ============================================
   KARTU KANDIDAT DI HALAMAN LOGIN
   ============================================ */
.kandidat-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.1);
  height: 100%;
  transition: transform .2s, box-shadow .2s;
}

.kandidat-foto {
  width: 100%;
  height: 220px;
  object-fit: cover;
  object-position: center top;
  background: #e5e7eb;
}

@media (min-width: 768px) {
  .kandidat-card:hover { transform: translateY(-4px); box-shadow: 0 10px 28px rgba(0,0,0,.18); }
  .kandidat-foto { height: 260px; }
}

.kandidat-no {
  position: absolute;
  top: 10px; left: 10px;
  background: #1e3a8a; color: #fff;
  font-weight: 700; font-size: .95rem;
  width: 40px; height: 40px;
  border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  border: 3px solid #fff;
  box-shadow: 0 3px 8px rgba(0,0,0,.2);
  z-index: 2;
}

.kandidat-body { padding: .9rem; }
.kandidat-nama { font-weight: 700; font-size: 1rem; color: #1e3a8a; }
.kandidat-kelas { font-size: .8rem; color: #6b7280; }
.kandidat-visi {
  font-size: .82rem; color: #4b5563; margin-top: .4rem;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

/* ============================================
   LOGIN BOX - STICKY DI MOBILE
   ============================================ */
.login-card {
  background: #fff;
  border-radius: 16px;
  box-shadow: 0 8px 24px rgba(0,0,0,.15);
}

.login-mobile-sticky {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top-left-radius: 20px;
  border-top-right-radius: 20px;
  box-shadow: 0 -8px 24px rgba(0,0,0,.2);
  padding: 1rem;
  z-index: 1000;
  max-height: 85vh;
  overflow-y: auto;
  transition: transform .3s ease;
}

.login-mobile-sticky.collapsed {
  transform: translateY(calc(100% - 70px));
}

.login-mobile-toggle {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding-bottom: .75rem;
  margin-bottom: .75rem;
  border-bottom: 1px solid #e5e7eb;
  cursor: pointer;
  font-weight: 600;
  color: #1e3a8a;
}

@media (min-width: 992px) {
  .login-mobile-sticky {
    position: static;
    box-shadow: 0 8px 24px rgba(0,0,0,.15);
    border-radius: 16px;
    max-height: none;
    padding: 1.5rem;
    transform: none !important;
  }
  .login-mobile-toggle { display: none; }
}

.nav-pills .nav-link {
  font-size: .85rem;
  padding: .55rem .25rem;
  min-height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* ============================================
   VOTING - KARTU KANDIDAT DASHBOARD
   ============================================ */
.kandidat-vote-card {
  background: #fff;
  border-radius: 16px;
  overflow: hidden;
  box-shadow: 0 4px 12px rgba(0,0,0,.08);
  margin-bottom: 1rem;
}

.kandidat-vote-foto {
  width: 100%;
  height: 240px;
  object-fit: cover;
  object-position: center top;
}

.kandidat-vote-body { padding: 1rem; }

.btn-pilih-besar {
  width: 100%;
  padding: 1rem;
  font-size: 1.05rem;
  font-weight: 700;
  border-radius: 12px;
  min-height: 52px;
}

@media (min-width: 768px) {
  .kandidat-vote-foto { height: 260px; }
  .btn-pilih-besar { font-size: 1rem; padding: .85rem; }
}

/* ============================================
   BOTTOM NAVIGATION UNTUK ADMIN MOBILE
   ============================================ */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  background: #fff;
  border-top: 1px solid #e5e7eb;
  box-shadow: 0 -2px 12px rgba(0,0,0,.08);
  display: flex;
  justify-content: space-around;
  align-items: stretch;
  z-index: 1030;
  padding-bottom: env(safe-area-inset-bottom);
}

.bottom-nav a {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: .55rem .25rem;
  color: #6b7280;
  text-decoration: none;
  font-size: .7rem;
  line-height: 1.2;
  transition: color .15s;
  min-height: 56px;
}

.bottom-nav a .nav-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: .15rem;
}

.bottom-nav a.active,
.bottom-nav a:active {
  color: #1e3a8a;
  font-weight: 600;
}

body.has-bottom-nav { padding-bottom: 80px; }

@media (min-width: 768px) {
  .bottom-nav { display: none; }
  body.has-bottom-nav { padding-bottom: 0 !important; }
}

/* ============================================
   TABEL RESPONSIF → CARD DI MOBILE
   ============================================ */
@media (max-width: 767.98px) {

  .table-responsive:has(.table-responsive-card),
  .table-responsive-card-wrapper {
    overflow-x: visible !important;
  }

  .table-responsive-card thead { display: none; }

  .table-responsive-card,
  .table-responsive-card tbody,
  .table-responsive-card tr,
  .table-responsive-card td {
    display: block;
    width: 100%;
  }

  .table-responsive-card tr {
    background: #fff;
    border-radius: 12px;
    margin-bottom: .75rem;
    padding: .75rem;
    box-shadow: 0 2px 6px rgba(0,0,0,.06);
    border-left: 4px solid #e5e7eb;
  }
  .table-responsive-card tr.row-sudah { border-left-color: #10b981; }
  .table-responsive-card tr.row-belum { border-left-color: #f59e0b; }

  .table-responsive-card td {
    padding: .25rem 0;
    border: none;
    display: flex;
    justify-content: space-between;
    align-items: center;
    text-align: right;
    word-break: break-word;
  }

  .table-responsive-card td[data-label]::before {
    content: attr(data-label);
    font-weight: 600;
    color: #6b7280;
    font-size: .8rem;
    text-align: left;
    flex-shrink: 0;
    margin-right: .75rem;
  }

  .table-responsive-card td[colspan] {
    display: block !important;
    text-align: center !important;
    padding: 1.5rem .75rem !important;
    border: none !important;
    margin: 0 !important;
  }
  .table-responsive-card td[colspan]::before { content: none !important; }

  .table-responsive-card td[data-label="Aksi"],
  .table-responsive-card td.aksi-cell {
    flex-direction: column !important;
    gap: .5rem;
    margin-top: .5rem;
    padding-top: .5rem;
    border-top: 1px solid #e5e7eb;
    align-items: stretch !important;
  }
  .table-responsive-card td[data-label="Aksi"]::before,
  .table-responsive-card td.aksi-cell::before { display: none !important; }

  .table-responsive-card td .btn,
  .table-responsive-card td form { width: 100%; }
}

/* ============================================
   MODAL RESPONSIF
   ============================================ */
@media (max-width: 767.98px) {
  .modal-dialog {
    margin: .5rem;
    max-width: calc(100% - 1rem);
  }
  .modal-dialog.modal-dialog-centered {
    min-height: calc(100% - 1rem);
    align-items: flex-end;
  }
  .modal-content {
    border-top-left-radius: 20px;
    border-top-right-radius: 20px;
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    max-height: 92vh;
  }
  .modal-body { max-height: 65vh; overflow-y: auto; }
}

/* ============================================
   FORM & INPUT DI MOBILE
   ============================================ */
@media (max-width: 767.98px) {
  .form-control, .form-select {
    padding: .75rem .9rem;
    font-size: 16px !important;
    border-radius: 10px;
  }
  .card-body { padding: 1rem; }
  .btn { font-size: .9rem; }
}

/* ============================================
   UTILITAS UMUM
   ============================================ */
.sticky-top-mobile {
  position: sticky;
  top: 0;
  z-index: 1020;
}

.text-truncate-2 {
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

@media (max-width: 767.98px) {
  .hide-mobile { display: none !important; }
}

@media (min-width: 768px) {
  .hide-desktop { display: none !important; }
}

::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-thumb { background: #cbd5e1; border-radius: 3px; }
::-webkit-scrollbar-track { background: transparent; }

/* ============================================
   TOAST MOBILE
   ============================================ */
.toast-mobile {
  position: fixed;
  bottom: 90px; left: 50%; transform: translateX(-50%);
  background: #1f2937; color: #fff;
  padding: .75rem 1.25rem;
  border-radius: 12px;
  font-size: .9rem;
  z-index: 2000;
  box-shadow: 0 8px 24px rgba(0,0,0,.25);
  animation: slideUp .3s ease;
}

@keyframes slideUp {
  from { opacity: 0; transform: translate(-50%, 20px); }
  to   { opacity: 1; transform: translate(-50%, 0); }
}

/* ============================================
   AKSI — Desktop vs Mobile
   ============================================ */
.aksi-desktop { display: none; }
.aksi-mobile  { display: block; }

@media (min-width: 768px) {
  .aksi-desktop { display: block; }
  .aksi-mobile  { display: none; }
}

@media (max-width: 767.98px) {
  .aksi-cell {
    flex-direction: column !important;
    align-items: stretch !important;
  }
  .aksi-cell::before { display: none !important; }
  .aksi-cell .btn,
  .aksi-cell form { width: 100%; }
}

/* ============================================
   FOOTER UNIVERSAL — Semua Halaman
   ============================================ */
.app-footer {
  text-align: center;
  padding: 1.5rem 1rem;
  font-size: .78rem;
  line-height: 1.6;
  margin-top: auto;
}

.app-footer-inner {
  max-width: 1200px;
  margin: 0 auto;
}

.app-footer .credit-line {
  display: block;
  margin-bottom: .25rem;
}

.app-footer .credit-line strong {
  font-weight: 700;
  letter-spacing: .3px;
}

.app-footer .copyright {
  display: block;
  font-size: .72rem;
  letter-spacing: .2px;
}

.app-footer .footer-heart {
  color: #ef4444;
  margin: 0 .15rem;
  display: inline-block;
  animation: heartbeat 1.5s ease-in-out infinite;
}

@keyframes heartbeat {
  0%, 100% { transform: scale(1); }
  50% { transform: scale(1.2); }
}

/* ---- Tema TERANG ---- */
.app-footer-light {
  background: #f8fafc;
  border-top: 1px solid #e5e7eb;
  color: #64748b;
}
.app-footer-light .credit-line strong {
  color: #1e3a8a;
}

/* ---- Tema GELAP ---- */
.app-footer-dark {
  color: rgba(255,255,255,.85);
}
.app-footer-dark .credit-line strong {
  color: #fff;
}

/* ---- Beri ruang untuk bottom nav di mobile ---- */
@media (max-width: 767.98px) {
  body.has-bottom-nav .app-footer {
    padding-bottom: 6rem;
  }
}

@media (max-width: 575.98px) {
  .app-footer {
    font-size: .72rem;
    padding: 1.25rem 1rem;
  }
  .app-footer .copyright {
    font-size: .68rem;
  }
}