/**
 * SROBI AKSI - PILPET SROBYONG 2026
 * Modern Clean Light Aesthetic & Robust Sidebar Layout
 */

@import url('https://fonts.googleapis.com/css2?family=Plus+Jakarta+Sans:wght@300;400;500;600;700;800;900&family=JetBrains+Mono:wght@500;600;700;800&display=swap');

:root {
  --font-sans: 'Plus Jakarta Sans', system-ui, -apple-system, sans-serif;
  --font-mono: 'JetBrains Mono', monospace, sans-serif;
  
  --sidebar-w: 260px;
  --header-h: 68px;
  
  --bg-app: #f8fafc;
  --sidebar-bg: #ffffff;
  --card-bg: #ffffff;
  --border-color: #e2e8f0;
  
  --primary: #4f46e5;
  --primary-hover: #4338ca;
  --primary-light: #eef2ff;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
}

* {
  box-sizing: border-box;
}

html, body {
  background-color: var(--bg-app);
  font-family: var(--font-sans);
  color: var(--text-main);
  margin: 0;
  padding: 0;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* Custom Scrollbar */
::-webkit-scrollbar {
  width: 6px;
  height: 6px;
}
::-webkit-scrollbar-track {
  background: #f1f5f9;
}
::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 9999px;
}
::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* =========================================================================
   LOGIN PAGE (SPLIT HERO LUXURY DESIGN)
   ========================================================================= */
