/* Monitoring Kehadiran Misa - Modern UI */
:root {
  --bg: #f8fafc;
  --surface: #ffffff;
  --surface-hover: #f1f5f9;
  --border: #e2e8f0;
  --text: #1e293b;
  --text-muted: #64748b;
  --accent: #2563eb;
  --accent-hover: #1e40af;
  --success: #16a34a;
  --warning: #d97706;
  --radius: 12px;
  --radius-sm: 8px;
  --shadow: 0 4px 12px rgba(0, 0, 0, 0.05);
  --font: 'Inter', system-ui, -apple-system, sans-serif;
}

* {
  box-sizing: border-box;
}

body {
  margin: 0;
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  line-height: 1.5;
  min-height: 100vh;
}

a {
  color: var(--accent);
  text-decoration: none;
}

a:hover {
  color: var(--accent-hover);
  text-decoration: underline;
}

/* Layout */
.container {
  max-width: 960px;
  margin: 0 auto;
  padding: 1rem;
}

.page-header {
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--border);
}

.page-header h1 {
  margin: 0;
  font-size: 1.5rem;
  font-weight: 600;
}

.page-header p {
  margin: .25rem 0 0;
  color: var(--text-muted);
  font-size: .9rem;
}

/* Cards */
.card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin-bottom: 1rem;
  box-shadow: var(--shadow);
}

.card h2,
.card h3 {
  margin: 0 0 .75rem;
  font-size: 1.1rem;
  font-weight: 600;
}

/* Forms */
label {
  display: block;
  margin-bottom: .35rem;
  font-size: .875rem;
  color: var(--text-muted);
}

input[type="text"],
input[type="password"],
input[type="number"],
input[type="date"],
input[type="time"],
select {
  width: 100%;
  padding: .6rem .75rem;
  font-size: 1rem;
  font-family: inherit;
  color: var(--text);
  background: var(--bg);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37, 99, 235, .2);
}

input::placeholder {
  color: var(--text-muted);
}

/* File Input Styling */
input[type="file"]::file-selector-button {
  padding: .4rem .75rem;
  margin-right: .75rem;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  color: var(--text);
  font-family: inherit;
  font-size: .875rem;
  font-weight: 500;
  cursor: pointer;
  transition: all .2s;
}

input[type="file"]::file-selector-button:hover {
  background: var(--surface-hover);
  border-color: var(--accent);
}

.form-row {
  display: grid;
  gap: 1rem;
}

@media (min-width: 600px) {
  .form-row.col-2 {
    grid-template-columns: 1fr 1fr;
  }

  .form-row.col-3 {
    grid-template-columns: 1fr 1fr 1fr;
  }
}

.input-file {
  width: 100%;
  padding: .5rem;
  border: 1px dashed var(--border);
  border-radius: var(--radius-sm);
  background: rgba(0, 0, 0, 0.02);
  margin-bottom: 1.5rem;
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: .5rem;
  padding: .6rem 1.25rem;
  font-size: .9375rem;
  font-weight: 500;
  font-family: inherit;
  border: none;
  border-radius: var(--radius-sm);
  cursor: pointer;
  transition: all .15s;
}

.btn-primary {
  background: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background: var(--accent-hover);
  color: #fff;
  text-decoration: none;
}

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  background: var(--surface-hover);
  color: var(--text);
  text-decoration: none;
}

.btn-block {
  width: 100%;
}

.btn-sm {
  padding: .35rem .65rem;
  font-size: .85rem;
}

/* Tables */
.table-wrap {
  overflow-x: auto;
  margin: 1rem 0;
}

table {
  width: 100%;
  border-collapse: collapse;
  font-size: .9rem;
}

th,
td {
  padding: .6rem .75rem;
  text-align: left;
  border-bottom: 1px solid var(--border);
}

th {
  font-weight: 600;
  color: var(--text-muted);
  font-size: .8rem;
  text-transform: uppercase;
  letter-spacing: .03em;
}

tr:hover td {
  background: rgba(0, 0, 0, .02);
}

td.numeric,
th.numeric {
  text-align: center;
  font-variant-numeric: tabular-nums;
}

tfoot th,
tfoot td {
  border-top: 2px solid var(--border);
  font-weight: 600;
  padding-top: .75rem;
}

/* Nav */
.nav {
  background: #1e3a8a;
  /* Elegant Navy Blue */
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  padding: .75rem 1rem;
  margin-bottom: 1.5rem;
  position: sticky;
  top: 0;
  z-index: 100;
  color: #fff;
}

.nav-inner {
  max-width: 960px;
  margin: 0 auto;
  display: flex;
  flex-direction: row;
  align-items: center;
}

.nav-brand-wrap {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-right: 1.5rem;
}

