/* =========================
   CHARTS
   ========================= */
#budget-graphs {
  display: flex;
}

#budget-by-category, 
#budget-by-person {
  width: 100%;
  min-width: 100%;
  height: 400px;
}

#budget-by-person {
  display: none;
}

@media (max-width: 768px) {
  #budget-by-category, 
  #budget-by-person {
    height: 500px; /* Taller for horizontal layout */
  }
}

/* =========================
   TABLE CONTAINER
   ========================= */
#budget-table-container {
  overflow: auto;
  margin-top: 1.5rem;
}

/* =========================
   TABLE BASE STYLES
   ========================= */
#budget-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.9rem;
  line-height: 1.4;
}

/* =========================
   TABLE HEADER
   ========================= */
#budget-table thead th {
  position: sticky;
  top: 0;
  background-color: var(--color-primary);
  color: #fff;
  font-weight: 600;
  text-align: left;
  padding: 0.75rem;
  border-bottom: 2px solid var(--color-border);
  z-index: 10;
}

/* =========================
   TABLE BODY
   ========================= */
#budget-table tbody td {
  padding: 0.65rem 0.75rem;
  border-bottom: 1px solid var(--color-border);
  vertical-align: top;
}

/* Zebra striping */
#budget-table tbody tr:nth-child(even) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Hover effect (desktop only) */
@media (hover: hover) {
  #budget-table tbody tr:hover {
    background-color: rgba(0, 0, 0, 0.04);
  }
}

/* =========================
   COLUMN WIDTHS & ALIGNMENT
   ========================= */
/* Date */
#budget-table td:nth-child(1), 
#budget-table th:nth-child(1) {
  width: 10%;
  min-width: 100px;
  white-space: nowrap;
}

/* Category */
#budget-table td:nth-child(2), 
#budget-table th:nth-child(2) {
  width: 10%;
  min-width: 100px;
}

/* Country */
#budget-table td:nth-child(4), 
#budget-table th:nth-child(4) {
  width: 10%;
  min-width: 100px;
}

/* City */
#budget-table td:nth-child(5), 
#budget-table th:nth-child(5) {
  width: 10%;
  min-width: 100px;
}

/* Description */
#budget-table td:nth-child(6), 
#budget-table th:nth-child(6) {
  width: 30%;
  min-width: 200px;
}

/* Price/Night */
#budget-table td:nth-child(7), 
#budget-table th:nth-child(7) {
  width: 10%;
  min-width: 100px;
}

/* Price/Adult */
#budget-table td:nth-child(8), 
#budget-table th:nth-child(8) {
  width: 10%;
  min-width: 100px;
}

/* Price/Child */
#budget-table td:nth-child(9), 
#budget-table th:nth-child(9) {
  width: 10%;
  min-width: 100px;
}

/* Total */
#budget-table td:nth-child(13), 
#budget-table th:nth-child(13) {
  width: 10%;
  min-width: 100px;
}

/* Numeric columns - right align */
#budget-table td:nth-child(7),
#budget-table td:nth-child(8),
#budget-table td:nth-child(9),
#budget-table td:nth-child(10),
#budget-table td:nth-child(11),
#budget-table td:nth-child(12),
#budget-table td:nth-child(13) {
  text-align: right;
  white-space: nowrap;
}

/* =========================
   HIDDEN COLUMNS
   ========================= */
/* Subcategory, Nights, Adults, Children, Participants, Notes */
#budget-table td:nth-child(3), #budget-table th:nth-child(3),
#budget-table td:nth-child(10), #budget-table th:nth-child(10),
#budget-table td:nth-child(11), #budget-table th:nth-child(11),
#budget-table td:nth-child(12), #budget-table th:nth-child(12),
#budget-table td:nth-child(14), #budget-table th:nth-child(14),
#budget-table td:nth-child(15), #budget-table th:nth-child(15) {
  display: none;
}

/* =========================
   CATEGORY BADGES
   ========================= */
#budget-table td:nth-child(2) span {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 12px;
  font-weight: 500;
  font-size: 0.75rem;
  white-space: nowrap;
}

.category-flight {
  background: #e3f2fd;
  color: #1565c0;
}
.category-flight:before {
  content: "✈️ ";
}

.category-train {
  background: #e8f5e9;
  color: #2e7d32;
}
.category-train:before {
  content: "🚆 ";
}

.category-transport {
  background: #fff8e1;
  color: #f57f17;
}
.category-transport:before {
  content: "🚕 ";
}

.category-hotel {
  background: #f3e5f5;
  color: #6a1b9a;
}
.category-hotel:before {
  content: "🏨 ";
}

