/* ================ GLOBAL VARIABLES ================ */
:root {
  /* Colors (DeepSeek-inspired palette) */
  --clr-dark: #0f172a;
  /* Main dark background */
  --clr-card: #1e293b;
  /* Cards and tables */
  --clr-card-light: #334155;
  /* Lighter tables */
  --clr-border: #475569;
  /* Borders */
  --clr-text: #f8fafc;
  /* White text */
  --clr-text-muted: #94a3b8;
  /* Gray text */

  /* Special colors */
  --clr-primary: #3b82f6;
  /* Primary blue */
  --clr-primary-dark: #2563eb;
  --clr-income: #10b981;
  /* Green for income */
  --clr-income-dark: #059669;
  --clr-expense: #ef4444;
  /* Red for expenses */
  --clr-expense-dark: #dc2626;

  /* Styles */
  --border-radius: 0.5rem;
  --box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --transition: all 0.15s ease-in-out;
}

/* ================ BASE STYLES ================ */
* {
  box-sizing: border-box;
}

body {
  background-color: var(--clr-dark);
  color: var(--clr-text);
  font-family: 'Inter', -apple-system, BlinkMacSystemFont, sans-serif;
  line-height: 1.5;
  min-height: 100dvh;
  margin: 0;
  padding: 0;
  animation: fadeIn 0.4s ease-out;
  /* Smooth transition */
  overflow-wrap: break-word; /* Prevents text overflow */
  word-wrap: break-word;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* ================ TYPOGRAPHY ================ */
h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--clr-text);
  font-weight: 600;
  margin-top: 0;
  margin-bottom: 1rem;
}

h1 {
  font-size: 2rem;
}

h2 {
  font-size: 1.75rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

h5 {
  font-size: 1.125rem;
}

h6 {
  font-size: 1rem;
}

p {
  margin-top: 0;
  margin-bottom: 1rem;
}

/* ================ LAYOUT COMPONENTS ================ */
.container {
  width: 100%;
  max-width: 1200px;
  margin: 0 auto;
  padding: 1.5rem;
}

/* ================ CARDS ================ */
.card {
  background-color: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--border-radius);
  box-shadow: var(--box-shadow);
  margin-bottom: 1.5rem;
  overflow: hidden;
}

.card-header {
  background-color: var(--clr-dark);
  border-bottom: 1px solid var(--clr-border);
  padding: 1rem 1.5rem;
}

.card-body {
  padding: 1.5rem;
}

/* ================ TABLES ================ */
.table {
  width: 100%;
  background-color: var(--clr-card);
  color: var(--clr-text);
  border-collapse: collapse;
  margin-bottom: 1rem;
}

.table th {
  background-color: var(--clr-dark);
  color: var(--clr-text);
  padding: 0.75rem 1rem;
  text-align: left;
  font-weight: 600;
  border-bottom: 2px solid var(--clr-border);
}

.table td {
  padding: 0.75rem 1rem;
  border-top: 1px solid var(--clr-border);
  vertical-align: middle;
}

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

/* ================ TABS ================ */
.nav-tabs {
  border-bottom: 1px solid var(--clr-border);
}

.nav-tabs .nav-link {
  color: var(--clr-text);
  background-color: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-bottom: none;
  border-top-left-radius: var(--border-radius);
  border-top-right-radius: var(--border-radius);
  padding: 0.75rem 1.25rem;
  margin-right: 0.25rem;
  transition: var(--transition);
}

.nav-tabs .nav-link:hover {
  background-color: var(--clr-card-light);
  border-color: var(--clr-border) var(--clr-border) transparent;
}

.nav-tabs .nav-link.active {
  color: var(--clr-text);
  background-color: var(--clr-dark);
  border-color: var(--clr-border) var(--clr-border) var(--clr-dark);
}

.tab-content {
  background-color: var(--clr-dark);
  border: 1px solid var(--clr-border);
  border-top: none;
  padding: 1.5rem;
  border-bottom-left-radius: var(--border-radius);
  border-bottom-right-radius: var(--border-radius);
}

/* ================ FORMS ================ */
.form-control,
.form-select {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background-color: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--border-radius);
  color: var(--clr-text);
  font-size: 1rem;
  line-height: 1.5;
  transition: var(--transition);
}

.form-control:focus,
.form-select:focus {
  outline: none;
  border-color: var(--clr-primary);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.25);
}

