/* ═══════════════════════════════════════════════════════
   PSDM Student Manager — Components
═══════════════════════════════════════════════════════ */

/* ─── Buttons ──────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 9px 18px;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  transition: all var(--transition);
  white-space: nowrap;
  text-decoration: none;
  font-family: inherit;
  line-height: 1.4;
  letter-spacing: .1px;
  position: relative;
  overflow: hidden;
}
.btn:focus-visible {
  outline: 2px solid var(--primary);
  outline-offset: 2px;
}
.btn:active { transform: scale(.97); }
.btn:disabled { opacity: .5; cursor: not-allowed; transform: none; }

.btn-primary {
  background: var(--primary);
  color: #fff;
  border-color: var(--primary);
  box-shadow: 0 1px 2px rgba(37,99,235,.3);
}
.btn-primary:hover:not(:disabled) {
  background: var(--primary-h);
  border-color: var(--primary-h);
  box-shadow: 0 4px 12px rgba(37,99,235,.35);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--green);
  color: #fff;
  border-color: var(--green);
  box-shadow: 0 1px 2px rgba(5,150,105,.3);
}
.btn-success:hover:not(:disabled) {
  background: var(--green-d);
  box-shadow: 0 4px 12px rgba(5,150,105,.3);
  transform: translateY(-1px);
}

.btn-danger {
  background: var(--red);
  color: #fff;
  border-color: var(--red);
}
.btn-danger:hover:not(:disabled) {
  filter: brightness(.9);
  box-shadow: 0 4px 12px rgba(220,38,38,.3);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--bg3);
  color: var(--text2);
  border-color: var(--border);
}
.btn-secondary:hover:not(:disabled) {
  background: var(--bg4);
  border-color: var(--border2);
  color: var(--text);
}

.btn-ghost {
  background: transparent;
  color: var(--text3);
  border-color: transparent;
}
.btn-ghost:hover:not(:disabled) {
  background: var(--bg3);
  color: var(--text2);
}

.btn-outline {
  background: transparent;
  color: var(--primary);
  border-color: var(--primary);
}
.btn-outline:hover:not(:disabled) {
  background: var(--primary-l);
  box-shadow: 0 2px 8px rgba(37,99,235,.15);
}

.btn-sm  { padding: 6px 13px; font-size: 12.5px; }
.btn-xs  { padding: 4px 9px;  font-size: 12px; border-radius: var(--radius-xs); }
.btn-lg  { padding: 12px 24px; font-size: 15px; border-radius: var(--radius); }
.w-full  { width: 100%; }

/* ─── Forms ────────────────────────────────────────────── */
.form-group { margin-bottom: 16px; }
.form-group label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text2);
  letter-spacing: .1px;
}
.form-group .req { color: var(--red); margin-left: 1px; }

.form-control {
  width: 100%;
  padding: 9px 13px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg2);
  color: var(--text);
  font-size: 14px;
  transition: all var(--transition);
  line-height: 1.5;
}
.form-control:hover { border-color: var(--border2); }
.form-control:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(37,99,235,.12);
  background: var(--bg2);
}
.form-control::placeholder { color: var(--text4); }
.form-control.error {
  border-color: var(--red);
  box-shadow: 0 0 0 3px rgba(220,38,38,.1);
}

textarea.form-control { min-height: 90px; resize: vertical; }

select.form-control {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath fill='%2364748b' d='M6 8L0 0h12z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 13px center;
  padding-right: 34px;
  cursor: pointer;
}

.form-hint { font-size: 12px; color: var(--text3); margin-top: 5px; line-height: 1.4; }
.form-row-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.form-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }

.form-section-title {
  font-size: 12px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text3);
  margin-bottom: 14px;
  padding: 10px 0 10px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: pointer;
  user-select: none;
}
.form-section-title:hover { color: var(--text2); }
.form-section-body.collapsed { display: none; }

.form-control-sm {
  padding: 5px 9px;
  font-size: 12.5px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-xs);
  background: var(--bg2);
  color: var(--text);
  font-family: inherit;
  transition: all var(--transition);
}
.form-control-sm:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(37,99,235,.1);
}

