/**
 * dFFA Rechner - Modernes Feuerwehr-Design
 * Professionell, clean, benutzerfreundlich
 */

:root {
  /* Feuerwehr Primärfarben */
  --fire-red: #DC2626;
  --fire-red-dark: #B91C1C;
  --fire-red-light: #FEE2E2;

  /* Neutrale Farben */
  --gray-50: #F9FAFB;
  --gray-100: #F3F4F6;
  --gray-200: #E5E7EB;
  --gray-300: #D1D5DB;
  --gray-400: #9CA3AF;
  --gray-500: #6B7280;
  --gray-600: #4B5563;
  --gray-700: #374151;
  --gray-800: #1F2937;
  --gray-900: #111827;

  /* Badge-Farben */
  --bronze: #CD7F32;
  --silver: #C0C0C0;
  --gold: #FFD700;

  /* Feedback-Farben */
  --success: #10B981;
  --error: #EF4444;
  --warning: #F59E0B;

  /* Schatten */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1);
}

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

body {
  font-family: 'Work Sans', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
  background: var(--gray-50);
  color: var(--gray-900);
  min-height: 100vh;
  line-height: 1.6;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 2rem 1.5rem;
}

/* Header */
header {
  text-align: center;
  margin-bottom: 3rem;
  padding: 2rem 0;
}

h1 {
  font-family: 'Bebas Neue', sans-serif;
  font-size: clamp(2.5rem, 6vw, 3.5rem);
  letter-spacing: 1px;
  margin-bottom: 0.5rem;
  color: var(--fire-red);
  text-transform: uppercase;
  line-height: 1.1;
}

.subtitle {
  font-size: 1.125rem;
  color: var(--gray-600);
  font-weight: 400;
}

/* Navigation */
.nav-tabs {
  display: flex;
  gap: 0.5rem;
  margin-bottom: 2rem;
  background: white;
  padding: 0.5rem;
  border-radius: 12px;
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--gray-200);
}

.nav-tab {
  flex: 1;
  min-width: 180px;
  padding: 0.875rem 1.25rem;
  background: transparent;
  border: none;
  border-radius: 8px;
  color: var(--gray-700);
  font-size: 0.9375rem;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.2s ease;
  text-align: center;
}

.nav-tab:hover {
  background: var(--gray-100);
  color: var(--gray-900);
}

.nav-tab.active {
  background: var(--fire-red);
  color: white;
  box-shadow: var(--shadow-sm);
}

/* Views */
.view {
  display: none;
}

.view.active {
  display: block;
}

/* Cards */
.card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 12px;
  padding: 2rem;
  margin-bottom: 1.5rem;
  box-shadow: var(--shadow-sm);
  transition: box-shadow 0.2s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.card-icon {
  font-size: 1.5rem;
}

.card-title {
  font-size: 1.375rem;
  font-weight: 600;
  color: var(--gray-900);
  letter-spacing: -0.025em;
}

h3.card-title {
  font-size: 1.25rem;
  margin-bottom: 1rem;
}

/* Form Elements */
.form-group {
  margin-bottom: 1.5rem;
}

.form-row {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
  gap: 1.5rem;
  margin-bottom: 1.5rem;
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--gray-700);
  font-size: 0.875rem;
}

.form-group > label {
  white-space: nowrap;
  overflow: visible;
}

input[type="number"],
input[type="text"],
select,
.discipline-select,
.performance-input {
  width: 100%;
  padding: 0.75rem 1rem;
  background: white;
  border: 1px solid var(--gray-300);
  border-radius: 8px;
  color: var(--gray-900);
  font-size: 0.9375rem;
  font-family: 'Work Sans', sans-serif;
  transition: all 0.2s ease;
}

input:focus,
select:focus {
  outline: none;
  border-color: var(--fire-red);
  box-shadow: 0 0 0 3px var(--fire-red-light);
}

input:hover,
select:hover {
  border-color: var(--gray-400);
}

/* Input Groups */
.time-input-group {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}

.time-input-group .input-addon {
  flex: 0 0 160px;
}

.performance-input-container .input-addon {
  max-width: 200px;
}

.input-addon {
  position: relative;
}

