/*
 * Custom Styles for Finance Tracker
 * Bootstrap is now loaded via CDN in the application layout
 */

/* Custom styles can be added here to override Bootstrap defaults */

/* Hide number-input up/down spinners app-wide (they aren't useful here) */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Navigation */
.navbar-brand {
  font-weight: 600;
}

/* Nav dropdowns: open on hover (desktop) and via the .show class (JS click /
   mobile). Position the menu ourselves since Bootstrap's positioning only
   applies once its JS runs. */
.navbar-nav .dropdown-menu {
  position: absolute;
  top: 100%;
  margin-top: 0;
}

@media (min-width: 992px) {
  .navbar-nav .dropdown:hover > .dropdown-menu {
    display: block;
  }

  .navbar-nav .dropdown-menu-end,
  .navbar-nav .dropdown-menu-lg-end {
    right: 0;
    left: auto;
  }
}

/* Cards */
.card {
  box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
  border: 1px solid rgba(0, 0, 0, 0.1);
}

/* Tables */
.table th {
  border-top: none;
  font-weight: 700;
  background-color: #e9ecef;
  color: #495057;
  font-size: 0.875rem;
  padding: 1rem 0.75rem;
  border-bottom: 2px solid #dee2e6;
  position: sticky;
  top: 0;
  z-index: 10;
}

.table-responsive {
  border-radius: 0.375rem;
}

/* Amount styling */
.text-success {
  color: #198754 !important;
}

.text-danger {
  color: #dc3545 !important;
}

/* Form improvements */
.form-label {
  font-weight: 500;
  margin-bottom: 0.5rem;
}

.form-control:focus,
.form-select:focus {
  border-color: #86b7fe;
  box-shadow: 0 0 0 0.25rem rgba(13, 110, 253, 0.25);
}

/* Button improvements */
.btn {
  font-weight: 500;
}

/* Alert improvements */
.alert {
  border: none;
  border-radius: 0.5rem;
}

/* Badge improvements */
.badge {
  font-weight: 500;
}

/* Dashboard cards */
.card.bg-primary .card-title,
.card.bg-success .card-title,
.card.bg-warning .card-title,
.card.bg-info .card-title {
  font-weight: 600;
  opacity: 0.9;
}

.card.bg-primary .card-text,
.card.bg-success .card-text,
.card.bg-warning .card-text,
.card.bg-info .card-text {
  font-size: 1.5rem;
  font-weight: 700;
}

/* Empty state styling */
.display-1 {
  font-size: 4rem;
  opacity: 0.3;
}

/* Responsive improvements */
@media (max-width: 768px) {
  .container-fluid {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .card.bg-primary .card-text,
  .card.bg-success .card-text,
  .card.bg-warning .card-text,
  .card.bg-info .card-text {
    font-size: 1.25rem;
  }
  
  .btn-group-sm .btn {
    padding: 0.25rem 0.5rem;
    font-size: 0.75rem;
  }
}

/* Mixed btn-groups (link_to anchors beside button_to forms): the anchor gets
   stretched to the form's height and its icon rides high — center everything */
.btn-group > .btn,
.btn-group form > .btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

/* Flush-table cards: a .card-flush table meets the card's edges, and its
   first column aligns with the card header's own left padding */
.card .card-flush table {
  margin-bottom: 0;
}
.card .card-flush table th:first-child,
.card .card-flush table td:first-child {
  padding-left: 1rem;
}
.card .card-flush table th:last-child,
.card .card-flush table td:last-child {
  padding-right: 1rem;
}

/* Budget vs Actual: compact enough for six-digit money in five numeric
   columns — smaller type, tight cells, numbers never wrap (names may) */
#ytd-budget table {
  font-size: 0.85rem;
}
#ytd-budget table th,
#ytd-budget table td {
  padding: 0.3rem 0.4rem;
}
#ytd-budget table .text-end {
  white-space: nowrap;
  font-variant-numeric: tabular-nums;
}
/* The compact cell padding above outweighs the .card-flush alignment rule
   (id vs classes), so restate the shared gutter here */
#ytd-budget .card-flush table th:first-child,
#ytd-budget .card-flush table td:first-child {
  padding-left: 1rem;
}
#ytd-budget .card-flush table th:last-child,
#ytd-budget .card-flush table td:last-child {
  padding-right: 1rem;
}

/* The plan options card: one uniform (small) type size — checkbox labels,
   field labels, and the little group labels were three different sizes */
#plan-options .card-body {
  font-size: 0.875rem;
}
#plan-options .small,
#plan-options small {
  font-size: 1em;
}

/* Center the checkboxes against the taller buttons beside them: kill the
   form-check's float/min-height/margins tuned for full-size stacked forms */
#plan-options .form-check {
  display: flex;
  align-items: center;
  gap: 0.375rem;
  margin-bottom: 0;
  min-height: 0;
  padding-left: 0;
}
#plan-options .form-check-input {
  float: none;
  margin: 0;
}

/* The property details card: every field label at the same (small) size the
   expense-line labels use */
#real-estate-fields .form-label {
  font-size: 0.875em;
  margin-bottom: 0.25rem;
}

/* Loading states and hover effects */
.btn:hover {
  transform: translateY(-1px);
  transition: transform 0.2s ease;
}

.table tbody tr:hover {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Custom utilities */
.text-truncate-30 {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  max-width: 30ch;
}

/* Icon improvements */
.bi {
  vertical-align: -0.125em;
}

/* Sortable table headers */
.sortable-header {
  color: #495057 !important;
  cursor: pointer;
  user-select: none;
  font-weight: 700;
  font-size: 0.875rem;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.375rem;
  text-decoration: none;
}

.sortable-header:hover {
  color: #212529 !important;
  background-color: rgba(0, 0, 0, 0.08);
  transform: translateY(-1px);
}

.sortable-header.active-sort {
  color: #212529 !important;
  background-color: rgba(0, 0, 0, 0.12);
  font-weight: 800;
}

.sortable-header.active-sort:hover {
  background-color: rgba(0, 0, 0, 0.15);
}

/* Table header improvements for sortable columns */
th .sortable-header {
  margin: -1rem -0.75rem;
  padding: 1rem 0.75rem;
  width: calc(100% + 1.5rem);
  justify-content: space-between;
  border-radius: 0;
}

th.text-end .sortable-header {
  justify-content: flex-end;
}

/* Sort indicators styling */
.sortable-header::after {
  font-size: 1rem;
  opacity: 0.7;
}

.sortable-header:hover::after {
  opacity: 1;
}

.sortable-header.active-sort::after {
  opacity: 1;
  font-weight: bold;
}
