/* =========================================
   SHARED COMPONENTS - Enhanced from v50
   ========================================= */

/* CSS Variables for v50 enhancements */
:root {
  --radius: 16px;
  --card-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
  --card-shadow-hover: 0 8px 20px rgba(0, 0, 0, 0.08);
}

/* --- ENHANCED METRIC CARDS --- */
.metric-card::after {
  content: "";
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, var(--primary), #a78bfa);
  opacity: 0;
  transition: opacity 0.3s;
}

.metric-card:hover::after {
  opacity: 1;
}

.metrics-row .metric-card:nth-child(1)::after,
.metrics-row .metric-card:nth-child(2)::after {
  display: none;
}

/* Update existing metric styling */
.metric-val {
  font-size: 2rem !important;
  letter-spacing: -1px;
}

.metric-label {
  font-size: 0.7rem !important;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* --- ENHANCED BUTTONS --- */
.btn-add-main {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.25);
  font-size: 0.95rem;
}

.btn-add-main:hover {
  box-shadow: 0 6px 20px rgba(99, 102, 241, 0.35);
}

.btn-sync {
  box-shadow: var(--card-shadow);
}

/* --- ENHANCED CARDS --- */
.card {
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  border: none;
}

/* --- ENHANCED MODALS --- */
.modal {
  backdrop-filter: blur(5px);
  background: rgba(15, 23, 42, 0.7);
}

.modal-box {
  border-radius: 24px;
  box-shadow: 0 25px 50px -12px rgba(0, 0, 0, 0.25);
  animation: fadeIn 0.2s ease;
}

/* --- ENHANCED BILL TABLE --- */
.bill-table {
  border-spacing: 0 10px;
}

.bill-table tbody tr {
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

.bill-table tbody tr:hover {
  box-shadow: 0 8px 20px rgba(0, 0, 0, 0.06);
}

/* --- ENHANCED STATUS BADGES --- */
.status-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
}

.btn-status-due {
  cursor: pointer;
  border: 1px solid #fecaca;
  background: #fff1f2;
  color: #991b1b;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: var(--transition);
  display: inline-block;
  width: 90px;
  text-align: center;
}

.btn-status-due:hover {
  background: #fecaca;
  transform: scale(1.05);
}

.btn-status-paid {
  cursor: pointer;
  border: 1px solid #a7f3d0;
  background: #ecfdf5;
  color: #065f46;
  padding: 8px 16px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  transition: var(--transition);
  display: inline-block;
  width: 90px;
  text-align: center;
}

.btn-status-paid:hover {
  background: #a7f3d0;
  transform: scale(1.05);
}

/* --- ENHANCED USER PROFILE --- */
.user-profile-box {
  box-shadow: var(--card-shadow);
  border-radius: 50px;
  padding: 6px 14px 6px 6px;
}

.user-profile-box:hover {
  box-shadow: var(--card-shadow-hover);
}

.user-avatar {
  background: linear-gradient(135deg, var(--primary), #a78bfa);
}

.user-dropdown {
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  z-index: 10000;
}

/* --- ENHANCED NAVIGATION --- */
.nav-item.active {
  background: linear-gradient(135deg, var(--primary), #818cf8);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.4);
}

.nav-item {
  position: relative;
}

/* allow tooltip to escape */
.nav-rail {
  overflow: visible;
}
.nav-item {
  position: relative;
  overflow: visible;
}

/* tooltip base */
.nav-item::after {
  content: attr(data-label);
  position: absolute;
  left: calc(100% + 10px);
  top: 50%;
  transform: translateY(-50%);
  background: #0f172a;
  color: #fff;
  font-size: 0.75rem;
  padding: 6px 10px;
  border-radius: 8px;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition:
    opacity 0.15s ease,
    transform 0.15s ease;
  z-index: 9999;
}

/* show ONLY when collapsed (uses your existing .expanded toggle) */
.nav-rail:not(.expanded) .nav-item:hover::after {
  opacity: 1;
  transform: translateY(-50%) translateX(2px);
}

/* never show when expanded */
.nav-rail.expanded .nav-item::after {
  display: none;
}

/* --- CUSTOMER DETAIL PANEL --- */
.detail-side-panel button {
  width: 100%;
  margin-bottom: 10px;
  padding: 10px;
  border: none;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.9rem;
  transition: all 0.2s;
}

.detail-side-panel .btn-call {
  background: #10b981;
  color: white;
}

.detail-side-panel .btn-sms {
  background: #3b82f6;
  color: white;
}

.detail-side-panel .btn-email {
  background: #8b5cf6;
  color: white;
}

.detail-side-panel .btn-note,
.detail-side-panel .btn-task {
  background: #f3f4f6;
  color: #374151;
  border: 1px solid #d1d5db;
}

.detail-side-panel button:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}

.detail-side-panel .side-section {
  margin-top: 20px;
  padding: 16px;
  background: #f9fafb;
  border-radius: 8px;
  border: 1px solid #e5e7eb;
}

.detail-side-panel .side-section h4 {
  margin: 0 0 12px 0;
  font-size: 0.9rem;
  font-weight: 600;
  color: #374151;
}

.detail-side-panel .side-section p {
  margin: 0;
  font-size: 0.85rem;
  color: #6b7280;
}

/* Condense customer list when detail panel is open */
.customer-list-container.condensed {
  max-height: 60vh;
  overflow-y: auto;
}

.customer-list-container.condensed .customer-item {
  padding: 8px 12px;
}

.customer-list-container.condensed .customer-item h4 {
  font-size: 0.9rem;
}

.customer-list-container.condensed .customer-item p {
  font-size: 0.8rem;
}

/* --- TAB PANELS --- */
.customer-tabs {
  display: flex;
  gap: 20px;
  margin-bottom: 25px;
  border-bottom: 2px solid #f1f5f9;
  margin-top: 20px;
}

.tab-panel {
  display: none;
}

.tab-panel.active {
  display: block;
}

/* --- UI PLACEHOLDER --- */
.ui-placeholder {
  opacity: 0.6;
  font-style: italic;
  color: var(--text-muted);
  /* background: #f1f5f9;
  border: 1px dashed #cbd5e1;
  border-radius: 8px;
  min-height: 60px;
  display: flex; 
  align-items: center;
  justify-content: center; */
}

/* =========================================
   CALENDAR COMPONENTS
   ========================================= */

/* --- FULL CALENDAR VIEW --- */
.calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 30px;
  padding: 20px;
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
}