.input-addon::after {
  content: attr(data-unit);
  position: absolute;
  right: 1rem;
  top: 50%;
  transform: translateY(-50%);
  color: var(--gray-400);
  pointer-events: none;
  font-size: 0.875rem;
  font-weight: 500;
}

.input-addon input {
  padding-right: 3.5rem;
}

/* Remove browser stepper buttons */
input[type="number"]::-webkit-inner-spin-button,
input[type="number"]::-webkit-outer-spin-button {
  -webkit-appearance: none;
  margin: 0;
}

input[type="number"] {
  -moz-appearance: textfield;
  appearance: textfield;
}

/* Buttons */
.btn,
.calculate-btn {
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 8px;
  font-size: 0.9375rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s ease;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
}

.btn-primary,
.calculate-btn {
  background: var(--fire-red);
  color: white;
  box-shadow: var(--shadow-sm);
}

.btn-primary:hover,
.calculate-btn:hover {
  background: var(--fire-red-dark);
  box-shadow: var(--shadow-md);
  transform: translateY(-1px);
}

.btn-secondary {
  background: var(--gray-100);
  color: var(--gray-700);
  border: 1px solid var(--gray-300);
}

.btn-secondary:hover {
  background: var(--gray-200);
  color: var(--gray-900);
}

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

.btn-danger:hover {
  background: #DC2626;
}

.btn-success {
  background: var(--success);
  color: white;
}

.info-btn {
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  margin-left: 0.5rem;
  padding: 0;
}

.info-btn:hover {
  border-color: var(--fire-red);
  background: var(--fire-red-light);
}

.info-icon {
  font-size: 0.875rem;
}

/* Results */
.results {
  margin-top: 2rem;
  padding: 1.5rem;
  background: var(--gray-50);
  border-radius: 12px;
  border: 1px solid var(--gray-200);
}

.result-header {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 1.5rem;
}

.result-category-section {
  margin-bottom: 2rem;
}

.result-category {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--gray-900);
  margin-bottom: 1rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.category-icon {
  font-size: 1.5rem;
}

.result-disciplines {
  display: grid;
  gap: 0.75rem;
}

.result-discipline {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr 1fr;
  gap: 1rem;
  padding: 1rem;
  background: white;
  border-radius: 8px;
  align-items: center;
  border: 1px solid var(--gray-200);
}

.discipline-name-with-info {
  display: flex;
  align-items: center;
}

.discipline-name {
  font-weight: 500;
  color: var(--gray-900);
}

.performance-value {
  font-weight: 600;
  color: var(--fire-red);
}

/* Badge Values */
.badge-value,
.badge-mini,
.badge-final {
  padding: 0.375rem 0.75rem;
  border-radius: 6px;
  font-weight: 600;
  font-size: 0.875rem;
  text-align: center;
  display: inline-block;
}

.badge-bronze,
.badge-value.badge-bronze,
.badge-mini.badge-bronze,
.badge-final.badge-bronze {
  background: var(--bronze) !important;
  color: white !important;
}

.badge-silver,
.badge-value.badge-silver,
.badge-mini.badge-silver,
.badge-final.badge-silver,
.badge-silber,
.badge-value.badge-silber,
.badge-mini.badge-silber,
.badge-final.badge-silber {
  background: linear-gradient(135deg, #C0C0C0 0%, #E8E8E8 50%, #C0C0C0 100%) !important;
  color: #1F2937 !important;
  border: 2px solid #9CA3AF !important;
  font-weight: 700 !important;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.15), inset 0 1px 2px rgba(255, 255, 255, 0.8) !important;
}

.badge-gold,
.badge-value.badge-gold,
.badge-mini.badge-gold,
.badge-final.badge-gold {
  background: var(--gold) !important;
  color: #1F2937 !important;
}

.badge-empty {
  background: transparent;
  border: 1px dashed var(--gray-300);
  color: var(--gray-400);
}

.badge-failed,
.badge-value.badge-failed {
  background: var(--error);
  color: white;
}

.badge-failed-mini {
  font-size: 1.25rem;
}

/* Final Badge */
.final-badge {
  margin-top: 2rem;
  padding: 2.5rem;
  text-align: center;
  border-radius: 12px;
  border: 2px solid;
  background: white;
}

.final-badge.bronze {
  border-color: var(--bronze);
  background: linear-gradient(135deg, rgba(205, 127, 50, 0.05) 0%, rgba(205, 127, 50, 0.1) 100%);
}

