:root {
  --sidebar-bg: #111827;
  --sidebar-accent: rgba(255, 255, 255, 0.05);
  --page-bg: #f8fafc;
  --card-bg: #ffffff;
  --primary-gradient: linear-gradient(135deg, #4f46e5 0%, #7c3aed 100%);
  --accent-color: #4f46e5;
  --text-main: #1e293b;
  --text-muted: #64748b;
  --border-color: #e2e8f0;
}

body {
  background-color: var(--page-bg);
  color: var(--text-main);
  font-family: 'Inter', sans-serif;
  min-height: 100vh;
}

.app-shell {
  min-height: 100vh;
}

@media (min-width: 992px) {
  .app-shell {
    display: grid;
    grid-template-columns: 280px 1fr;
    align-items: start;
  }

  .sidebar {
    position: sticky;
    top: 0;
    height: 100vh;
  }
}

/* Sidebar Styling - Preserving Dark Look */
.sidebar {
  background: var(--sidebar-bg);
  padding: 1.5rem;
  overflow-y: auto;
  color: #fff;
}

.sidebar-brand {
  font-size: 1.5rem;
  font-weight: 800;
  margin-bottom: 2.5rem;
  background: linear-gradient(to right, #fff, #a5b4fc);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.sidebar-logo {
  width: 32px !important;
  height: 32px !important;
  object-fit: contain;
}

.sidebar a {
  color: #94a3b8;
  text-decoration: none;
  padding: 0.75rem 1rem;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 0.25rem;
  transition: all 0.2s ease;
  font-weight: 500;
}

.sidebar a:hover {
  background: var(--sidebar-accent);
  color: #fff;
}

.sidebar a.active {
  background: var(--primary-gradient);
  color: #fff;
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
}

/* Card Styling for Light Background */
.card {
  background: var(--card-bg);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.05), 0 2px 4px -2px rgba(0, 0, 0, 0.05);
  color: var(--text-main);
  transition: box-shadow 0.3s ease;
}

.card:hover {
  box-shadow: 0 10px 15px -3px rgba(0, 0, 0, 0.08);
}

.card-header {
  border-bottom: 1px solid var(--border-color);
  background: transparent;
  font-weight: 700;
  color: var(--text-main);
}

/* Buttons */
.btn {
  border-radius: 10px;
  padding: 0.6rem 1.2rem;
  font-weight: 600;
  transition: all 0.2s ease;
}

.btn-primary {
  background: var(--primary-gradient);
  border: none;
  color: #fff !important;
}

.btn-primary:hover {
  transform: translateY(-1px);
  box-shadow: 0 4px 12px rgba(79, 70, 229, 0.3);
  color: #fff !important;
}

.btn-outline-primary {
  border-color: var(--accent-color) !important;
  color: var(--accent-color) !important;
}

.btn-outline-primary:hover {
  background: var(--primary-gradient);
  border-color: transparent !important;
  color: #fff !important;
}

/* Inputs for Light Background */
.form-control,
.form-select {
  background: #fff !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 8px !important;
  color: var(--text-main) !important;
  padding: 0.6rem 0.9rem;
}

.form-floating>.form-control,
.form-floating>.form-select {
  padding-top: 1.625rem;
  padding-bottom: 0.625rem;
}

.form-control:focus,
.form-select:focus {
  border-color: var(--accent-color) !important;
  box-shadow: 0 0 0 4px rgba(79, 70, 229, 0.1) !important;
  background-color: #fff !important;
}

/* Modals for Light Background */
.modal-content {
  background-color: #fff !important;
  color: var(--text-main) !important;
  border: 1px solid var(--border-color) !important;
  border-radius: 16px !important;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1), 0 10px 10px -5px rgba(0, 0, 0, 0.04) !important;
}

.modal-header {
  border-bottom: 1px solid var(--border-color) !important;
}

.modal-footer {
  border-top: 1px solid var(--border-color) !important;
}

.btn-close {
  filter: none !important;
  /* Ensure close button is visible on white background */
}

/* Tables for Light Background */
.table {
  color: var(--text-main);
}

.table thead th {
  background-color: #f1f5f9 !important;
  color: #475569 !important;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
  font-weight: 700;
  border-bottom: 1px solid var(--border-color) !important;
}

.table-striped>tbody>tr:nth-of-type(odd)>* {
  --bs-table-accent-bg: #f8fafc;
}

.table-hover>tbody>tr:hover>* {
  --bs-table-accent-bg: #f1f5f9;
}

/* Utils */
.text-muted {
  color: var(--text-muted) !important;
}

