/* Reset and Base Styles */
* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

:root {
  --primary-color: #3b82f6;
  --primary-hover: #2563eb;
  --secondary-color: #64748b;
  --success-color: #10b981;
  --danger-color: #ef4444;
  --warning-color: #f59e0b;
  --bg-color: #f8fafc;
  --sidebar-bg: #1e293b;
  --card-bg: #ffffff;
  --text-primary: #0f172a;
  --text-secondary: #475569;
  --border-color: #e2e8f0;
  --shadow: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
}

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, Cantarell, sans-serif;
  background-color: var(--bg-color);
  color: var(--text-primary);
  line-height: 1.6;
}

/* Login Page */
.login-page {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
}

.login-container {
  width: 100%;
  max-width: 400px;
  padding: 20px;
}

.login-card {
  background: var(--card-bg);
  padding: 40px;
  border-radius: 12px;
  box-shadow: var(--shadow-lg);
}

.login-card h1 {
  font-size: 28px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

.subtitle {
  color: var(--text-secondary);
  margin-bottom: 30px;
  font-size: 14px;
}

/* Form Styles */
.form-group {
  margin-bottom: 20px;
}

.form-group label {
  display: block;
  margin-bottom: 8px;
  font-weight: 500;
  color: var(--text-primary);
  font-size: 14px;
}

.form-group input {
  width: 100%;
  padding: 12px 16px;
  border: 1px solid var(--border-color);
  border-radius: 8px;
  font-size: 14px;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

/* Buttons */
.btn {
  padding: 12px 24px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s;
  display: inline-flex;
  align-items: center;
  gap: 8px;
  justify-content: center;
}

.btn-primary {
  background-color: var(--primary-color);
  color: white;
  width: 100%;
}

.btn-primary:hover {
  background-color: var(--primary-hover);
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background-color: var(--secondary-color);
  color: white;
  width: 100%;
}

.btn-secondary:hover {
  background-color: #475569;
}

/* Filter Buttons (Header Labels) */
.filter-btn,
.hub-filter-btn {
  cursor: pointer;
  font-size: 15px;
  padding: 10px 20px;
  border-radius: 12px;
  transition: all 0.2s;
  font-weight: 500;
  display: flex;
  align-items: center;
  gap: 8px;
  min-width: 140px;
  justify-content: center;
  border: 2px solid var(--border-color);
  background: var(--bg-color);
}

.filter-btn:hover,
.hub-filter-btn:hover {
  transform: translateY(-1px);
  box-shadow: var(--shadow);
}

/* Hub Labels/Badges - Reusable across pages */
.hub-label {
  display: inline-block;
  font-size: 11px;
  padding: 4px 10px;
  border-radius: 6px;
  font-weight: 500;
  border: 1px solid;
  white-space: nowrap;
}

/* Specific hub colors will be applied via inline styles using hubColors.js */

/* Error Message */
.error-message {
  color: var(--danger-color);
  font-size: 14px;
  margin-bottom: 16px;
  display: none;
}

.error-message.show {
  display: block;
}

/* Dashboard Layout */
.dashboard {
  display: flex;
  min-height: 100vh;
}

/* Sidebar */
.sidebar {
  width: 260px;
  background-color: var(--sidebar-bg);
  color: white;
  display: flex;
  flex-direction: column;
  position: fixed;
  height: 100vh;
  left: 0;
  top: 0;
}

.sidebar-header {
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-header h2 {
  font-size: 20px;
  font-weight: 600;
}

.sidebar-nav {
  flex: 1;
  padding: 20px 0;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 20px;
  color: rgba(255, 255, 255, 0.7);
  text-decoration: none;
  transition: all 0.2s;
  font-size: 14px;
}

.nav-link:hover {
  background-color: rgba(255, 255, 255, 0.05);
  color: white;
}

.nav-link.active {
  background-color: rgba(59, 130, 246, 0.15);
  color: white;
  border-left: 3px solid var(--primary-color);
  padding-left: 17px;
  font-weight: 500;
}

.sidebar-footer {
  padding: 20px;
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

/* Main Content */
.main-content {
  flex: 1;
  margin-left: 260px;
  padding: 32px;
  min-height: 100vh;
}

/* Page Header */
.page-header {
  margin-bottom: 32px;
}

.page-header h1 {
  font-size: 32px;
  margin-bottom: 8px;
}

.page-header p {
  color: var(--text-secondary);
  font-size: 14px;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: 12px;
  padding: 24px;
  box-shadow: var(--shadow);
  margin-bottom: 24px;
}

.card-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 18px;
  font-weight: 600;
}

/* Stats Grid */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 20px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--card-bg);
  padding: 24px;
  border-radius: 12px;
  box-shadow: var(--shadow);
}

.stat-label {
  color: var(--text-secondary);
  font-size: 14px;
  margin-bottom: 8px;
}

.stat-value {
  font-size: 32px;
  font-weight: 700;
  color: var(--text-primary);
}

.stat-change {
  font-size: 12px;
  margin-top: 8px;
}

.stat-change.positive {
  color: var(--success-color);
}

.stat-change.negative {
  color: var(--danger-color);
}

/* Table */
.table-container {
  overflow-x: auto;
}

table {
  width: 100%;
  border-collapse: collapse;
}

thead {
  background-color: var(--bg-color);
}

th {
  text-align: left;
  padding: 12px 16px;
  font-weight: 600;
  font-size: 12px;
  text-transform: uppercase;
  color: var(--text-secondary);
  border-bottom: 2px solid var(--border-color);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border-color);
  font-size: 14px;
  vertical-align: top;
  line-height: 1.5;
}

