@import url("https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap");

:root {
  --primary-color: #2e6b56;
  --primary-dark: #1b4b39;
  --secondary-color: #3b8b6f;
  --bg-color: #f0f2f5;
  --text-dark: #333;
  --text-gray: #666;
  --white: #fff;
  --border-color: #e0e0e0;
  --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 15px rgba(0, 0, 0, 0.08);
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
  font-family: "Inter", sans-serif;
}

html, body {
  max-width: 100vw;
  overflow-x: hidden;
}

body {
  background-color: var(--bg-color);
  color: var(--text-dark);
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
  color: var(--text-dark);
}

a {
  text-decoration: none;
  color: inherit;
}

/* Utilities */
.container-fluid {
  width: 100%;
  min-height: 100vh;
}

.content-wrapper {
  padding: 2rem;
  max-width: 1200px;
  margin: 0 auto;
  margin-top: 1.5rem;
  min-height: 80vh;
}

/* ─── VISIBILITY CLASSES ─── */
.sapaan-mobile { display: none !important; }
.sapaan-desktop { display: flex !important; }

.card {
  background: var(--white);
  border-radius: 12px;
  padding: 1.5rem;
  box-shadow: var(--shadow);
}

.flex { display: flex; }
.flex-col { flex-direction: column; }
.items-center { align-items: center; }
.justify-between { justify-content: space-between; }
.justify-center { justify-content: center; }
.gap-2 { gap: 0.5rem; }
.gap-4 { gap: 1rem; }
.gap-6 { gap: 1.5rem; }
.mb-4 { margin-bottom: 1rem; }
.mb-6 { margin-bottom: 1.5rem; }
.w-full { width: 100%; }

/* Flex responsive - wraps on mobile */
.flex-wrap { flex-wrap: wrap; }

/* Buttons */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 6px;
  border: none;
  cursor: pointer;
  font-weight: 500;
  transition: all 0.3s ease;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 0.4rem;
  text-decoration: none;
  width: fit-content;
}

.btn-primary {
  background-color: var(--primary-color);
  color: var(--white);
}

.btn-primary:hover {
  background-color: var(--secondary-color);
  color: var(--white);
}

.btn-outline {
  background-color: transparent;
  border: 1px solid var(--primary-color);
  color: var(--primary-color);
}

.btn-outline:hover {
  background-color: var(--primary-color);
  color: var(--white);
}

/* Inputs */
.form-group { margin-bottom: 1rem; }

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-gray);
}

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--border-color);
  border-radius: 6px;
  outline: none;
  transition: border-color 0.3s;
  font-size: 0.95rem;
}

.form-control:focus {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(46, 107, 86, 0.1);
}

/* ═══════════════════════════════════════
   TOP NAVBAR
═══════════════════════════════════════ */

.top-nav {
  background:
    linear-gradient(rgba(27, 75, 57, 0.9), rgba(46, 107, 86, 0.9)),
    url("background.jpg");
  background-size: cover;
  background-position: center;
  color: var(--white);
  padding: 0.9rem 2rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: 0 4px 10px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 0;
  z-index: 1000;
  gap: 1rem;
}

.top-nav-left {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  flex-shrink: 0;
}

.top-nav-logo { height: 40px; }

.top-nav-title {
  font-size: 0.75rem;
  font-weight: 700;
  letter-spacing: 0.5px;
  line-height: 1.3;
  white-space: nowrap;
}

.top-nav-title span {
  display: block;
  font-size: 0.9rem;
  font-weight: 800;
}

.top-nav-links {
  display: flex;
  gap: 0.4rem;
  align-items: center;
  flex: 1;
  justify-content: center;
  flex-wrap: wrap;
}

.nav-link {
  color: rgba(255, 255, 255, 0.8);
  font-size: 0.85rem;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  gap: 0.35rem;
  padding: 0.45rem 0.75rem;
  border-radius: 8px;
  white-space: nowrap;
}

.nav-link:hover,
.nav-link.active {
  color: var(--white);
  font-weight: 700;
  background: transparent;
}

.nav-link svg { flex-shrink: 0; }

/* Profile area */
.top-nav-right {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex-shrink: 0;
}

.top-nav-profile {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  cursor: pointer;
  position: relative;
}