/* ─── Tables ────────────────────────────────────────────── */
.tbl-wrap {
  overflow-x: auto;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}
.tbl {
  width: 100%;
  border-collapse: collapse;
  font-size: 13.5px;
}
.tbl thead { background: var(--bg3); }
.tbl th {
  padding: 11px 14px;
  text-align: left;
  font-weight: 600;
  font-size: 12px;
  color: var(--text3);
  white-space: nowrap;
  border-bottom: 1px solid var(--border);
  text-transform: uppercase;
  letter-spacing: .4px;
}
.tbl td {
  padding: 11px 14px;
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
  color: var(--text2);
}
.tbl tr:last-child td { border-bottom: none; }
.tbl tbody tr {
  transition: background var(--transition);
}
.tbl tbody tr:hover td {
  background: var(--bg3);
  color: var(--text);
}
.tbl .actions { white-space: nowrap; text-align: right; }

/* ─── Badges ────────────────────────────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  padding: 3px 9px;
  border-radius: 20px;
  font-size: 11.5px;
  font-weight: 600;
  white-space: nowrap;
  letter-spacing: .2px;
}
.badge-blue   { background: var(--primary-l); color: var(--primary); }
.badge-green  { background: var(--green-l);   color: var(--green-d); }
.badge-red    { background: var(--red-l);     color: var(--red); }
.badge-yellow { background: var(--yellow-l);  color: var(--yellow); }
.badge-orange { background: var(--orange-l);  color: var(--orange); }
.badge-purple { background: var(--purple-l);  color: var(--purple); }
.badge-gray   { background: var(--bg4);       color: var(--text3); }

/* ─── Modals ────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15,23,42,.55);
  backdrop-filter: blur(3px);
  -webkit-backdrop-filter: blur(3px);
  z-index: 500;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity .2s var(--ease);
}
.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}
.modal {
  background: var(--bg2);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  border: 1px solid var(--border);
  width: 100%;
  max-width: 520px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(-16px) scale(.98);
  transition: transform .2s var(--ease);
}
.modal-overlay.open .modal {
  transform: translateY(0) scale(1);
}
.modal-lg  { max-width: 720px; }
.modal-xl  { max-width: 960px; }

.modal-header {
  padding: 18px 22px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
  font-size: 16px;
  font-weight: 700;
  position: sticky;
  top: 0;
  background: var(--bg2);
  z-index: 1;
  color: var(--text);
}
.modal-close {
  background: var(--bg3);
  border: none;
  font-size: 18px;
  cursor: pointer;
  color: var(--text3);
  line-height: 1;
  padding: 6px 8px;
  border-radius: var(--radius-xs);
  transition: all var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
}
.modal-close:hover {
  background: var(--red-l);
  color: var(--red);
}
.modal-body   { padding: 22px; }
.modal-footer {
  padding: 16px 22px;
  border-top: 1px solid var(--border);
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  background: var(--bg3);
  border-radius: 0 0 var(--radius) var(--radius);
}

/* ─── Toasts ────────────────────────────────────────────── */
#toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 8px;
  max-width: 360px;
}
.toast {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-left: 4px solid var(--primary);
  padding: 13px 16px;
  border-radius: var(--radius);
  box-shadow: var(--shadow-lg);
  font-size: 13.5px;
  animation: toastIn .25s var(--ease);
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-weight: 500;
  line-height: 1.4;
}
.toast.success { border-left-color: var(--green); }
.toast.error   { border-left-color: var(--red);   }
.toast.warning { border-left-color: var(--yellow); }
@keyframes toastIn {
  from { transform: translateX(calc(100% + 24px)); opacity: 0; }
  to   { transform: translateX(0); opacity: 1; }
}
@keyframes toastOut {
  to { transform: translateX(calc(100% + 24px)); opacity: 0; }
}
.toast.removing { animation: toastOut .3s var(--ease) forwards; }