/* Ensure badge containers in table cells wrap properly */
td > div[style*="flex-wrap"] {
  max-width: 100%;
}

tbody tr {
  border-bottom: 1px solid var(--border-color);
}

tbody tr:nth-child(even) {
  background-color: rgba(248, 250, 252, 0.5);
}

tbody tr:hover {
  background-color: var(--bg-color) !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

/* Badge */
.badge {
  display: inline-block;
  padding: 4px 12px;
  border-radius: 12px;
  font-size: 12px;
  font-weight: 500;
}

.badge-success {
  background-color: rgba(16, 185, 129, 0.1);
  color: var(--success-color);
}

.badge-warning {
  background-color: rgba(245, 158, 11, 0.1);
  color: var(--warning-color);
}

.badge-danger {
  background-color: rgba(239, 68, 68, 0.1);
  color: var(--danger-color);
}

.badge-secondary {
  background-color: rgba(100, 116, 139, 0.1);
  color: var(--secondary-color);
}

/* Loading State */
.loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: var(--text-secondary);
}

/* Empty State */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.empty-state h3 {
  font-size: 18px;
  margin-bottom: 8px;
  color: var(--text-primary);
}

/* Filter Controls Responsive */
@media (max-width: 1400px) {
  /* 2-column layout on medium screens */
  .filter-controls-grid {
    grid-template-columns: 1fr 1fr !important;
  }
  
  .filter-controls-grid > div:first-child {
    grid-column: 1 / -1;
  }
  
  #resetFilters {
    grid-column: 1 / -1;
  }
}

@media (max-width: 900px) {
  /* Single column on small screens */
  .filter-controls-grid {
    grid-template-columns: 1fr !important;
  }
  
  #resetFilters .reset-text {
    display: inline;
  }
  
  #resetFilters {
    padding: 10px 20px !important;
    width: 100%;
  }
}

/* Responsive */
@media (max-width: 768px) {
  .sidebar {
    width: 80px;
  }

  .sidebar-header h2,
  .nav-link span,
  .sidebar-footer button span {
    display: none;
  }

  .main-content {
    margin-left: 80px;
    padding: 20px;
  }

  .stats-grid {
    grid-template-columns: 1fr;
  }
  
  .page-header {
    flex-direction: column !important;
    align-items: flex-start !important;
  }
  
  .page-header > div:last-child {
    width: 100%;
    margin-top: 16px;
    justify-content: flex-start;
    flex-wrap: wrap;
  }
}

/* Mobile Header (Hamburger) */
.mobile-header {
  display: none;
  align-items: center;
  gap: 16px;
  padding: 16px 20px;
  background: var(--sidebar-bg);
  color: white;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 40;
  height: 60px;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.mobile-header h1 {
  font-size: 18px;
  font-weight: 600;
  margin: 0;
}

.icon-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  padding: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
}

/* Sidebar Overlay */
.sidebar-overlay {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  z-index: 45;
  opacity: 0;
  transition: opacity 0.3s;
  backdrop-filter: blur(2px);
}

.sidebar-overlay.show {
  display: block;
  opacity: 1;
}

