/**
 * SharePoint Modal - Mobile First Design
 * Specific styles for SharePoint configuration and data display modals
 */

/* SharePoint Configuration Modal */
.sharepoint-config-modal .modal-content {
  /* Inherits base modal styles */
}

.sharepoint-config-form {
  display: flex;
  flex-direction: column;
  gap: var(--form-gap);
}

.sharepoint-config-form .form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.sharepoint-config-form .form-label {
  font-size: 14px;
  font-weight: 500;
  color: #374151;
  margin: 0;
}

.sharepoint-config-form .form-input {
  width: 100%;
  padding: 12px 16px;
  font-size: 16px; /* Prevents zoom on iOS */
  border: 1px solid #d1d5db;
  border-radius: 8px;
  background: white;
  transition: all 0.2s ease;
  min-height: 44px; /* Touch-friendly */
}

.sharepoint-config-form .form-input:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.1);
}

.sharepoint-config-form .form-input::placeholder {
  color: #9ca3af;
}

/* Validation messages */
.sharepoint-validation-messages {
  font-size: 14px;
  color: #dc2626;
  margin-top: 8px;
  display: none;
}

.sharepoint-validation-messages.show {
  display: block;
}

/* SharePoint Data Display Modal */
.sharepoint-data-modal .modal-content {
  /* Inherits base modal styles */
}

/* SharePoint Full Width Grid - spans both columns on desktop */
.sharepoint-full-width-grid {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

/* Tablet and up: Full width (spans both columns) */
@media (min-width: 768px) {
  .sharepoint-full-width-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column that spans full width */
  }
}

/* Selected Sources Section */
.selected-sources-card {
  margin-bottom: var(--card-gap);
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
}

.selected-sources-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  cursor: pointer;
  user-select: none;
}

.selected-sources-title {
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
  flex: 1;
}

.selected-sources-count {
  font-size: 12px;
  color: #6b7280;
  margin-left: 8px;
}

.collapse-button {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #1f2937;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  min-width: 20px;
  text-align: center;
  transition: all 0.2s ease;
}

.collapse-button:hover {
  background: #e2e8f0;
}

.selected-sources-body {
  padding: 12px 16px;
  display: block; /* Default visible */
}

.selected-sources-body.collapsed {
  display: none;
}

/* Selected Sources Table */
.selected-table-container {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: white;
  -webkit-overflow-scrolling: touch;
}

.selected-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 0;
  font-size: 14px;
}

.selected-table th {
  padding: 8px 4px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
  color: #0f172a;
  text-align: center;
  font-weight: 600;
  background: #f8fafc;
  position: sticky;
  top: 0;
  z-index: 1;
}

.selected-table td {
  padding: 8px 4px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
}

/* File Type Badges */
.file-type-badge {
  display: inline-flex;
  align-items: center;
  padding: 2px 6px;
  border-radius: 999px;
  font-size: 10px;
  font-weight: 500;
  white-space: nowrap;
  gap: 4px;
}

.file-type-badge.pdf {
  background: #fef2f2;
  border: 1px solid #fecaca;
  color: #991b1b;
}

.file-type-badge.docx {
  background: #f0f9ff;
  border: 1px solid #bae6fd;
  color: #0369a1;
}

.file-type-badge.xlsx {
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  color: #166534;
}

.file-type-badge.ppt {
  background: #fefce8;
  border: 1px solid #fde68a;
  color: #a16207;
}

.file-type-badge.txt {
  background: #f8fafc;
  border: 1px solid #e2e8f0;
  color: #475569;
}

.file-type-badge.file {
  background: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #64748b;
}

/* File Type Icons */
.file-type-icon {
  font-size: 16px;
  line-height: 1;
}

