:root {
  /* Per design spec */
  --color-white: #FFFFFF;
  --color-cream: #FFF9F5;
  --color-pink: #FFC8C8;
  --color-peach: #FFE4C4;
  --color-navy: #2C3E50;
  --color-gray: #7F8C8D;
  --color-success: #27AE60;
  --color-error: #E74C3C;
  --color-border: #ECF0F1;
}

/* Ensure consistent column widths across all monthly tables */
.month-section table {
  table-layout: fixed;
  width: 100%;
  min-width: 700px;
}

.month-section table th:nth-child(1),
.month-section table td:nth-child(1) {
  width: 10%;
}

.month-section table th:nth-child(2),
.month-section table td:nth-child(2) {
  width: 25%;
}

.month-section table th:nth-child(3),
.month-section table td:nth-child(3) {
  width: 12%;
}

.month-section table th:nth-child(4),
.month-section table td:nth-child(4) {
  width: 13%;
}

.month-section table th:nth-child(5),
.month-section table td:nth-child(5) {
  width: 13%;
}

.month-section table th:nth-child(6),
.month-section table td:nth-child(6) {
  width: 15%;
}

.month-section table th:nth-child(7),
.month-section table td:nth-child(7) {
  width: 12%;
}

/* Prevent text wrapping in tables */
.month-section table th,
.month-section table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* Dashboard table styling */
.dashboard table {
  min-width: 500px;
}

.dashboard table th,
.dashboard table td {
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

body {
  font-family: 'Inter', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
  background-color: var(--color-cream);
  color: var(--color-navy);
}

.sidebar {
  width: 240px;
  min-width: 240px;
  max-width: 240px;
  min-height: 100vh;
  background: var(--color-navy);
  border-right: none;
  position: sticky;
  top: 0;
  color: white;
  flex-shrink: 0;
}

.sidebar-overlay {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.35);
  z-index: 15;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

body.sidebar-open .sidebar-overlay {
  opacity: 1;
  pointer-events: auto;
}

.sidebar .sidebar-brand {
  color: white;
}

.sidebar .nav-link {
  color: rgba(255, 255, 255, 0.85);
  border-radius: 12px;
  padding: 10px 14px;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.sidebar .nav-link.active,
.sidebar .nav-link:hover {
  background-color: var(--color-pink);
  color: var(--color-navy);
}

.sidebar .nav-link i {
  color: inherit;
  width: 1.25rem;
  text-align: center;
  flex-shrink: 0;
}

.sidebar-brand {
  font-size: 1.05rem;
}

.logo-mark {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 12px;
  background: linear-gradient(135deg, var(--color-pink), var(--color-peach));
  color: var(--color-navy);
  font-size: 1.35rem;
}

.logo-mark-lg {
  width: 56px;
  height: 56px;
  font-size: 1.65rem;
  border-radius: 16px;
}

#app-wrapper {
  min-height: 100vh;
}

.app-header {
  background: var(--color-white);
  padding: 20px 0;
  position: sticky;
  top: 0;
  z-index: 12;
  border-bottom: 1px solid rgba(26, 42, 79, 0.08);
}

.header-action-group .btn {
  min-width: 40px;
}

.datetime-display {
  font-size: 0.875rem;
  line-height: 1.3;
  color: var(--color-navy);
  user-select: none;
}

.datetime-display #current-date {
  font-size: 0.8125rem;
}

.datetime-display #current-time {
  font-size: 0.75rem;
}

.app-content {
  background-color: transparent;
}

.app-footer {
  font-size: 0.85rem;
  color: rgba(26, 42, 79, 0.7);
}

.summary-card {
  border-radius: 18px;
  background: linear-gradient(145deg, var(--color-white), var(--color-cream));
  border: 1px solid rgba(26, 42, 79, 0.08);
}

.accent-positive {
  color: var(--color-success);
}

.accent-negative {
  color: var(--color-error);
}

.table thead th {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  color: rgba(26, 42, 79, 0.6);
  border-bottom: none;
}

.table-hover tbody tr:hover {
  background-color: rgba(247, 165, 165, 0.12);
}

.split-details {
  background-color: rgba(255, 219, 182, 0.2);
  border-radius: 12px;
  padding: 12px 16px;
}

.split-row-item {
  border: 1px dashed rgba(26, 42, 79, 0.25);
  border-radius: 12px;
  padding: 12px;
  margin-bottom: 12px;
  background-color: var(--color-white);
}