.final-badge.silver {
  border-color: #9CA3AF;
  background: linear-gradient(135deg, rgba(232, 232, 232, 0.3) 0%, rgba(192, 192, 192, 0.4) 100%);
  box-shadow: inset 0 2px 4px rgba(255, 255, 255, 0.5);
}

.final-badge.gold {
  border-color: var(--gold);
  background: linear-gradient(135deg, rgba(255, 215, 0, 0.05) 0%, rgba(255, 215, 0, 0.1) 100%);
}

.final-badge.failed {
  border-color: var(--error);
  background: rgba(239, 68, 68, 0.05);
}

.final-badge-emoji {
  font-size: 4rem;
  margin-bottom: 1rem;
  display: block;
}

.final-badge-title {
  font-size: 2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
}

.final-badge-subtitle {
  color: var(--gray-600);
  font-size: 1.125rem;
}

/* Group Statistics */
.group-stats {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
  gap: 1rem;
  margin-bottom: 2rem;
}

.stat-card {
  background: white;
  border: 1px solid var(--gray-200);
  border-radius: 8px;
  padding: 1.25rem;
  text-align: center;
  box-shadow: var(--shadow-sm);
}

.stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--fire-red);
  display: block;
  margin-bottom: 0.25rem;
}

.stat-label {
  font-size: 0.875rem;
  color: var(--gray-600);
  font-weight: 500;
}

.badge-distribution {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  margin-top: 0.5rem;
  flex-wrap: wrap;
}

.badge-stat {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.25rem;
}

.badge-stat-value {
  font-size: 1.25rem;
  font-weight: 700;
}

.badge-stat-label {
  font-size: 0.75rem;
  color: var(--gray-600);
}

/* Group Table */
.group-table-container {
  margin-top: 1rem;
  border-radius: 12px;
  border: 1px solid var(--gray-200);
  overflow: visible;
}

.group-table {
  width: 100%;
  border-collapse: collapse;
  background: white;
  table-layout: fixed;
}

.group-table thead {
  background: var(--gray-50);
  border-bottom: 2px solid var(--gray-200);
}

.group-table th {
  padding: 0.75rem 0.5rem;
  text-align: left;
  font-weight: 600;
  color: var(--gray-900);
  font-size: 0.8125rem;
  white-space: nowrap;
  border-right: 1px solid var(--gray-200);
}

.group-table th:last-child {
  border-right: none;
}

.group-table td {
  padding: 0.75rem 0.5rem;
  border-top: 1px solid var(--gray-200);
  border-right: 1px solid var(--gray-200);
  font-size: 0.8125rem;
}

.group-table td:last-child {
  border-right: none;
}

.group-table tbody tr:nth-child(even) {
  background: var(--gray-50);
}

.group-table tbody tr:hover {
  background: var(--fire-red-light);
}

.name-cell {
  font-weight: 600;
  color: var(--gray-900);
  width: 12%;
}

.discipline-cell {
  font-size: 0.75rem;
  color: var(--gray-600);
  line-height: 1.3;
  width: 15%;
}

.value-cell {
  font-weight: 600;
  color: var(--gray-900);
  width: 8%;
  text-align: center;
}

.badge-cell {
  text-align: center;
  width: 7%;
}

.final-badge-cell {
  text-align: center;
  width: 8%;
}

.actions-cell {
  text-align: center;
  width: 8%;
}

/* Age and AK columns */
.group-table td:nth-child(2),
.group-table th:nth-child(2) {
  width: 5%;
  text-align: center;
}

.group-table td:nth-child(3),
.group-table th:nth-child(3) {
  width: 6%;
  text-align: center;
}

.action-btn {
  background: transparent;
  border: 1px solid var(--gray-300);
  border-radius: 6px;
  width: 32px;
  height: 32px;
  cursor: pointer;
  transition: all 0.2s ease;
  margin: 0 0.25rem;
  padding: 0;
  display: inline-flex;
  align-items: center;
  justify-content: center;
}

.action-btn:hover {
  transform: scale(1.1);
}

.edit-btn:hover {
  border-color: var(--fire-red);
  background: var(--fire-red-light);
}

.delete-btn:hover {
  border-color: var(--error);
  background: #FEE2E2;
}

