/* ====================================
   CENTRALIZED COLOR SYSTEM
   ==================================== */
:root {
  /* Primary Colors (Blue) */
  --color-primary: #2563eb;
  --color-primary-light: #3b82f6;
  --color-primary-dark: #1d4ed8;
  --color-primary-50: #eff6ff;
  --color-primary-100: #dbeafe;
  --color-primary-200: #bfdbfe;

  /* Success Colors (Green) */
  --color-success: #059669;
  --color-success-light: #10b981;
  --color-success-dark: #047857;
  --color-success-50: #ecfdf5;
  --color-success-100: #d1fae5;

  /* Danger Colors (Red) */
  --color-danger: #dc2626;
  --color-danger-light: #ef4444;
  --color-danger-dark: #b91c1c;
  --color-danger-50: #fef2f2;
  --color-danger-100: #fee2e2;

  /* Warning Colors (Orange/Yellow) */
  --color-warning: #f59e0b;
  --color-warning-light: #fbbf24;
  --color-warning-dark: #d97706;
  --color-warning-50: #fffbeb;
  --color-warning-100: #fef3c7;

  /* Premium/Upgrade Colors (Sophisticated Orange/Amber) */
  --color-premium: #f97316;
  --color-premium-light: #fb923c;
  --color-premium-dark: #ea580c;
  --color-premium-50: #fff7ed;
  --color-premium-100: #ffedd5;

  /* Text Colors */
  --color-text-primary: #1f2937;
  --color-text-secondary: #4b5563;
  --color-text-muted: #6b7280;
  --color-text-light: #9ca3af;

  /* Background Colors */
  --color-background: #ffffff;
  --color-background-alt: #f8fafc;
  --color-background-hover: #f3f4f6;
  --color-background-disabled: #f9fafb;

  /* Border Colors */
  --color-border: #e5e7eb;
  --color-border-light: #f3f4f6;
  --color-border-dark: #d1d5db;

  /* Apple-like Panel Defaults */
  --panel-bg: linear-gradient(120deg, #f8fafc 0%, #f1f5f9 100%);
  --panel-radius: 18px;
  --panel-shadow: 0 8px 32px 0 rgba(60, 60, 60, 0.10), 0 1.5px 6px 0 rgba(60, 60, 60, 0.08);
  --panel-header-bg: rgba(255, 255, 255, 0.85);
  --panel-header-shadow: 0 2px 8px 0 rgba(180, 180, 180, 0.03);
  --panel-font: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  --panel-width: 430px;

  /* Status Colors */
  --status-for-sale: #10b981;
  --status-under-contract: #f59e0b;
  --status-sold: #ef4444;
  --status-removed: #ef4444;
  --status-default: #9e9e9e;

  /* Spacing */
  /* --spacing-xs: 4px; */
  --spacing-sm: 8px;
  --spacing-md: 16px;
  --spacing-lg: 24px;
  --spacing-xl: 32px;

  /* Border Radius */
  --radius-sm: 4px;
  --radius-md: 8px;
  --radius-lg: 12px;

  /* Shadows */
  --shadow-sm: 0 1px 2px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

/* Apple-like panel base styles */
.panel {
  background: var(--panel-bg);
  border-radius: var(--panel-radius);
  box-shadow: var(--panel-shadow);
  font-family: var(--panel-font);
  color: var(--color-text-primary);
  overflow: hidden;
}

.panel-header {
  background: var(--panel-header-bg);
}

/* Unified Apple-like button base */
.panel-btn,
.btn-action,
.admin-edit-btn,
.modal-actions button,
.settings-container .action-buttons button,
.tab-button,
.select-controls button {
  background: linear-gradient(90deg, #f4f7fa 0%, #e8eef4 100%);
  border: 1.5px solid #dde6ef;
  color: #222;
  font-family: var(--panel-font);
  font-size: 15px;
  font-weight: 500;
  padding: 7px 18px;
  border-radius: 8px;
  box-shadow: 0 1px 2px 0 rgba(200, 200, 200, 0.05);
  cursor: pointer;
  outline: none;
  transition: background 0.2s, border 0.2s, box-shadow 0.2s, color 0.2s;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.panel-btn:hover,
.select-controls button:hover {
  background: #e8eef4;
  border-color: #b6c6da;
  color: #222;
}

.panel-btn:disabled,
.panel-btn[disabled],
.btn-action:disabled,
.btn-action[disabled],
.settings-container .action-buttons button:disabled,
.settings-container .action-buttons button[disabled] {
  background: #f8f9fa !important;
  border-color: #e9ecef !important;
  color: #6c757d !important;
  cursor: not-allowed !important;
  opacity: 0.6 !important;
}

.panel-btn:disabled:hover,
.panel-btn[disabled]:hover,
.btn-action:disabled:hover,
.btn-action[disabled]:hover,
.settings-container .action-buttons button:disabled:hover,
.settings-container .action-buttons button[disabled]:hover {
  background: #f8f9fa !important;
  border-color: #e9ecef !important;
  color: #6c757d !important;
  transform: none !important;
}

.apple-input {
  font-family: var(--panel-font);
  background: #f4f8fb;
  border: 1.5px solid #dde6ef;
  color: #222;
  border-radius: 8px;
  box-shadow: 0 1.5px 4px 0 rgba(200, 200, 200, 0.04);
  transition: border 0.2s, box-shadow 0.2s;
  padding: 7px 10px;
  font-size: 15px;
}

.apple-input:focus {
  border-color: #007aff;
  box-shadow: 0 0 0 2px #b6e0fe;
}


/* Settings Panel Styles */
:root {
  --accent-color: #0071e3;
  --background-color: #f5f5f7;
  --text-color: #1d1d1f;
  --secondary-text: #86868b;
  --card-background: #ffffff;
  --card-shadow: 0 4px 16px rgba(0, 0, 0, 0.08);
  --card-hover-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  /* Legacy Variables (for compatibility) */
  --danger-color: var(--color-danger);
  --danger-color-dark: var(--color-danger-dark);
  --danger-color-light: var(--color-danger-light);
  --success-color: var(--color-success);
  --success-color-dark: var(--color-success-dark);
  --success-color-light: var(--color-success-light);
  --primary-color: var(--color-primary);
  --primary-color-dark: var(--color-primary-dark);
  --primary-color-light: var(--color-primary-light);
  --accent-color: var(--color-primary);
  --accent-color-dark: var(--color-primary-dark);
  --border-radius: 18px;
}

/* ========================================
   SETTINGS PANEL - SIMPLIFIED & CONSOLIDATED
   ======================================== */

/* Panel Base - Desktop */
#settings-panel.panel.settings-panel-fullscreen {
  display: none;
  position: fixed;
  top: 5vh;
  left: 50%;
  transform: translateX(-50%);
  width: 80%;
  max-width: 1000px;
  height: 90vh;
  background: var(--background-color);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  z-index: 2000;
  overflow: hidden;
}

#settings-panel.panel.settings-panel-fullscreen.visible {
  display: flex;
  flex-direction: column;
}

/* Panel Close Button */
#settings-panel .panel-close {
  position: absolute;
  top: 1rem;
  right: 1rem;
  background: none;
  border: none;
  font-size: 1.5rem;
  color: var(--color-text-muted);
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease;
  z-index: 10;
}

#settings-panel .panel-close:hover {
  background: rgba(0, 0, 0, 0.1);
  color: var(--text-color);
}

