/* =========================================
   COMPONENTS.css - Reusable UI Components
   ========================================= */

/* ── LAYOUT ── */
.main-content {
  flex: 1;
  margin-top: var(--header-h);
  margin-bottom: var(--nav-h);
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px 12px 20px;
}

/* ── HEADER ── */
.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: var(--header-h);
  background: linear-gradient(135deg, var(--primary), var(--primary-light));
  color: #fff;
  display: flex;
  align-items: center;
  padding: 0 16px;
  z-index: 100;
  box-shadow: 0 2px 8px rgba(0,0,0,.15);
}
.app-header .header-logo {
  width: 36px; height: 36px;
  border-radius: 50%;
  margin-right: 10px;
  object-fit: contain;
  background: #fff;
  padding: 2px;
}
.app-header h1 {
  font-size: 17px;
  font-weight: 700;
  flex: 1;
  line-height: 1.2;
}
.app-header .header-btn {
  background: rgba(255,255,255,.2);
  border: none;
  color: #fff;
  width: 40px; height: 40px;
  border-radius: 50%;
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  margin-left: 8px;
}

/* ── BOTTOM NAV ── */
.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: var(--nav-h);
  background: #fff;
  display: flex;
  border-top: 2px solid var(--border);
  z-index: 700;
  padding-bottom: env(safe-area-inset-bottom);
}
.nav-item {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all .2s;
  border: none;
  background: none;
  color: var(--text3);
  font-size: 11px;
  font-weight: 600;
  gap: 2px;
  padding: 4px 0;
  position: relative;
}
.nav-item.active { color: var(--primary); }
.nav-item .nav-icon { font-size: 26px; line-height: 1; }
.nav-item.active::before {
  content: '';
  position: absolute;
  top: -2px;
  left: 20%; right: 20%;
  height: 3px;
  background: var(--primary);
  border-radius: 0 0 4px 4px;
}
.nav-badge {
  position: absolute;
  top: 4px; right: 50%;
  transform: translateX(18px);
  background: var(--red);
  color: #fff;
  font-size: 10px;
  min-width: 18px;
  height: 18px;
  border-radius: 9px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  padding: 0 4px;
}

/* ── PAGES ── */
.page { display: none; }
.page.active { display: block; }

/* ── CARDS ── */
.card {
  background: var(--card);
  border-radius: var(--radius);
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
}
.card-title {
  font-size: 15px;
  font-weight: 700;
  color: var(--text2);
  margin-bottom: 12px;
  display: flex;
  align-items: center;
  gap: 8px;
}

/* ── BUTTONS ── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: var(--radius-sm);
  font-size: 16px;
  font-weight: 700;
  border: none;
  cursor: pointer;
  transition: all .15s;
  min-height: 52px;
  width: 100%;
  text-align: center;
}
.btn:disabled, .btn[disabled] {
  background: #d9d9d9;
  color: #9c9c9c;
  cursor: not-allowed;
  box-shadow: none;
  transform: none;
  pointer-events: none;
  opacity: 1;
}
.btn-primary { background: var(--primary); color: #fff; }
.btn-primary:active { background: var(--primary-dark); transform: scale(.97); }
.btn-green { background: var(--green); color: #fff; }
.btn-secondary { border: 2px solid var(--primary); color: var(--primary); background: transparent; }
.btn-green:active { background: #1B5E20; transform: scale(.97); }
.btn-red { background: var(--red); color: #fff; }
.btn-red:active { background: #8E0000; transform: scale(.97); }
.btn-outline { background: #fff; color: var(--primary); border: 2px solid var(--primary); }
.btn-outline:active { background: var(--orange-bg); }
.btn-ghost { background: transparent; color: var(--text2); border: 1px solid var(--border); }
.btn-ghost:active { background: #f5f5f5; }
.btn-sm { padding: 10px 16px; font-size: 14px; min-height: 42px; border-radius: 10px; }
.btn-icon { width: 48px; height: 48px; min-height: 48px; padding: 0; border-radius: 50%; font-size: 20px; }
.btn-row { display: flex; gap: 8px; }
.btn-row .btn { flex: 1; }

/* ── FAB ── */
.fab {
  position: fixed;
  bottom: calc(var(--nav-h) + 16px);
  right: 16px;
  width: 64px; height: 64px;
  border-radius: 50%;
  background: var(--primary);
  color: #fff;
  border: none;
  font-size: 32px;
  cursor: pointer;
  box-shadow: 0 4px 16px rgba(230,81,0,.4);
  z-index: 50;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all .2s;
}
.fab:active { transform: scale(.9); }