.calendar-controls {
  display: flex;
  gap: 12px;
  align-items: center;
}

.calendar-nav-btn {
  background: white;
  border: 1px solid #e2e8f0;
  padding: 8px 12px;
  border-radius: 8px;
  cursor: pointer;
  transition: var(--transition);
  display: flex;
  align-items: center;
  justify-content: center;
  color: #64748b;
}

.calendar-nav-btn:hover {
  background: #f8fafc;
  border-color: var(--primary);
  color: var(--primary);
}

.calendar-today-btn {
  background: var(--primary);
  color: white;
  border: none;
  padding: 8px 16px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
}

.calendar-today-btn:hover {
  background: #4338ca;
  transform: translateY(-1px);
}

.calendar-view-toggle {
  display: flex;
  gap: 0;
  background: #f1f5f9;
  border-radius: 8px;
  padding: 4px;
}

.calendar-toggle-btn {
  background: transparent;
  border: none;
  padding: 6px 14px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.8rem;
  color: #64748b;
  transition: var(--transition);
}

.calendar-toggle-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
}

.calendar-date-label {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--text-main);
  min-width: 200px;
  text-align: center;
}

.calendar-grid {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 20px;
}

.calendar-day-headers {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 10px;
  margin-bottom: 10px;
}

.calendar-day-header {
  text-align: center;
  font-size: 0.75rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  padding: 10px 0;
}

.calendar-days-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  grid-auto-rows: 1fr;
  gap: 10px;
}

.calendar-day-cell {
  aspect-ratio: 1 / 1;
  border: 1px solid #e2e8f0;
  border-radius: 10px;
  padding: 8px;
  background: white;
  transition: var(--transition);
  cursor: pointer;
}

.calendar-day-cell:hover {
  border-color: var(--primary);
  background: #f8fafc;
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
}

/* --- MINI CALENDAR WIDGET --- */
.mini-calendar-card {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  margin-bottom: 20px;
  border-left: 4px solid var(--primary);
}

.mini-calendar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 15px;
}

.mini-calendar-header h3 {
  margin: 0;
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--text-main);
}

.mini-calendar-toggle {
  display: flex;
  gap: 4px;
  background: #f1f5f9;
  border-radius: 6px;
  padding: 3px;
}

.mini-toggle-btn {
  background: transparent;
  border: none;
  padding: 4px 10px;
  border-radius: 4px;
  cursor: pointer;
  font-weight: 600;
  font-size: 0.7rem;
  color: #64748b;
  transition: var(--transition);
}

.mini-toggle-btn.active {
  background: white;
  color: var(--primary);
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.1);
}

.mini-calendar-events {
  max-height: 200px;
  overflow-y: auto;
  margin-bottom: 15px;
  padding-right: 5px;
}

.mini-calendar-events::-webkit-scrollbar {
  width: 4px;
}

.mini-calendar-events::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.mini-event-item {
  padding: 10px;
  background: #f8fafc;
  border-left: 3px solid var(--primary);
  border-radius: 6px;
  margin-bottom: 8px;
  cursor: pointer;
  transition: var(--transition);
}

.mini-event-item:hover {
  background: #f1f5f9;
  transform: translateX(2px);
}