/* Header */
#settings-panel .settings-header {
  padding: 1rem;
  text-align: center;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--background-color);
  flex-shrink: 0;
}

#settings-panel .settings-header h2 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-color);
}

/* Container */
#settings-panel .settings-container {
  display: flex;
  flex-direction: column;
  flex: 1;
  overflow: hidden;
}

/* Tabs */
#settings-panel .settings-tabs {
  display: flex;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  background: var(--background-color);
  flex-shrink: 0;
  padding: 0 1rem;
}

#settings-panel .tab-button {
  background: transparent;
  border: none;
  padding: 0.75rem 1rem;
  font-size: 0.9rem;
  color: var(--secondary-text);
  cursor: pointer;
  position: relative;
  transition: all 0.2s ease;
}

#settings-panel .tab-button:hover {
  color: var(--text-color);
}

#settings-panel .tab-button.active {
  color: var(--accent-color);
  font-weight: 600;
}

#settings-panel .tab-button.active:after {
  content: '';
  position: absolute;
  bottom: -1px;
  left: 0;
  right: 0;
  height: 2px;
  background: var(--accent-color);
}

/* Content Area */
#settings-panel .settings-content {
  flex: 1;
  overflow: hidden;
  background: var(--background-color);
}

#settings-panel .tab-pane {
  display: none;
  height: 100%;
  overflow-y: auto;
}