.drag-handle {
  cursor: grab;
}

.transaction-row.dragging {
  opacity: 0.6;
}

.icon-button {
  background: none;
  border: 1px solid rgba(26, 42, 79, 0.15);
  border-radius: 8px;
  width: 36px;
  height: 36px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  color: var(--color-navy);
}

.icon-only {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  width: 36px;
  height: 36px;
}

.icon-only.btn-sm {
  width: 32px;
  height: 32px;
}

.icon-button:hover {
  background-color: rgba(247, 165, 165, 0.2);
}

.icon-button.text-danger {
  border-color: rgba(197, 48, 48, 0.25);
}

.icon-button.text-danger:hover {
  background-color: rgba(197, 48, 48, 0.1);
}

.badge.bg-accent {
  background-color: var(--color-pink);
  color: var(--color-navy);
}

.modal-content {
  border-radius: 18px;
  border: 1px solid rgba(26, 42, 79, 0.08);
}

/* Ensure modal scrolls on all screen sizes */
.modal-dialog-scrollable {
  max-height: calc(100vh - 3rem);
}

.modal-dialog-scrollable .modal-content {
  max-height: calc(100vh - 3rem);
  overflow: hidden;
}

.modal-dialog-scrollable .modal-body {
  overflow-y: auto;
  max-height: calc(100vh - 200px);
}

/* On small screens, ensure modal is fully scrollable */
@media (max-width: 767.98px) {
  /* Reduce font sizes for mobile */
  body {
    font-size: 14px;
  }

  .table {
    font-size: 13px;
  }

  .table th,
  .table td {
    padding: 0.5rem 0.3rem;
  }

  .month-section table {
    font-size: 12px;
  }

  .btn {
    font-size: 13px;
    padding: 0.375rem 0.5rem;
  }

  .h4, h4 {
    font-size: 1.3rem;
  }

  .h5, h5 {
    font-size: 1.1rem;
  }

  .h6, h6 {
    font-size: 1rem;
  }

  /* Ensure horizontal scrolling works smoothly */
  .table-responsive {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    width: 100%;
  }

  .modal-fullscreen-md-down .modal-body {
    max-height: calc(100vh - 140px);
    overflow-y: auto;
    -webkit-overflow-scrolling: touch;
  }

  .modal-fullscreen-md-down .modal-content {
    height: 100vh;
    display: flex;
    flex-direction: column;
  }

  .modal-fullscreen-md-down .modal-header,
  .modal-fullscreen-md-down .modal-footer {
    flex-shrink: 0;
  }
}

.calculator-grid {
  display: grid;
  grid-template-columns: repeat(4, minmax(0, 1fr));
  gap: 0.5rem;
}

.calculator-grid button {
  border: 1px solid rgba(26, 42, 79, 0.2);
  background-color: var(--color-cream);
  border-radius: 8px;
  padding: 0.75rem;
  font-weight: 600;
  color: var(--color-navy);
}

.calculator-grid button:hover {
  background-color: rgba(247, 165, 165, 0.3);
}

.calculator-grid .span-2 {
  grid-column: span 2;
}

.amount-income {
  color: var(--color-success) !important;
  font-weight: 600;
}

.amount-expense {
  color: var(--color-error) !important;
  font-weight: 600;
}

.amount-transfer {
  color: var(--color-gray) !important;
}

.accent-positive {
  color: var(--color-success);
}

.accent-negative {
  color: var(--color-error);
}

.btn-primary {
  background-color: var(--color-pink);
  border-color: var(--color-pink);
  color: var(--color-navy);
}

.btn-primary:hover,
.btn-primary:focus {
  background-color: #f49393;
  border-color: #f49393;
  color: var(--color-navy);
}

.btn-outline-primary {
  color: var(--color-navy);
  border-color: var(--color-pink);
}

.btn-outline-primary:hover,
.btn-outline-primary:focus {
  background-color: var(--color-pink);
  border-color: var(--color-pink);
  color: var(--color-navy);
}

.btn-outline-secondary {
  color: var(--color-navy);
  border-color: var(--color-border);
}

.btn-outline-secondary:hover,
.btn-outline-secondary:focus {
  background-color: var(--color-cream);
  color: var(--color-navy);
  border-color: var(--color-gray);
}

.btn-checkmark {
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  color: var(--color-navy);
}

.btn-checkmark:hover,
.btn-checkmark:focus {
  background-color: var(--color-cream);
  color: var(--color-navy);
  border-color: var(--color-gray);
}

