/* ============================================
   Customer Page Layout Standardization & Optimization
   - Consistent widths across all customer pages (matching leads page)
   - Reduced header/title heights to minimize scrolling
   - Calendar optimizations for full-view display
   ============================================ */

/* ====================================
   1. GLOBAL CONTAINER WIDTH STANDARDIZATION
   ==================================== */

/* Set consistent max-width for all customer page containers */
.container-fluid.px-4,
.app-content-container {
  max-width: 1400px !important;
  width: 100% !important;
  margin: 0 auto !important;
  padding-left: 0.75rem !important;  /* Reduced from 1.5rem for tighter layout */
  padding-right: 0.75rem !important; /* Reduced from 1.5rem for tighter layout */
}

/* ====================================
   2. HEADER & TITLE HEIGHT REDUCTION
   ==================================== */

/* Elegant admin dashboard header with prominent title */
.admin-dashboard-header {
  background: linear-gradient(135deg, rgba(16,185,129,0.1), rgba(16,185,129,0.03)) !important;
  border-radius: 16px !important;
  padding: 1.75rem 1.5rem !important;
  margin-bottom: 1.5rem !important;
  border: 1px solid rgba(16,185,129,0.15) !important;
  height: auto !important; /* Allow natural height for content */
  min-height: auto !important;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.08) !important;
}

.admin-dashboard-title {
  font-family: 'Poppins', 'Inter', sans-serif !important;
  font-weight: 800 !important;
  font-size: 2rem !important; /* Large, elegant title */
  color: #0b1320 !important;
  margin: 0 0 0.5rem 0 !important;
  letter-spacing: -0.02em !important;
  line-height: 1.3 !important;
}

.admin-dashboard-subtitle {
  color: #64748b !important;
  font-size: 0.95rem !important; /* Readable subtitle */
  margin: 0 !important;
  line-height: 1.5 !important;
  font-weight: 400 !important;
}

/* Reduce page title heights */
.page-title,
h1.admin-dashboard-title,
h1.page-title {
  height: auto !important;
  padding: 0 !important;
  margin-top: 0 !important;
  margin-bottom: 0.25rem !important;
}

/* Mobile: Elegant but compact */
@media (max-width: 768px) {
  .admin-dashboard-header {
    padding: 1.25rem 1rem !important;
    margin-bottom: 1rem !important;
  }

  .admin-dashboard-title {
    font-size: 1.5rem !important;
  }

  .admin-dashboard-subtitle {
    font-size: 0.85rem !important;
  }
}

/* ====================================
   3. COMPACT SECTION HEADERS
   ==================================== */

/* Reduce section header spacing */
h2, h3, h4, h5 {
  margin-top: 0.75rem !important;
  margin-bottom: 0.5rem !important;
  line-height: 1.3 !important;
}

/* Specific title box reductions (messaggi, posta, etc.) */
.messages-header,
.posta-header,
.calendar-header,
.leads-header,
.customers-header {
  height: 40px !important;
  padding: 10px 15px !important;
  margin-bottom: 0.75rem !important;
  display: flex !important;
  align-items: center !important;
}

/* ====================================
   4. CALENDAR-SPECIFIC OPTIMIZATIONS
   ==================================== */

/* Calendar Container - Let it size naturally without max-height constraint */
#calendar-container,
.calendar-main-container {
  min-height: 600px !important;
  padding: 0.75rem !important;
  margin-bottom: 0.5rem !important;
}

/* Reduce calendar status bar height */
.calendar-status-bar {
  min-height: 24px !important;
  margin-bottom: 0.75rem !important;
  padding: 0.25rem 0.5rem !important;
}

.calendar-status-pill {
  font-size: 0.625rem !important;
  padding: 0.1875rem 0.375rem !important;
  line-height: 1.2 !important;
}

/* Google Connect Banner - Ultra compact */
.google-connect-banner {
  padding: 0.5rem 0.625rem !important;
  margin-bottom: 0.375rem !important;
}

.google-connect-banner .banner-icon {
  width: 28px !important;
  height: 28px !important;
}

.google-connect-banner .banner-icon i {
  font-size: 0.875rem !important;
}

.google-connect-banner strong {
  font-size: 0.8125rem !important;
  margin-bottom: 0.125rem !important;
}

.google-connect-banner p {
  font-size: 0.6875rem !important;
  line-height: 1.3 !important;
  margin-bottom: 0.375rem !important;
}

.btn-connect-google {
  font-size: 0.75rem !important;
  padding: 0.3125rem 0.875rem !important;
}

/* REMOVE absolute positioning from sync indicator - keep it in normal flow */
#sync-indicator {
  position: static !important;
  top: auto !important;
  right: auto !important;
  z-index: auto !important;
}

/* Ensure calendar fills entire container */
.fc,
.fc-view-harness {
  height: 100% !important;
}