.text-gradient {
  background: var(--primary-gradient);
  -webkit-background-clip: text;
  background-clip: text;
  -webkit-text-fill-color: transparent;
}

.menu-count {
  background: rgba(79, 70, 229, 0.1);
  border-radius: 6px;
  padding: 0.1rem 0.5rem;
  font-size: 0.7rem;
  font-weight: 700;
  color: var(--accent-color);
}

/* Specific component fixes */
.badge.bg-dark {
  background-color: #1e293b !important;
}

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

/* Contact List Thumbnails */
.contact-thumb {
  width: 32px !important;
  height: 32px !important;
  border-radius: 50% !important;
  object-fit: cover !important;
  border: 1px solid var(--border-color) !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  background-color: #f1f5f9 !important;
}

/* Contact Detail (Zoom) Photos */
.contact-thumb-lg {
  width: 56px !important;
  height: 56px !important;
}

.gallery-photo {
  width: 60px !important;
  height: 60px !important;
  object-fit: cover !important;
  border-radius: 6px !important;
  border: 1px solid var(--border-color) !important;
}

.gallery-item {
  position: relative;
  width: 60px;
  display: inline-block;
}

/* Client Logos */
.client-logo-inline {
  width: 48px !important;
  height: 48px !important;
  object-fit: contain !important;
  border-radius: 8px !important;
  padding: 4px !important;
  background: #f8fafc !important;
  border: 1px solid var(--border-color) !important;
}

/* Additional Button Clarity */
.btn-outline-danger {
  border-color: #ef4444 !important;
  color: #ef4444 !important;
}

.btn-outline-danger:hover {
  background-color: #ef4444 !important;
  color: #fff !important;
}

.btn-outline-secondary {
  border-color: #94a3b8 !important;
  color: #64748b !important;
}

.btn-outline-secondary:hover {
  background-color: #94a3b8 !important;
  color: #fff !important;
}

/* Project Balance specific classes */
.balance-card-positive {
  background: rgba(16, 185, 129, 0.05) !important;
  border: 1px solid rgba(16, 185, 129, 0.1) !important;
}

.balance-card-negative {
  background: rgba(239, 68, 68, 0.05) !important;
  border: 1px solid rgba(239, 68, 68, 0.1) !important;
}

img {
  max-width: 100%;
  height: auto;
}

/* Calendar System */
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  background-color: var(--border-color);
  border: 1px solid var(--border-color);
  border-radius: 12px;
  overflow: hidden;
}

.calendar-header-day {
  background-color: #f1f5f9;
  padding: 1rem;
  text-align: center;
  font-weight: 700;
  font-size: 0.8rem;
  text-transform: uppercase;
  color: var(--text-muted);
}

.calendar-day {
  background-color: #fff;
  min-height: 120px;
  padding: 0.75rem;
  transition: background-color 0.2s ease;
}

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

.calendar-day.not-current-month {
  background-color: #f9fafb;
  color: #d1d5db;
}

.calendar-date-number {
  font-weight: 600;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.calendar-event {
  background: var(--primary-gradient);
  color: #fff;
  padding: 0.4rem 0.6rem;
  border-radius: 6px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-bottom: 4px;
  cursor: pointer;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  box-shadow: 0 2px 4px rgba(79, 70, 229, 0.1);
  transition: transform 0.1s ease;
  display: block;
  text-decoration: none !important;
}

.calendar-event:hover {
  transform: scale(1.02);
  color: #fff;
}

.calendar-event.status-draft {
  background: #94a3b8;
}

.calendar-event.status-planned {
  background: var(--primary-gradient);
}

.calendar-event.status-published {
  background: #10b981;
}

.calendar-nav {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  margin-bottom: 2rem;
}

.calendar-grid-week {
  grid-template-rows: auto 1fr;
}

.calendar-week-date {
  font-size: 0.75rem;
  color: #64748b;
  font-weight: 600;
}

.calendar-today {
  outline: 2px solid rgba(37, 99, 235, 0.3);
  outline-offset: -2px;
}

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

.calendar-year-month {
  border: 1px solid var(--border-color);
  border-radius: 10px;
  background: #fff;
  padding: 0.8rem;
}

.calendar-year-list {
  display: grid;
  gap: 0.4rem;
  max-height: 240px;
  overflow: auto;
}

.calendar-event-date {
  opacity: 0.85;
  font-weight: 700;
  margin-right: 0.3rem;
}

@media (min-width: 992px) {
  .calendar-year-grid {
    grid-template-columns: repeat(3, minmax(0, 1fr));
  }
}