.category-food {
  background: #fff3e0;
  color: #e65100;
}
.category-food:before {
  content: "🍜 ";
}

.category-activity {
  background: #e0f2f1;
  color: #00695c;
}
.category-activity:before {
  content: "🎟️ ";
}

/* =========================
   TOTAL ROW
   ========================= */
#budget-table td.row-total {
  font-weight: 600;
}

.table-total-row {
  border-top: 2px solid var(--color-border);
  background: rgba(0, 0, 0, 0.04);
}

.table-total-row td {
  padding-top: 0.75rem;
  padding-bottom: 0.75rem;
  font-weight: 600;
}

.table-grand-total {
  text-align: right;
  font-size: 1.05rem;
  font-weight: bold;
}

/* =========================
   MOBILE CARD LAYOUT
   ========================= */
@media (max-width: 768px) {
  #budget-table-container {
    overflow: visible;
  }

  /* Hide traditional table structure */
  #budget-table thead {
    display: none;
  }

  #budget-table,
  #budget-table tbody,
  #budget-table tbody tr,
  #budget-table tbody td {
    display: block;
    width: 100% !important;
  }

  /* Card styling for each row */
  #budget-table tbody tr {
    margin-bottom: 1rem;
    border: 1px solid var(--color-border);
    border-radius: 8px;
    padding: 1rem;
    background: #fff;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
  }

  #budget-table tbody tr:nth-child(even) {
    background: #fff;
  }

  /* Total row styling */
  .table-total-row {
    background: var(--color-primary, #007bff) !important;
    color: #fff;
    border: none;
    padding: 1.25rem 1rem;
    text-align: center;
    font-size: 1.1rem;
  }

  .table-total-row td {
    color: #fff;
  }

  /* Reset cell styles */
  #budget-table tbody td {
    padding: 0.4rem 0;
    border: none;
    text-align: left !important;
    position: relative;
    padding-left: 45%;
  }

  /* Add labels before each cell */
  #budget-table tbody td:before {
    content: attr(data-label);
    position: absolute;
    left: 0;
    width: 42%;
    padding-right: 10px;
    font-weight: 600;
    color: #666;
    text-align: left;
  }

  /* Date */
  #budget-table tbody td:nth-child(1):before {
    display: none;
  }

  /* Category */
  #budget-table tbody td:nth-child(2) {
		float: right;
    text-align: right !important;
  }

  /* Country */
  #budget-table tbody td:nth-child(4):before {
    content: "Country";
  }

  /* City */
  #budget-table tbody td:nth-child(5):before {
    content: "City";
  }

  /* Description */
  #budget-table tbody td:nth-child(6):before {
    content: "Description";
  }

  /* Price/Night */
  #budget-table tbody td:nth-child(7):before {
    content: "Price/Night";
  }

  /* Price/Adult */
  #budget-table tbody td:nth-child(8):before {
    content: "Price/Adult";
  }

  /* Price/Child */
  #budget-table tbody td:nth-child(9):before {
    content: "Price/Child";
  }

  /* Total */
  #budget-table tbody td:nth-child(13):before {
    content: "Total";
  }

  /* Special handling for category badges */
  #budget-table tbody td:nth-child(2) {
    padding-left: 0;
  }

  #budget-table tbody td:nth-child(2):before {
    display: none;
  }

  #budget-table tbody td:nth-child(2) span {
    display: inline-block;
    margin-bottom: 0.5rem;
  }

  /* Hide empty cells on mobile */
  #budget-table tbody td:empty,
  #budget-table tbody td:nth-child(7)[data-price-night="0.00"],
  #budget-table tbody td:nth-child(8)[data-price-adult="0.00"],
  #budget-table tbody td:nth-child(9)[data-price-child="0.00"] {
    display: none;
  }

  /* Highlight total */
  #budget-table tbody td:nth-child(13) {
    margin-top: 0.75rem;
    padding-top: 0.75rem;
    border-top: 1px solid var(--color-border);
    font-size: 1.05rem;
    font-weight: 700;
    color: var(--color-primary, #007bff);
  }

  /* Description gets more space */
  #budget-table tbody td:nth-child(6) {
    padding-left: 0;
    margin-top: 0.5rem;
    margin-bottom: 0.5rem;
    font-weight: 500;
  }

  #budget-table tbody td:nth-child(6):before {
    display: none;
  }

  /* Date and location section */
  #budget-table tbody td:nth-child(1),
  #budget-table tbody td:nth-child(4),
  #budget-table tbody td:nth-child(5) {
    font-size: 0.85rem;
  }

  /* Total row on mobile */
  .table-total-row td:before {
    display: none;
  }

  .table-total-row td {
    padding: 0;
    text-align: center !important;
  }

	/* Collapsed state - show only essential info */
  #budget-table tbody tr.collapsed {
    cursor: pointer;
    transition: all 0.3s ease;
  }

  #budget-table tbody tr.collapsed:active {
    transform: scale(0.98);
  }

  /* Hide detail cells when collapsed */
  #budget-table tbody tr.collapsed td:nth-child(4),  /* Country */
  #budget-table tbody tr.collapsed td:nth-child(5),  /* City */
  #budget-table tbody tr.collapsed td:nth-child(7),  /* Price/Night */
  #budget-table tbody tr.collapsed td:nth-child(8),  /* Price/Adult */
  #budget-table tbody tr.collapsed td:nth-child(9)   /* Price/Child */
  {
    display: none;
  }

  /* Compact collapsed card */
  #budget-table tbody tr.collapsed {
    padding: 0.75rem;
    margin-bottom: 0.5rem;
  }

  /* Add expand indicator */
  #budget-table tbody tr.collapsed:after {
    content: "▼ Tap for details";
    display: block;
    text-align: center;
    margin-top: 0.5rem;
    font-size: 0.75rem;
    color: #999;
    font-weight: 500;
  }

  #budget-table tbody tr.expanded:after {
    content: "▲ Tap to collapse";
    display: block;
    text-align: center;
    margin-top: 0.75rem;
    font-size: 0.75rem;
    color: #999;
    font-weight: 500;
  }

  /* Collapsed - make date, category, description more compact */
  #budget-table tbody tr.collapsed td:nth-child(1) {
    display: inline-block;
		width: 40% !important;
		padding: 0 !important;
		padding-left: 0 !important;
		font-size: 0.8rem;
		color: #666;
		margin-bottom: 0.25rem;
	}

  #budget-table tbody tr.collapsed td:nth-child(1):before {
		display: none;
	}

	#budget-table tbody tr.collapsed td:nth-child(2) {
		display: inline-block;
		width: 40% !important;
		padding: 0 !important;
		padding-left: 0 !important;
		margin-left: 0.5rem;
		margin-bottom: 0.25rem;
	}

	#budget-table tbody tr.collapsed td:nth-child(6) {
		width: 100% !important;
		margin: 0.25rem 0 0.5rem 0;
		padding-top: 0.5rem;
		padding-left: 0 !important;
		font-size: 0.95rem;
	}

	#budget-table tbody tr.collapsed td:nth-child(13) {
		width: 100% !important;
		margin-top: 0.5rem;
		padding-top: 0.5rem;
		padding-left: 0 !important;
		text-align: right !important;
		font-size: 1.1rem;
	}

	#budget-table tbody tr.collapsed td:nth-child(13):before {
		position: relative;
		width: auto;
		display: inline;
		padding-right: 0.5rem;
	}

  /* Expanded state - show all details */
  #budget-table tbody tr.expanded {
    padding: 1rem;
  }

  #budget-table tbody tr.expanded td:nth-child(1) {
    display: inline-block;
		width: 40% !important;
		padding: 0 !important;
		padding-left: 0 !important;
		font-size: 0.8rem;
		color: #666;
		margin-bottom: 0.25rem;
  }

  #budget-table tbody tr.expanded td:nth-child(1):before {
		display: none;
  }

  #budget-table tbody tr.expanded td:nth-child(2) {
    display: inline-block;
		width: 40% !important;
		padding: 0 !important;
		padding-left: 0 !important;
		margin-left: 0.5rem;
		margin-bottom: 0.25rem;
  }
	
	#budget-table tbody tr.expanded td:nth-child(4) {
		padding-top: 1rem !important;
	}
	
	#budget-table tbody tr.expanded td:nth-child(13) {
		width: 100% !important;
		margin-top: 0.5rem;
		padding-top: 0.5rem;
		padding-left: 0 !important;
		text-align: right !important;
		font-size: 1.1rem;
	}

	#budget-table tbody tr.expanded td:nth-child(13):before {
		position: relative;
		width: auto;
		display: inline;
		padding-right: 0.5rem;
	}

  /* Total row - never collapsed */
  .table-total-row {
    cursor: default !important;
  }

  .table-total-row:after {
    display: none !important;
  }
}