.fc .fc-view-harness {
  flex: 1 !important;
  min-height: 0 !important;
}

/* ====================================
   5. FULLCALENDAR COMPACT OPTIMIZATIONS
   ==================================== */

/* Reduce toolbar height and spacing */
.fc .fc-toolbar {
  padding: 0.375rem 0 !important;
  margin-bottom: 0.5rem !important;
  min-height: auto !important;
}

.fc .fc-toolbar-title {
  font-size: 1.125rem !important;
  line-height: 1.2 !important;
  margin: 0 !important;
}

.fc .fc-button {
  padding: 0.375rem 0.75rem !important;
  font-size: 0.8125rem !important;
  line-height: 1.2 !important;
}

/* Compact column headers */
.fc .fc-col-header-cell {
  padding: 0.375rem 0.25rem !important;
  font-size: 0.8125rem !important;
}

/* Reduce timegrid slot height for day/week views */
.fc .fc-timegrid-slot {
  height: 2em !important;
}

.fc .fc-timegrid-slot-label {
  font-size: 0.6875rem !important;
  padding: 0 0.25rem !important;
}

/* Compact event styling */
.fc .fc-event {
  font-size: 0.75rem !important;
  padding: 2px 4px !important;
  margin: 1px !important;
}

.fc .fc-daygrid-day-number {
  font-size: 0.8125rem !important;
  padding: 0.375rem !important;
}

/* ====================================
   6. MOBILE/RESPONSIVE OPTIMIZATIONS
   ==================================== */

@media (max-width: 767px) {
  /* Ultra-compact headers on mobile */
  .admin-dashboard-header {
    padding: 0.875rem 1rem !important;
    margin-bottom: 0.625rem !important;
  }

  .admin-dashboard-title {
    font-size: 1.25rem !important;
  }

  .admin-dashboard-subtitle {
    font-size: 0.75rem !important;
  }
  
  /* Reduced lateral padding on mobile too */
  .container-fluid.px-4,
  .app-content-container {
    padding-left: 0.5rem !important;  /* Even tighter on mobile */
    padding-right: 0.5rem !important; /* Even tighter on mobile */
  }

  /* Calendar mobile optimizations */
  #calendar-container,
  .calendar-main-container {
    min-height: 500px !important;
    padding: 0.5rem !important;
  }

  /* Even more compact FullCalendar on mobile */
  .fc .fc-toolbar {
    padding: 0.25rem 0 !important;
    margin-bottom: 0.25rem !important;
  }

  .fc .fc-toolbar-title {
    font-size: 0.9375rem !important;
  }

  .fc .fc-button {
    padding: 0.25rem 0.5rem !important;
    font-size: 0.75rem !important;
  }

  .fc .fc-col-header-cell {
    padding: 0.25rem 0.1875rem !important;
    font-size: 0.75rem !important;
  }

  .fc .fc-timegrid-slot {
    height: 1.75rem !important;
  }

  .fc .fc-timegrid-slot-label {
    font-size: 0.625rem !important;
  }

  .fc .fc-event {
    font-size: 0.6875rem !important;
    padding: 0.125rem 0.25rem !important;
  }

  .fc .fc-daygrid-day-number {
    font-size: 0.75rem !important;
  }
}

/* ====================================
   7. DAILY VIEW - FULL WIDTH APPOINTMENTS
   ==================================== */

/* Ensure daily view appointments use full column width */
.fc-timeGridDay-view .fc-timegrid-event,
.fc-timeGridWeek-view .fc-timegrid-event {
  left: 0 !important;
  right: 0 !important;
  width: 100% !important;
  margin-left: 0 !important;
  margin-right: 0 !important;
}

/* Remove padding that creates gaps */
.fc .fc-timegrid-col-events {
  margin: 0 !important;
}

.fc .fc-timegrid-event-harness {
  left: 0 !important;
  right: 0 !important;
}

/* Ensure events don't overlap with axis */
.fc .fc-timegrid-col {
  position: relative !important;
}

/* ====================================
   8. MESSAGES & OTHER CUSTOMER PAGES
   ==================================== */

/* Messages page layout optimization */
.messages-wrap {
  height: calc(100vh - 280px) !important;
  max-height: calc(100vh - 280px) !important;
}

.convo-list {
  height: calc(100vh - 320px) !important;
  max-height: calc(100vh - 320px) !important;
}

.chat-window {
  height: calc(100vh - 320px) !important;
  max-height: calc(100vh - 320px) !important;
}

/* Leads page KPI cards - more compact */
.admin-kpi-card {
  padding: 1rem !important;
}

.admin-kpi-value {
  font-size: 1.75rem !important;
}

/* Chart containers - optimize height */
.admin-chart-card,
.graph-container {
  min-height: 350px !important;
  max-height: 400px !important;
}

.chart-container canvas,
.graph-container canvas {
  max-height: 320px !important;
}