.top-nav-profile img {
  width: 36px;
  height: 36px;
  border-radius: 50%;
  object-fit: cover;
  border: 2px solid rgba(255, 255, 255, 0.4);
  flex-shrink: 0;
}

/* Profile Dropdown */
#profileDropdown {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: 0;
  background: white;
  border-radius: 10px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  width: 180px;
  z-index: 2000;
  border: 1px solid #eee;
}
#profileDropdown::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 0;
  width: 100%;
  height: 15px;
  background: transparent;
}

.top-nav-profile:hover #profileDropdown,
.top-nav-profile:focus-within #profileDropdown {
  display: block !important;
}

#profileDropdown a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.8rem 1rem;
  color: #333;
  font-size: 0.9rem;
  transition: background 0.2s;
  border-bottom: 1px solid #f5f5f5;
}

#profileDropdown a:last-child {
  border-bottom: none;
  color: #d32f2f;
}

#profileDropdown a:hover {
  background: #f8f9fa;
}

/* ═══════════════════════════════════════
   HAMBURGER MENU (MOBILE)
═══════════════════════════════════════ */

.hamburger-btn {
  display: none;
  flex-direction: column;
  gap: 5px;
  background: none;
  border: none;
  cursor: pointer;
  padding: 6px;
  border-radius: 6px;
  transition: background 0.2s;
}

.hamburger-btn:hover {
  background: rgba(255,255,255,0.15);
}

.hamburger-btn span {
  display: block;
  width: 24px;
  height: 2px;
  background: white;
  border-radius: 2px;
  transition: all 0.3s;
}

.hamburger-btn.active span:nth-child(1) {
  transform: translateY(7px) rotate(45deg);
}
.hamburger-btn.active span:nth-child(2) {
  opacity: 0;
}
.hamburger-btn.active span:nth-child(3) {
  transform: translateY(-7px) rotate(-45deg);
}

.method-card:hover { border-color: #38a169; transform: translateY(-2px); }

/* Sapaan Classes */
.sapaan-desktop { display: flex !important; }

/* Keuangan - Tagihan Item */
.tagihan-item {
  border-width: 1px;
  border-style: solid;
  border-radius: 12px;
  padding: 1.5rem;
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 1rem;
}
.metode-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
}

/* Mobile Nav Overlay */
.mobile-nav-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.4);
  z-index: 1500;
  backdrop-filter: blur(2px);
}

.mobile-nav-overlay.active {
  display: block;
}

/* Mobile Nav Drawer */
.mobile-nav-drawer {
  display: flex;
  position: fixed;
  top: 0;
  left: 0;
  width: 280px;
  height: 100vh;
  background: var(--primary-dark);
  z-index: 1600;
  flex-direction: column;
  overflow-y: auto;
  transform: translateX(-100%);
  transition: transform 0.3s ease;
  visibility: hidden;
}

.mobile-nav-drawer.active {
  transform: translateX(0);
  visibility: visible;
}

.mobile-nav-header {
  padding: 1.5rem 1.2rem;
  border-bottom: 1px solid rgba(255,255,255,0.1);
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.mobile-nav-header img { height: 36px; }

.mobile-nav-header-text {
  color: white;
  font-size: 0.75rem;
  font-weight: 700;
  line-height: 1.3;
}

.mobile-nav-header-text span {
  display: block;
  font-size: 0.85rem;
  font-weight: 800;
}

.mobile-nav-links {
  padding: 1rem 0;
  flex: 1;
}

.mobile-nav-link {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.9rem 1.5rem;
  color: rgba(255,255,255,0.75);
  font-size: 0.9rem;
  font-weight: 500;
  transition: all 0.2s;
  border-left: 3px solid transparent;
}

.mobile-nav-link:hover,
.mobile-nav-link.active {
  color: white;
  background: rgba(255,255,255,0.1);
  border-left-color: rgba(255,255,255,0.6);
  font-weight: 700;
}

.mobile-nav-footer {
  padding: 1rem 1.5rem;
  border-top: 1px solid rgba(255,255,255,0.1);
}

.mobile-nav-footer a {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  color: #ff6b6b;
  font-size: 0.9rem;
  font-weight: 600;
}

/* Notif Badge */
.notif-badge {
  position: absolute;
  top: -5px;
  right: -5px;
  background: #ff4d4d;
  color: white;
  font-size: 0.6rem;
  padding: 2px 5px;
  border-radius: 10px;
  font-weight: bold;
  border: 2px solid var(--primary-color);
}

/* Notif Dropdown */
#notifDropdown {
  display: none;
  position: absolute;
  top: calc(100% + 5px);
  right: -10px;
  background: white;
  width: 300px;
  border-radius: 12px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.15);
  z-index: 2000;
}
#notifDropdown::before {
  content: "";
  position: absolute;
  top: -15px;
  left: 0;
  width: 100%;
  height: 15px;
  background: transparent;
}
.notif-wrapper:hover #notifDropdown,
.notif-wrapper:focus-within #notifDropdown {
  display: block !important;
}