/* =========================
   TABLET ADJUSTMENTS
   ========================= */
@media (max-width: 900px) and (min-width: 769px) {
  #budget-table {
    font-size: 0.85rem;
  }

  #budget-table thead th,
  #budget-table tbody td {
    padding: 0.5rem;
  }

  /* Hide price/night and price/child columns on tablet */
  #budget-table td:nth-child(7), 
  #budget-table th:nth-child(7),
  #budget-table td:nth-child(9), 
  #budget-table th:nth-child(9) {
    display: none;
  }
}

/* =========================
   FILTER PANEL
   ========================= */
#filter-panel {
  background: #f8f9fa;
  border: 1px solid var(--color-border);
  border-radius: 8px;
  padding: 1rem;
  margin-bottom: 1rem;
}

.filter-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 0.75rem;
}

.filter-row:last-child {
  margin-bottom: 0;
}

.filter-group {
  display: flex;
  flex-direction: column;
}

.filter-group label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #555;
  margin-bottom: 0.25rem;
}

.filter-group input,
.filter-group select {
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
  background: white;
  transition: border-color 0.2s;
}

.filter-group input:focus,
.filter-group select:focus {
  outline: none;
  border-color: var(--color-primary, #007bff);
}

#reset-filters {
  padding: 0.5rem 1rem;
  background: #6c757d;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  margin-top: auto;
  transition: background 0.2s;
}

