/* Modern Calendar Sync UI Styles */

:root {
  --primary: #4285f4;
  --primary-hover: #357ae8;
  --success: #34a853;
  --success-hover: #2d8e47;
  --danger: #ea4335;
  --danger-hover: #d33828;
  --warning: #fbbc04;
  --gray-50: #f9fafb;
  --gray-100: #f3f4f6;
  --gray-200: #e5e7eb;
  --gray-300: #d1d5db;
  --gray-400: #9ca3af;
  --gray-500: #6b7280;
  --gray-600: #4b5563;
  --gray-700: #374151;
  --gray-800: #1f2937;
  --gray-900: #111827;
  --border-radius: 12px;
  --border-radius-sm: 8px;
  --shadow-sm: 0 1px 2px 0 rgba(0, 0, 0, 0.05);
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1);
  --transition: all 0.2s ease;
}

* {
  box-sizing: border-box;
}

/* Loading States */
.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 3rem;
  color: var(--gray-600);
}

.spinner {
  display: inline-block;
  animation: spin 1s linear infinite;
  font-size: 1.5rem;
}

@keyframes spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

.loading-dots::after {
  content: '';
  animation: dots 1.5s steps(4, end) infinite;
}

@keyframes dots {
  0%, 20% { content: ''; }
  40% { content: '.'; }
  60% { content: '..'; }
  80%, 100% { content: '...'; }
}

/* Error Banner */
.error-banner {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.25rem;
  background: #fef2f2;
  border: 1px solid #fee2e2;
  border-radius: var(--border-radius-sm);
  color: var(--danger);
  margin-bottom: 1.5rem;
}

.error-icon {
  font-size: 1.25rem;
  flex-shrink: 0;
}

.error-text {
  flex: 1;
  font-size: 0.9375rem;
}

/* Section Titles */
.section-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
}

.section-description {
  margin: 0 0 1.5rem 0;
  color: var(--gray-600);
  font-size: 0.9375rem;
}

/* Provider Buttons */
.provider-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.provider-btn {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 1rem 1.5rem;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
  font-weight: 500;
}

.provider-btn:hover:not(:disabled) {
  border-color: var(--primary);
  box-shadow: var(--shadow);
  transform: translateY(-2px);
}

.provider-btn.active {
  border-color: var(--primary);
  background: #eff6ff;
}

.provider-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.provider-btn.google {
  color: #4285f4;
}

.provider-btn.outlook {
  color: #0078d4;
}

.provider-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  border-radius: 50%;
  background: var(--gray-100);
  font-weight: 700;
  font-size: 1.25rem;
}

.provider-text {
  flex: 1;
  text-align: left;
  color: var(--gray-800);
}

/* Calendar Selector */
.calendar-selector {
  padding: 1.5rem 0;
}

.selector-title {
  margin: 0 0 0.5rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
}

.selector-description {
  margin: 0 0 1.25rem 0;
  color: var(--gray-600);
  font-size: 0.875rem;
}