/* ─── Dropdowns ─────────────────────────────────────────── */
.dropdown { position: relative; display: inline-block; }
.dropdown-menu {
  position: absolute;
  top: calc(100% + 6px);
  right: 0;
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  box-shadow: var(--shadow-xl);
  min-width: 190px;
  z-index: 300;
  display: none;
  overflow: hidden;
}
.dropdown-menu.open { display: block; }
.dropdown-item {
  padding: 10px 15px;
  font-size: 13px;
  cursor: pointer;
  display: flex;
  align-items: center;
  gap: 9px;
  color: var(--text);
  transition: background var(--transition);
  font-weight: 500;
}
.dropdown-item:hover { background: var(--bg3); }
.dropdown-item.danger { color: var(--red); }
.dropdown-divider { height: 1px; background: var(--border); margin: 4px 0; }

/* ─── Filter / Search Bar ───────────────────────────────── */
.filter-bar {
  display: flex;
  gap: 10px;
  flex-wrap: wrap;
  align-items: center;
  margin-bottom: 18px;
  background: var(--bg2);
  padding: 14px 16px;
  border-radius: var(--radius);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-xs);
}

.search-input {
  flex: 1;
  min-width: 220px;
  padding: 9px 13px 9px 38px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 13.5px;
  transition: all var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='16' height='16' viewBox='0 0 24 24' fill='none' stroke='%2364748b' stroke-width='2' stroke-linecap='round'%3E%3Ccircle cx='11' cy='11' r='8'/%3E%3Cline x1='21' y1='21' x2='16.65' y2='16.65'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: 12px center;
}
.search-input:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg2);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}
.search-input::placeholder { color: var(--text4); }