/* Mobile Specific Layout & Light Version */
@media (max-width: 768px) {
  /* Show Header */
  .mobile-header {
    display: flex;
  }

  /* Sidebar as Drawer */
  .sidebar {
    display: flex;
    transform: translateX(-100%);
    transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1);
    z-index: 50;
    width: 280px;
    box-shadow: 4px 0 24px rgba(0,0,0,0.2);
  }

  .sidebar.open {
    transform: translateX(0);
  }
  
  /* Show elements hidden on desktop if needed */
  .sidebar-header h2,
  .nav-link span,
  .sidebar-footer button span {
    display: block;
  }
  
  .sidebar {
    width: 280px; /* Restore width for drawer */
  }

  .main-content {
    margin-left: 0;
    padding: 20px;
    padding-top: 80px; /* Space for top header */
  }

  /* Hide page headers on mobile since we have the top bar */
  .page-header {
    display: none !important;
  }
  
  /* Exception: Show Map page header for hub filters */
  .map-page-layout ~ .page-header,
  .page-header:has(+ .map-page-layout),
  .page-container:has(.map-page-layout) .page-header {
    display: flex !important;
    padding-bottom: 12px !important;
    border-bottom: 1px solid var(--border-color) !important;
    margin-bottom: 16px !important;
  }
  
  /* Hide title/description in Map page header but show filters */
  .page-container:has(.map-page-layout) .page-header > div:first-child {
    display: none !important;
  }
  
  .page-container:has(.map-page-layout) .page-header > div:last-child {
    width: 100% !important;
  }

  /* Show Orders Table (override previous hide) */
  #ordersContent {
    display: block !important;
    margin-top: 0 !important;
  }
  
  /* Remove the "Switch to desktop" message */
  #ordersContent:after {
    display: none;
  }

  /* Hide Top Performers Section */
  .top-performers-section {
    display: none !important;
  }

  /* Compact Orders Table */
  #ordersContent table {
    table-layout: fixed;
    width: 100%;
  }

  /* Hide columns: Appointment(2), Agent(3), Photographer(4), Hub/Package(5), Addons(6), Process(7) */
  #ordersContent table th:nth-child(2),
  #ordersContent table td:nth-child(2),
  #ordersContent table th:nth-child(3),
  #ordersContent table td:nth-child(3),
  #ordersContent table th:nth-child(4),
  #ordersContent table td:nth-child(4),
  #ordersContent table th:nth-child(5),
  #ordersContent table td:nth-child(5),
  #ordersContent table th:nth-child(6),
  #ordersContent table td:nth-child(6),
  #ordersContent table th:nth-child(7),
  #ordersContent table td:nth-child(7) {
    display: none;
  }
  
  /* Adjust remaining column width (Address) */
  #ordersContent table th:nth-child(1) { 
    width: 100% !important;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  #ordersContent table td:nth-child(1) {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 0 !important;
    padding-right: 0 !important;
  }
  
  #ordersContent table td:nth-child(1) > div {
    display: flex;
    align-items: center;
    width: 100%;
  }
  
  /* Status dot adjustment */
  #ordersContent table td:nth-child(1) > div > div {
    margin-right: 8px;
  }
  
  /* Address text truncation */
  #ordersContent table td:nth-child(1) span {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    display: block;
    width: 100%;
  }
  
  /* Hide Image Icon */
  #ordersContent table td:nth-child(1) a[href*="http"] {
    display: none !important;
  }
  
  /* Remove card padding on mobile for max width */
  #ordersContent .card {
    padding: 10px !important;
    border-radius: 8px;
    overflow: hidden;
  }
  
  /* Ensure table container doesn't scroll if not needed */
  #ordersContent .table-container {
    overflow-x: hidden;
  }
  
  /* Adjust stats cards */
  .filter-btn strong {
    font-size: 18px !important;
  }
  
  .filter-btn span {
    font-size: 12px !important;
  }

  /* Packages Page Mobile */
  #hubTablesContainer {
    grid-template-columns: 1fr !important;
    gap: 16px !important;
  }
  
  /* Make package cards more compact for mobile */
  #hubTablesContainer .card {
    padding: 12px !important;
  }
  
  #hubTablesContainer h3 {
    font-size: 15px !important;
  }
  
  #hubTablesContainer p {
    font-size: 11px !important;
  }
  
  #hubTablesContainer table {
    font-size: 11px !important;
  }
  
  #hubTablesContainer th {
    font-size: 9px !important;
    padding: 6px 4px !important;
  }
  
  #hubTablesContainer td {
    font-size: 11px !important;
    padding: 6px 4px !important;
  }
  
  #hubTablesContainer .selection-checkbox {
    width: 14px !important;
    height: 14px !important;
  }

  /* Photographers Page Mobile */
  /* Hide stats pills */
  .photographer-stats {
    display: none !important;
  }

  /* Override inline grid styles for filters - Make 2 columns */
  .filter-controls-grid {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 8px !important;
  }
  
  /* Search box spans full width */
  .filter-controls-grid > div:first-child {
    grid-column: 1 / -1 !important;
    width: 100% !important;
  }

  /* Make filter inputs smaller */
  .filter-select, #resetFilters {
    padding: 6px 8px !important;
    font-size: 12px !important;
    height: 32px !important;
  }
  
  #searchInput {
    padding: 8px 10px 8px 32px !important;
    font-size: 13px !important;
  }

  /* Hide less critical columns in Photographers table */
  /* Column 3 (Hub), 4 (Entry), 5 (Services) */
  .photographer-row td:nth-child(3),
  .photographer-row td:nth-child(4),
  .photographer-row td:nth-child(5),
  .table-container th:nth-child(3),
  .table-container th:nth-child(4),
  .table-container th:nth-child(5) {
    display: none;
  }
  
  /* Adjust Name column width */
  .table-container th:first-child {
    width: auto !important;
  }
  
  /* Map Page Mobile */
  /* Make hub filter buttons smaller and scrollable */
  .page-container .page-header > div:last-child {
    overflow-x: auto !important;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none; /* Firefox */
    display: flex !important;
    flex-wrap: nowrap !important;
    gap: 8px !important;
    padding-bottom: 8px;
  }
  
  .page-container .page-header > div:last-child::-webkit-scrollbar {
    display: none; /* Chrome/Safari */
  }
  
  .hub-filter-btn {
    min-width: auto !important;
    padding: 6px 12px !important;
    flex-shrink: 0 !important;
    font-size: 12px !important;
    gap: 4px !important;
  }
  
  .hub-filter-btn strong {
    font-size: 16px !important;
  }
  
  .hub-filter-btn span {
    font-size: 11px !important;
  }

  .map-page-layout {
    grid-template-columns: 1fr !important;
    display: flex !important;
    flex-direction: column-reverse !important; /* Map on top, list below */
    gap: 16px !important;
    height: calc(100vh - 140px) !important; /* Fit within view */
  }

  /* Map container (Right Column -> Top on mobile) */
  .map-page-layout > div:last-child {
    height: 50% !important;
    flex-shrink: 0 !important;
  }
  
  .map-page-layout > div:last-child .card {
    height: 100% !important;
    padding: 0 !important;
  }
  
  #fullMap {
    width: 100% !important;
    height: 100% !important;
    min-height: 200px;
  }
  
  /* List container (Left Column -> Bottom on mobile) */
  .map-page-layout > div:first-child {
    height: 50% !important;
    overflow: hidden !important;
  }
  
  .map-page-layout > div:first-child .card {
    height: 100% !important;
  }
}