.form-label {
  display: block;
  margin-bottom: 0.5rem;
  color: var(--clr-text);
  font-weight: 500;
}

/* ================ BUTTONS ================ */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-weight: 500;
  padding: 0.5rem 1rem;
  border-radius: var(--border-radius);
  transition: var(--transition);
  cursor: pointer;
  border: 1px solid transparent;
  font-size: 0.875rem;
  line-height: 1.25rem;
}

.btn-primary {
  background-color: var(--clr-primary);
  color: white;
}

.btn-primary:hover {
  background-color: var(--clr-primary-dark);
}

.btn-outline-primary {
  background-color: transparent;
  border-color: var(--clr-primary);
  color: var(--clr-primary);
}

.btn-outline-primary:hover {
  background-color: var(--clr-primary);
  color: white;
}

.btn-success {
  background-color: var(--clr-income);
  color: white;
}

.btn-success:hover {
  background-color: var(--clr-income-dark);
}

.btn-danger {
  background-color: var(--clr-expense);
  color: white;
}

.btn-danger:hover {
  background-color: var(--clr-expense-dark);
}

/* ================ SPECIAL COMPONENTS ================ */
/* Summary Cards */
.summary-card {
  background-color: var(--clr-card);
  border: 1px solid var(--clr-border);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  margin-bottom: 1.5rem;
  text-align: center;
}

.summary-card h5 {
  color: var(--clr-text-muted);
  font-size: 1rem;
  margin-bottom: 0.5rem;
}

.summary-card h3 {
  font-size: 1.75rem;
  font-weight: 700;
  margin-bottom: 0;
}

/* Index Page Buttons */
.btn-hover {
  position: relative;
  overflow: hidden;
  padding: 1.5rem;
  border: none;
  border-radius: var(--border-radius);
  color: var(--clr-text);
  font-weight: 600;
  font-size: 1.1rem;
  text-align: center;
  cursor: pointer;
  transition: var(--transition);
  box-shadow: var(--box-shadow);
  background-color: var(--clr-card);
}

.btn-hover:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

.btn-number {
  display: block;
  font-size: 1.5rem;
  margin-bottom: 0.5rem;
}

.category-title {
  font-weight: 700;
  color: var(--clr-primary);
  text-transform: uppercase;
  letter-spacing: 1px;
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
  display: flex;
  align-items: center;
  gap: 10px;
}

.category-title::after {
  content: "";
  flex: 1;
  height: 1px;
  background: linear-gradient(to right, var(--clr-border), transparent);
}