.mobile-toggle {
  display: none;
  background: rgba(255, 255, 255, 0.1);
  color: #fff;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  font-size: 1.25rem;
  padding: 0.25rem 0.6rem;
  cursor: pointer;
}

.nav-links {
  display: flex;
  flex-grow: 1;
  align-items: center;
  gap: 1rem;
}

.nav-logout {
  margin-left: auto;
}

.nav-logout a {
  color: #fecaca !important;
  /* Soft pale red/pinkish for contrast on navy */
  padding: .35rem .75rem;
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: var(--radius-sm);
  background: rgba(255, 255, 255, 0.05);
  font-weight: 500;
}

.nav-logout a:hover {
  background: rgba(248, 113, 113, 0.2);
  color: #fff !important;
  border-color: rgba(255, 255, 255, 0.4);
  text-decoration: none;
}

.nav-links a {
  color: rgba(255, 255, 255, 0.85);
  padding: .35rem 0;
  font-weight: 500;
}

.nav-links a:hover {
  color: #fff;
  text-decoration: underline;
}

.nav .brand {
  font-weight: 700;
  color: #fff;
  margin-right: .5rem;
  font-size: 1.35rem;
  /* Larger Title */
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.nav-logo {
  max-height: 36px;
  width: auto;
  border-radius: 4px;
  background: #fff;
  padding: 2px;
}

/* Nav dropdown */
.nav-dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
}

.nav-trigger {
  background: transparent;
  border: 1px solid transparent;
  color: rgba(255, 255, 255, 0.85);
  font: inherit;
  font-weight: 500;
  padding: .35rem 0;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: .25rem;
}

.nav-trigger:hover {
  color: #fff;
  text-decoration: underline;
}

.nav-caret {
  font-size: .8em;
  opacity: .85;
}

.nav-menu {
  position: absolute;
  top: calc(100% + .5rem);
  left: 0;
  min-width: 220px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 10px 25px rgba(0, 0, 0, 0.1);
  padding: .4rem;
  display: none;
  z-index: 50;
}

.nav-dropdown:hover .nav-menu,
.nav-dropdown.open .nav-menu {
  display: block;
}

.nav-menu a {
  display: block;
  padding: .55rem .6rem;
  border-radius: var(--radius-sm);
  color: var(--text);
}

.nav-menu a:hover {
  background: var(--surface-hover);
  color: var(--accent);
}

/* Alerts */
.alert {
  padding: .75rem 1rem;
  border-radius: var(--radius-sm);
  margin-bottom: 1rem;
  font-weight: 500;
}

.alert-success {
  background: #f0fdf4;
  border: 1px solid #bcf0da;
  color: #166534;
}

