/* ============================================================
   components.css — Buttons, tabs, modals, toasts, forms,
                    summary card, surah table, backup/trash lists
   Silatek-inspired design system
   ============================================================ */

/* ============================
   BUTTONS
   ============================ */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: var(--space-xs);
  padding: 9px 18px;
  font-family: var(--font);
  font-size: 0.9rem;
  font-weight: 600;
  line-height: 1;
  border: none;
  border-radius: var(--radius);
  cursor: pointer;
  transition: background-color var(--transition),
              box-shadow      var(--transition),
              transform       var(--transition),
              opacity         var(--transition);
  text-decoration: none;
  white-space: nowrap;
  user-select: none;
}

.btn:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring);
}

.btn:active { transform: scale(0.97); }

.btn:disabled {
  opacity: 0.55;
  cursor: not-allowed;
  transform: none;
}

/* Primary — silatek green #30ab59 */
.btn-primary {
  background-color: var(--primary);
  color: #ffffff;
}
.btn-primary:hover:not(:disabled) {
  background-color: var(--primary-dark);
  box-shadow: var(--shadow-sm);
}

/* Secondary — outlined silatek blue */
.btn-secondary {
  background-color: transparent;
  color: var(--secondary);
  border: 2px solid var(--secondary);
}
.btn-secondary:hover:not(:disabled) {
  background-color: var(--blue-50);
}

/* Danger */
.btn-danger {
  background-color: var(--danger);
  color: #ffffff;
}
.btn-danger:hover:not(:disabled) {
  background-color: #dc2626;
}

/* Small */
.btn-sm {
  padding: 5px 12px;
  font-size: 0.82rem;
}

/* Large */
.btn-lg {
  padding: 12px 28px;
  font-size: 1.05rem;
}

/* Full width */
.btn-block {
  width: 100%;
  justify-content: center;
}

/* Icon-only header buttons */
.btn-icon {
  background: rgba(255,255,255,.15);
  border: 1px solid rgba(255,255,255,.3);
  border-radius: var(--radius);
  color: var(--text-light);
  font-size: 1.1rem;
  padding: 6px 10px;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition),
              transform var(--transition);
  line-height: 1;
  font-family: var(--font);
}
.btn-icon:hover {
  background: rgba(255,255,255,.28);
  border-color: rgba(255,255,255,.6);
}
.btn-icon:active { transform: scale(0.95); }
.btn-icon:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,.5);
}

/* Add child button in tabs bar */
.btn-add-child {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 6px 14px;
  margin: auto 6px;
  background-color: rgba(255,255,255,.15);
  color: #ffffff;
  font-family: var(--font);
  font-size: 0.88rem;
  font-weight: 600;
  border: 2px dashed rgba(255,255,255,.4);
  border-radius: var(--radius);
  cursor: pointer;
  flex-shrink: 0;
  white-space: nowrap;
  transition: background-color var(--transition), border-color var(--transition);
}
.btn-add-child:hover {
  background-color: rgba(255,255,255,.25);
  border-color: rgba(255,255,255,.7);
}
.btn-add-child:focus-visible {
  outline: none;
  box-shadow: 0 0 0 3px rgba(255,255,255,.5);
}

/* ============================
   CHILD TABS
   ============================ */

.child-tab {
  display: inline-flex;
  align-items: center;
  padding: 10px 20px;
  font-family: var(--font);
  font-size: 0.93rem;
  font-weight: 600;
  color: rgba(255,255,255,.75);
  background-color: transparent;
  border: none;
  border-bottom: 3px solid transparent;
  cursor: pointer;
  transition: color var(--transition), border-color var(--transition),
              background-color var(--transition);
  white-space: nowrap;
  user-select: none;
  align-self: stretch;
}
.child-tab:hover {
  color: #ffffff;
  background-color: rgba(255,255,255,.08);
}
.child-tab.active {
  color: var(--gold-light);
  border-bottom-color: var(--gold);
  background-color: rgba(255,255,255,.1);
}
.child-tab:focus-visible {
  outline: none;
  box-shadow: inset 0 0 0 2px rgba(255,255,255,.6);
}

/* ============================
   CHILD PANEL
   ============================ */

.child-panel {
  display: none;
  flex-direction: column;
  gap: var(--space-lg);
  animation: fadeIn 0.25s ease;
}
.child-panel.active {
  display: flex;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(6px); }
  to   { opacity: 1; transform: translateY(0); }
}

/* ============================
   SUMMARY CARD
   ============================ */