.login-page-wrapper {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px 16px;
  background: radial-gradient(circle at 10% 20%, #e0e7ff 0%, #f8fafc 60%, #e2e8f0 100%);
}

.login-luxury-card {
  width: 100%;
  max-width: 980px;
  background: #ffffff;
  border-radius: 2rem;
  box-shadow: 0 25px 60px -15px rgba(79, 70, 229, 0.18), 0 0 0 1px rgba(226, 232, 240, 0.8);
  overflow: hidden;
  display: flex;
  flex-direction: column;
}

@media (min-width: 860px) {
  .login-luxury-card {
    flex-direction: row;
  }
}

/* HERO SIDE: HIDDEN ON SMALL SCREENS AS REQUESTED */
.login-hero-side {
  display: none;
  flex: 1;
  background: linear-gradient(135deg, #1e1b4b 0%, #312e81 60%, #4338ca 100%);
  color: white;
  padding: 40px 36px;
  flex-direction: column;
  justify-content: space-between;
  position: relative;
  overflow: hidden;
}

@media (min-width: 860px) {
  .login-hero-side {
    display: flex;
  }
}

.login-hero-side::after {
  content: '';
  position: absolute;
  top: -50%;
  right: -50%;
  width: 200%;
  height: 200%;
  background: radial-gradient(circle, rgba(99, 102, 241, 0.25) 0%, transparent 60%);
  pointer-events: none;
}

.login-form-side {
  flex: 1.15;
  padding: 40px 36px;
  background: #ffffff;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

@media (max-width: 859.98px) {
  .login-page-wrapper {
    padding: 20px 14px;
    align-items: center;
  }
  .login-luxury-card {
    max-width: 460px;
    border-radius: 1.5rem;
    box-shadow: 0 15px 35px -8px rgba(79, 70, 229, 0.15), 0 0 0 1px rgba(226, 232, 240, 0.85);
  }
  .login-form-side {
    padding: 28px 20px;
  }
}

/* =========================================================================
   APP CONTAINER & SIDEBAR LAYOUT (FLAWLESS FLEX STRUCTURE)
   ========================================================================= */
.app-layout-wrapper {
  display: flex;
  min-height: 100vh;
  width: 100%;
  background-color: var(--bg-app);
}

/* SIDEBAR */
.app-sidebar {
  width: var(--sidebar-w);
  min-width: var(--sidebar-w);
  max-width: var(--sidebar-w);
  height: 100vh;
  position: sticky;
  top: 0;
  background: var(--sidebar-bg);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  z-index: 1040;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

.sidebar-header {
  height: var(--header-h);
  padding: 0 20px;
  display: flex;
  align-items: center;
  gap: 12px;
  border-bottom: 1px solid var(--border-color);
  flex-shrink: 0;
}

.sidebar-brand-logo {
  width: 42px;
  height: 42px;
  border-radius: 12px;
  object-fit: contain;
  background: #f8fafc;
  padding: 3px;
  border: 1px solid #e2e8f0;
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.04);
}

.sidebar-menu-wrapper {
  flex: 1;
  overflow-y: auto;
  padding: 16px 12px;
}

.sidebar-section-title {
  font-size: 0.68rem;
  font-weight: 800;
  text-transform: uppercase;
  letter-spacing: 0.08em;
  color: #94a3b8;
  padding: 10px 12px 6px;
}

.sidebar-nav-item {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 10px 14px;
  border-radius: 0.85rem;
  color: #475569;
  font-weight: 600;
  font-size: 0.88rem;
  text-decoration: none;
  transition: all 0.18s ease;
  margin-bottom: 4px;
  cursor: pointer;
  border: 1px solid transparent;
}

.sidebar-nav-item i {
  font-size: 1.05rem;
  width: 22px;
  text-align: center;
  color: #64748b;
  transition: color 0.18s ease;
}

.sidebar-nav-item:hover {
  background: #f1f5f9;
  color: #0f172a;
}
.sidebar-nav-item:hover i {
  color: var(--primary);
}

.sidebar-nav-item.active {
  background: #eef2ff;
  color: var(--primary);
  border-color: #e0e7ff;
  font-weight: 700;
  box-shadow: 0 2px 8px rgba(79, 70, 229, 0.08);
}
.sidebar-nav-item.active i {
  color: var(--primary);
}

.sidebar-footer {
  padding: 14px 16px;
  border-top: 1px solid var(--border-color);
  background: #f8fafc;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

/* RIGHT CONTENT WRAPPER */
.app-content-wrapper {
  flex: 1;
  min-width: 0; /* CRUCIAL: prevents flex child from expanding beyond container */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  background-color: var(--bg-app);
}

/* TOPBAR */
.app-topbar {
  height: var(--header-h);
  background: #ffffff;
  border-bottom: 1px solid var(--border-color);
  position: sticky;
  top: 0;
  z-index: 1020;
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0 28px;
  flex-shrink: 0;
}

/* MAIN CONTENT AREA */
.app-main-content {
  flex: 1;
  width: 100%;
}

.app-page-body {
  padding: 24px 28px;
  width: 100%;
  max-width: 1600px;
  margin: 0 auto;
}

/* Mobile Sidebar Backdrop */
.sidebar-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.55);
  backdrop-filter: blur(4px);
  z-index: 1050;
  display: none;
  opacity: 0;
  transition: opacity 0.25s ease;
}

@media (max-width: 991.98px) {
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .app-layout-wrapper, .app-content-wrapper {
    overflow-x: hidden;
    max-width: 100vw;
  }
  .app-sidebar {
    position: fixed;
    top: 0;
    bottom: 0;
    left: 0;
    height: 100vh;
    height: 100dvh;
    width: 280px;
    max-width: 84vw;
    z-index: 1060;
    transform: translateX(-100%);
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.25);
    transition: transform 0.3s cubic-bezier(0.16, 1, 0.3, 1);
  }
  .app-sidebar.show-mobile {
    transform: translateX(0);
  }
  .sidebar-backdrop.show-mobile {
    display: block;
    opacity: 1;
  }
  .app-topbar {
    padding: 0 14px;
    height: 60px;
  }
  .app-page-body {
    padding: 16px 12px 84px 12px; /* Extra bottom padding for mobile bottom nav */
  }
}

/* =========================================================================
   STAT CARDS & MODERN METRICS
   ========================================================================= */
.metric-card {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 1.15rem;
  padding: 18px 20px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  justify-content: space-between;
  height: 100%;
  position: relative;
  overflow: hidden;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.06), 0 0 0 1px rgba(79, 70, 229, 0.15);
  border-color: #cbd5e1;
}

.metric-val {
  font-size: 1.85rem;
  font-weight: 800;
  font-family: var(--font-mono);
  line-height: 1.1;
  color: #0f172a;
}

/* CARD CUSTOM & TABLE STYLING */
.card-custom {
  background: #ffffff;
  border: 1px solid var(--border-color);
  border-radius: 1.25rem;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.03);
}

.table-scroll-container {
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  border-radius: 0.85rem;
  border: 1px solid var(--border-color);
}

.chart-container-row {
  position: relative;
  height: 240px;
  width: 100%;
}

/* =========================================================================
   TUNGSURA CANDIDATE CARDS
   ========================================================================= */