.alert-error {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.alert-info {
  background: #eff6ff;
  border: 1px solid #bfdbfe;
  color: #1e40af;
}

/* Input page (mobile-first for petugas) */
.input-page {
  max-width: 420px;
  margin: 0 auto;
  padding: 1rem;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  justify-content: center;
}

.input-page .card {
  margin-bottom: 0;
}

.input-page h1 {
  font-size: 1.25rem;
  margin: 0 0 .5rem;
}

.input-page .church-name {
  color: var(--accent);
  font-weight: 600;
  margin-bottom: 1.25rem;
}

/* QR code display */
.qr-card {
  text-align: center;
  padding: 1.5rem;
}

.qr-card img {
  max-width: 200px;
  height: auto;
  border-radius: var(--radius-sm);
  margin: 0 auto 1rem;
  display: block;
}

.qr-card .url {
  font-size: .8rem;
  word-break: break-all;
  color: var(--text-muted);
  margin-top: .5rem;
}

/* Stats / summary */
.stat-grid {
  display: grid;
  gap: 1rem;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  margin-bottom: 1.5rem;
}

.stat-box {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1rem;
  text-align: center;
}

.stat-box .value {
  font-size: 1.5rem;
  font-weight: 700;
  color: var(--accent);
  font-variant-numeric: tabular-nums;
}

.stat-box .label {
  font-size: .8rem;
  color: var(--text-muted);
  margin-top: .25rem;
}

/* Chart container */
.chart-wrap {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 1.25rem;
  margin: 1rem 0;
  min-height: 280px;
}

/* Utils */
.text-muted {
  color: var(--text-muted);
}

.text-right {
  text-align: right;
}

.mt-1 {
  margin-top: .5rem;
}

.mb-2 {
  margin-bottom: 1.5rem;
}

/* Modal */
.modal-backdrop {
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  display: none;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  z-index: 1000;
}

.modal-backdrop.open {
  display: flex;
}

.modal {
  width: 100%;
  max-width: 560px;
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  padding: 1rem 1.25rem;
  border-bottom: 1px solid var(--border);
}

.modal-title {
  margin: 0;
  font-size: 1.05rem;
  font-weight: 600;
}

.modal-body {
  padding: 1.25rem;
}

.modal-footer {
  display: flex;
  gap: .75rem;
  justify-content: flex-end;
  padding: 1rem 1.25rem;
  border-top: 1px solid var(--border);
}

.icon-btn {
  background: transparent;
  border: 1px solid transparent;
  color: var(--text-muted);
  cursor: pointer;
  padding: .25rem .5rem;
  border-radius: var(--radius-sm);
}

.icon-btn:hover {
  color: var(--text);
  background: var(--surface-hover);
}

@media (max-width: 768px) {

  /* Navigation Hamburger Behavior */
  .nav-inner {
    flex-direction: column;
    align-items: stretch;
    position: relative;
  }

  .nav-brand-wrap {
    margin-right: 0;
  }

  .mobile-toggle {
    display: block;
  }

  .nav-links {
    display: none;
    position: absolute;
    top: 100%;
    left: -1rem;
    width: calc(100% + 2rem);
    background: #fff;
    padding: 1rem;
    box-shadow: 0 8px 16px rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid var(--border);
    z-index: 100;
    flex-direction: column;
    align-items: flex-start;
    text-align: left;
    gap: 0.5rem;
  }

  .nav-links.show {
    display: flex;
  }

  .nav-links a {
    color: var(--text) !important;
    width: 100%;
    padding: 0.5rem 0;
  }

  .nav-trigger {
    color: var(--text) !important;
  }

  .nav-logout {
    margin-left: 0;
    margin-top: 0.5rem;
    width: 100%;
  }

  .nav-logout a {
    padding: 0.5rem 0;
    display: block;
  }

  .nav-dropdown {
    width: 100%;
    flex-direction: column;
    align-items: flex-start;
  }

  .nav-menu {
    position: static;
    display: none;
    box-shadow: none;
    border: none;
    background: transparent;
    padding-left: 1rem;
    border-left: 2px solid var(--border);
    margin-top: 0.5rem;
    text-align: left;
    width: 100%;
  }

  .nav-dropdown.open .nav-menu {
    display: block;
  }

  /* Core table rules for mobile */
  th,
  td {
    padding: .75rem .5rem;
    font-size: .85rem;
  }

  .table-wrap {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    border: 1px solid var(--border);
    border-radius: var(--radius-sm);
  }

  input[type="text"],
  input[type="number"],
  input[type="date"],
  select,
  .btn {
    padding: .75rem 1rem;
    font-size: 1rem;
  }
}

/* Print Styles */
.print-header {
  display: none;
}

@media print {
  @page {
    margin: 1.5cm;
    size: A4 portrait;
  }

  body {
    background: #fff !important;
    color: #000 !important;
    font-size: 11pt !important;
  }

  .print-header {
    display: block !important;
    text-align: center;
    border-bottom: 3px double #000;
    padding-bottom: 0.5rem;
    margin-bottom: 1.5rem;
  }

  .print-header h1 {
    margin: 0;
    font-size: 16pt !important;
    text-transform: uppercase;
  }

  .print-header p {
    margin: 0;
    font-size: 10pt !important;
    color: #444 !important;
  }

  .nav,
  form,
  .btn,
  .no-print,
  .alert {
    display: none !important;
  }

  .container {
    width: 100% !important;
    max-width: none !important;
    padding: 0 !important;
    margin: 0 !important;
  }

  .page-header {
    border-bottom: none !important;
    padding-bottom: 0 !important;
    margin-bottom: 1rem !important;
  }

  .card,
  .chart-wrap,
  .stat-box {
    box-shadow: none !important;
    border: none !important;
    background: transparent !important;
    padding: 0 !important;
    margin-bottom: 1.5rem !important;
  }

  h1,
  h2,
  h3,
  th,
  td,
  .text-muted {
    color: #000 !important;
  }

  table {
    width: 100% !important;
    border-collapse: collapse !important;
  }

  th,
  td {
    border: 1px solid #ddd !important;
    padding: 0.4rem !important;
  }

  thead {
    display: table-header-group !important;
  }

  tr {
    page-break-inside: avoid !important;
  }

  canvas,
  .chart-wrap {
    max-width: 100% !important;
    page-break-inside: avoid !important;
  }
}

/* Floating Action Button - Scroll to Top */
.fab-top {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  background-color: var(--accent);
  color: white;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.4);
  cursor: pointer;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
  border: none;
}

.fab-top.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.fab-top:hover {
  background-color: var(--accent-hover);
  transform: translateY(-3px);
  box-shadow: 0 6px 16px rgba(37, 99, 235, 0.5);
  color: white;
  text-decoration: none;
}

@media (max-width: 768px) {
  .fab-top {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
  }
}