#reset-filters:hover {
  background: #5a6268;
}

/* =========================
   TABLE INFO & PAGINATION
   ========================= */
#table-info {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1rem;
  padding: 0.75rem 0;
}

#showing-count {
  font-size: 0.9rem;
  color: #666;
  font-weight: 500;
}

#pagination-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

.pagination-btn {
  padding: 0.4rem 0.75rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 0.85rem;
  transition: all 0.2s;
}

.pagination-btn:hover:not(:disabled) {
  background: var(--color-primary, #007bff);
  color: white;
  border-color: var(--color-primary, #007bff);
}

.pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.pagination-btn.active {
  background: var(--color-primary, #007bff);
  color: white;
  border-color: var(--color-primary, #007bff);
  font-weight: 600;
}

.pagination-info {
  font-size: 0.85rem;
  color: #666;
  margin: 0 0.5rem;
}

#items-per-page {
  padding: 0.4rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.85rem;
}

/* Hidden row styling */
#budget-table tbody tr.filtered-out {
  display: none !important;
}

/* =========================
   MOBILE ADJUSTMENTS
   ========================= */
@media (max-width: 768px) {
  .filter-row {
    grid-template-columns: 1fr;
  }

  #table-info {
    flex-direction: column;
    gap: 1rem;
    align-items: flex-start;
  }

  #pagination-controls {
    flex-wrap: wrap;
  }

  .pagination-btn {
    padding: 0.5rem 0.6rem;
    font-size: 0.8rem;
  }
}

/* =========================
   COLLAPSIBLE FILTER PANEL
   ========================= */
#toggle-filters {
  width: 100%;
  padding: 0.75rem 1rem;
  background: var(--color-primary, #007bff);
  color: white;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-size: 1rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: space-between;
  transition: background 0.2s;
  margin-bottom: 0;
}

#toggle-filters:hover {
  background: #0056b3;
}

.toggle-icon {
  font-size: 0.9rem;
  transition: transform 0.3s ease;
  display: inline-block;
}

#filter-panel.collapsed .toggle-icon {
  transform: rotate(-90deg);
}

#filter-panel.expanded .toggle-icon {
  transform: rotate(0deg);
}

.filter-content {
  max-height: 500px;
  overflow: hidden;
  transition: max-height 0.3s ease, opacity 0.3s ease, padding 0.3s ease;
  opacity: 1;
  padding-top: 1rem;
}

#filter-panel.collapsed .filter-content {
  max-height: 0;
  opacity: 0;
  padding-top: 0;
}

#filter-panel.collapsed {
  padding: 0;
}

#filter-panel.expanded {
  padding: 1rem;
  padding-top: 0;
}

#filter-panel.expanded #toggle-filters {
  margin-bottom: 1rem;
}

/* Date range styling */
.filter-group-date {
  grid-column: span 2; /* Takes up 2 columns for more space */
}

.date-range-inputs {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.date-range-inputs input[type="date"] {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 4px;
  font-size: 0.9rem;
}

.date-separator {
  color: #666;
  font-weight: 500;
  font-size: 0.85rem;
}

@media (max-width: 768px) {
  .filter-group-date {
    grid-column: span 1;
  }
  
  .date-range-inputs {
    flex-direction: column;
    align-items: stretch;
  }
  
  .date-separator {
    text-align: center;
    padding: 0.25rem 0;
  }
}