.filter-select {
  padding: 9px 30px 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  background: var(--bg3);
  color: var(--text);
  font-size: 13.5px;
  appearance: none;
  cursor: pointer;
  font-family: inherit;
  transition: all var(--transition);
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='10' height='6' viewBox='0 0 10 6'%3E%3Cpath fill='%2364748b' d='M5 6L0 0h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 11px center;
}
.filter-select:focus {
  outline: none;
  border-color: var(--primary);
  background-color: var(--bg2);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

/* ─── Tabs ──────────────────────────────────────────────── */
.tabs {
  display: flex;
  border-bottom: 2px solid var(--border);
  margin-bottom: 20px;
  gap: 2px;
  flex-wrap: nowrap;
  overflow-x: auto;
  scrollbar-width: none;
}
.tabs::-webkit-scrollbar { display: none; }
.tab-btn {
  padding: 10px 18px;
  font-size: 13.5px;
  font-weight: 600;
  cursor: pointer;
  color: var(--text3);
  border: none;
  background: none;
  border-bottom: 2px solid transparent;
  margin-bottom: -2px;
  transition: all var(--transition);
  font-family: inherit;
  white-space: nowrap;
  border-radius: var(--radius-xs) var(--radius-xs) 0 0;
}
.tab-btn:hover { color: var(--text2); background: var(--bg3); }
.tab-btn.active {
  color: var(--primary);
  border-bottom-color: var(--primary);
  background: var(--primary-l);
}
.tab-content { display: none; }
.tab-content.active { display: block; }

/* ─── Empty States ──────────────────────────────────────── */
.empty-state {
  text-align: center;
  padding: 56px 24px;
  color: var(--text3);
}
.empty-icon {
  font-size: 52px;
  margin-bottom: 14px;
  opacity: .7;
  display: block;
}
.empty-state h3 {
  font-size: 17px;
  font-weight: 700;
  margin-bottom: 8px;
  color: var(--text2);
}
.empty-state p { font-size: 14px; line-height: 1.6; }

/* ─── Loading ────────────────────────────────────────────── */
.spinner {
  width: 24px;
  height: 24px;
  border: 2.5px solid var(--border);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin .7s linear infinite;
  display: inline-block;
  flex-shrink: 0;
}
@keyframes spin { to { transform: rotate(360deg); } }

.page-loader {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 60px;
  gap: 12px;
  color: var(--text3);
  font-size: 13.5px;
}

/* ─── Reminders ─────────────────────────────────────────── */
.reminder-card {
  background: var(--bg2);
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  padding: 13px 15px;
  margin-bottom: 10px;
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 12px;
  flex-wrap: wrap;
  transition: all var(--transition);
}
.reminder-card:hover { box-shadow: var(--shadow-md); }
.reminder-card.overdue {
  border-left: 4px solid var(--red);
  background: linear-gradient(to right, rgba(220,38,38,.03), var(--bg2));
}
.reminder-card.today {
  border-left: 4px solid var(--yellow);
  background: linear-gradient(to right, rgba(217,119,6,.03), var(--bg2));
}
.reminder-card.upcoming {
  border-left: 4px solid var(--green);
}
.reminder-info h4 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 3px;
  color: var(--text);
}
.reminder-info p { font-size: 12.5px; color: var(--text3); }
.reminder-actions { display: flex; gap: 6px; flex-shrink: 0; align-items: center; }
.reminder-section-title {
  font-size: 11px;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .6px;
  color: var(--text4);
  margin: 18px 0 10px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.reminder-badge {
  background: var(--red);
  color: #fff;
  border-radius: 12px;
  font-size: 11px;
  font-weight: 700;
  padding: 2px 7px;
  min-width: 20px;
  text-align: center;
}

/* ─── Separator ─────────────────────────────────────────── */
.separator { height: 1px; background: var(--border); margin: 16px 0; }

/* ─── Data callouts ─────────────────────────────────────── */
.overdue-text  { color: var(--red);    font-weight: 600; }
.balance-text  { color: var(--orange); font-weight: 600; }
.success-text  { color: var(--green);  font-weight: 600; }

/* ─── Info boxes ────────────────────────────────────────── */
.alert {
  padding: 13px 16px;
  border-radius: var(--radius-sm);
  font-size: 13.5px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
  line-height: 1.5;
  font-weight: 500;
}
.alert-warning {
  background: var(--yellow-l);
  border: 1px solid rgba(217,119,6,.2);
  color: #92400e;
}
.alert-error {
  background: var(--red-l);
  border: 1px solid rgba(220,38,38,.2);
  color: #991b1b;
}
.alert-success {
  background: var(--green-l);
  border: 1px solid rgba(5,150,105,.2);
  color: #065f46;
}
.alert-info {
  background: var(--primary-l);
  border: 1px solid rgba(37,99,235,.2);
  color: #1e40af;
}

/* ─── Utility ────────────────────────────────────────────── */
.text-muted    { color: var(--text3); }
.text-center   { text-align: center; }
.text-right    { text-align: right; }
.fw-bold       { font-weight: 700; }
.fw-semibold   { font-weight: 600; }
.d-block       { display: block; }
.d-flex        { display: flex; }
.items-center  { align-items: center; }
.justify-between { justify-content: space-between; }
.flex-wrap     { flex-wrap: wrap; }

.mt-1 { margin-top: 6px; }
.mt-2 { margin-top: 12px; }
.mt-3 { margin-top: 20px; }
.mt-4 { margin-top: 28px; }
.mb-1 { margin-bottom: 6px; }
.mb-2 { margin-bottom: 12px; }
.mb-3 { margin-bottom: 20px; }
.mb-4 { margin-bottom: 28px; }

.gap-1 { gap: 6px; }
.gap-2 { gap: 12px; }
.gap-3 { gap: 18px; }

.grid-2 { display: grid; grid-template-columns: 1fr 1fr; gap: 18px; }
.grid-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 18px; }

.fs-sm { font-size: 12.5px; }
.fs-xs { font-size: 11.5px; }
.truncate { overflow: hidden; white-space: nowrap; text-overflow: ellipsis; }

/* ─── Pagination ─────────────────────────────────────────── */
.pagination {
  display: flex;
  align-items: center;
  gap: 4px;
  margin-top: 16px;
  flex-wrap: wrap;
}
.pagination .text-muted {
  font-size: 12.5px;
  margin-left: 8px;
}
