/* 歷史數據查詢對話框樣式 */

/* 對話框背景遮罩 */
.history-dialog-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.6);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 2000;
  animation: fadeIn 0.3s ease;
}

.history-dialog-overlay.show {
  display: flex;
}

/* 對話框容器 */
.history-dialog {
  background: white;
  border-radius: 12px;
  width: 90%;
  max-width: 900px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.2);
  animation: slideUp 0.3s ease;
  overflow: hidden;
}

/* 對話框標題區 */
.history-dialog-header {
  background: linear-gradient(135deg, #79b450 0%, #6da241 100%);
  color: white;
  padding: 20px 24px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.history-dialog-title {
  font-size: 18px;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 8px;
  margin: 0;
}

.history-dialog-close {
  background: rgba(255, 255, 255, 0.2);
  border: none;
  color: white;
  width: 32px;
  height: 32px;
  border-radius: 50%;
  cursor: pointer;
  font-size: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s ease;
}

.history-dialog-close:hover {
  background: rgba(255, 255, 255, 0.3);
  transform: scale(1.1);
}

/* 對話框主體內容 */
.history-dialog-body {
  padding: 24px;
  overflow-y: auto;
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* 設備資訊區 */
.history-device-info {
  background: #f8f9fa;
  padding: 16px;
  border-radius: 8px;
  border-left: 4px solid #79b450;
}

.history-device-info-item {
  font-size: 14px;
  color: #666;
  margin-bottom: 6px;
  line-height: 1.5;
}

.history-device-info-item:last-child {
  margin-bottom: 0;
}

.history-device-info-item strong {
  color: #333;
  font-weight: 600;
}

/* 查詢控制區 */
.history-query-controls {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  padding: 20px;
}

.history-query-row {
  display: flex;
  gap: 12px;
  margin-bottom: 16px;
  align-items: center;
  flex-wrap: wrap;
}

.history-query-row:last-child {
  margin-bottom: 0;
}

.history-query-row label {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  min-width: 100px;
}

.history-datetime-input {
  flex: 1;
  min-width: 200px;
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  transition: all 0.2s ease;
}

.history-datetime-input:focus {
  outline: none;
  border-color: #79b450;
  box-shadow: 0 0 0 3px rgba(121, 180, 80, 0.1);
}

/* 快速選擇按鈕 */
.history-quick-buttons {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.history-quick-btn {
  padding: 8px 16px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #333;
}

.history-quick-btn:hover {
  background: #79b450;
  color: white;
  border-color: #79b450;
}

/* 排序選擇下拉框 */
.history-order-select {
  padding: 8px 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  background: white;
  min-width: 180px;
  transition: all 0.2s ease;
}

.history-order-select:focus {
  outline: none;
  border-color: #79b450;
  box-shadow: 0 0 0 3px rgba(121, 180, 80, 0.1);
}

/* 查詢按鈕 */
.history-query-btn {
  padding: 8px 24px;
  background: linear-gradient(135deg, #79b450 0%, #6da241 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 6px rgba(121, 180, 80, 0.3);
}

.history-query-btn:hover {
  box-shadow: 0 4px 12px rgba(121, 180, 80, 0.5);
  transform: translateY(-1px);
}

.history-query-btn:active {
  transform: translateY(0);
}

/* 資料表格容器 */
.history-table-container {
  background: white;
  border: 1px solid #e0e0e0;
  border-radius: 8px;
  overflow: hidden;
  flex: 1;
  display: flex;
  flex-direction: column;
  min-height: 300px;
}

.history-table-wrapper {
  overflow-x: auto;
  overflow-y: auto;
  max-height: 400px;
  flex: 1;
}

/* 資料表格 */
.history-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 14px;
}

.history-table thead {
  position: sticky;
  top: 0;
  background: #f8f9fa;
  z-index: 10;
}

.history-table th {
  padding: 12px 16px;
  text-align: left;
  font-weight: 600;
  color: #333;
  border-bottom: 2px solid #79b450;
  white-space: nowrap;
}

.history-table td {
  padding: 12px 16px;
  border-bottom: 1px solid #f0f0f0;
  color: #666;
}

.history-table tr:hover {
  background: #f8f9fa;
}

.history-table tr:last-child td {
  border-bottom: none;
}

/* 空資料狀態 */
.history-empty-state {
  padding: 60px 20px;
  text-align: center;
  color: #999;
}

.history-empty-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.5;
}

.history-empty-text {
  font-size: 14px;
  color: #999;
}

/* Loading 狀態 */
.history-loading {
  padding: 60px 20px;
  text-align: center;
}

.history-loading-spinner {
  width: 40px;
  height: 40px;
  border: 4px solid #f3f3f3;
  border-top: 4px solid #79b450;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 16px;
}

.history-loading-text {
  font-size: 14px;
  color: #666;
}

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

/* 分頁控制 */
.history-pagination {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  flex-shrink: 0;
}

.history-pagination-controls {
  display: flex;
  align-items: center;
  gap: 16px;
}

.history-pagination-btn {
  padding: 6px 16px;
  background: white;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 13px;
  cursor: pointer;
  transition: all 0.2s ease;
  color: #333;
}

.history-pagination-btn:hover:not(:disabled) {
  background: #79b450;
  color: white;
  border-color: #79b450;
}

.history-pagination-btn:disabled {
  opacity: 0.4;
  cursor: not-allowed;
}

.history-pagination-info {
  font-size: 13px;
  color: #666;
}

.history-record-count {
  font-size: 13px;
  color: #999;
}

/* 對話框底部按鈕區 */
.history-dialog-footer {
  padding: 16px 24px;
  background: #f8f9fa;
  border-top: 1px solid #e0e0e0;
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  flex-shrink: 0;
}

.history-export-btn {
  padding: 10px 20px;
  background: linear-gradient(135deg, #79b450 0%, #6da241 100%);
  color: white;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  align-items: center;
  gap: 6px;
}

.history-export-btn:hover {
  box-shadow: 0 4px 12px rgba(121, 180, 80, 0.5);
  transform: translateY(-1px);
}

.history-close-btn {
  padding: 10px 20px;
  background: #f0f0f0;
  color: #666;
  border: none;
  border-radius: 6px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

.history-close-btn:hover {
  background: #e0e0e0;
}

/* 響應式設計 */
@media (max-width: 768px) {
  .history-dialog {
    width: 95%;
    max-height: 95vh;
  }

  .history-dialog-header {
    padding: 16px 20px;
  }

  .history-dialog-title {
    font-size: 16px;
  }

  .history-dialog-body {
    padding: 16px;
    gap: 16px;
  }

  .history-query-controls {
    padding: 16px;
  }

  .history-query-row {
    flex-direction: column;
    align-items: stretch;
  }

  .history-query-row label {
    min-width: auto;
  }

  .history-datetime-input {
    min-width: auto;
  }

  .history-quick-buttons {
    flex-direction: column;
  }

  .history-quick-btn {
    width: 100%;
  }

  .history-order-select {
    width: 100%;
  }

  .history-table-wrapper {
    max-height: 300px;
  }

  .history-table {
    font-size: 12px;
  }

  .history-table th,
  .history-table td {
    padding: 8px 12px;
  }

  .history-pagination {
    flex-direction: column;
    gap: 12px;
    align-items: stretch;
  }

  .history-pagination-controls {
    justify-content: space-between;
    width: 100%;
  }

  .history-dialog-footer {
    padding: 12px 16px;
    flex-direction: column;
  }

  .history-export-btn,
  .history-close-btn {
    width: 100%;
    justify-content: center;
  }
}

/* 動畫效果 */
@keyframes fadeIn {
  from {
    opacity: 0;
  }
  to {
    opacity: 1;
  }
}

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