.summary-card {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  padding: var(--space-lg);
  display: grid;
  grid-template-columns: 1fr auto auto;
  gap: var(--space-lg);
  align-items: start;
}

/* Left block: totals */
.summary-main {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
}

.total-label {
  font-size: 0.82rem;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.total-amount {
  font-size: 2rem;
  font-weight: 700;
  color: var(--gold);
  line-height: 1.1;
}

.summary-breakdown {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
  margin-top: 4px;
}

.breakdown-row {
  background: var(--primary-light);
  border: 1px solid var(--green-200);
  border-radius: var(--radius-sm);
  padding: 3px 10px;
  font-size: 0.82rem;
  color: var(--green-700);
  font-weight: 600;
  display: flex;
  gap: 6px;
  align-items: center;
}

.breakdown-row span:last-child {
  color: var(--gold);
}

/* Center block: progress */
.summary-progress {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  min-width: 160px;
}

.progress-text {
  font-size: 0.9rem;
  color: var(--text-medium);
  display: flex;
  align-items: baseline;
  gap: 4px;
  flex-wrap: wrap;
}

.progress-percent {
  font-size: 0.82rem;
  color: var(--text-muted);
}

.progress-bar-wrap {
  background: var(--border-light);
  border-radius: var(--radius-full);
  height: 10px;
  overflow: hidden;
  min-width: 140px;
}

.progress-bar {
  height: 100%;
  border-radius: var(--radius-full);
  background: linear-gradient(90deg, var(--primary), var(--secondary));
  transition: width 0.5s ease;
  min-width: 2px;
  will-change: width;
}

/* Right block: actions */
.summary-actions {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  align-items: flex-start;
  flex-shrink: 0;
}

/* ============================
   SURAH TABLE
   ============================ */

.table-wrapper {
  background: var(--bg-card);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow);
  border: 1px solid var(--border);
  overflow: hidden;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
}

.surah-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.88rem;
}

/* Header — silatek primary green (contrast with blue juz rows) */
.surah-table thead th {
  background: var(--primary);
  color: #ffffff;
  padding: 10px 12px;
  font-weight: 700;
  text-align: center;
  white-space: nowrap;
  font-size: 0.82rem;
  border-bottom: 2px solid var(--secondary-dark);
  position: sticky;
  top: 0;
  z-index: 2;
}

/* Body */
.surah-table tbody td {
  padding: 8px 10px;
  border-bottom: 1px solid var(--border-light);
  vertical-align: middle;
  text-align: center;
}
.surah-table tbody td.col-name {
  text-align: right;
}
.surah-table tbody tr:last-child td {
  border-bottom: none;
}
.surah-table tbody tr:hover {
  background-color: var(--primary-light);
}

/* Memorized row highlight */
.surah-table tbody tr.surah-row.memorized {
  background-color: var(--green-50);
}
.surah-table tbody tr.surah-row.memorized:hover {
  background-color: var(--green-100);
}

/* Paid row */
.surah-table tbody tr.surah-row.memorized.paid {
  background-color: var(--gold-pale);
}
.surah-table tbody tr.surah-row.memorized.paid:hover {
  background-color: var(--gold-light);
  opacity: 0.9;
}

/* Juz header row — silatek secondary blue */
.juz-header-row td {
  background: var(--secondary) !important;
  color: #ffffff !important;
  font-weight: 700;
  font-size: 0.85rem;
  padding: 7px 14px !important;
  text-align: right;
  border-bottom: 1px solid var(--secondary-dark) !important;
}

/* Surah link */
.surah-link {
  color: var(--secondary);
  font-weight: 600;
  text-decoration: none;
  transition: color var(--transition);
}
.surah-link:hover {
  color: var(--primary);
  text-decoration: underline;
}

/* Grade dropdown */
.grade-select {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  cursor: pointer;
  min-width: 88px;
  transition: border-color var(--transition);
}
.grade-select:disabled { opacity: 0.4; cursor: not-allowed; }
.grade-select:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

/* Date input */
.date-input {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  width: 128px;
  transition: border-color var(--transition);
}
.date-input:disabled { opacity: 0.4; cursor: not-allowed; }
.date-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

/* Partial pages input — same style as date-input but narrower */
.pages-input {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  width: 68px;
  text-align: center;
  transition: border-color var(--transition);
}
.pages-input:disabled { opacity: 0.4; cursor: not-allowed; }
.pages-input:focus-visible { outline: none; border-color: var(--primary); box-shadow: var(--focus-ring); }