.dashboard-card {
  background: linear-gradient(145deg, var(--clr-card), #16213e);
  border: 1px solid var(--clr-border);
  border-radius: var(--border-radius);
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  padding: 1.25rem;
  text-decoration: none;
  color: var(--clr-text);
}

.dashboard-card:hover {
  transform: translateY(-5px);
  background: linear-gradient(145deg, #2a3a52, #1e293b);
  border-color: var(--clr-primary);
  color: var(--clr-text);
  box-shadow: 0 10px 20px rgba(0, 0, 0, 0.3);
}

.dashboard-card i {
  font-size: 2.5rem;
  margin-bottom: 0.75rem;
  transition: transform 0.3s ease;
}

.dashboard-card:hover i {
  transform: scale(1.1);
}

.dashboard-card span {
  font-weight: 600;
  font-size: 0.95rem;
}

/* ================ UTILITY CLASSES ================ */
.text-primary {
  color: var(--clr-primary) !important;
}

.text-success {
  color: var(--clr-income) !important;
}

.text-danger {
  color: var(--clr-expense) !important;
}

.text-muted {
  color: var(--clr-text-muted) !important;
}

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

/* ================ RESPONSIVE ADJUSTMENTS & MOBILE APP STYLES ================ */
@media (max-width: 768px) {
  .container {
    padding: 1rem;
    padding-bottom: 80px;
    /* Space for bottom nav */
  }

  .btn-hover {
    padding: 1rem;
    font-size: 1rem;
  }

  /* Mobile Dashboard Grid (2 columns, elegant icons) */
  .category-title {
    font-size: 1.1rem;
    margin-bottom: 12px;
  }

  .dashboard-card {
    padding: 15px 10px;
    min-height: 110px;
    border-radius: 14px;
  }

  .dashboard-card i {
    font-size: 2rem;
    margin-bottom: 8px;
  }

  .dashboard-card span {
    font-size: 0.85rem;
  }

  /* --- Mobile Stacked Cards (Takes place of Tables) --- */
  .mobile-table-card table,
  .mobile-table-card thead,
  .mobile-table-card tbody,
  .mobile-table-card th,
  .mobile-table-card td,
  .mobile-table-card tr {
    display: block;
    width: 100%;
  }

  /* Hide table headers on mobile */
  .mobile-table-card thead tr {
    position: absolute;
    top: -9999px;
    left: -9999px;
  }

  /* Form style rows */
  .mobile-table-card tbody tr {
    background-color: var(--clr-card);
    border: 1px solid var(--clr-border);
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    padding: 10px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    position: relative;
  }

  /* Create faux columns using data-label */
  .mobile-table-card td {
    padding: 10px 10px 10px 45%;
    border-bottom: 1px solid rgba(255, 255, 255, 0.05);
    text-align: right;
    /* Values pushed right */
    position: relative;
    border-top: none;
    font-size: 0.95rem;
    min-height: 40px;
    word-break: break-word; /* Fix for long overlapping text */
    overflow-wrap: break-word;
  }

  .mobile-table-card td:last-child {
    border-bottom: 0;
  }

  .mobile-table-card td::before {
    content: attr(data-label);
    position: absolute;
    left: 10px;
    top: 10px;
    width: 40%;
    white-space: normal; /* Fix for long labels */
    word-break: break-word;
    text-align: left;
    font-weight: 600;
    color: var(--clr-text-muted);
    font-size: 0.85rem;
    text-transform: uppercase;
  }

  /* Center actions on mobile */
  .mobile-table-card td.text-end {
    text-align: center !important;
    display: flex;
    justify-content: center;
    gap: 10px;
    padding: 15px 10px !important; /* Override 45% left padding */
  }

  .mobile-table-card td.text-end::before {
    display: none;
    /* Hide label for actions */
  }

  /* Ensure header flex containers wrap on mobile so buttons don't go off-screen */
  .d-flex.align-items-center.gap-3 {
    flex-wrap: wrap !important;
    justify-content: center;
  }
  
  .card-body > .d-flex {
    justify-content: center !important;
  }

  /* Prevent buttons from overflowing and allow text to wrap */
  .btn {
    white-space: normal !important;
    word-break: break-word;
    height: auto;
  }
  
  .dropdown-menu {
    max-width: 100vw;
    white-space: normal;
  }
  
  .dropdown-item {
    white-space: normal;
    word-break: break-word;
  }
}

/* ================ FLOATING ACTION BUTTON (FAB) ================ */
.fab-container {
  position: fixed;
  bottom: 80px;
  /* Above mobile bottom nav */
  right: 20px;
  z-index: 999;
}

@media (min-width: 769px) {
  .fab-container {
    bottom: 30px;
    right: 30px;
  }
}

.fab-button {
  width: 60px;
  height: 60px;
  background-color: var(--clr-primary);
  border-radius: 50%;
  color: white;
  font-size: 28px;
  display: flex;
  justify-content: center;
  align-items: center;
  box-shadow: 0 4px 15px rgba(59, 130, 246, 0.5);
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

.fab-button:hover,
.fab-button:active {
  background-color: var(--clr-primary-dark);
  transform: scale(1.05) rotate(90deg);
  color: white;
}

.fab-menu {
  position: absolute;
  bottom: 70px;
  right: 0;
  display: flex;
  flex-direction: column-reverse;
  /* items pop up */
  gap: 10px;
  opacity: 0;
  visibility: hidden;
  transform: translateY(20px);
  transition: all 0.3s ease;
}

.fab-menu.show {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.fab-menu-item {
  background-color: var(--clr-card);
  border: 1px solid var(--clr-border);
  color: var(--clr-text);
  padding: 10px 15px;
  border-radius: 20px;
  white-space: nowrap;
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
  box-shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
  font-weight: 500;
}

.fab-menu-item:hover {
  background-color: var(--clr-card-light);
  color: white;
}

/* ================ BOTTOM NAVIGATION (Mobile Only) ================ */
.bottom-nav {
  display: none;
}

@media (max-width: 768px) {
  .bottom-nav {
    display: flex;
    justify-content: space-around;
    align-items: center;
    background-color: rgba(15, 23, 42, 0.85);
    /* Darker blur */
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    position: fixed;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 65px;
    border-top: 1px solid rgba(255, 255, 255, 0.05);
    z-index: 1000;
    padding-bottom: env(safe-area-inset-bottom);
  }

  .bottom-nav-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    color: var(--clr-text-muted);
    text-decoration: none;
    flex: 1;
    transition: color 0.2s, transform 0.1s;
    font-size: 0.70rem;
    gap: 3px;
    height: 100%;
  }

  .bottom-nav-item i {
    font-size: 1.35rem;
    margin-bottom: 2px;
  }

  .bottom-nav-item.active {
    color: var(--clr-primary);
    font-weight: 600;
  }

  .bottom-nav-item:active {
    transform: scale(0.92);
  }
}

/* ================ DATEPICKER ADJUSTMENTS ================ */
.ui-datepicker {
  background: #1a1a2e;
  border: 1px solid #16213e;
  border-radius: 15px;
  padding: 20px;
  box-shadow: 0 8px 30px rgba(0, 0, 0, 0.6);
  color: #fff;
  font-family: 'Poppins', sans-serif;
  width: auto;
}

.ui-datepicker-header {
  background: #0f3460;
  color: #fff;
  border-radius: 10px 10px 0 0;
  padding: 10px;
  position: relative;
}

.ui-datepicker-title {
  text-align: center;
  font-weight: bold;
  font-size: 1.2em;
}

.ui-datepicker-prev,
.ui-datepicker-next {
  cursor: pointer;
  top: 50%;
  transform: translateY(-50%);
}

.ui-datepicker-prev {
  left: 10px;
  position: absolute;
}

.ui-datepicker-next {
  right: 10px;
  position: absolute;
}

.ui-datepicker th {
  padding: 5px;
  color: #bbb;
}

.ui-datepicker-calendar td a {
  display: inline-flex;
  width: 2.5em;
  height: 2.5em;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  background: #16213e;
  color: #fff;
  transition: 0.3s;
  font-weight: 600;
}

.ui-datepicker-calendar td a:hover {
  background: #e94560;
  color: white;
}

.ui-datepicker-today a {
  background: #0f3460;
  color: white;
}

.ui-datepicker-current-day a {
  background: #e94560;
  color: white;
}

/* ================ MISCELLANEOUS ================ */
.title-container {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
}

.title-container img {
  height: 50px;
}

.wrench-icon {
  font-size: 1.5rem;
  color: #ffcc00;
}

.action-buttons .btn {
  margin-right: 5px;
}

.alert {
  margin-top: 10px;
}

/* ================ DASHBOARD STYLES ================ */
.category-title {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--clr-text-muted);
  text-transform: uppercase;
  letter-spacing: 1.5px;
  margin-bottom: 20px;
  padding-bottom: 10px;
  border-bottom: 2px solid var(--clr-border);
  display: flex;
  align-items: center;
  gap: 10px;
}

.dashboard-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 25px 15px;
  background: linear-gradient(145deg, #1e293b, #0f172a);
  border: 1px solid #334155;
  border-radius: 16px;
  text-decoration: none !important;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  height: 100%;
  min-height: 140px;
  text-align: center;
  position: relative;
  overflow: hidden;
}

.dashboard-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: radial-gradient(circle at 50% 0%, rgba(59, 130, 246, 0.1), transparent 70%);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.dashboard-card:hover {
  transform: translateY(-8px);
  border-color: var(--clr-primary);
  box-shadow: 0 10px 25px -5px rgba(0, 0, 0, 0.3), 0 8px 10px -6px rgba(0, 0, 0, 0.3);
}

.dashboard-card:active {
  transform: scale(0.96);
  /* Touch feedback */
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.2);
}

.dashboard-card:hover::before {
  opacity: 1;
}

.dashboard-card i {
  font-size: 2.5rem;
  margin-bottom: 12px;
  transition: transform 0.3s ease;
}

.dashboard-card:hover i {
  transform: scale(1.1);
}

.dashboard-card span {
  font-size: 0.95rem;
  font-weight: 600;
  color: var(--clr-text);
  transition: color 0.3s ease;
}

.dashboard-card:hover span {
  color: var(--clr-primary);
}

/* ================ UTILITIES ================ */
.fw-600 {
  font-weight: 600;
}

.ls-1 {
  letter-spacing: 1px;
}

.transition {
  transition: all 0.2s ease;
}

/* Force equal height for all stat-cards across the app */
.stat-card {
  height: 100% !important;
  display: flex !important;
  flex-direction: column !important;
  justify-content: center !important;
}