/* Modal */
.modal {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 0, 0, 0.5);
  z-index: 1000;
  align-items: center;
  justify-content: center;
  backdrop-filter: blur(4px);
}

.modal.show {
  display: flex;
}

.modal-content {
  background: white;
  border-radius: 12px;
  padding: 2rem;
  max-width: 600px;
  width: 90%;
  max-height: 80vh;
  overflow-y: auto;
  box-shadow: var(--shadow-lg);
}

.modal-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
  padding-bottom: 1rem;
  border-bottom: 1px solid var(--gray-200);
}

.modal-title {
  font-size: 1.5rem;
  font-weight: 600;
  color: var(--gray-900);
}

.modal-close {
  background: transparent;
  border: none;
  color: var(--gray-400);
  font-size: 1.5rem;
  cursor: pointer;
  transition: color 0.2s ease;
  padding: 0;
  line-height: 1;
  width: 32px;
  height: 32px;
}

.modal-close:hover {
  color: var(--gray-900);
}

.modal-body {
  color: var(--gray-600);
  line-height: 1.6;
  white-space: pre-line;
}

/* Empty State */
.empty-message {
  text-align: center;
  padding: 3rem 2rem;
  color: var(--gray-500);
  font-size: 1rem;
}

.error-message {
  background: #FEE2E2;
  border: 1px solid #FCA5A5;
  border-radius: 8px;
  padding: 1rem;
  color: var(--error);
  margin: 1rem 0;
}

/* Footer */
footer {
  text-align: center;
  margin-top: 4rem;
  padding: 2rem;
  color: var(--gray-600);
  font-size: 0.875rem;
  border-top: 1px solid var(--gray-200);
}

footer a {
  color: var(--fire-red);
  text-decoration: none;
  transition: color 0.2s ease;
}

footer a:hover {
  color: var(--fire-red-dark);
  text-decoration: underline;
}

/* Responsive */
@media (min-width: 1200px) {
  .group-table {
    table-layout: auto;
  }
}

@media (max-width: 1024px) {
  .result-discipline {
    grid-template-columns: 1fr;
    gap: 0.5rem;
  }

  .badge-value {
    width: fit-content;
  }
}

@media (max-width: 1024px) {
  .group-table-container {
    overflow-x: auto;
  }

  .group-table {
    table-layout: auto;
    min-width: 1000px;
  }
}

@media (max-width: 768px) {
  .container {
    padding: 1rem;
  }

  h1 {
    font-size: 2.5rem;
  }

  .nav-tabs {
    flex-direction: column;
  }

  .nav-tab {
    min-width: auto;
  }

  .card {
    padding: 1.5rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .group-stats {
    grid-template-columns: 1fr 1fr;
  }

  .stat-card {
    padding: 1rem;
  }

  .stat-value {
    font-size: 1.5rem;
  }

  .group-table-container {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }

  .group-table {
    font-size: 0.7rem;
    min-width: 900px;
  }

  .group-table th,
  .group-table td {
    padding: 0.5rem 0.25rem;
  }

  .discipline-cell {
    font-size: 0.65rem;
  }
}

/* Responsive input fields for mobile */
@media (max-width: 480px) {
  .time-input-group {
    flex-direction: column;
    gap: 0.75rem;
  }

  .time-input-group .input-addon {
    flex: 1 1 auto;
  }

  .performance-input-container .input-addon {
    max-width: 100%;
  }

  .card {
    padding: 1rem;
  }

  h1 {
    font-size: 2rem;
  }

  .group-stats {
    grid-template-columns: 1fr;
  }

  .stat-card {
    padding: 0.875rem;
  }

  .badge-distribution {
    flex-direction: column;
    gap: 0.375rem;
  }

  .final-badge {
    padding: 1.5rem;
  }

  .final-badge-emoji {
    font-size: 3rem;
  }

  .final-badge-title {
    font-size: 1.5rem;
  }
}

/* Accessibility */
@media (prefers-reduced-motion: reduce) {
  * {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Print Styles */
@media print {
  body {
    background: white;
  }

  .nav-tabs,
  .btn,
  .action-btn {
    display: none;
  }

  .card {
    box-shadow: none;
    border: 1px solid #ddd;
    page-break-inside: avoid;
  }
}