.candidate-voting-card {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 1.5rem;
  padding: 24px 20px;
  text-align: center;
  transition: all 0.18s cubic-bezier(0.4, 0, 0.2, 1);
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.candidate-voting-card:hover {
  transform: translateY(-4px);
  border-color: #4f46e5;
  box-shadow: 0 15px 35px -8px rgba(79, 70, 229, 0.25);
}

.candidate-voting-card:active {
  transform: scale(0.97);
}

@keyframes popVotingCard {
  0% { transform: scale(0.95); filter: brightness(1.2); }
  50% { transform: scale(1.03); }
  100% { transform: scale(1); filter: brightness(1); }
}

.candidate-voting-card.card-clicked-pop {
  animation: popVotingCard 0.22s ease-out forwards !important;
  box-shadow: 0 0 0 5px rgba(79, 70, 229, 0.4) !important;
}

.candidate-number-seal {
  width: 54px;
  height: 54px;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.6rem;
  font-weight: 900;
  color: white;
  margin-bottom: 12px;
  box-shadow: 0 6px 16px rgba(0, 0, 0, 0.12);
}

.candidate-avatar-img {
  width: 100px;
  height: 100px;
  border-radius: 1.25rem;
  object-fit: cover;
  object-position: top center;
  margin: 0 auto 12px;
  display: block;
  border: 3px solid #f1f5f9;
  box-shadow: 0 6px 18px rgba(0, 0, 0, 0.08);
}

.btn-vote-invalid {
  border: 2px dashed #f87171;
  background-color: #fff1f2;
  color: #e11d48;
  border-radius: 1.25rem;
  padding: 14px;
  font-weight: 800;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s ease;
}

.btn-vote-invalid:hover {
  background-color: #ffe4e6;
  border-color: #e11d48;
}

.candidate-voting-card.is-locked, .btn-vote-invalid.is-locked {
  opacity: 0.45 !important;
  cursor: not-allowed !important;
  pointer-events: none !important;
  filter: grayscale(80%);
}

/* =========================================================================
   TOAST NOTIFICATION
   ========================================================================= */
.toast-custom-container {
  position: fixed;
  top: 24px;
  right: 24px;
  z-index: 2050;
  display: flex;
  flex-direction: column;
  gap: 10px;
  pointer-events: none;
}

.toast-custom {
  pointer-events: auto;
  background: #ffffff;
  color: #1e293b;
  border-radius: 1rem;
  padding: 12px 18px;
  box-shadow: 0 15px 35px -5px rgba(0, 0, 0, 0.15), 0 0 0 1px rgba(0, 0, 0, 0.05);
  display: flex;
  align-items: center;
  gap: 12px;
  font-size: 0.9rem;
  font-weight: 600;
  min-width: 290px;
  max-width: 440px;
  animation: slideDownToast 0.25s ease-out forwards;
}

@keyframes slideDownToast {
  0% { transform: translateY(-25px); opacity: 0; }
  100% { transform: translateY(0); opacity: 1; }
}

/* =========================================================================
   PRESENSI & INPUT NIK STYLING
   ========================================================================= */
.search-nik-box {
  background: #f8fafc;
  border: 2px solid #cbd5e1;
  border-radius: 1.25rem;
  padding: 8px 12px;
  transition: all 0.2s ease;
}
.search-nik-box:focus-within {
  border-color: #4f46e5;
  background: #ffffff;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.12);
}
.input-nik-responsive {
  font-size: 1.25rem;
  font-family: var(--font-mono);
  font-weight: 700;
  letter-spacing: 0.05em;
  color: #0f172a;
}

/* Tungsura Component Classes */
.card-calon {
  background: #ffffff;
  border: 2px solid #e2e8f0;
  border-radius: 1.5rem;
  text-align: center;
  position: relative;
  cursor: pointer;
  padding: 20px;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: space-between;
}
.card-calon:hover {
  transform: translateY(-4px);
  border-color: #4f46e5;
  box-shadow: 0 15px 30px -5px rgba(79, 70, 229, 0.2);
}
.card-calon:active {
  transform: scale(0.97);
}
.nomor-urut-badge {
  width: 44px;
  height: 44px;
  border-radius: 50%;
  color: white;
  font-size: 1.4rem;
  font-weight: 900;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 10px;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.15);
}
.foto-calon-img {
  width: 100px;
  height: 100px;
  object-fit: cover;
  border-radius: 1.25rem;
  margin-bottom: 12px;
  border: 3px solid #f1f5f9;
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.06);
}
.btn-batal-suara {
  background: #fff1f2;
  border: 2px dashed #f43f5e;
  color: #e11d48;
  border-radius: 1.25rem;
  padding: 14px;
  text-align: center;
  cursor: pointer;
  font-weight: 800;
  transition: all 0.15s ease;
}
.btn-batal-suara:hover {
  background: #ffe4e6;
  transform: translateY(-2px);
}