/* ── FORMS ── */
.form-group { margin-bottom: 16px; }
.form-label { display: block; font-size: 14px; font-weight: 700; color: var(--text2); margin-bottom: 6px; }
.form-input {
  width: 100%;
  padding: 14px 16px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 17px;
  font-weight: 600;
  background: #fff;
  color: var(--text);
  transition: border .2s;
  -webkit-appearance: none;
}
.form-input:focus { outline: none; border-color: var(--primary); }
.form-input::placeholder { color: #bbb; }
select.form-input {
  background: #fff url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23888' stroke-width='2' fill='none'/%3E%3C/svg%3E") no-repeat right 16px center;
}

/* ── SEARCH ── */
.search-box { position: relative; margin-bottom: 12px; }
.search-box input {
  width: 100%;
  padding: 12px 16px 12px 44px;
  border: 2px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: 15px;
  font-weight: 600;
  background: #fff;
}
.search-box input:focus { outline: none; border-color: var(--primary); }
.search-box .search-icon {
  position: absolute;
  left: 14px; top: 50%;
  transform: translateY(-50%);
  font-size: 18px;
  color: var(--text3);
}

/* ── DATE NAV ── */
.date-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 12px;
}
.date-nav .date-label {
  flex: 1;
  text-align: center;
  font-size: 16px;
  font-weight: 800;
  padding: 10px;
  background: #fff;
  border-radius: 10px;
  border: 2px solid var(--border);
}
.date-nav .date-btn {
  width: 44px; height: 44px;
  border-radius: 50%;
  background: #fff;
  border: 2px solid var(--border);
  font-size: 20px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  color: var(--text);
}
.date-nav .date-btn:active { background: #f5f5f5; }
.date-nav .date-label { transition: opacity .15s ease; }
.date-nav .date-label:active { opacity: .6; }
.date-nav .date-label.active {
  color: var(--primary);
  text-decoration: underline;
  text-underline-offset: 3px;
}
.date-nav .custom-date-input {
  border: 2px solid var(--border);
  border-radius: 10px;
  padding: 9px 10px;
  font-size: 15px;
  font-weight: 700;
  color: var(--text);
  background: #fff;
  outline: none;
  -webkit-appearance: none;
  appearance: none;
  max-width: 100%;
}
.date-nav .custom-date-input:focus { border-color: var(--primary); }

/* ===== Kontekstual date picker (harian / mingguan / bulanan) ===== */
.date-nav .cal-title {
  text-align: center;
  font-weight: 800;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
}
.date-nav .cal-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 3px;
}
.date-nav .cal-head {
  text-align: center;
  font-size: 10px;
  font-weight: 800;
  color: var(--text3);
  padding-bottom: 2px;
}
.date-nav .cal-cell {
  height: clamp(30px, 7vw, 38px);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 700;
  color: var(--text);
  background: #f7f7f7;
  border-radius: 8px;
  cursor: pointer;
  user-select: none;
}
.date-nav .cal-cell.empty { visibility: hidden; }
.date-nav .cal-cell.today { border: 2px solid var(--primary); }
.date-nav .cal-cell.sel { background: var(--primary); color: #fff; }
.date-nav .cal-cell.inrange { background: rgba(230,81,0,.14); box-shadow: inset 0 0 0 1px rgba(230,81,0,.35); }
.date-nav .cal-cell:active { opacity: .6; }
.date-nav .week-opt {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 8px 12px;
  margin-bottom: 5px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.date-nav .week-opt b { font-weight: 800; }
.date-nav .week-opt span {
  font-size: 12px;
  color: var(--text3);
  font-weight: 600;
}
.date-nav .week-opt.sel {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.date-nav .week-opt.sel span { color: rgba(255,255,255,.85); }
.date-nav .week-opt:active { opacity: .7; }
/* Opsi bulan disusun grid 4 kolom biar kompak */
.date-nav .month-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 6px;
}
.date-nav .month-opt {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 1px;
  padding: 10px 4px;
  border: 2px solid var(--border);
  border-radius: 10px;
  background: #fff;
  font-size: 13px;
  cursor: pointer;
  color: var(--text);
}
.date-nav .month-opt b { font-weight: 800; }
.date-nav .month-opt span {
  font-size: 10px;
  color: var(--text3);
  font-weight: 600;
}
.date-nav .month-opt.sel {
  border-color: var(--primary);
  background: var(--primary);
  color: #fff;
}
.date-nav .month-opt.sel span { color: rgba(255,255,255,.85); }
.date-nav .month-opt:active { opacity: .7; }

