/**
 * Halaqah Tahfizh — style.css
 * Diadaptasi dari Index.html GAS.
 * Diload hanya di halaman yang punya shortcode [halaqah_app].
 */

/* ============================================================
   RESET & BASE
   ============================================================ */
#halaqahApp *,
#halaqahApp *::before,
#halaqahApp *::after {
  box-sizing: border-box;
}

#halaqahApp {
  font-family: system-ui, -apple-system, sans-serif;
  color: #1e293b;
  line-height: 1.6;
}

/* ============================================================
   CARD
   ============================================================ */
#halaqahApp .card {
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
  margin-bottom: 1.5rem;
  border: 1px solid #e2e8f0;
}

/* ============================================================
   STAT CARD
   ============================================================ */
#halaqahApp .stat-card {
  text-align: center;
  padding: 1.5rem;
  border-radius: 0.75rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  color: white;
  position: relative;
  overflow: hidden;
}

#halaqahApp .stat-card::before {
  content: '';
  position: absolute;
  top: 0;
  right: 0;
  width: 100px;
  height: 100px;
  background: rgba(255, 255, 255, 0.1);
  border-radius: 50%;
  transform: translate(30px, -30px);
}

/* ============================================================
   INPUTS
   ============================================================ */
#halaqahApp .input-field {
  width: 100%;
  padding: 0.75rem 1rem;
  border-radius: 0.5rem;
  border: 1px solid #d1d5db;
  font-size: 0.95rem;
  transition: all 0.2s;
  box-sizing: border-box;
  font-family: inherit;
  background: #fff;
  color: #1e293b;
}

#halaqahApp .input-field:focus {
  outline: none;
  border-color: #3b82f6;
  border-width: 2px;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

#halaqahApp .input-field-small {
  width: 60px;
  padding: 0.5rem;
  border-radius: 0.375rem;
  border: 1px solid #d1d5db;
  font-size: 0.875rem;
  text-align: center;
  transition: all 0.2s;
  background: #fff;
  font-family: inherit;
}

#halaqahApp .input-field-small:focus {
  outline: none;
  border-color: #3b82f6;
  border-width: 2px;
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

#halaqahApp .input-field-small.error {
  border-color: #ef4444;
  background-color: #fee2e2;
}

/* ============================================================
   BUTTONS
   ============================================================ */
#halaqahApp .btn {
  padding: 0.75rem 1.5rem;
  border-radius: 0.5rem;
  border: none;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  font-size: 0.95rem;
  background-color: #3b82f6;
  color: #ffffff;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  font-family: inherit;
  text-decoration: none;
}

#halaqahApp .btn:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(59, 130, 246, 0.3);
}

#halaqahApp .btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
  transform: none;
}

#halaqahApp .btn-success  { background-color: #10b981; }
#halaqahApp .btn-warning  { background-color: #f59e0b; }
#halaqahApp .btn-danger   { background-color: #ef4444; }
#halaqahApp .btn-secondary { background-color: #6b7280; }
#halaqahApp .btn-inactive {
  background-color: #f1f5f9;
  color: #64748b;
}
#halaqahApp .btn-inactive:hover {
  box-shadow: none;
  transform: none;
}

#halaqahApp .btn-small {
  padding: 0.375rem 0.75rem;
  font-size: 0.875rem;
}

/* ============================================================
   BADGES
   ============================================================ */
#halaqahApp .badge {
  display: inline-block;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.875rem;
  font-weight: 600;
}

#halaqahApp .badge-success { background-color: #dcfce7; color: #166534; }
#halaqahApp .badge-warning  { background-color: #fef3c7; color: #92400e; }
#halaqahApp .badge-danger   { background-color: #fee2e2; color: #991b1b; }
#halaqahApp .badge-info     { background-color: #dbeafe; color: #1e40af; }

/* ============================================================
   TABLE
   ============================================================ */
#halaqahApp .table-container {
  overflow-x: auto;
  border-radius: 0.5rem;
  border: 1px solid #e2e8f0;
  -webkit-overflow-scrolling: touch;
}

#halaqahApp table {
  width: 100%;
  border-collapse: collapse;
}

#halaqahApp th,
#halaqahApp td {
  padding: 0.75rem 1rem;
  text-align: left;
  border-bottom: 1px solid #e2e8f0;
}

#halaqahApp th {
  font-weight: 600;
  background-color: #f8fafc;
  color: #475569;
  font-size: 0.875rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

#halaqahApp tr:hover td {
  background-color: #f8fafc;
}

#halaqahApp tr.saved td { background-color: #f0fdf4; }
#halaqahApp tr.error  td { background-color: #fef2f2; }

/* ============================================================
   CHART
   ============================================================ */
#halaqahApp .chart-container {
  position: relative;
  height: 300px;
  margin: 1rem 0;
}

/* ============================================================
   ALERTS
   ============================================================ */
#halaqahApp .alert {
  padding: 1rem;
  border-radius: 0.5rem;
  margin-bottom: 1rem;
  border-left: 4px solid;
}