.calendar-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.calendar-item-wrapper {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar-item-wrapper .calendar-item {
  flex: 1;
}

.calendar-item-delete {
  flex-shrink: 0;
  width: 2.25rem;
  height: 2.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1rem;
}

.calendar-item-delete:hover:not(:disabled) {
  border-color: var(--danger, #dc2626);
  background: #fef2f2;
}

.calendar-item-delete:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

.calendar-item {
  width: 100%;
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
  text-align: left;
  font: inherit;
}

.calendar-item:hover {
  border-color: var(--primary);
  box-shadow: var(--shadow-sm);
}

.calendar-item.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.calendar-color {
  width: 1rem;
  height: 1rem;
  border-radius: 50%;
  flex-shrink: 0;
}

.calendar-info {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.calendar-name {
  font-weight: 500;
  color: var(--gray-900);
}

.calendar-badge {
  padding: 0.125rem 0.5rem;
  background: var(--primary);
  color: white;
  font-size: 0.75rem;
  border-radius: 9999px;
  font-weight: 500;
}

.selected-icon {
  color: var(--primary);
  font-size: 1.25rem;
  font-weight: 700;
}

.create-calendar-btn {
  width: 100%;
  padding: 0.875rem;
  background: white;
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius-sm);
  color: var(--primary);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

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

.create-calendar-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.calendar-name-input {
  padding: 0.875rem 1rem;
  border: 2px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  font-size: 1rem;
  transition: var(--transition);
}

.calendar-name-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.1);
}

.form-actions {
  display: flex;
  gap: 0.75rem;
}

/* Buttons */
.btn-primary, .btn-secondary, .btn-danger {
  padding: 0.75rem 1.5rem;
  border-radius: var(--border-radius-sm);
  font-weight: 500;
  font-size: 0.9375rem;
  cursor: pointer;
  transition: var(--transition);
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

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

.btn-primary:hover:not(:disabled) {
  background: var(--primary-hover);
  box-shadow: var(--shadow);
}

.btn-secondary {
  background: white;
  color: var(--gray-700);
  border: 2px solid var(--gray-300);
}

.btn-secondary:hover:not(:disabled) {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

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

.btn-danger:hover:not(:disabled) {
  background: var(--danger-hover);
  box-shadow: var(--shadow);
}

.btn-primary:disabled, .btn-secondary:disabled, .btn-danger:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.btn-icon {
  font-size: 1.125rem;
}

/* Connected Actions */
.connected-actions {
  margin-top: 1.5rem;
}

.target-calendar-panel {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  margin-bottom: 1rem;
}

.action-buttons {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.btn-sync, .btn-clear, .btn-disconnect {
  flex: 1;
  min-width: 160px;
}

/* Sync Progress */
.sync-progress {
  padding: 1.5rem;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  border-radius: var(--border-radius);
  color: white;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-lg);
}

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

.progress-title {
  font-size: 1.125rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.progress-stats {
  font-size: 1.25rem;
  font-weight: 700;
}

.progress-bar-container {
  height: 2rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 9999px;
  overflow: hidden;
  margin-bottom: 1rem;
  position: relative;
}

.progress-bar-fill {
  height: 100%;
  background: linear-gradient(90deg, #34a853 0%, #4caf50 100%);
  border-radius: 9999px;
  transition: width 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: flex-end;
  padding-right: 1rem;
  min-width: 3rem;
}

.progress-percentage {
  font-weight: 700;
  font-size: 0.875rem;
}

.current-event {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem;
  background: rgba(255, 255, 255, 0.15);
  border-radius: var(--border-radius-sm);
  margin-bottom: 1rem;
}

.event-icon {
  font-size: 1.5rem;
}

.event-details {
  flex: 1;
}

.event-student {
  font-weight: 600;
  margin-bottom: 0.25rem;
}

.event-time {
  font-size: 0.875rem;
  opacity: 0.9;
}

.progress-summary {
  display: flex;
  gap: 1rem;
  margin-top: 1rem;
}

.stat {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
}

.stat-icon {
  font-weight: 700;
}

.completion-message {
  margin-top: 1rem;
  padding: 0.75rem;
  background: rgba(255, 255, 255, 0.2);
  border-radius: var(--border-radius-sm);
  text-align: center;
  font-weight: 500;
}

/* Schedule Emulator */
.schedule-emulator {
  padding: 1.5rem;
  background: white;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow);
}

.emulator-header {
  margin-bottom: 1.5rem;
}

.emulator-header h3 {
  margin: 0 0 0.5rem 0;
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
}

.emulator-description {
  margin: 0;
  color: var(--gray-600);
  font-size: 0.9375rem;
}

.bulk-actions {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: #eff6ff;
  border-radius: var(--border-radius-sm);
  margin-bottom: 1rem;
}

.selection-count {
  flex: 1;
  font-weight: 500;
  color: var(--primary);
}

.schedule-list {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
  margin-bottom: 1rem;
}

.schedule-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: white;
  border: 2px solid var(--gray-200);
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.schedule-item:hover {
  box-shadow: var(--shadow-sm);
}

.schedule-item.synced {
  background: #f0fdf4;
  border-color: #bbf7d0;
}

.schedule-item.selected {
  border-color: var(--primary);
  background: #eff6ff;
}

.item-checkbox input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.item-content {
  flex: 1;
}

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

.item-title {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.student-name {
  font-weight: 600;
  color: var(--gray-900);
}

.class-type-badge {
  padding: 0.25rem 0.625rem;
  background: var(--gray-100);
  color: var(--gray-700);
  font-size: 0.75rem;
  border-radius: 9999px;
  font-weight: 500;
}

.sync-status {
  display: flex;
  align-items: center;
}

.status-badge {
  padding: 0.25rem 0.75rem;
  font-size: 0.75rem;
  border-radius: 9999px;
  font-weight: 500;
}

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

.status-badge.not-synced {
  background: var(--gray-100);
  color: var(--gray-600);
}

.item-details {
  display: flex;
  flex-direction: column;
  gap: 0.375rem;
}

.detail-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.detail-icon {
  font-size: 1rem;
}

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

.resync-btn {
  padding: 0.5rem;
  background: white;
  border: 2px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  cursor: pointer;
  transition: var(--transition);
  font-size: 1.25rem;
}

.resync-btn:hover:not(:disabled) {
  border-color: var(--primary);
  background: #eff6ff;
}

.resync-btn:disabled {
  opacity: 0.5;
  cursor: not-allowed;
}

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
  color: var(--gray-500);
}

.empty-icon {
  font-size: 3rem;
  margin-bottom: 1rem;
}

.emulator-footer {
  display: flex;
  justify-content: center;
  margin-top: 1rem;
}

.refresh-btn {
  padding: 0.75rem 1.5rem;
  background: white;
  border: 2px solid var(--gray-300);
  border-radius: var(--border-radius-sm);
  color: var(--gray-700);
  font-weight: 500;
  cursor: pointer;
  transition: var(--transition);
}

.refresh-btn:hover {
  background: var(--gray-50);
  border-color: var(--gray-400);
}

/* Disconnect Flow Modal */
.disconnect-flow {
  position: fixed;
  z-index: 1000;
}

.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
  animation: fadeIn 0.2s ease;
}

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

.modal-content {
  background: white;
  border-radius: var(--border-radius);
  max-width: 500px;
  width: 100%;
  box-shadow: 0 20px 25px -5px rgba(0, 0, 0, 0.1);
  animation: slideUp 0.3s ease;
}

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

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1.5rem;
  border-bottom: 1px solid var(--gray-200);
}

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

.close-btn {
  background: none;
  border: none;
  font-size: 1.75rem;
  color: var(--gray-400);
  cursor: pointer;
  line-height: 1;
  padding: 0;
  width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: var(--border-radius-sm);
  transition: var(--transition);
}

.close-btn:hover {
  background: var(--gray-100);
  color: var(--gray-600);
}

.modal-body {
  padding: 1.5rem;
}

.warning-box {
  display: flex;
  gap: 1rem;
  padding: 1rem;
  background: #fef3c7;
  border: 1px solid #fde047;
  border-radius: var(--border-radius-sm);
  margin-bottom: 1.5rem;
}

.warning-icon {
  font-size: 1.5rem;
  flex-shrink: 0;
}

.warning-content h4 {
  margin: 0 0 0.5rem 0;
  font-size: 1rem;
  font-weight: 600;
  color: var(--gray-900);
}

.warning-content p {
  margin: 0;
  color: var(--gray-700);
  font-size: 0.9375rem;
}

.disconnect-options {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.option-item {
  padding: 1rem;
  background: var(--gray-50);
  border-radius: var(--border-radius-sm);
}

.checkbox-label {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  cursor: pointer;
  margin-bottom: 0.5rem;
}

.checkbox-label input[type="checkbox"] {
  width: 1.25rem;
  height: 1.25rem;
  cursor: pointer;
}

.checkbox-text {
  font-weight: 500;
  color: var(--gray-900);
}

.option-description {
  margin: 0;
  padding-left: 2rem;
  font-size: 0.875rem;
  color: var(--gray-600);
}

.info-box {
  padding: 0.875rem 1rem;
  background: #eff6ff;
  border-radius: var(--border-radius-sm);
  font-size: 0.875rem;
  color: var(--gray-700);
}

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  padding: 1.5rem;
  border-top: 1px solid var(--gray-200);
}

.selection-actions {
  display: flex;
  gap: 0.75rem;
  margin-top: 1.5rem;
}

.selection-actions .btn-primary,
.selection-actions .btn-secondary {
  flex: 1;
}

/* Connection Status */
.connection-status {
  margin-bottom: 1.5rem;
}

.connection-status.disconnected {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  background: var(--gray-50);
  border: 2px dashed var(--gray-300);
  border-radius: var(--border-radius);
}

.connection-status.connected {
  padding: 1.5rem;
  background: linear-gradient(135deg, #dcfce7 0%, #d1fae5 100%);
  border: 2px solid #86efac;
  border-radius: var(--border-radius);
}

.status-icon {
  font-size: 2rem;
}

.status-content {
  flex: 1;
}

.status-title {
  margin: 0 0 0.25rem 0;
  font-size: 1.125rem;
  font-weight: 600;
  color: var(--gray-900);
}

.status-description {
  margin: 0;
  color: var(--gray-600);
  font-size: 0.9375rem;
}

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

.provider-info {
  display: flex;
  align-items: center;
  gap: 1rem;
  flex: 1;
}

.provider-icon {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 700;
  color: white;
  flex-shrink: 0;
}

.provider-icon.google {
  background: linear-gradient(135deg, #4285f4 0%, #34a853 100%);
}

.provider-icon.outlook {
  background: linear-gradient(135deg, #0078d4 0%, #106ebe 100%);
}

.provider-details {
  flex: 1;
}

.calendar-name {
  margin: 0.25rem 0 0 0;
  font-size: 0.875rem;
  color: var(--gray-700);
}

.connected-badge {
  padding: 0.5rem 1rem;
  background: rgba(22, 101, 52, 0.2);
  color: #166534;
  font-weight: 600;
  border-radius: 9999px;
  font-size: 0.875rem;
}

.status-stats {
  display: flex;
  gap: 2rem;
}

.stat-item {
  flex: 1;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-700);
  margin-bottom: 0.25rem;
}

.stat-value {
  font-size: 1.5rem;
  font-weight: 700;
  color: #166534;
}

.no-status {
  color: var(--gray-500);
  text-align: center;
  padding: 1rem;
}

/* Responsive */
@media (max-width: 640px) {
  .provider-buttons {
    flex-direction: column;
  }
  
  .provider-btn {
    min-width: 100%;
  }
  
  .action-buttons {
    flex-direction: column;
  }
  
  .btn-sync, .btn-disconnect {
    min-width: 100%;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .bulk-actions {
    flex-direction: column;
    align-items: stretch;
  }

  .status-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 1rem;
  }

  .status-stats {
    flex-direction: column;
    gap: 1rem;
  }
}