/* Action Buttons */
.action-button {
  background: linear-gradient(90deg, #dc2626, #ef4444);
  border: 1px solid #b91c1c;
  color: #fff;
  padding: 4px 8px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 11px;
  white-space: nowrap;
  transition: all 0.2s ease;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.action-button:hover {
  background: linear-gradient(90deg, #b91c1c, #dc2626);
  transform: translateY(-1px);
}

/* SharePoint Folder Browser */
.sharepoint-folder-browser {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: white;
  -webkit-overflow-scrolling: touch;
}

.folder-tree {
  list-style: none;
  padding: 0;
  margin: 0;
}

.folder-item {
  margin: 0;
  padding: 0;
}

.folder-node {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 4px 0;
  min-height: 44px; /* Touch-friendly */
}

.folder-twisty {
  background: #f1f5f9;
  border: 1px solid #e2e8f0;
  color: #1f2937;
  border-radius: 8px;
  padding: 2px 6px;
  font-size: 12px;
  cursor: pointer;
  min-width: 20px;
  text-align: center;
  transition: all 0.2s ease;
  display: none; /* Hidden by default for files */
}

.folder-twisty:hover {
  background: #e2e8f0;
}

.folder-twisty.visible {
  display: block;
}

.folder-icon {
  font-size: 14px;
  min-width: 20px;
  text-align: center;
}

.folder-name {
  background: transparent;
  border: none;
  color: #1f2937;
  cursor: pointer;
  text-align: left;
  flex: 1;
  font-size: 14px;
  padding: 2px 4px;
  border-radius: 4px;
  transition: all 0.2s ease;
  min-height: 32px;
  display: flex;
  align-items: center;
}

.folder-name:hover {
  text-decoration: underline;
  background: #f9fafb;
}

.folder-name:disabled {
  cursor: default;
  color: #374151;
}

.folder-name:disabled:hover {
  text-decoration: none;
  background: transparent;
}

.folder-train-button {
  background: transparent;
  border: none;
  color: #10b981;
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  margin-left: auto;
  transition: all 0.2s ease;
  min-height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.folder-train-button:hover {
  background: #ecfdf5;
  color: #059669;
}

.folder-train-button:disabled {
  background: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

.folder-children {
  margin-left: 20px;
  display: none;
}

.folder-children.expanded {
  display: block;
}

/* Empty folder message */
.empty-folder {
  padding: 8px;
  color: #64748b;
  font-style: italic;
  font-size: 14px;
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  .selected-table th,
  .selected-table td {
    padding: 6px 2px;
    font-size: 12px;
  }
  
  .file-type-badge {
    font-size: 9px;
    padding: 1px 4px;
  }
  
  .action-button {
    font-size: 10px;
    padding: 3px 6px;
    min-height: 28px;
  }
  
  .folder-node {
    padding: 6px 0;
  }
  
  .folder-name {
    font-size: 13px;
  }
  
  .folder-train-button {
    font-size: 11px;
    padding: 1px 4px;
    min-height: 28px;
  }
}

/* Tablet and up adjustments */
@media (min-width: 768px) {
  .selected-table th,
  .selected-table td {
    padding: 8px 4px;
    font-size: 14px;
  }
  
  .file-type-badge {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  .action-button {
    font-size: 11px;
    padding: 4px 8px;
    min-height: 32px;
  }
  
  .folder-node {
    padding: 4px 0;
  }
  
  .folder-name {
    font-size: 14px;
  }
  
  .folder-train-button {
    font-size: 12px;
    padding: 2px 6px;
    min-height: 32px;
  }
}

/* Progress indicators */
.sharepoint-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #6b7280;
  font-size: 14px;
}

.sharepoint-loading::before {
  content: '';
  width: 20px;
  height: 20px;
  border: 2px solid #e5e7eb;
  border-top: 2px solid #3b82f6;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-right: 12px;
}

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

/* Error states */
.sharepoint-error {
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin: 12px 0;
}

/* Success states */
.sharepoint-success {
  color: #059669;
  background: #f0fdf4;
  border: 1px solid #bbf7d0;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin: 12px 0;
}