/* =========================================================================
   MOBILE BOTTOM NAVIGATION BAR (FLOATING NATIVE APP FEEL)
   ========================================================================= */
.mobile-bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  height: 64px;
  background: rgba(255, 255, 255, 0.96);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  border-top: 1px solid var(--border-color);
  box-shadow: 0 -4px 20px rgba(15, 23, 42, 0.06);
  display: flex;
  align-items: center;
  justify-content: space-around;
  z-index: 1030;
  padding: 0 4px;
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  flex: 1;
  height: 100%;
  color: #64748b;
  text-decoration: none;
  font-size: 0.68rem;
  font-weight: 700;
  gap: 3px;
  transition: all 0.18s ease;
  user-select: none;
  cursor: pointer;
  border: none;
  background: transparent;
}

.bottom-nav-item i {
  font-size: 1.15rem;
  transition: transform 0.18s ease, color 0.18s ease;
}

.bottom-nav-item.active {
  color: var(--primary);
}

.bottom-nav-item.active i {
  transform: translateY(-2px);
  color: var(--primary);
}

.bottom-nav-item:active {
  transform: scale(0.92);
}

/* =========================================================================
   COMPREHENSIVE MOBILE RESPONSIVE TWEAKS (< 768px and < 576px)
   ========================================================================= */
@media (max-width: 768px) {
  /* Prevent iOS / WebKit browser auto-zooming into inputs */
  input[type="text"],
  input[type="password"],
  input[type="number"],
  input[type="date"],
  select,
  textarea,
  .form-control,
  .form-select {
    font-size: 16px !important;
  }

  /* Table horizontal scrolling indicator & scrollbar */
  .table-scroll-container {
    -webkit-overflow-scrolling: touch;
    position: relative;
    border-radius: 0.75rem;
  }

  .table-scroll-container::-webkit-scrollbar {
    height: 4px;
  }
  .table-scroll-container::-webkit-scrollbar-track {
    background: #f1f5f9;
  }
  .table-scroll-container::-webkit-scrollbar-thumb {
    background: #cbd5e1;
    border-radius: 9999px;
  }
}

@media (max-width: 576px) {
  /* Metric Cards on Mobile 2-column grid */
  .metric-card {
    padding: 12px 14px;
    border-radius: 1rem;
  }
  .metric-val {
    font-size: 1.4rem;
  }

  /* Candidate Cards in Tungsura */
  .candidate-voting-card, .card-calon {
    padding: 14px 8px !important;
    border-radius: 1.25rem !important;
  }
  .candidate-avatar-img, .foto-calon-img {
    width: 74px !important;
    height: 74px !important;
    border-radius: 1rem !important;
    margin-bottom: 8px !important;
  }
  .candidate-number-seal, .nomor-urut-badge {
    width: 36px !important;
    height: 36px !important;
    font-size: 1.15rem !important;
    margin-bottom: 6px !important;
  }
  .btn-batal-suara {
    padding: 10px 12px !important;
    font-size: 0.85rem !important;
  }

  /* Chart Row Height Constraint on Mobile */
  .chart-container-row {
    height: 210px !important;
  }

  /* Bootstrap Modals on Mobile */
  .modal-dialog {
    margin: 10px auto !important;
    max-width: calc(100% - 20px) !important;
  }
  .modal-content {
    border-radius: 1.25rem !important;
  }
  .modal-header {
    padding: 14px 16px !important;
  }
  .modal-body {
    padding: 16px 14px !important;
  }

  /* Presensi View search box on mobile */
  .search-nik-box {
    padding: 6px 10px;
  }

  /* Toast Notification container on mobile */
  .toast-custom-container {
    top: 12px;
    left: 12px;
    right: 12px;
  }
  .toast-custom {
    min-width: 100%;
    max-width: 100%;
    font-size: 0.84rem;
    padding: 10px 14px;
  }
}

