/* ==========================================================
   ExpTrack — global styling + responsive (mobile + desktop)
   ========================================================== */

:root {
  --et-radius: 0.6rem;
  --et-shadow-sm: 0 1px 2px rgba(15, 23, 42, 0.06), 0 1px 3px rgba(15, 23, 42, 0.05);
  --et-shadow-md: 0 4px 12px rgba(15, 23, 42, 0.08);
  --et-bg-soft: #f6f8fb;
}

html, body {
  -webkit-text-size-adjust: 100%;
}

body {
  font-size: 0.92rem;
  background: var(--et-bg-soft);
}

/* Larger tap targets on touch devices (excludes checkboxes/radios so they
   keep their square aspect ratio) */
@media (hover: none) and (pointer: coarse) {
  .btn, .form-control, .form-select, .nav-link, .page-link {
    min-height: 38px;
  }
  .btn-sm, .form-control-sm, .form-select-sm {
    min-height: 32px;
  }
  .form-check-input[type="checkbox"],
  .form-check-input[type="radio"] {
    width: 1.15em;
    height: 1.15em;
    min-height: 0;
  }
}

/* ── Navbar ─────────────────────────────────────────────── */
.navbar-brand {
  font-size: 1.1rem;
  letter-spacing: 0.01em;
}

.navbar .nav-link {
  padding: 0.45rem 0.7rem;
  border-radius: 0.4rem;
  transition: background-color 0.15s ease;
}

.navbar .nav-link:hover,
.navbar .nav-link:focus {
  background: rgba(255, 255, 255, 0.12);
}

.navbar-avatar {
  border: 2px solid rgba(255, 255, 255, 0.4);
}

@media (max-width: 991.98px) {
  .navbar-collapse {
    margin-top: 0.5rem;
    padding-top: 0.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.15);
    max-height: 75vh;
    overflow-y: auto;
  }
  .navbar .nav-link {
    padding: 0.55rem 0.6rem;
  }
  .dropdown-menu {
    border: 0;
    background: rgba(255, 255, 255, 0.08);
    box-shadow: none;
  }
  .dropdown-menu .dropdown-item {
    color: rgba(255, 255, 255, 0.85);
  }
  .dropdown-menu .dropdown-item:hover {
    background: rgba(255, 255, 255, 0.15);
    color: #fff;
  }
}

/* ── Cards ──────────────────────────────────────────────── */
.card {
  border: none;
  border-radius: var(--et-radius);
}

.card.shadow-sm {
  box-shadow: var(--et-shadow-sm) !important;
}

.card-header {
  background: #fff;
  border-bottom: 1px solid #eef0f4;
  font-weight: 600;
}

/* ── Tables ─────────────────────────────────────────────── */
.table th {
  font-weight: 600;
  font-size: 0.78rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  white-space: nowrap;
}

.table td {
  vertical-align: middle;
}

@media (max-width: 575.98px) {
  .table {
    font-size: 0.82rem;
  }
  .table th, .table td {
    padding: 0.45rem 0.5rem;
  }
}

/* Smooth horizontal scroll on mobile + scroll hint */
.table-responsive {
  -webkit-overflow-scrolling: touch;
}

@media (max-width: 575.98px) {
  .table-responsive::-webkit-scrollbar {
    height: 4px;
  }
  .table-responsive::-webkit-scrollbar-thumb {
    background: rgba(0, 0, 0, 0.2);
    border-radius: 2px;
  }
}

/* Generic helper to hide columns on small screens — used inline */
@media (max-width: 575.98px) {
  .col-hide-xs { display: none !important; }
}
@media (max-width: 767.98px) {
  .col-hide-sm { display: none !important; }
}

/* ── Badges ─────────────────────────────────────────────── */
.badge {
  font-weight: 500;
}

/* ── Forms ──────────────────────────────────────────────── */
.form-label {
  font-weight: 500;
  font-size: 0.85rem;
  margin-bottom: 0.3rem;
}

.form-control, .form-select {
  border-radius: 0.45rem;
}

/* Prevent iOS zoom on input focus */
@media (max-width: 575.98px) {
  input[type="text"], input[type="email"], input[type="number"],
  input[type="password"], input[type="date"], input[type="search"],
  input[type="tel"], textarea, select {
    font-size: 16px;
  }
  .form-control-sm, .form-select-sm {
    font-size: 14px;
  }
}

/* ── Drop zone ──────────────────────────────────────────── */
#drop-zone {
  border: 2px dashed #dee2e6;
  transition: background 0.2s, border-color 0.2s;
}

#drop-zone:hover {
  background: rgba(13, 110, 253, 0.05);
  border-color: #0d6efd;
}

/* ── Misc ───────────────────────────────────────────────── */
.cursor-pointer { cursor: pointer; }