/* Checkboxes */
.surah-table input[type="checkbox"] {
  width: 17px;
  height: 17px;
  cursor: pointer;
  accent-color: var(--primary);
}
.surah-table input[type="checkbox"]:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

/* Earnings cell */
.col-earn {
  font-weight: 700;
  color: var(--gold);
  min-width: 58px;
}

/* Hide pages column on mobile */
@media (max-width: 680px) {
  .col-hide-mobile { display: none !important; }
}

/* ============================
   FORMS & INPUTS
   ============================ */

.form-group {
  display: flex;
  flex-direction: column;
  gap: 6px;
  margin-bottom: var(--space-md);
}
.form-group:last-child {
  margin-bottom: 0;
}

label {
  font-size: 0.88rem;
  font-weight: 600;
  color: var(--text-medium);
}

.form-input {
  font-family: var(--font);
  font-size: 0.95rem;
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  background: var(--bg-input);
  color: var(--text-dark);
  width: 100%;
  transition: border-color var(--transition), box-shadow var(--transition);
}
.form-input:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

.input-short {
  max-width: 180px;
}

.input-row {
  display: flex;
  gap: var(--space-sm);
  align-items: flex-start;
  flex-wrap: wrap;
}
.input-row .form-input {
  flex: 1;
  min-width: 100px;
}

/* ============================
   MODALS
   ============================ */

.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: var(--z-modal);
  padding: var(--space-md);
  animation: overlayFadeIn 0.2s ease;
}
@keyframes overlayFadeIn {
  from { opacity: 0; }
  to   { opacity: 1; }
}

.modal-box {
  background: var(--bg-card);
  border-radius: var(--radius-xl);
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  animation: modalSlideIn 0.25s ease;
  direction: rtl;
}
.modal-box.modal-sm {
  max-width: 400px;
}

@keyframes modalSlideIn {
  from { opacity: 0; transform: translateY(-16px) scale(0.97); }
  to   { opacity: 1; transform: translateY(0)     scale(1);    }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: var(--space-md) var(--space-lg);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  background: var(--bg-card);
  border-radius: var(--radius-xl) var(--radius-xl) 0 0;
  z-index: 1;
}

.modal-header h2 {
  font-size: 1.05rem;
  color: var(--text-dark);
  margin: 0;
}

.modal-close {
  background: none;
  border: none;
  font-size: 1.25rem;
  color: var(--text-muted);
  cursor: pointer;
  padding: 4px 6px;
  border-radius: var(--radius-sm);
  line-height: 1;
  transition: color var(--transition), background var(--transition);
}
.modal-close:hover {
  color: var(--danger);
  background: var(--danger-bg);
}
.modal-close:focus-visible {
  outline: none;
  box-shadow: var(--focus-ring-danger);
}

.modal-body {
  padding: var(--space-lg);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: var(--space-sm);
  padding: var(--space-md) var(--space-lg);
  border-top: 1px solid var(--border-light);
  background: var(--bg-page);
  border-radius: 0 0 var(--radius-xl) var(--radius-xl);
  flex-wrap: wrap;
}

.modal-hint {
  font-size: 0.85rem;
  color: var(--text-muted);
  margin-bottom: var(--space-md);
}

/* ============================
   SETTINGS — Tiered Bonus
   ============================ */

.bonus-info-box {
  background: var(--primary-light);
  border: 1px solid var(--green-200);
  border-radius: var(--radius);
  padding: var(--space-md);
  margin-top: var(--space-sm);
}

.bonus-info-title {
  font-size: 0.88rem;
  font-weight: 700;
  color: var(--green-700);
  margin-bottom: var(--space-sm);
}

.tiered-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: var(--space-md);
}

.tiered-group {
  display: flex;
  flex-direction: column;
  gap: var(--space-xs);
}

.tiered-group-label {
  font-size: 0.78rem;
  font-weight: 700;
  color: var(--primary-dark);
  text-align: center;
  padding-bottom: 4px;
  border-bottom: 1px solid var(--green-200);
  margin-bottom: 4px;
}

.tiered-inputs {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.tiered-input-row {
  display: flex;
  align-items: center;
  gap: 6px;
}

.tiered-input-row label {
  font-size: 0.78rem;
  color: var(--text-muted);
  min-width: 28px;
  flex-shrink: 0;
}

.tiered-val {
  font-family: var(--font);
  font-size: 0.82rem;
  padding: 3px 6px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg-input);
  width: 60px;
  text-align: center;
  transition: border-color var(--transition);
}
.tiered-val:focus-visible {
  outline: none;
  border-color: var(--primary);
  box-shadow: var(--focus-ring);
}