#settings-panel .tab-pane.active {
  display: flex;
  flex-direction: column;
}

/* Section Styles */
#settings-panel .section-header {
  padding: 1.5rem 2rem 1rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.1);
  flex-shrink: 0;
}

#settings-panel .section-header h3 {
  font-size: 1.1rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-color);
}

#settings-panel .section-content {
  padding: 2rem;
  flex: 1;
  overflow-y: auto;
}

/* Mobile Responsive */
@media (max-width: 768px) {
  #settings-panel.panel.settings-panel-fullscreen {
    top: 0;
    left: 0;
    transform: none;
    width: 100%;
    height: 100%;
    border-radius: 0;
  }
  
  #settings-panel .settings-header {
    padding: 0.5rem 1rem;
    display: flex;
    align-items: center;
    justify-content: center;
    text-align: center;
    position: relative;
  }

  #settings-panel .settings-header h2 {
    font-size: 1rem;
    margin: 0;
    flex: 1;
  }

  #settings-panel .settings-header p {
    display: none;
  }

  #settings-panel .section-header {
    padding: 1rem;
  }
  
  #settings-panel .section-content {
    padding: 1rem;
  }
  
  #settings-panel .panel-close {
    position: static;
    font-size: 1.5rem;
    margin-left: auto;
  }
}

/* Modal Styles */
.modal-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 3000;
  justify-content: center;
  align-items: center;
}

.modal-overlay.visible {
  display: flex;
}

.modal-content {
  background: var(--card-background);
  border-radius: var(--border-radius);
  box-shadow: var(--card-shadow);
  width: 90%;
  max-width: 500px;
  max-height: 85vh;
  overflow: hidden;
  display: flex;
  flex-direction: column;
  animation: modalFadeIn 0.3s;
}

@keyframes modalFadeIn {
  from {
    opacity: 0;
    transform: translateY(-20px);
  }

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

.modal-header {
  padding: 1.25rem 1.5rem;
  border-bottom: 1px solid rgba(0, 0, 0, 0.06);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  font-size: 1.2rem;
  font-weight: 600;
  margin: 0;
  color: var(--text-color);
}

.modal-close {
  background: transparent;
  border: none;
  font-size: 1.5rem;
  color: var(--secondary-text);
  cursor: pointer;
  padding: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  transition: all 0.2s ease;
}

.modal-close:hover {
  background: rgba(0, 0, 0, 0.05);
  color: var(--text-color);
}

.modal-body {
  padding: 1.5rem;
  flex: 1;
  overflow-y: auto;
  min-height: 0;
}

.modal-body p {
  color: var(--secondary-text);
  margin-bottom: 1.25rem;
  font-size: 0.95rem;
}

.form-group {
  margin-bottom: 1.25rem;
}

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

.form-control {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid rgba(0, 0, 0, 0.1);
  border-radius: 8px;
  font-size: 0.95rem;
  color: var(--text-color);
  transition: border-color 0.2s;
  box-sizing: border-box;
  max-width: 100%;
}

.form-control:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(0, 113, 227, 0.2);
}

/* Ensure textareas don't overflow and only resize vertically */
textarea.form-control {
  resize: vertical;
  max-width: 100%;
  box-sizing: border-box;
}

.error-message {
  color: var(--danger-color);
  font-size: 0.85rem;
  margin-bottom: 1rem;
}

/* Hide empty error placeholders so they don't take space */
.error-message:empty {
  display: none;
}

.success-message {
  color: var(--success-color, #34c759);
  font-size: 0.85rem;
  margin-top: 0.25rem;
}

.success-message:empty {
  display: none;
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 1.5rem;
}


/* Reset & Base Styles */
html,
body {
  height: 100%;
  margin: 0;
  padding: 0;
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  color: var(--color-text-primary);
  line-height: 1.5;
  touch-action: pan-x pan-y;
}

#container {
  display: flex;
  height: 100%;
  width: 100%;
  position: relative;
}

/* Utility Classes */
.text-sm {
  font-size: 0.875rem;
}

.text-md {
  font-size: 1rem;
}