.mini-event-time {
  font-size: 0.7rem;
  color: #64748b;
  font-weight: 600;
  margin-bottom: 4px;
}

.mini-event-title {
  font-size: 0.85rem;
  color: var(--text-main);
  font-weight: 600;
}

.view-full-calendar-btn {
  width: 100%;
  background: linear-gradient(135deg, var(--primary), #818cf8);
  color: white;
  border: none;
  padding: 10px;
  border-radius: 8px;
  font-weight: 600;
  cursor: pointer;
  transition: var(--transition);
  font-size: 0.85rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
}

.view-full-calendar-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(99, 102, 241, 0.3);
}

/* Responsive calendar grid */
@media (max-width: 1024px) {
  .calendar-days-grid {
    gap: 6px;
  }

  .calendar-day-cell {
    padding: 6px;
    font-size: 0.85rem;
  }
}

/* =========================================
   VIEW-SPECIFIC SCOPING
   ========================================= */

/* --- ACTIVITY / LOGS VIEW --- */
#view-activity {
  /* Scoped styles to prevent cross-view bleed */
}

/* Filters bar consistency */
#view-activity .filters-bar {
  background: white;
  padding: 20px;
  border-radius: var(--radius);
  border: 1px solid #e2e8f0;
  align-items: center;
  margin-bottom: 25px;
}

/* Typography hierarchy */
#view-activity .dash-title {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  margin: 0;
}

/* Table header styling */
#view-activity .bill-table thead th {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding-bottom: 12px;
}

/* Table row spacing and consistency */
#view-activity .bill-table tbody tr {
  background: white;
  border-radius: 12px;
  margin-bottom: 10px;
}

#view-activity .bill-table td {
  padding: 18px 20px;
  font-size: 0.9rem;
  color: var(--text-main);
  vertical-align: middle;
}

/* First and last cell rounding */
#view-activity .bill-table td:first-child {
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
}

#view-activity .bill-table td:last-child {
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* Refined scrollbar for activity log */
#view-activity .card > div {
  scrollbar-width: thin;
  scrollbar-color: #cbd5e1 transparent;
}

#view-activity .card > div::-webkit-scrollbar {
  width: 6px;
}

#view-activity .card > div::-webkit-scrollbar-track {
  background: transparent;
}

#view-activity .card > div::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 10px;
}

#view-activity .card > div::-webkit-scrollbar-thumb:hover {
  background: #94a3b8;
}

/* Icon alignment */
#view-activity .bill-table td i {
  vertical-align: middle;
  margin-right: 6px;
}

/* --- INVENTORY VIEW --- */
#view-inventory {
  /* Scoped styles to prevent cross-view bleed */
}

/* Card consistency with v50 aesthetic */
#view-inventory .card {
  background: white;
  border-radius: var(--radius);
  box-shadow: var(--card-shadow);
  padding: 25px;
}

/* Typography matching dashboard */
#view-inventory h1 {
  font-size: 1.75rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  color: var(--text-main);
}

#view-inventory h4 {
  font-size: 0.95rem;
  font-weight: 700;
  margin-top: 0;
}

/* Table spacing matching billing */
#view-inventory table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0 10px;
  margin-top: 10px;
}

#view-inventory thead th {
  font-size: 0.7rem;
  font-weight: 700;
  color: #94a3b8;
  text-transform: uppercase;
  letter-spacing: 1px;
  padding: 0 20px 12px 20px;
  text-align: left;
}

/* Row styling with enhanced hover */
#view-inventory tbody tr {
  background: white;
  transition: var(--transition);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.03);
}

#view-inventory tbody tr:hover {
  transform: translateY(-2px);
  box-shadow: var(--card-shadow-hover);
}

#view-inventory tbody td {
  padding: 18px 20px;
  font-size: 0.9rem;
  color: var(--text-main);
  vertical-align: middle;
  border-top: 1px solid #f1f5f9;
  border-bottom: 1px solid #f1f5f9;
}

#view-inventory tbody td:first-child {
  border-left: 1px solid #f1f5f9;
  border-top-left-radius: 12px;
  border-bottom-left-radius: 12px;
  font-weight: 600;
}

#view-inventory tbody td:last-child {
  border-right: 1px solid #f1f5f9;
  border-top-right-radius: 12px;
  border-bottom-right-radius: 12px;
}

/* Status badge consistency */
#view-inventory .status-badge {
  padding: 6px 12px;
  border-radius: 20px;
  font-size: 0.7rem;
  font-weight: 800;
  text-transform: uppercase;
  display: inline-block;
}

/* Enhanced status visibility */
#view-inventory .status-badge.status-low {
  background: #fee2e2;
  color: #991b1b;
}

#view-inventory .status-badge.status-ok {
  background: #d1fae5;
  color: #065f46;
}

#view-inventory .status-badge.status-warning {
  background: #fef3c7;
  color: #92400e;
}
