/**
 * iMIS Modal - Mobile First Design
 * Specific styles for iMIS training menu modal
 */

/* iMIS Modal Container - inherits base modal styles from modal-base.css */

/* iMIS Grid Layout - Mobile First */
.imis-grid {
  display: flex;
  flex-direction: column;
  gap: var(--card-gap);
}

/* Tablet and up: Two columns */
@media (min-width: 768px) {
  .imis-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
  }
}

/* iMIS Cards */
.imis-card {
  background: white;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  box-shadow: 0 8px 24px rgba(15, 23, 42, 0.06);
  overflow: hidden;
}

.imis-card-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.imis-card-body {
  padding: 12px 16px;
  display: flex;
  flex-direction: column;
  gap: 12px;
}

/* Tablet and up: Larger card padding */
@media (min-width: 768px) {
  .imis-card-header {
    padding: 16px 20px;
    font-size: 16px;
  }
  
  .imis-card-body {
    padding: 16px 20px;
    gap: 16px;
  }
}

/* RiSE and IQA Lists */
.imis-list {
  max-height: 360px;
  overflow: auto;
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  background: white;
  -webkit-overflow-scrolling: touch;
}

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

.imis-tree-item {
  margin: 0;
  padding: 0;
}

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

.imis-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 content items */
}

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

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

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

.imis-name-button {
  background: transparent;
  border: none;
  color: #0b57d0;
  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;
}

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

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

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

.imis-train-button {
  background: transparent;
  border: none;
  color: #059669;
  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;
}

.imis-train-button:hover {
  background: #ecfdf5;
  color: #047857;
}

.imis-train-button:disabled {
  background: #d1fae5;
  color: #059669;
  cursor: not-allowed;
}

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

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

/* 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;
}

/* Type Badges */
.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;
}

.type-badge.rise {
  background: #eef2ff;
  border: 1px solid #e0e7ff;
  color: #3730a3;
}

.type-badge.iqa {
  background: #f3e8ff;
  border: 1px solid #c4b5fd;
  color: #7c3aed;
}

/* Type Icons */
.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);
}

/* Section Headers in Table */
.section-header {
  padding: 12px 10px 8px 10px;
  border-bottom: 1px solid #e5e7eb;
  vertical-align: middle;
  background: #f8fafc;
  font-weight: 600;
  text-align: left;
}

.section-header.rise {
  color: #1e40af;
}

.section-header.iqa {
  color: #7c3aed;
}

/* Mobile-specific adjustments */
@media (max-width: 767px) {
  .selected-table th,
  .selected-table td {
    padding: 6px 2px;
    font-size: 12px;
  }
  
  .type-badge {
    font-size: 9px;
    padding: 1px 4px;
  }
  
  .action-button {
    font-size: 10px;
    padding: 3px 6px;
    min-height: 28px;
  }
  
  .imis-tree-node {
    padding: 6px 0;
  }
  
  .imis-name-button {
    font-size: 13px;
  }
  
  .imis-train-button {
    font-size: 11px;
    padding: 1px 4px;
    min-height: 28px;
  }
  
  /* Hide less important columns on mobile */
  .table-cell-mobile-hidden {
    display: none;
  }
}

/* Tablet and up adjustments */
@media (min-width: 768px) {
  .selected-table th,
  .selected-table td {
    padding: 8px 4px;
    font-size: 14px;
  }
  
  .type-badge {
    font-size: 10px;
    padding: 2px 6px;
  }
  
  .action-button {
    font-size: 11px;
    padding: 4px 8px;
    min-height: 32px;
  }
  
  .imis-tree-node {
    padding: 4px 0;
  }
  
  .imis-name-button {
    font-size: 14px;
  }
  
  .imis-train-button {
    font-size: 12px;
    padding: 2px 6px;
    min-height: 32px;
  }
  
  /* Show more columns on tablet+ */
  .table-cell-mobile-hidden {
    display: table-cell;
  }
}

/* Progress Card */
.progress-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);
  display: none;
}

.progress-card.visible {
  display: block;
}

.progress-header {
  padding: 14px 16px;
  border-bottom: 1px solid #e5e7eb;
  background: #f8fafc;
  font-size: 14px;
  font-weight: 600;
  color: #0f172a;
  margin: 0;
}

.progress-body {
  padding: 12px 16px;
}

.progress-title {
  margin: 0 0 8px 0;
  font-size: 14px;
  color: #0f172a;
}

.progress-detail {
  font-size: 13px;
  color: #334155;
  margin: 6px 0;
}

.progress-bar-container {
  width: 100%;
  height: 10px;
  background: #f1f5f9;
  border-radius: 999px;
  overflow: hidden;
  border: 1px solid #e2e8f0;
}

.progress-bar {
  display: block;
  height: 100%;
  background: linear-gradient(90deg, #10b981, #22c55e);
  width: 0%;
  transition: width 0.3s ease;
}

/* Tablet and up: Larger progress card padding */
@media (min-width: 768px) {
  .progress-header {
    padding: 16px 20px;
    font-size: 16px;
  }
  
  .progress-body {
    padding: 16px 20px;
  }
  
  .progress-title {
    font-size: 16px;
  }
  
  .progress-detail {
    font-size: 14px;
  }
}

/* Loading and Error States */
.imis-loading {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  color: #6b7280;
  font-size: 14px;
}

.imis-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 */
.imis-error {
  color: #dc2626;
  background: #fef2f2;
  border: 1px solid #fecaca;
  padding: 12px;
  border-radius: 8px;
  font-size: 14px;
  margin: 12px 0;
}

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

/* Empty state */
.imis-empty {
  padding: 20px;
  text-align: center;
  color: #6b7280;
  font-style: italic;
  font-size: 14px;
}

/* Highlighted items (already trained) */
.imis-item-trained {
  background-color: #f0f9ff !important;
  border: 1px solid #0ea5e9 !important;
  border-radius: 8px !important;
  padding: 8px !important;
  margin: 4px 0 !important;
}

.imis-train-button-trained {
  background: #d1fae5 !important;
  color: #059669 !important;
  cursor: not-allowed !important;
  padding: 4px 8px !important;
  font-size: 12px !important;
  border-radius: 6px !important;
  border: 1px solid #a7f3d0 !important;
}