.text-lg {
  font-size: 1.125rem;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.font-bold {
  font-weight: 700;
}

.flex {
  display: flex;
}

.flex-col {
  flex-direction: column;
}

.items-center {
  align-items: center;
}

.justify-between {
  justify-content: space-between;
}

.gap-sm {
  gap: var(--spacing-sm);
}

.gap-md {
  gap: var(--spacing-md);
}

/* Scrollbar Styles */
.custom-scrollbar {
  scrollbar-width: thin;
  scrollbar-color: var(--color-text-muted) transparent;
}

.custom-scrollbar::-webkit-scrollbar {
  width: 6px;
}

.custom-scrollbar::-webkit-scrollbar-track {
  background: transparent;
}

.custom-scrollbar::-webkit-scrollbar-thumb {
  background-color: var(--color-text-muted);
  border-radius: var(--radius-sm);
}

/* Status Colors */
.status-for-sale {
  background-color: var(--status-for-sale);
}

.status-under-contract {
  background-color: var(--status-under-contract);
}

.status-sold {
  background-color: var(--status-sold);
}

.status-default {
  background-color: var(--status-default);
}

/* Status Badge Styles for Settings */
.status-warning {
  background-color: rgba(220, 53, 69, 0.1) !important;
  color: #dc3545 !important;
  border: 1px solid rgba(220, 53, 69, 0.2) !important;
}

/* Past Due Modal Styles */
.past-due-modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10000;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.past-due-modal-overlay.show {
  opacity: 1;
}

.past-due-modal-content {
  background: white;
  border-radius: 16px;
  max-width: 500px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: 0 20px 40px rgba(0, 0, 0, 0.15);
  transform: translateY(20px);
  transition: transform 0.3s ease;
}

.past-due-modal-overlay.show .past-due-modal-content {
  transform: translateY(0);
}

.past-due-modal-header {
  padding: 24px 24px 16px;
  border-bottom: 1px solid #e5e7eb;
}

.past-due-modal-header h2 {
  margin: 0 0 8px 0;
  color: #dc3545;
  font-size: 24px;
  font-weight: 600;
}

.past-due-modal-header p {
  margin: 0;
  color: #6b7280;
  font-size: 16px;
  line-height: 1.5;
}

.past-due-modal-body {
  padding: 24px;
  text-align: center;
}

.past-due-icon {
  font-size: 48px;
  margin-bottom: 16px;
  display: block;
}

.past-due-message p {
  margin: 0;
  color: #4b5563;
  font-size: 16px;
  line-height: 1.5;
}

.past-due-modal-footer {
  padding: 16px 24px 24px;
}

.past-due-actions {
  display: flex;
  gap: 12px;
  justify-content: flex-end;
}

.past-due-btn {
  padding: 12px 20px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
}

.past-due-btn.primary {
  background: #dc3545;
  color: white;
}

.past-due-btn.primary:hover {
  background: #c82333;
  transform: translateY(-1px);
}

.past-due-btn.secondary {
  background: #f8f9fa;
  color: #6c757d;
  border: 1px solid #e9ecef;
}

.past-due-btn.secondary:hover {
  background: #e9ecef;
  color: #495057;
}

@media (max-width: 600px) {
  .past-due-modal-content {
    margin: 20px;
    width: calc(100% - 40px);
  }
  
  .past-due-actions {
    flex-direction: column-reverse;
  }
  
  .past-due-btn {
    width: 100%;
  }
}

/* Responsive Breakpoints */
@media (max-width: 768px) {
  .hide-mobile {
    display: none !important;
  }
}

@media (min-width: 769px) {
  .hide-desktop {
    display: none !important;
  }
}

.panel-toggle-btn,
.map-nav-btn {
  -webkit-user-select: none;
  -moz-user-select: none;
  -ms-user-select: none;
  user-select: none;
  -webkit-touch-callout: none;
}

.mobile-tooltip {
  position: fixed;
  background-color: rgba(0, 0, 0, 0.9);
  color: white;
  padding: 8px 12px;
  border-radius: 6px;
  font-size: 13px;
  line-height: 1.4;
  max-width: 280px;
  z-index: 10000;
  pointer-events: none;
  opacity: 0;
  transform: translateY(4px);
  transition: opacity 0.2s ease, transform 0.2s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.3);
  white-space: normal;
  word-wrap: break-word;
}

.mobile-tooltip.visible {
  opacity: 1;
  transform: translateY(0);
}
