/* Minimal admin styles and spinner */
:root { 
  color-scheme: light;
  --primary-color: #f59e0b;
  --primary-hover: #d97706;
  --secondary-color: #1976d2;
  --success-color: #10b981;
  --warning-color: #f59e0b;
  --error-color: #ef4444;
  --border-radius: 8px;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px 0 rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -2px rgba(0, 0, 0, 0.05);
  /* Fluid type scale base for mobile-first sizing */
  --fluid-rem: clamp(14px, 3.5vw, 16px);
}

.spinner { 
  border: 4px solid rgba(255,255,255,0.15);
  border-top-color: rgba(255,255,255,0.9);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Organizational Dashboard Specific Styles */

/* Dashboard Cards */
.dashboard-card {
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: box-shadow 0.2s ease;
}

.dashboard-card:hover {
  box-shadow: var(--shadow-lg);
}

.metric-card {
  background: white;
  border-radius: 0.5rem;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.metric-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}

/* Status Indicators */
.status-indicator {
  display: inline-flex;
  align-items: center;
  padding: 0.25rem 0.75rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.status-active {
  background-color: #dcfce7;
  color: #166534;
}

.status-pending {
  background-color: #fef3c7;
  color: #92400e;
}

.status-inactive {
  background-color: #fecaca;
  color: #991b1b;
}

.status-suspended {
  background-color: #f3f4f6;
  color: #374151;
}

/* Role Badges */
.role-badge {
  display: inline-flex;
  align-items: center;
  padding: 0.125rem 0.625rem;
  border-radius: 9999px;
  font-size: 0.75rem;
  font-weight: 500;
}

.role-owner {
  background-color: #f3e8ff;
  color: #6b21a8;
}

.role-manager {
  background-color: #dbeafe;
  color: #1e40af;
}

.role-technician {
  background-color: #dcfce7;
  color: #166534;
}

.role-viewer {
  background-color: #f3f4f6;
  color: #374151;
}

/* Progress Bars */
.progress-bar {
  width: 100%;
  height: 8px;
  background-color: #e5e7eb;
  border-radius: 9999px;
  overflow: hidden;
}

.progress-fill {
  height: 100%;
  background: linear-gradient(90deg, var(--success-color), var(--primary-color));
  transition: width 0.3s ease;
}

/* Efficiency Indicator */
.efficiency-indicator {
  display: inline-flex;
  align-items: center;
  font-weight: 600;
}

.efficiency-excellent {
  color: #059669;
}

.efficiency-good {
  color: #2563eb;
}

.efficiency-average {
  color: #d97706;
}

.efficiency-poor {
  color: #dc2626;
}

/* Verification Queue Styles */
.verification-item {
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 1rem;
  transition: background-color 0.2s ease;
}

.verification-item:hover {
  background-color: #f9fafb;
}

.verification-item.urgent {
  border-color: #fbbf24;
  background-color: #fffbeb;
}

.verification-actions {
  display: flex;
  gap: 0.5rem;
}

.verification-actions button {
  padding: 0.25rem 0.75rem;
  font-size: 0.875rem;
  border-radius: 0.375rem;
  font-weight: 500;
  /* Sharing indicator tweaks */
  #sharing-indicator { transition: background-color 0.2s ease, color 0.2s ease, border-color 0.2s ease; }
  transition: background-color 0.2s ease;
  border: none;
  cursor: pointer;
}

.verify-approve {
  background-color: #dcfce7;
  color: #15803d;
}

.verify-approve:hover {
  background-color: #bbf7d0;
}

.verify-reject {
  background-color: #fecaca;
  color: #dc2626;
}

.verify-reject:hover {
  background-color: #fca5a5;
}

.verify-review {
  background-color: #dbeafe;
  color: #1d4ed8;
}

.verify-review:hover {
  background-color: #bfdbfe;
}

/* Team Member Cards */
.team-member-card {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem;
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  transition: background-color 0.2s ease;
}

.team-member-card:hover {
  background-color: #f9fafb;
}

.member-avatar {
  height: 2.5rem;
  width: 2.5rem;
  border-radius: 9999px;
  background-color: #e5e7eb;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  color: #4b5563;
}

.member-info {
  flex: 1;
  min-width: 0;
}

.member-name {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.member-role {
  font-size: 0.75rem;
  color: #6b7280;
}

.member-stats {
  text-align: right;
}

.member-efficiency {
  font-size: 0.875rem;
  font-weight: 600;
}

.member-jobs {
  font-size: 0.75rem;
  color: #6b7280;
}

/* Leaderboard Styles */
.leaderboard-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 0.75rem;
  border-bottom: 1px solid #f3f4f6;
}

.leaderboard-item:last-child {
  border-bottom: none;
}

.leaderboard-rank {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.rank-number {
  width: 1.5rem;
  height: 1.5rem;
  border-radius: 9999px;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 0.75rem;
  font-weight: 700;
}

.rank-number.first {
  background-color: #fef3c7;
  color: #92400e;
}

.rank-number.second {
  background-color: #d1d5db;
  color: #374151;
}

.rank-number.third {
  background-color: #fed7aa;
  color: #ea580c;
}

/* Chart Container */
.chart-container {
  position: relative;
  height: 300px;
  width: 100%;
}

.chart-container canvas {
  max-height: 100%;
}

/* Organization Setup Panel */
.setup-card {
  border: 1px solid #d1d5db;
  border-radius: 0.5rem;
  padding: 1.5rem;
  transition: all 0.2s ease;
}

.setup-card:hover {
  border-color: #fbbf24;
  box-shadow: var(--shadow);
}

/* Modal Styles */
.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(75, 85, 99, 0.5);
  overflow-y: auto;
  height: 100vh;
  width: 100vw;
  z-index: 50;
}

.modal-container {
  position: relative;
  top: 5rem;
  margin: 0 auto;
  padding: 1.25rem;
  border: 1px solid #d1d5db;
  width: 100%;
  max-width: 28rem;
  box-shadow: var(--shadow-lg);
  border-radius: 0.375rem;
  background-color: white;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 1rem;
}

.modal-title {
  font-size: 1.125rem;
  font-weight: 500;
  color: #111827;
}

.modal-close {
  color: #9ca3af;
  transition: color 0.2s ease;
  cursor: pointer;
}

.modal-close:hover {
  color: #4b5563;
}

/* Form Styles */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.875rem;
  font-weight: 500;
  color: #374151;
  margin-bottom: 0.5rem;
}

.form-input, .form-select, .form-textarea {
  width: 100%;
  border: 1px solid #d1d5db;
  border-radius: 0.375rem;
  padding: 0.5rem 0.75rem;
  font-size: 0.875rem;
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

.form-input:focus, .form-select:focus, .form-textarea:focus {
  outline: none;
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.1);
}

.form-select {
  background-color: white;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' fill='none' viewBox='0 0 20 20'%3e%3cpath stroke='%236b7280' stroke-linecap='round' stroke-linejoin='round' stroke-width='1.5' d='m6 8 4 4 4-4'/%3e%3c/svg%3e");
  background-position: right 0.5rem center;
  background-repeat: no-repeat;
  background-size: 1.5em 1.5em;
  padding-right: 2.5rem;
}

.form-textarea {
  resize: none;
}

/* Button Styles */
.btn {
  padding: 0.5rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  transition: all 0.2s ease;
  border: none;
  cursor: pointer;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
}

.btn:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(0, 0, 0, 0.1);
}

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