.btn-dismiss {
  background-color: var(--color-pink);
  border: 1px solid var(--color-pink);
  color: var(--color-navy);
}

.btn-dismiss:hover,
.btn-dismiss:focus {
  background-color: #f49393;
  border-color: #f49393;
  color: var(--color-navy);
}

.btn,
.btn-outline-danger,
.btn-outline-primary,
.btn-outline-secondary {
  border-radius: 10px;
}

.alerts-wrapper .alert {
  border-radius: 12px;
}

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  position: relative;
  background: linear-gradient(135deg, rgba(247, 165, 165, 0.2), rgba(255, 219, 182, 0.2));
}

.login-overlay {
  position: absolute;
  inset: 0;
  background: linear-gradient(135deg, rgba(26, 42, 79, 0.2), rgba(247, 165, 165, 0.2));
  opacity: 0.85;
  pointer-events: none;
}

.login-container {
  position: relative;
  z-index: 2;
  width: min(420px, 92%);
}

.bg-white {
  background-color: var(--color-white) !important;
}

.bg-cream {
  background-color: var(--color-cream);
}

.bg-peach {
  background-color: var(--color-peach);
}

.bg-pink {
  background-color: var(--color-pink);
}

/* Floating Action Button (FAB) */
.fab-button {
  position: fixed;
  bottom: 24px;
  right: 24px;
  width: 56px;
  height: 56px;
  border-radius: 50%;
  background: linear-gradient(135deg, var(--color-pink), var(--color-peach));
  border: none;
  box-shadow: 0 4px 12px rgba(26, 42, 79, 0.2);
  color: var(--color-navy);
  font-size: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.3s ease;
  z-index: 999;
}

.fab-button:hover {
  transform: scale(1.1);
  box-shadow: 0 6px 16px rgba(26, 42, 79, 0.3);
}

.fab-button:active {
  transform: scale(0.95);
}

@media (max-width: 991px) {
  .sidebar {
    position: fixed;
    z-index: 20;
    transform: translateX(-260px);
    transition: transform 0.3s ease;
  }

  body.sidebar-open .sidebar {
    transform: translateX(0);
  }

  .app-header {
    padding: 16px 0;
  }

  main {
    width: 100%;
  }

  .header-action-group {
    gap: 1rem !important;
  }
}

@media (max-width: 575px) {
  .header-action-group .btn {
    min-width: 36px;
  }

  .app-header .container-fluid {
    gap: 1rem;
    flex-wrap: wrap;
  }
}

/* Collapsible Year/Month Sections */
.month-section {
  border-top: 1px solid rgba(26, 42, 79, 0.08);
}

.month-section:first-child {
  border-top: none;
}

.month-header {
  padding: 12px 20px;
  background-color: var(--color-white);
}

.month-header:hover {
  background-color: rgba(247, 165, 165, 0.1);
}

.month-header button {
  color: var(--color-navy);
  font-size: 0.95rem;
}

.month-header button:hover {
  color: var(--color-navy);
}

.collapse-icon {
  transition: transform 0.2s ease;
  font-size: 0.85rem;
}

.btn-link:focus {
  box-shadow: none;
}

.text-navy {
  color: var(--color-navy);
}

/* Icon buttons for actions */
.icon-button {
  background: none;
  border: none;
  color: var(--color-navy);
  padding: 4px 8px;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s ease;
}

.icon-button:hover {
  background-color: rgba(247, 165, 165, 0.2);
}

.icon-button.text-danger:hover {
  background-color: rgba(197, 48, 48, 0.1);
  color: var(--color-error);
}

.split-details-row {
  background-color: var(--color-cream);
}

/* Enhanced table styling */
.table thead th {
  font-size: 0.875rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--color-navy);
  border-bottom: 2px solid rgba(26, 42, 79, 0.1);
}

.table-hover tbody tr:hover {
  background-color: rgba(247, 165, 165, 0.05);
}

/* Calendar Grid */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 4px;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 600;
  color: var(--color-navy);
  padding: 8px 4px;
  text-transform: uppercase;
}

.calendar-day {
  aspect-ratio: 1;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 8px;
  cursor: pointer;
  font-size: 0.875rem;
  color: var(--color-navy);
  background-color: var(--color-white);
  border: 1px solid var(--color-border);
  transition: all 0.2s ease;
}

.calendar-day:hover {
  background-color: rgba(247, 165, 165, 0.2);
  border-color: var(--color-pink);
}

