/* Base styles */
:root {
  --primary-color: #4a6da7;
  --secondary-color: #304878;
  --accent-color: #ff7b25;
  --light-color: #f0f5ff;
  --dark-color: #1e2749;
  --success-color: #48a75a;
  --warning-color: #ffc107;
  --danger-color: #dc3545;
  --gray-color: #6c757d;
  --light-gray-color: #e9ecef;
}

* {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}

body {
  font-family: "Segoe UI", Tahoma, Geneva, Verdana, sans-serif;
  line-height: 1.6;
  color: var(--dark-color);
  background-color: var(--light-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

header {
  background-color: var(--primary-color);
  color: white;
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.1);
}

header h1 {
  font-size: 2rem;
  margin-bottom: 0.5rem;
}

main {
  flex: 1;
  padding: 1.5rem;
  max-width: 1200px;
  margin: 0 auto;
  width: 100%;
}

footer {
  background-color: var(--dark-color);
  color: var(--light-color);
  padding: 1rem;
  text-align: center;
  font-size: 0.9rem;
}

/* Mode selector */
.mode-selector {
  display: flex;
  justify-content: center;
  gap: 1rem;
  margin-bottom: 2rem;
}

.mode-button {
  padding: 0.75rem 1.5rem;
  background-color: var(--light-gray-color);
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  transition: all 0.3s ease;
  text-decoration: none;
  color: var(--dark-color);
}

.mode-button:hover {
  background-color: var(--gray-color);
  color: white;
}

.mode-button.active {
  background-color: var(--primary-color);
  color: white;
}

/* Sections */
.section {
  background-color: white;
  border-radius: 8px;
  padding: 2rem;
  margin-bottom: 2rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.section h2 {
  color: var(--secondary-color);
  margin-bottom: 1rem;
}

.section p {
  margin-bottom: 1.5rem;
  color: var(--gray-color);
}

.hidden {
  display: none;
}

/* Control panel */
.control-panel {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
}

.primary-button,
.secondary-button {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 4px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
}

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

.primary-button:hover {
  background-color: var(--secondary-color);
}

.secondary-button {
  background-color: var(--light-gray-color);
  color: var(--dark-color);
}

.secondary-button:hover {
  background-color: var(--gray-color);
  color: white;
}

button:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Progress container */
.progress-container {
  border: 1px solid var(--light-gray-color);
  padding: 1.5rem;
  border-radius: 4px;
  margin-bottom: 1.5rem;
}

.frequency-display,
.frequency-range {
  margin-bottom: 1rem;
  font-size: 1.1rem;
}

.frequency-display span:nth-child(2),
.frequency-range span:nth-child(2) {
  font-weight: bold;
  color: var(--primary-color);
}

.progress-bar {
  height: 20px;
  background-color: var(--light-gray-color);
  border-radius: 10px;
  overflow: hidden;
  margin-top: 1rem;
}

.progress {
  height: 100%;
  background-color: var(--primary-color);
  width: 0;
  transition: width 0.3s ease;
}

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

.status {
  font-size: 1.1rem;
  margin-bottom: 1rem;
}

.status span {
  font-weight: bold;
  color: var(--primary-color);
}

.listening-indicator {
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.sound-wave {
  width: 100%;
  height: 40px;
  background: linear-gradient(
    to bottom,
    var(--light-gray-color) 50%,
    var(--light-color) 50%
  );
  position: relative;
}

.sound-wave.active {
  background: linear-gradient(
    to bottom,
    var(--primary-color) 50%,
    var(--light-color) 50%
  );
  animation: wave 1.5s infinite ease-in-out;
}

@keyframes wave {
  0%,
  100% {
    height: 10px;
  }
  50% {
    height: 40px;
  }
}

/* Results section */
.results-summary {
  margin-bottom: 2rem;
}

/* Speaker grades styling */
.speaker-grades {
  margin-bottom: 2rem;
}

.score-cards {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  justify-content: space-between;
  margin-top: 1rem;
}

.score-card {
  flex: 1;
  min-width: 150px;
  background-color: white;
  border-radius: 8px;
  padding: 1.5rem;
  text-align: center;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  transition: transform 0.2s ease;
}

.score-card:hover {
  transform: translateY(-5px);
}

.score-title {
  font-size: 1.2rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
  color: var(--secondary-color);
}

.score-value {
  font-size: 2.5rem;
  font-weight: bold;
  margin-bottom: 0.5rem;
}

.score-label {
  font-size: 0.9rem;
  color: var(--gray-color);
}

.chart-container {
  width: 100%;
  height: 400px;
  margin-bottom: 2rem;
}

.range-results {
  margin-bottom: 2rem;
}

table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 1rem;
}

table th,
table td {
  padding: 0.75rem;
  border: 1px solid var(--light-gray-color);
  text-align: left;
}

table th {
  background-color: var(--primary-color);
  color: white;
}

table tr:nth-child(even) {
  background-color: var(--light-color);
}

/* Title icon styling */
.title-icon {
  height: 32px;
  width: auto;
  vertical-align: middle;
  margin-right: 10px;
}

/* Compact title styling */
.compact-title {
  display: flex;
  align-items: center;
  text-align: left;
  max-width: 1200px;
  padding-inline: 1.5rem;
  margin: 0 auto;
}

.compact-title h1 {
  font-size: 1.6rem;
  margin-bottom: 0;
  line-height: 1.2;
}

.compact-title p {
  font-size: 0.9rem;
  margin: 0;
  opacity: 0.9;
}

/* Speaker name input styling */
.speaker-name-container {
  display: flex;
  align-items: center;
  gap: 1rem;
  margin-bottom: 1.5rem;
  background-color: var(--light-color);
  padding: 1rem;
  border-radius: 4px;
}

.speaker-name-container label {
  font-weight: bold;
  color: var(--secondary-color);
}

.speaker-name-container input {
  padding: 0.5rem;
  border: 1px solid var(--light-gray-color);
  border-radius: 4px;
  font-size: 1rem;
  flex: 1;
}

/* History section styling */
.history-container {
  margin-bottom: 2rem;
}

.history-filters {
  display: flex;
  gap: 1rem;
  margin-bottom: 1rem;
}

.history-filters input,
.history-filters select {
  padding: 0.5rem;
  border: 1px solid var(--light-gray-color);
  border-radius: 4px;
  font-size: 0.9rem;
}

.history-filters input {
  flex: 1;
}

.history-list {
  border: 1px solid var(--light-gray-color);
  border-radius: 4px;
  max-height: 400px;
  overflow-y: auto;
}

.history-empty {
  padding: 2rem;
  text-align: center;
  color: var(--gray-color);
  font-style: italic;
}

.history-item {
  padding: 1rem;
  border-bottom: 1px solid var(--light-gray-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
  cursor: pointer;
  transition: background-color 0.2s ease;
}

.history-item:hover {
  background-color: var(--light-color);
}

.history-item-left {
  display: flex;
  flex-direction: column;
}

.history-item-name {
  font-weight: bold;
  color: var(--secondary-color);
  margin-bottom: 0.25rem;
}

.history-item-date {
  font-size: 0.8rem;
  color: var (--gray-color);
}

.history-item-score {
  font-weight: bold;
  font-size: 1.5rem;
}

.history-actions {
  display: flex;
  justify-content: space-between;
  margin-bottom: 1.5rem;
}

.history-manage-buttons {
  display: flex;
  gap: 1rem;
}

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

.danger-button:hover {
  background-color: var(--danger-color);
  filter: brightness(0.9);
}

.history-details {
  margin-top: 2rem;
}

.history-result-view {
  background-color: white;
  border-radius: 8px;
  padding: 1.5rem;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.05);
}

.history-result-view h3 {
  margin-bottom: 0.5rem;
  color: var(--secondary-color);
}

#history-result-date {
  color: var(--gray-color);
  font-size: 0.9rem;
  margin-bottom: 1.5rem;
}

/* Rename dialog */
.rename-dialog {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.rename-dialog-content {
  background-color: white;
  padding: 2rem;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
  width: 100%;
  max-width: 400px;
}

.rename-dialog h3 {
  margin-bottom: 1.5rem;
  color: var(--secondary-color);
}

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

.rename-form input {
  padding: 0.75rem;
  border: 1px solid var(--light-gray-color);
  border-radius: 4px;
  font-size: 1rem;
}

.rename-buttons {
  display: flex;
  justify-content: flex-end;
  gap: 1rem;
  margin-top: 1rem;
}

/* Responsive design */
@media (max-width: 768px) {
  .mode-selector {
    flex-direction: column;
  }

  .control-panel {
    flex-direction: column;
  }

  .section {
    padding: 1.5rem;
  }

  .speaker-name-container {
    flex-direction: column;
    align-items: stretch;
  }

  .history-filters {
    flex-direction: column;
  }

  .history-actions {
    flex-direction: column;
    gap: 1rem;
  }

  .history-manage-buttons {
    justify-content: space-between;
  }
}