.btn-primary:hover {
  background-color: var(--primary-hover);
}

.btn-primary:focus {
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

.btn-secondary {
  background-color: #3b82f6;
  color: white;
}

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

.btn-secondary:focus {
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.3);
}

.btn-success {
  background-color: var(--success-color);
  color: white;
}

.btn-success:hover {
  background-color: #059669;
}

.btn-danger {
  background-color: var(--error-color);
  color: white;
}

.btn-danger:hover {
  background-color: #dc2626;
}

.btn-outline {
  border: 1px solid #d1d5db;
  color: #374151;
  background-color: white;
}

.btn-outline:hover {
  background-color: #f9fafb;
}

.btn-ghost {
  color: #374151;
  background-color: transparent;
}

.btn-ghost:hover {
  background-color: #f3f4f6;
}

/* Quick Action Buttons */
.quick-action {
  width: 100%;
  background-color: #f9fafb;
  border: 1px solid #e5e7eb;
  border-radius: 0.375rem;
  padding: 0.75rem 1rem;
  text-align: left;
  transition: all 0.2s ease;
  cursor: pointer;
}

.quick-action:hover {
  background-color: #f3f4f6;
  box-shadow: var(--shadow);
}

.quick-action-content {
  display: flex;
  align-items: center;
}

.quick-action-icon {
  height: 1.25rem;
  width: 1.25rem;
  color: #9ca3af;
  margin-right: 0.75rem;
}

.quick-action-text {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
}

/* Notification Styles */
.notification {
  position: fixed;
  top: 1rem;
  right: 1rem;
  max-width: 24rem;
  width: 100%;
  background-color: white;
  box-shadow: var(--shadow-lg);
  border-radius: 0.5rem;
  pointer-events: auto;
  border: 1px solid rgba(0, 0, 0, 0.05);
  overflow: hidden;
  z-index: 50;
}

.notification-success {
  border-left: 4px solid #10b981;
}

.notification-error {
  border-left: 4px solid #ef4444;
}

.notification-warning {
  border-left: 4px solid #f59e0b;
}

.notification-info {
  border-left: 4px solid #3b82f6;
}

.notification-content {
  padding: 1rem;
}

.notification-title {
  font-size: 0.875rem;
  font-weight: 500;
  color: #111827;
}

.notification-message {
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #6b7280;
}

/* Loading States */
.loading-skeleton {
  animation: pulse 2s cubic-bezier(0.4, 0, 0.6, 1) infinite;
}

@keyframes pulse {
  0%, 100% {
    opacity: 1;
  }
  50% {
    opacity: 0.5;
  }
}