.notif-item {
  padding: 1rem;
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: 0.2s;
}

.notif-item:hover { background: #f9f9f9; }

.notif-title {
  font-weight: 700;
  font-size: 0.85rem;
  color: #333;
  margin-bottom: 2px;
}

.notif-desc {
  font-size: 0.75rem;
  color: #777;
}

/* Modal Base Styles */
.modal-box {
  max-height: 90vh;
  overflow-y: auto;
}

/* ═══════════════════════════════════════
   BREADCRUMB
═══════════════════════════════════════ */

.breadcrumb {
  display: flex;
  gap: 0.5rem;
  font-size: 0.9rem;
  color: var(--text-gray);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.breadcrumb a { color: var(--primary-color); }

/* ═══════════════════════════════════════
   TABS
═══════════════════════════════════════ */

.tabs {
  display: flex;
  gap: 2rem;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
}

.tab {
  padding: 0.5rem 0;
  color: var(--text-gray);
  cursor: pointer;
  border-bottom: 2px solid transparent;
  font-weight: 500;
}

.tab.active {
  color: var(--primary-color);
  border-bottom-color: var(--primary-color);
}

/* ═══════════════════════════════════════
   LOGIN PAGE
═══════════════════════════════════════ */

.login-container {
  display: flex;
  height: 100vh;
  width: 100vw;
}

.login-left {
  flex: 1.2;
  background-color: var(--primary-color);
  position: relative;
  overflow: hidden;
}

.login-left img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.login-right {
  flex: 0.8;
  display: flex;
  justify-content: center;
  align-items: center;
  background-color: var(--white);
  overflow-y: auto;
}

.login-form-box {
  width: 100%;
  max-width: 400px;
  padding: 2rem;
  text-align: center;
}

.login-form-box .logo {
  width: 80px;
  margin-bottom: 1rem;
}

.login-form-box h2 {
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.login-form-box p {
  color: var(--text-gray);
  font-size: 0.9rem;
  margin-bottom: 2rem;
}

.login-error {
  color: #d32f2f;
  background: #ffebee;
  border: 1px solid #ef9a9a;
  border-radius: 8px;
  padding: 0.75rem 1rem;
  margin-bottom: 1rem;
  font-size: 0.9rem;
  text-align: left;
}

.form-group-left { text-align: left; }
.form-group-relative { text-align: left; position: relative; }
.btn-full { width: 100%; margin-top: 10px; }
.w-full { width: 100% !important; }

/* Default Sembunyikan Splash Screen di Desktop */
.splash-screen { display: none; }

@keyframes pulse {
  0% { transform: scale(0.9); }
  50% { transform: scale(1.1); }
  100% { transform: scale(0.9); }
}

/* ═══════════════════════════════════════
   FOOTER
═══════════════════════════════════════ */

.main-footer {
  text-align: center;
  font-size: 0.8rem;
  color: #888;
  padding: 2rem 0;
  margin-top: 2rem;
  border-top: 1px solid #eee;
}

.footer-content {
  display: flex;
  justify-content: center;
  gap: 2rem;
  margin-bottom: 0.5rem;
  flex-wrap: wrap;
}

/* ═══════════════════════════════════════
   ALERTS / MESSAGES
═══════════════════════════════════════ */

.alert {
  padding: 1rem 1.25rem;
  border-radius: 8px;
  margin-bottom: 1rem;
  font-size: 0.9rem;
}

.alert-success {
  background: #e8f5e9;
  color: #2e7d32;
  border: 1px solid #a5d6a7;
}

.alert-danger {
  background: #ffebee;
  color: #c62828;
  border: 1px solid #ef9a9a;
}

.alert-warning {
  background: #fff3e0;
  color: #e65100;
  border: 1px solid #ffcc80;
}

/* ═══════════════════════════════════════
   RESPONSIVE - TABLET (1024px)
═══════════════════════════════════════ */

@media (max-width: 1024px) {
  .content-wrapper {
    padding: 1.5rem;
    max-width: 100%;
  }

  .card { padding: 1.25rem; }

  .top-nav { padding: 0.9rem 1.5rem; }

  .top-nav-links { gap: 0.2rem; }

  .nav-link {
    font-size: 0.78rem;
    padding: 0.4rem 0.6rem;
  }

  #notifDropdown {
    width: 260px;
    right: 60px;
  }
}

/* ═══════════════════════════════════════
   RESPONSIVE - MOBILE (768px)
═══════════════════════════════════════ */

@media (max-width: 768px) {
  /* Show hamburger, hide nav links */
  .hamburger-btn { display: flex; }
  .top-nav-links { display: none; }

  /* Nav */
  .top-nav {
    padding: 0.75rem 1rem;
    gap: 0.75rem;
  }

  .top-nav-logo { height: 34px; }

  /* Header adjustments */
  .top-nav { padding: 0.5rem 0.75rem; }
  .top-nav-logo { width: 32px; height: 32px; }
  
  /* Fix hamburger icon explicit display */
  .hamburger-btn { display: flex !important; flex-direction: column; justify-content: center; width: 32px; height: 32px; margin-right: 0.5rem; gap: 5px; }
  .hamburger-btn span { width: 22px; height: 2px; background-color: white !important; margin: 0 auto !important; display: block !important; flex-shrink: 0; }

  /* Sembunyikan tulisan PONDOK PESANTREN dan kecilkan sisanya agar muat di HP */
  .top-nav-title {
    font-size: 0.5rem !important;
    line-height: 1.2;
    margin-left: 0.2rem;
  }
  .top-nav-title span { font-size: 0.7rem !important; margin-top: 1px; }

  /* Sembunyikan teks profil di kanan atas agar tidak menabrak */
  .nav-profile-text { display: none; }
  .top-nav-profile img { width: 32px; height: 32px; border-width: 1px; }
  .top-nav-right { gap: 0.75rem !important; }

  /* Content */
  .content-wrapper {
    padding: 0.5rem !important;
    max-width: 100%;
    margin-top: 0 !important;
  }

  .card, div[class*="card"] {
    padding: 1rem !important;
    margin-bottom: 1rem;
    border-radius: 15px !important;
  }
  
  /* Override inline paddings that are too large on mobile */
  div[style*="padding: 2.5rem"], 
  div[style*="padding: 2rem"], 
  div[style*="padding: 1.5rem"],
  div[style*="padding: 1.5rem 2rem"] {
    padding: 1rem !important;
  }
  
  .sapaan-mobile {
    padding: 1rem !important;
    gap: 0.75rem !important;
  }
  .sapaan-mobile div:first-child {
    width: 55px !important;
    height: 55px !important;
  }

  /* Forms */
  .form-control {
    padding: 0.65rem 0.9rem;
    font-size: 16px; /* Prevents zoom on iOS */
  }

  /* Table Base Cleanup */
  table {
    display: table;
    width: 100%;
  }

  /* Fix untuk div grid tertentu agar menurun ke bawah di HP */
  div[style*="grid-template-columns: repeat(3, 1fr)"],
  div[style*="grid-template-columns: 1fr 1fr"],
  div[style*="grid-template-columns: 2fr 1fr"],
  .transkrip-grid,
  .metode-grid {
    grid-template-columns: 1fr !important;
  }
  
  /* Calendar Mobile Fix */
  #calGrid { gap: 1px !important; }
  #calGrid > div { padding: 4px 1px !important; min-height: 30px !important; }
  #calGrid span { font-size: 0.65rem !important; }
  
  /* Sapaan visibility */
  .sapaan-mobile { display: flex !important; }
  .sapaan-desktop { display: none !important; }
  
  /* Normalize grids for responsive layout */
  .tagihan-item {
    flex-direction: column;
    align-items: flex-start;
  }
  .tagihan-price {
    text-align: left !important;
    margin-left: 2.3rem; /* Sejajar dengan teks tagihan (setelah titik 20px + gap 1rem) */
    margin-top: 0.5rem;
  }

  /* Kurangi jarak gap di Info Santri */
  div[style*="gap: 4rem;"] {
    gap: 0.5rem !important;
  }
  
  /* Fix untuk tombol agar ke tengah di HP */
  div[style*="justify-content: flex-end"] {
    justify-content: center !important;
  }

  /* Notif dropdown */
  #notifDropdown {
    width: 240px;
    right: 10px;
    top: 55px;
  }

  /* Splash Screen Tokopedia-style (Hanya di Mobile) */
  .splash-screen {
    display: flex;
    position: fixed;
    inset: 0;
    background-color: var(--primary-color);
    z-index: 9999;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    transition: opacity 0.5s ease-out, visibility 0.5s ease-out;
  }
  .splash-content { text-align: center; padding: 20px; }
  .splash-poster {
    width: 280px;
    height: auto;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    animation: pulse 1.5s infinite;
  }
  .splash-screen.hidden {
    opacity: 0;
    visibility: hidden;
  }

  /* Login Page Mobile Clean Layout */
  .login-container { flex-direction: column; height: 100vh; }
  .login-left { display: none !important; } /* Sembunyikan foto awal, diganti splash screen */
  
  .login-right { 
    flex: 1; 
    border-radius: 0; 
    margin-top: 0; 
    z-index: 10; 
    background: white; 
    box-shadow: none; 
    align-items: center;
    height: 100vh;
  }
  .login-form-box { padding: 2rem 1.5rem; width: 100%; max-width: 100%; }


  /* Sapaan Classes Mobile */
  .sapaan-desktop { display: none !important; }
  .sapaan-mobile { display: flex !important; margin-bottom: 1.5rem !important; }

  /* Footer */
  .main-footer { padding: 1rem 0 !important; }
  .footer-content { gap: 0.3rem !important; align-items: center; text-align: center; justify-content: center; }
  .footer-content span { font-size: 0.65rem !important; }
  .footer-sep { display: none; }
  .footer-break { display: block !important; width: 100%; height: 0; }

  /* Sapaan Mobile */
  .sapaan-desktop { display: none !important; }
  .sapaan-mobile { display: flex !important; margin-bottom: 1.5rem !important; }
}

/* ═══════════════════════════════════════
   RESPONSIVE - SMALL MOBILE (480px)
═══════════════════════════════════════ */

@media (max-width: 480px) {
  /* Typography */
  h1 { font-size: 1.2rem; }
  h2 { font-size: 1.1rem; }
  h3 { font-size: 1rem; }

  /* Layout */
  .content-wrapper { padding: 0.75rem; }
  .card { padding: 0.85rem; }

  /* Buttons */
  .btn {
    padding: 0.45rem 0.8rem;
    font-size: 0.8rem;
  }

  /* Forms */
  input, textarea, select {
    font-size: 16px !important;
  }

  label { font-size: 0.85rem; }

  /* Modal */
  .modal-box {
    width: 95vw !important;
    max-width: 95vw !important;
    padding: 1.25rem !important;
    border-radius: 12px !important;
  }

  /* Breadcrumb */
  .breadcrumb { font-size: 0.8rem; }
}

/* ═══════════════════════════════════════
   TABLE & GRID RESPONSIVE FIX (NO SCROLL)
═══════════════════════════════════════ */
@media (max-width: 768px) {
  /* Buat tabel bisa digeser secara horizontal di dalam areanya sendiri agar teks tidak menumpuk */
  table {
    display: block !important;
    width: 100% !important;
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
  }
  th, td {
    font-size: 0.8rem !important; /* Kembalikan ukuran font agar nyaman dibaca */
    padding: 0.6rem 0.5rem !important;
    white-space: nowrap !important; /* Biarkan teks memanjang ke samping (tidak ditumpuk) */
  }
  
  /* Ubah tampilan grid info yang terbagi 2 menjadi atas-bawah */
  .transkrip-grid, 
  [style*="grid-template-columns: 1fr 1fr"] {
    grid-template-columns: 1fr !important;
    gap: 1rem !important;
    padding: 1rem !important;
  }

  /* Rapikan font judul yang kebesaran di HP */
  .card h2, h2[style] {
    font-size: 1.3rem !important;
  }
  .card h3, h3[style] {
    font-size: 1.1rem !important;
  }
  .card p, p[style] {
    font-size: 0.85rem !important;
  }
}