.alert-success { --bs-alert-color: #0a3622; }
.alert-danger  { --bs-alert-color: #58151c; }
.alert-info    { --bs-alert-color: #055160; }

/* Page header row — used at the top of many pages */
.page-header {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.page-header > .page-title {
  margin: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 600;
}

.page-header > .page-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 0.4rem;
}

@media (max-width: 575.98px) {
  .page-header > .page-actions {
    width: 100%;
  }
  .page-header > .page-actions > .btn,
  .page-header > .page-actions > form > .btn {
    flex: 1 1 auto;
  }
}

/* Category checkbox grids in preferences */
.category-check-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0.35rem 0.75rem;
  max-height: 260px;
  overflow-y: auto;
  padding: 0.5rem;
  border: 1px solid #dee2e6;
  border-radius: 0.4rem;
  background: #fafafa;
}

@media (max-width: 575.98px) {
  .category-check-grid {
    grid-template-columns: 1fr;
    max-height: 220px;
  }
}

.category-check-item .form-check-label {
  font-size: 0.85rem;
  cursor: pointer;
}

.cat-dot {
  display: inline-block;
  width: 10px;
  height: 10px;
  border-radius: 50%;
  flex-shrink: 0;
}

/* Dashboard chart column: keep chart square but responsive */
.donut-wrap {
  position: relative;
  width: 100%;
  max-width: 280px;
  aspect-ratio: 1 / 1;
  flex-shrink: 0;
  margin-inline: auto;
}

@media (min-width: 768px) {
  .donut-wrap {
    margin-inline: 0;
  }
}

.donut-center {
  position: absolute;
  inset: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  pointer-events: none;
}

.chart-legend {
  flex: 1 1 240px;
  min-width: 0;
  max-height: 280px;
  overflow-y: auto;
}

@media (max-width: 767.98px) {
  .chart-legend {
    max-height: 200px;
  }
}

/* KPI card */
.kpi-card .kpi-label {
  font-size: 0.72rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.kpi-card .kpi-value {
  font-weight: 700;
  font-size: 1.4rem;
  line-height: 1.2;
}

@media (max-width: 575.98px) {
  .kpi-card .kpi-value {
    font-size: 1.15rem;
  }
}

/* Filter card – tighter & wraps cleanly on mobile */
.filter-card .form-label {
  font-size: 0.72rem;
  text-transform: uppercase;
  letter-spacing: 0.04em;
  color: #6c757d;
  margin-bottom: 0.2rem;
}

.filter-card .filter-actions {
  display: flex;
  gap: 0.4rem;
  flex-wrap: wrap;
}

@media (max-width: 575.98px) {
  .filter-card .filter-actions > .btn {
    flex: 1 1 auto;
  }
}

/* Mobile expense card list (alt view) */
.mobile-list { display: none; }

@media (max-width: 575.98px) {
  .mobile-list {
    display: block;
  }
  .mobile-hide {
    display: none !important;
  }
  .mobile-list .item {
    background: #fff;
    border-radius: var(--et-radius);
    padding: 0.7rem 0.85rem;
    margin-bottom: 0.55rem;
    box-shadow: var(--et-shadow-sm);
  }
  .mobile-list .item .row-1 {
    display: flex;
    justify-content: space-between;
    align-items: baseline;
    gap: 0.5rem;
    margin-bottom: 0.3rem;
  }
  .mobile-list .item .row-1 .desc {
    font-weight: 500;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    flex: 1 1 auto;
    min-width: 0;
  }
  .mobile-list .item .row-1 .amount {
    font-weight: 700;
    flex-shrink: 0;
    white-space: nowrap;
  }
  .mobile-list .item .row-2 {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 0.4rem;
    font-size: 0.78rem;
    color: #6c757d;
  }
  .mobile-list .item .row-2 .left {
    display: flex;
    gap: 0.4rem;
    flex-wrap: wrap;
    align-items: center;
    min-width: 0;
  }
  .mobile-list .item .actions {
    display: flex;
    gap: 0.3rem;
    flex-shrink: 0;
  }
}

/* Pagination — tap-friendlier */
.pagination .page-link {
  border-radius: 0.4rem;
  margin: 0 0.1rem;
  border: 1px solid #e3e6ec;
}

/* Footer */
footer small {
  color: #94a3b8;
}

/* Container padding — tighter on mobile */
@media (max-width: 575.98px) {
  main.container-fluid {
    padding-left: 0.75rem !important;
    padding-right: 0.75rem !important;
    padding-top: 0.75rem !important;
  }
}

/* Modals — full-width on mobile */
@media (max-width: 575.98px) {
  .modal-dialog:not(.modal-fullscreen) {
    margin: 0.5rem;
  }
}

/* Scroll-to-top floating button */
.scroll-top-btn {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  width: 44px;
  height: 44px;
  border-radius: 50%;
  border: 0;
  background: #0d6efd;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  box-shadow: 0 6px 18px rgba(13, 110, 253, 0.35);
  opacity: 0;
  pointer-events: none;
  transform: translateY(8px);
  transition: opacity 0.18s ease, transform 0.18s ease, background 0.18s ease;
  z-index: 1040;
}

.scroll-top-btn.show {
  opacity: 1;
  pointer-events: auto;
  transform: translateY(0);
}

.scroll-top-btn:hover,
.scroll-top-btn:focus {
  background: #0b5ed7;
  outline: none;
}

@media (max-width: 575.98px) {
  .scroll-top-btn {
    right: 0.75rem;
    bottom: 0.75rem;
    width: 42px;
    height: 42px;
  }
}