#halaqahApp .alert-info    { background-color: #eff6ff; border-color: #3b82f6; color: #1e40af; }
#halaqahApp .alert-warning { background-color: #fffbeb; border-color: #f59e0b; color: #92400e; }
#halaqahApp .alert-success { background-color: #f0fdf4; border-color: #10b981; color: #065f46; }
#halaqahApp .alert-danger  { background-color: #fef2f2; border-color: #ef4444; color: #991b1b; }

/* ============================================================
   GRIDS
   ============================================================ */
#halaqahApp .grid-2 { display: grid; grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); gap: 1.5rem; }
#halaqahApp .grid-3 { display: grid; grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); gap: 1rem; }
#halaqahApp .grid-4 { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 1rem; }

/* ============================================================
   PROGRESS BAR
   ============================================================ */
#halaqahApp .progress-bar {
  width: 100%;
  height: 24px;
  background-color: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
  position: relative;
}

#halaqahApp .progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #3b82f6 0%, #10b981 100%);
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  color: white;
  font-size: 0.75rem;
  font-weight: 600;
}

/* ============================================================
   BULK INPUT TABLE
   ============================================================ */
#halaqahApp .bulk-input-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  min-width: 1100px;
}

#halaqahApp .bulk-input-table th {
  position: sticky;
  top: 0;
  background-color: #667eea;
  color: white;
  z-index: 10;
  padding: 0.75rem 0.5rem;
  font-size: 0.8rem;
}

#halaqahApp .bulk-input-table td {
  padding: 0.5rem;
  text-align: center;
  vertical-align: middle;
  border-bottom: 1px solid #e2e8f0;
}

#halaqahApp .bulk-input-table td:first-child {
  text-align: left;
  font-weight: 600;
  position: sticky;
  left: 0;
  background-color: white;
  z-index: 5;
  min-width: 150px;
}

#halaqahApp .bulk-input-table tr:hover td:first-child {
  background-color: #f8fafc;
}

/* ============================================================
   LOADING SPINNER
   ============================================================ */
#halaqahApp .loading,
.loading {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 3px solid rgba(255, 255, 255, 0.3);
  border-radius: 50%;
  border-top-color: #fff;
  animation: halaqah-spin 1s ease-in-out infinite;
  vertical-align: middle;
}

@keyframes halaqah-spin {
  to { transform: rotate(360deg); }
}

/* ============================================================
   MODAL OVERLAY
   ============================================================ */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 99999;
}

.modal-content {
  width: 100%;
  max-width: 720px;
  background: #ffffff;
  border-radius: 0.75rem;
  padding: 1.5rem;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.25);
  border: 1px solid #e2e8f0;
  max-height: 90vh;
  overflow-y: auto;
}

/* ============================================================
   STATUS ICON
   ============================================================ */
#halaqahApp .status-icon {
  font-size: 1.25rem;
  display: inline-block;
}

/* ============================================================
   RESPONSIVE — MOBILE
   ============================================================ */
@media (max-width: 768px) {
  #halaqahApp .card {
    padding: 0.875rem;
    margin-bottom: 0.875rem;
  }

  #halaqahApp .grid-2,
  #halaqahApp .grid-3,
  #halaqahApp .grid-4 {
    grid-template-columns: 1fr;
    gap: 0.75rem;
  }

  #halaqahApp .input-field-small {
    width: 50px;
    padding: 0.375rem;
    font-size: 0.8rem;
  }

  #halaqahApp .stat-card {
    padding: 1rem;
  }

  #halaqahApp .btn {
    padding: 0.625rem 1rem;
    font-size: 0.9rem;
    width: 100%;
    justify-content: center;
  }

  #halaqahApp .btn-small {
    width: auto;
    padding: 0.4rem 0.75rem;
    font-size: 0.8rem;
  }

  #halaqahApp table {
    font-size: 0.75rem;
    min-width: 700px;
  }

  #halaqahApp th,
  #halaqahApp td {
    padding: 0.5rem 0.4rem;
    white-space: nowrap;
  }

  #halaqahApp #navigationTabs {
    flex-direction: column;
    gap: 0.375rem;
  }

  #halaqahApp #navigationTabs .btn {
    width: 100%;
    justify-content: center;
  }

  #halaqahApp .chart-container {
    height: 220px;
  }

  #halaqahApp .progress-bar {
    height: 18px;
  }

  .modal-content {
    margin: 0.5rem;
    padding: 1rem;
    max-height: 95vh;
  }
}

@media (max-width: 480px) {
  #halaqahApp .card {
    padding: 0.625rem;
    border-radius: 0.5rem;
  }

  #halaqahApp .btn {
    padding: 0.625rem 0.875rem;
    font-size: 0.85rem;
  }

  #halaqahApp .input-field {
    padding: 0.625rem 0.75rem;
    font-size: 0.875rem;
  }

  #halaqahApp .input-field-small {
    width: 44px;
    font-size: 0.75rem;
  }

  #halaqahApp table {
    font-size: 0.7rem;
  }

  #halaqahApp th,
  #halaqahApp td {
    padding: 0.375rem 0.2rem;
  }

  #halaqahApp .badge {
    font-size: 0.65rem;
    padding: 0.15rem 0.4rem;
  }

  #halaqahApp .chart-container {
    height: 200px;
  }
}