/* Search Input Focus */
input[type="text"]:focus {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
}

/* Select Dropdown Focus */
select:focus {
  border-color: var(--primary-color) !important;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1) !important;
  outline: none;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%23475569' d='M6 9L1 4h10z'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 36px;
}

/* Loading Spinner Animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Filter Buttons */
.filter-btn:hover {
  background: var(--bg-color) !important;
}

.filter-btn:active {
  transform: scale(0.98);
}

/* Reset Filters Button */
#resetFilters:hover {
  background: rgba(59, 130, 246, 0.2) !important;
  border-color: var(--primary-color) !important;
  color: var(--primary-color) !important;
  box-shadow: 0 2px 8px rgba(59, 130, 246, 0.15);
}

#resetFilters:active {
  transform: scale(0.98);
  background: rgba(59, 130, 246, 0.15) !important;
}

/* Modal Styles */
.modal-overlay {
  animation: fadeIn 0.2s ease-in-out;
}

@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

.modal-content {
  animation: slideUp 0.3s ease-out;
}

@keyframes slideUp {
  from {
    transform: translateY(20px);
    opacity: 0;
  }
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.close-modal:hover {
  background: var(--bg-color) !important;
}

/* Checkbox Labels */
label:has(input[type="checkbox"]):hover {
  background: var(--bg-color) !important;
}

input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--primary-color);
}

/* Modal Responsive */
@media (max-width: 900px) {
  .modal-content {
    max-width: 95% !important;
  }
  
  #editPhotographerForm > div:first-child {
    grid-template-columns: 1fr !important;
  }
}

/* Utility Classes */
.text-center {
  text-align: center;
}

.mt-1 { margin-top: 8px; }
.mt-2 { margin-top: 16px; }
.mt-3 { margin-top: 24px; }
.mt-4 { margin-top: 32px; }

.mb-1 { margin-bottom: 8px; }
.mb-2 { margin-bottom: 16px; }
.mb-3 { margin-bottom: 24px; }
.mb-4 { margin-bottom: 32px; }

.flex {
  display: flex;
}

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

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

.gap-2 {
  gap: 16px;
}