/* ============================
   TOAST NOTIFICATIONS
   ============================ */

.toast {
  background: var(--bg-card);
  border-radius: var(--radius);
  padding: 12px 16px;
  box-shadow: var(--shadow-lg);
  border: 1px solid var(--border);
  font-size: 0.88rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: var(--space-sm);
  pointer-events: auto;
  opacity: 0;
  transform: translateX(20px);
  transition: opacity 0.3s ease, transform 0.3s ease;
  border-right: 4px solid var(--primary);
}

.toast.toast-visible {
  opacity: 1;
  transform: translateX(0);
}

.toast.toast-success { border-right-color: var(--primary);  color: var(--green-700); }
.toast.toast-error   { border-right-color: var(--danger);   color: var(--danger);    }
.toast.toast-warning { border-right-color: var(--warning);  color: var(--warning);   }
.toast.toast-info    { border-right-color: var(--info);     color: var(--info);      }

/* ============================
   BACKUP & TRASH LISTS
   ============================ */

.item-list {
  display: flex;
  flex-direction: column;
  gap: var(--space-sm);
  max-height: 420px;
  overflow-y: auto;
}

.backup-item,
.trash-item {
  background: var(--bg-page);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: var(--space-md);
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: var(--space-sm);
  flex-wrap: wrap;
  transition: background-color var(--transition);
}

.backup-item:hover,
.trash-item:hover {
  background: var(--border-light);
}

/* Backup info */
.backup-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
  flex: 1;
}

.backup-date {
  font-size: 0.78rem;
  color: var(--text-muted);
}

.backup-reason {
  font-size: 0.9rem;
  font-weight: 700;
  color: var(--text-dark);
}

.backup-type {
  display: inline-block;
  font-size: 0.75rem;
  padding: 2px 8px;
  border-radius: var(--radius-full);
  font-weight: 700;
  margin-top: 2px;
}

.backup-type-auto   { background: var(--primary-light); color: var(--primary-dark); }
.backup-type-manual { background: var(--gold-pale);     color: #8a6400;             }
.backup-type-safety { background: var(--info-bg);       color: var(--info);         }

/* Trash info */
.trash-item {
  gap: var(--space-sm);
  flex-wrap: wrap;
}

.trash-name {
  font-weight: 700;
  color: var(--text-dark);
  font-size: 0.95rem;
  flex: 1;
  min-width: 120px;
}

.trash-date {
  font-size: 0.78rem;
  color: var(--text-muted);
  width: 100%;
}

.trash-item > .btn {
  flex-shrink: 0;
}

/* Empty message */
.empty-msg {
  text-align: center;
  color: var(--text-muted);
  font-size: 0.9rem;
  padding: var(--space-lg);
}

/* ============================
   CONFIRM MODAL
   ============================ */

#confirm-message {
  font-size: 1rem;
  color: var(--text-dark);
  line-height: 1.7;
  margin-bottom: 0;
}

/* ============================
   RESPONSIVE — SUMMARY CARD
   ============================ */

@media (max-width: 820px) {
  .summary-card {
    grid-template-columns: 1fr 1fr;
    grid-template-rows: auto auto;
  }
  .summary-actions {
    grid-column: 1 / -1;
    flex-direction: row;
    flex-wrap: wrap;
  }
}

@media (max-width: 560px) {
  .summary-card {
    grid-template-columns: 1fr;
  }
  .summary-progress {
    min-width: unset;
  }
  .total-amount {
    font-size: 1.6rem;
  }
}

/* ============================
   RESPONSIVE — TABLE
   ============================ */

@media (max-width: 768px) {
  .surah-table thead th,
  .surah-table tbody td {
    padding: 6px 7px;
    font-size: 0.8rem;
  }
.date-input  { width: 110px; }
  .grade-select { min-width: 76px; }
}

/* ============================
   RESPONSIVE — MODALS
   ============================ */

@media (max-width: 480px) {
  .modal-box {
    border-radius: var(--radius-lg);
  }
  .modal-header {
    padding: var(--space-sm) var(--space-md);
    border-radius: var(--radius-lg) var(--radius-lg) 0 0;
  }
  .modal-body   { padding: var(--space-md); }
  .modal-footer {
    padding: var(--space-sm) var(--space-md);
    border-radius: 0 0 var(--radius-lg) var(--radius-lg);
  }
  .modal-footer .btn {
    flex: 1;
    justify-content: center;
  }
  .tiered-grid { grid-template-columns: 1fr; }
  .input-row   { flex-direction: column; }
  .input-short { max-width: 100%; }
}