.skeleton-line {
  height: 1rem;
  background-color: #e5e7eb;
  border-radius: 0.25rem;
  width: 100%;
}

.skeleton-circle {
  height: 2.5rem;
  width: 2.5rem;
  background-color: #e5e7eb;
  border-radius: 9999px;
}

.skeleton-button {
  height: 2rem;
  background-color: #e5e7eb;
  border-radius: 0.25rem;
  width: 5rem;
}

/* Responsive Design */
@media (max-width: 640px) {
  /* Root font scaling for compact mobile layout */
  html { font-size: var(--fluid-rem); }

  /* Headings: slightly reduce to fit better on narrow screens */
  h1 { font-size: clamp(1.35rem, 6vw, 1.75rem); }
  h2 { font-size: clamp(1.15rem, 5.2vw, 1.5rem); }
  h3 { font-size: clamp(1rem, 4.6vw, 1.25rem); }

  /* Large stat and hero text often rendered oversized */
  .text-4xl, .text-5xl, .text-6xl, .text-7xl, .text-8xl {
    font-size: clamp(1.6rem, 7vw, 2rem) !important;
    line-height: 1.15 !important;
  }

  /* Buttons and chips that looked bulky on mobile */
  .btn, .badge, .chip, .pill, .quick-action-text {
    font-size: 0.95rem !important;
  }

  /* KPI tiles / metric numbers */
  .metric-card .text-3xl,
  .metric-card .text-4xl,
  .overall-efficiency .text-5xl,
  .efficiency-indicator .text-4xl {
    font-size: clamp(1.25rem, 6vw, 1.6rem) !important;
  }

  /* Header toolbar buttons (Install App / Refresh / Status) */
  .toolbar, .toolbar button, .toolbar .btn, .toolbar .status-indicator {
    font-size: 0.95rem !important;
  }

  .modal-container {
    margin: 0 1rem;
    width: auto;
  }
  
  .metric-card {
    padding: 1rem;
  }
  
  .team-member-card {
    padding: 0.5rem;
    gap: 0.5rem;
  }
  
  .verification-item {
    padding: 0.75rem;
  }
  
  .quick-action {
    padding: 0.75rem;
  }
  
  .verification-actions {
    flex-direction: column;
    gap: 0.25rem;
  }
  
  .verification-actions button {
    width: 100%;
    min-height: 44px; /* Mobile touch target */
  }
  
  /* Mobile Touch Improvements */
  button, .btn, [role="button"] {
    min-height: 44px !important;
    min-width: 44px !important;
    padding: 0.75rem 1rem !important;
  }
  
  /* Dashboard tab buttons */
  .dashboard-tab {
    min-height: 44px !important;
    padding: 0.75rem 1rem !important;
  }
  
  /* Navigation improvements */
  nav a, nav button {
    min-height: 44px !important;
    padding: 0.75rem !important;
  }
  
  /* Form elements */
  input, select, textarea {
    min-height: 44px !important;
    padding: 0.75rem !important;
    font-size: 16px !important; /* Prevent zoom on iOS */
  }
  
  /* Modal close buttons */
  .modal .close-btn {
    min-width: 44px !important;
    min-height: 44px !important;
  }
  
  /* Modal responsiveness improvements */
  .fixed.inset-0 .relative {
    margin: 1rem !important;
    max-height: calc(100vh - 2rem) !important;
    overflow-y: auto !important;
  }
  
  .fixed.inset-0 .relative .bg-white {
    max-width: none !important;
    width: auto !important;
    border-radius: 0.5rem !important;
  }
  
  /* Improve modal content spacing on mobile */
  .modal .p-4, .modal .p-5, .modal .p-6 {
    padding: 1rem !important;
  }
  
  /* Stack modal buttons vertically on mobile */
  .modal .flex.justify-end,
  .modal .flex.space-x-3 {
    flex-direction: column !important;
    gap: 0.75rem !important;
  }
  
  .modal .flex.justify-end button,
  .modal .flex.space-x-3 button {
    width: 100% !important;
    margin: 0 !important;
  }
}

/* Animation Classes */
@keyframes fadeIn {
  from { 
    opacity: 0; 
    transform: translateY(10px); 
  }
  to { 
    opacity: 1; 
    transform: translateY(0); 
  }
}

@keyframes slideIn {
  from { transform: translateX(-100%); }
  to { transform: translateX(0); }
}

.animate-fade-in {
  animation: fadeIn 0.3s ease-out;
}

.animate-slide-in {
  animation: slideIn 0.3s ease-out;
}

/* Focus and Accessibility */
.focus-ring:focus {
  outline: none;
  box-shadow: 0 0 0 3px rgba(245, 158, 11, 0.3);
}

/* Print Styles for Reports */
@media print {
  .no-print {
    display: none !important;
  }
  
  .dashboard-card {
    break-inside: avoid;
    page-break-inside: avoid;
  }
  
  .chart-container {
    height: auto !important;
  }
  
  .modal-backdrop {
    display: none !important;
  }
}
