/* ============================================================
   Dashboard & History Page Styles
   ============================================================ */

/* Dashboard Header Area */
.dashboard-header-bar {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 32px;
  flex-wrap: wrap;
  gap: 16px;
}

.dash-btn {
  flex: 1;
  min-width: 200px;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 16px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  font-weight: 600;
  color: var(--navy);
  text-decoration: none;
  transition: all 0.2s ease;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
}

.dash-btn:hover {
  border-color: var(--green);
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.dash-btn.disabled {
  opacity: 0.5;
  cursor: not-allowed;
  pointer-events: none;
  background: var(--bg-alt);
}

/* Controls (Search & Sort) */
.history-controls {
  display: flex;
  flex-wrap: wrap;
  gap: 16px;
  align-items: center;
}

.search-wrap {
  position: relative;
  flex: 1;
  min-width: 250px;
}

.search-wrap svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--text-secondary);
}

.search-input {
  width: 100%;
  padding: 10px 10px 10px 36px;
  border: 1px solid var(--border);
  border-radius: var(--radius-xs);
  font-size: 14px;
  background: #fff;
}

.search-input:focus {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.sort-wrap {
  display: flex;
  align-items: center;
  gap: 8px;
}

.sort-select {
  padding: 10px 16px;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  background-color: #fff;
  font-size: 14px;
  font-family: inherit;
  font-weight: 600;
  color: var(--navy);
  cursor: pointer;
  transition: all var(--transition);
  box-shadow: var(--shadow-sm);
}

.sort-select:hover, .sort-select:focus {
  border-color: var(--green);
  outline: none;
  box-shadow: 0 0 0 3px rgba(76, 175, 80, 0.1);
}

.custom-dropdown {
  position: relative;
  display: inline-block;
  height: 100%;
}

.dropdown-menu {
  position: absolute;
  top: calc(100% + 8px);
  right: 0;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-sm);
  box-shadow: var(--shadow-md);
  min-width: 220px;
  z-index: 100;
  overflow: hidden;
}

.dropdown-item {
  padding: 12px 16px;
  font-size: 14px;
  font-weight: 500;
  color: var(--navy);
  cursor: pointer;
  transition: all 0.2s;
}

.dropdown-item:hover {
  background: var(--bg-alt);
  color: var(--green);
}

.dropdown-item.selected {
  background: rgba(76, 175, 80, 0.1);
  color: var(--green);
  font-weight: 600;
}

.back-btn:hover {
  border-color: var(--green) !important;
  color: var(--green) !important;
}

/* History Grid */
.history-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
  gap: 20px;
}

/* History Card */
.history-card {
  background: #fff;
  border: 1px solid var(--border);
  border-radius: var(--radius-md);
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  transition: all 0.2s ease;
  position: relative;
}

.history-card:hover {
  border-color: var(--primary-light);
  box-shadow: var(--shadow-md);
}

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

.sim-badge {
  background: rgba(76, 175, 80, 0.1);
  color: var(--green);
  padding: 4px 8px;
  border-radius: var(--radius-xs);
  font-weight: 700;
  font-size: 14px;
  border: 1px solid rgba(76, 175, 80, 0.2);
}

.sim-badge.high {
  background: rgba(244, 67, 54, 0.1);
  color: #d32f2f;
  border-color: rgba(244, 67, 54, 0.2);
}

.sim-badge.medium {
  background: rgba(255, 152, 0, 0.1);
  color: #ed6c02;
  border-color: rgba(255, 152, 0, 0.2);
}

.card-date {
  font-size: 12px;
  color: var(--text-secondary);
}

.card-files {
  flex: 1;
  margin-bottom: 16px;
}

.file-row {
  display: flex;
  align-items: center;
  gap: 8px;
  font-family: 'JetBrains Mono', monospace;
  font-size: 13px;
  color: var(--text);
  margin-bottom: 6px;
  word-break: break-all;
}

.file-row svg {
  flex-shrink: 0;
  color: var(--text-secondary);
}

.file-extra {
  font-size: 12px;
  color: var(--text-secondary);
  font-style: italic;
  margin-top: 4px;
}

.card-actions {
  display: flex;
  gap: 8px;
  border-top: 1px solid var(--border);
  padding-top: 16px;
  justify-content: space-between;
}

.card-btn {
  flex: 1;
  padding: 8px;
  border-radius: var(--radius-xs);
  border: 1px solid transparent;
  background: var(--bg-alt);
  color: var(--text);
  font-size: 13px;
  font-weight: 600;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  cursor: pointer;
  transition: all 0.2s ease;
}

.card-btn:hover {
  background: var(--border);
}

.card-btn.delete {
  color: #d32f2f;
  background: rgba(244, 67, 54, 0.05);
}

.card-btn.delete:hover {
  background: rgba(244, 67, 54, 0.1);
  border-color: rgba(244, 67, 54, 0.2);
}

.btn-spinner {
  width: 14px;
  height: 14px;
  border: 2px solid currentColor;
  border-right-color: transparent;
  border-radius: 50%;
  animation: spin 0.75s linear infinite;
  display: inline-block;
  vertical-align: middle;
}

/* Empty State */
.history-empty {
  text-align: center;
  padding: 60px 20px;
  background: #fff;
  border: 1px dashed var(--border);
  border-radius: var(--radius-md);
}

.empty-icon {
  width: 48px;
  height: 48px;
  color: var(--text-secondary);
  margin-bottom: 16px;
  opacity: 0.5;
}

.history-empty h3 {
  margin-bottom: 8px;
  color: var(--navy);
}

.history-empty p {
  color: var(--text-secondary);
  margin-bottom: 24px;
}

/* SVG Chart Bar */
.chart-bar {
  transition: all 0.2s ease;
  cursor: pointer;
}
.chart-bar:hover {
  filter: brightness(1.1);
  transform: translateY(-2px);
}

/* Loading State & Spinner */
.history-loading {
  text-align: center;
  padding: 60px 20px;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
}

.duotone-spinner {
  width: 48px;
  height: 48px;
  border: 4px solid var(--blue);
  border-top: 4px solid var(--green);
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

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

/* Error State */
.history-error {
  text-align: center;
  padding: 20px;
  color: #d32f2f;
  background: rgba(244, 67, 54, 0.05);
  border-radius: var(--radius-xs);
  margin-bottom: 20px;
}

/* Modal Styles */
.modal {
  position: fixed;
  inset: 0;
  background: rgba(15, 23, 42, 0.4);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(4px);
  padding: 20px;
}

.modal.hidden {
  display: none !important;
}

.modal-content {
  background: #ffffff;
  border-radius: var(--radius-lg);
  padding: 32px;
  box-shadow: var(--shadow-lg);
  max-height: 90vh;
  overflow-y: auto;
  position: relative;
}