.calendar-day.other-month {
  color: var(--color-gray);
  opacity: 0.4;
}

.calendar-day.today {
  font-weight: 700;
  background-color: var(--color-peach);
  border-color: var(--color-pink);
}

.calendar-day.selected {
  background-color: var(--color-pink);
  color: var(--color-navy);
  font-weight: 700;
  border-color: var(--color-pink);
}

.calendar-day.selected:hover {
  background-color: #f49393;
}

/* Print Styles */
@media print {
  /* Hide non-printable elements */
  .sidebar,
  .app-header,
  .app-footer,
  .fab-button,
  .no-print,
  .btn,
  button,
  .modal,
  .modal-backdrop,
  .collapse-icon,
  .badge,
  nav,
  .sidebar-overlay {
    display: none !important;
  }

  /* Reset page layout */
  body {
    background-color: white !important;
    color: black !important;
    font-size: 10pt;
    margin: 0;
    padding: 0;
  }

  #app-wrapper,
  main,
  .app-content {
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  /* Print header */
  .app-content::before {
    content: "Wells Budget Manager - Transaction Report";
    display: block;
    font-size: 18pt;
    font-weight: bold;
    text-align: center;
    margin-bottom: 20px;
    padding-bottom: 10px;
    border-bottom: 2px solid #2C3E50;
  }

  .app-content::after {
    content: "Printed on " attr(data-print-date);
    display: block;
    font-size: 8pt;
    text-align: right;
    margin-top: 20px;
    color: #666;
  }

  /* Cards and containers */
  .card {
    border: none !important;
    box-shadow: none !important;
    page-break-inside: avoid;
    margin-bottom: 10px !important;
  }

  .card-header {
    background-color: white !important;
    border-bottom: 1px solid #ddd !important;
    padding: 5px 0 !important;
  }

  .card-body {
    padding: 5px 0 !important;
  }

  /* Expand all collapsed sections for printing */
  .collapse {
    display: block !important;
    height: auto !important;
    visibility: visible !important;
  }

  /* Tables */
  .table {
    width: 100% !important;
    font-size: 9pt !important;
    border-collapse: collapse !important;
  }

  .table thead th {
    background-color: #f0f0f0 !important;
    color: black !important;
    border: 1px solid #ddd !important;
    padding: 5px !important;
    font-size: 9pt !important;
  }

  .table tbody td {
    border: 1px solid #ddd !important;
    padding: 4px !important;
    color: black !important;
  }

  .table-hover tbody tr:hover {
    background-color: transparent !important;
  }

  /* Remove background colors */
  .summary-card,
  .month-header,
  .split-details-row {
    background-color: white !important;
  }

  /* Text colors */
  .text-navy,
  .text-muted,
  .text-success,
  .text-danger,
  .amount-income,
  .amount-expense,
  .amount-transfer {
    color: black !important;
  }

  /* Page breaks */
  .year-section,
  .month-section {
    page-break-inside: avoid;
  }

  h1, h2, h3, h4, h5, h6 {
    page-break-after: avoid;
    color: black !important;
  }

  /* Links */
  a {
    color: black !important;
    text-decoration: none !important;
  }

  /* Ensure visibility */
  * {
    -webkit-print-color-adjust: exact !important;
    print-color-adjust: exact !important;
  }
}

/* Inline editing styles */
.editable-cell {
  cursor: pointer;
  position: relative;
  transition: background-color 0.2s ease;
}

.editable-cell:hover:not(.editing) {
  background-color: rgba(13, 110, 253, 0.05);
}

.editable-cell.editing {
  background-color: rgba(13, 110, 253, 0.1);
  cursor: default;
}

.editable-cell .cell-input {
  width: 100%;
}

.editable-cell .cell-input input,
.editable-cell .cell-input select {
  width: 100%;
}

/* Success feedback animation */
.transaction-row.table-success {
  animation: successPulse 1s ease;
}

@keyframes successPulse {
  0%, 100% {
    background-color: transparent;
  }
  50% {
    background-color: rgba(25, 135, 84, 0.2);
  }
}

/* Loading spinner for save button */
.save-transaction-btn .spinner-border {
  width: 1rem;
  height: 1rem;
}

/* Make sure inputs in editable cells don't overflow */
.month-section table th,
.month-section table td {
  white-space: normal;
  overflow: visible;
}

.editable-cell {
  white-space: normal;
  overflow: visible;
}