/* ====================================
   9. TABLE OPTIMIZATIONS
   ==================================== */

/* Compact table styling */
.admin-stats-table th,
.admin-stats-table td {
  padding: 0.75rem 0.875rem !important;
}

.admin-stats-table {
  font-size: 0.9rem !important;
}

/* ====================================
   10. UTILITY CLASSES FOR SPACING
   ==================================== */

/* Reduced margin utilities */
.mb-compact {
  margin-bottom: 0.5rem !important;
}

.mt-compact {
  margin-top: 0.5rem !important;
}

.py-compact {
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}

/* No-scroll class for content that should fill viewport */
.no-overflow-scroll {
  overflow: hidden !important;
}

/* Full viewport height container */
.vh-fill {
  height: calc(100vh - 280px) !important;
  min-height: calc(100vh - 280px) !important;
  max-height: calc(100vh - 280px) !important;
}

/* ====================================
   11. PRINT OPTIMIZATION
   ==================================== */

@media print {
  .admin-dashboard-header {
    padding: 0.5rem !important;
    margin-bottom: 0.5rem !important;
  }

  .admin-dashboard-title {
    font-size: 1.25rem !important;
  }

  .calendar-status-bar,
  .google-connect-banner {
    display: none !important;
  }

  #calendar-container {
    min-height: auto !important;
    max-height: none !important;
  }
}

/* ====================================
   12. ACCESSIBILITY - MAINTAIN READABILITY
   ==================================== */

/* Ensure text remains readable despite compact spacing */
body {
  line-height: 1.5 !important;
}

p, li, span {
  line-height: 1.6 !important;
}

/* Focus states for compact elements */
.btn:focus,
.form-control:focus,
.fc-button:focus {
  outline: 2px solid #10b981 !important;
  outline-offset: 2px !important;
}

/* ====================================
   13. SMOOTH TRANSITIONS
   ==================================== */

.admin-dashboard-header,
#calendar-container,
.fc .fc-toolbar,
.messages-wrap,
.admin-kpi-card {
  transition: all 0.3s ease !important;
}

/* ====================================
   14. PAGE LOADER OVERLAY FIX
   ==================================== */

/* Ensure page loader doesn't block interaction when hidden */
#page-loader-overlay {
  pointer-events: none !important;
  z-index: 999 !important;
}

#page-loader-overlay.show {
  pointer-events: auto !important;
  z-index: 2000 !important;
}

/* ====================================
   15. MODAL POPUP FIXES - CRITICAL
   ==================================== */

/* FIX: Remove pointer-events: none from .modal - it blocks all interaction! */
.modal {
  z-index: 1050 !important;
  /* pointer-events removed - was causing modal freeze */
}

.modal.fade {
  z-index: 1050 !important;
}

/* Light backdrop - not too dark */
.modal-backdrop {
  z-index: 1040 !important;
  background-color: rgba(0, 0, 0, 0.3) !important; /* Reduced from 0.5 */
  pointer-events: auto !important;
}

.modal-dialog {
  z-index: 1051 !important; /* Simplified from 1055 */
  pointer-events: auto !important;
}

.modal-content {
  z-index: 1052 !important; /* Simplified from 1060 */
  pointer-events: auto !important;
  background: #ffffff !important;
}

/* Critical: Enable pointer-events when modal is shown */
.modal.show {
  pointer-events: auto !important; /* Allow all clicks */
}

.modal.show .modal-dialog {
  pointer-events: auto !important;
}

.modal.show .modal-content {
  pointer-events: auto !important;
}

/* Ensure all form controls are fully interactive */
.modal input,
.modal textarea,
.modal select,
.modal button,
.modal .btn,
.modal .form-control,
.modal .form-select,
.modal .form-check-input,
.modal .form-check-label {
  pointer-events: auto !important;
  position: relative !important;
}

.modal input:focus,
.modal textarea:focus,
.modal select:focus,
.modal .form-control:focus,
.modal .form-select:focus {
  z-index: auto !important; /* Let browser handle focus */
  outline: auto !important; /* Ensure visible focus */
}

/* Dropdown menus in modals */
.modal .dropdown-menu {
  z-index: 1060 !important;
  pointer-events: auto !important;
}

/* ====================================
   16. MESSAGGI TOGGLE STYLING - COMPACT
   ==================================== */

/* Compact toggle for Messaggi without box styling */
.carla-status-toggle-compact {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0;
  margin: 0;
  white-space: nowrap;
}

.carla-toggle-switch-compact {
  margin: 0;
  padding: 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.carla-toggle-switch-compact .form-check-input {
  width: 2.5rem;
  height: 1.25rem;
  margin: 0;
  cursor: pointer;
}

.carla-toggle-switch-compact .form-check-label {
  margin: 0;
  font-size: 0.875rem;
  font-weight: 500;
  color: #475569;
  cursor: pointer;
  white-space: nowrap;
  padding: 0;
}
