@import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

:root {
  /* Brand Colors */
  --brand-red: #E63946;
  --brand-dark-red: #D62828;
  --brand-light-red: rgba(230, 57, 70, 0.1);
  --success: #2A9D8F;
  --warning: #F4A261;

  /* Backgrounds & Surfaces */
  --bg-color: #F8F9FA;
  --card-bg: #FFFFFF;
  --header-bg: rgba(255, 255, 255, 0.85);

  /* Typography */
  --text-main: #1A1A1A;
  --text-muted: #6C757D;
  --font-family: 'Inter', system-ui, -apple-system, sans-serif;

  /* Layout & Spacing */
  --container-width: 1140px;
  --border-radius-sm: 8px;
  --border-radius-md: 16px;
  --border-radius-full: 999px;

  /* Shadows */
  --shadow-sm: 0 4px 6px -1px rgba(0, 0, 0, 0.05);
  --shadow-md: 0 10px 15px -3px rgba(0, 0, 0, 0.05), 0 4px 6px -2px rgba(0, 0, 0, 0.025);
  --shadow-hover: 0 20px 25px -5px rgba(0, 0, 0, 0.08), 0 10px 10px -5px rgba(0, 0, 0, 0.04);

  /* Borders */
  --border-light: #E9ECEF;
}

/* Base Reset & Mobile First Setup */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-color);
  color: var(--text-main);
  line-height: 1.6;
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

h1,
h2,
h3,
h4,
h5,
h6 {
  color: var(--text-main);
  font-weight: 700;
  line-height: 1.2;
  margin-bottom: 0.75em;
  letter-spacing: -0.02em;
}

h1 {
  font-size: clamp(2rem, 5vw, 2.5rem);
}

h2 {
  font-size: clamp(1.5rem, 4vw, 2rem);
}

h3 {
  font-size: clamp(1.25rem, 3vw, 1.5rem);
}

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

a:hover {
  color: var(--brand-dark-red);
}

p,
ul,
ol {
  margin-bottom: 1.2rem;
  color: #4A4A4A;
}

/* Layout */
.container {
  width: 100%;
  max-width: var(--container-width);
  margin: 0 auto;
  padding: 0 16px;
}

.main-content {
  flex: 1;
  padding-top: 32px;
  padding-bottom: 64px;
}

/* Header */
header {
  background: var(--header-bg);
  backdrop-filter: blur(16px);
  -webkit-backdrop-filter: blur(16px);
  border-bottom: 1px solid var(--border-light);
  position: sticky;
  top: 0;
  z-index: 1000;
}

.header-top {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
  padding: 16px 0;
}

.brand {
  font-size: 1.5rem;
  font-weight: 800;
  letter-spacing: -0.5px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.brand a {
  color: var(--brand-red);
}

.header-actions {
  display: flex;
  flex-direction: column;
  gap: 8px;
  width: 100%;
}

.header-actions .btn {
  width: 100%;
  text-align: center;
  padding: 10px 16px;
  font-size: 0.95rem;
}

/* Cards */
.card {
  background: var(--card-bg);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  padding: 24px;
  margin-bottom: 24px;
  border: 1px solid var(--border-light);
  transition: box-shadow 0.3s ease;
}

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

/* Buttons */
.btn,
button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  background-color: var(--brand-red);
  color: white;
  padding: 14px 28px;
  border: none;
  border-radius: var(--border-radius-full);
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  text-decoration: none;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  box-shadow: 0 4px 12px rgba(230, 57, 70, 0.2);
  min-height: 48px;
  width: 100%;
  /* Mobile first: full width buttons */
}

.btn:hover,
button:hover {
  background-color: var(--brand-dark-red);
  transform: translateY(-2px);
  box-shadow: 0 6px 16px rgba(230, 57, 70, 0.3);
  color: white;
}

.btn:active,
button:active {
  transform: translateY(0) scale(0.98);
}

.btn-secondary {
  background-color: white;
  color: var(--text-main);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.btn-secondary:hover {
  background-color: #F8F9FA;
  border-color: #DEE2E6;
  color: var(--text-main);
  box-shadow: var(--shadow-md);
}

.btn-full {
  width: 100%;
}

/* Forms & Inputs */
label {
  display: block;
  font-size: 0.95rem;
  font-weight: 600;
  margin-bottom: 6px;
  color: var(--text-main);
}

input[type="text"],
input[type="password"],
input[type="email"],
input[type="number"],
input[type="date"],
input[type="time"],
select,
textarea {
  width: 100%;
  padding: 14px 16px;
  background-color: #F8F9FA;
  border: 1px solid var(--border-light);
  border-radius: var(--border-radius-sm);
  font-size: 16px;
  /* Prevents iOS auto-zoom */
  font-family: inherit;
  color: var(--text-main);
  transition: all 0.2s ease;
  margin-bottom: 20px;
}

input:focus,
select:focus,
textarea:focus {
  outline: none;
  background-color: #FFFFFF;
  border-color: var(--brand-red);
  box-shadow: 0 0 0 4px var(--brand-light-red);
}

/* Dashboard KPIs */
.kpis {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
  margin-top: 16px;
  margin-bottom: 24px;
}

@media (max-width: 480px) {
  .kpis {
    grid-template-columns: 1fr;
  }
}

.kpis .card {
  padding: 16px;
  display: flex;
  flex-direction: column;
  justify-content: center;
  align-items: center;
  text-align: center;
  min-width: 0;
  /* Prevents flex children from breaking grid columns */
}

.kpi-title,
.card-title {
  font-size: 0.85rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--text-muted);
  margin-bottom: 8px;
}

.kpi-value,
.card-value {
  font-size: 2.2rem;
  font-weight: 800;
  color: var(--text-main);
  line-height: 1;
}

/* Charts */
.chart-wrap {
  position: relative;
  width: 100%;
  height: 250px;
  margin-top: 24px;
}

.chart-wrap.tall {
  height: 300px;
}

/* Utilities */
.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

.mt-2 {
  margin-top: 16px;
}

.mb-2 {
  margin-bottom: 16px;
}

.muted {
  color: var(--text-muted);
}

.small {
  font-size: 0.85rem;
}

.error {
  color: var(--brand-red);
  font-weight: 600;
}

.alert,
.message {
  padding: 16px;
  border-radius: var(--border-radius-sm);
  background-color: var(--brand-light-red);
  color: var(--brand-dark-red);
  margin-bottom: 24px;
  font-weight: 500;
  border-left: 4px solid var(--brand-red);
}

/* Grids */
.grid {
  display: grid;
  gap: 24px;
  grid-template-columns: 1fr;
}

/* Filters Component */
.filters {
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
  margin-bottom: 32px;
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.filters label {
  margin-bottom: 4px;
}

.filters input,
.filters select {
  margin-bottom: 0;
}

/* Tables */
.table-wrap {
  width: 100%;
  overflow-x: auto;
  -webkit-overflow-scrolling: touch;
  background: var(--card-bg);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--border-light);
}

table {
  width: 100%;
  border-collapse: collapse;
  min-width: 600px;
  /* Forces scroll on mobile */
}

th,
td {
  padding: 16px;
  border-bottom: 1px solid var(--border-light);
  text-align: left;
}

th {
  background-color: #F8F9FA;
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.85rem;
  letter-spacing: 0.5px;
}

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

/* Footer */
footer {
  background-color: #111;
  color: #fff;
  padding: 48px 0 24px;
  margin-top: auto;
}

.footer-links {
  display: flex;
  flex-direction: column;
  gap: 16px;
  align-items: center;
  margin-bottom: 32px;
}

.footer-links a {
  color: #aaa;
  font-weight: 500;
}

.footer-links a:hover {
  color: #fff;
}

.footer-copy {
  text-align: center;
  color: #666;
  font-size: 0.85rem;
  border-top: 1px solid #333;
  padding-top: 24px;
}

/* Action Groups (e.g. Card buttons) */
.action-buttons,
.delete-form {
  margin-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Tablet Breakpoint (768px+) */
@media (min-width: 768px) {
  .header-top {
    flex-direction: row;
    justify-content: space-between;
    padding: 0;
    height: 72px;
  }

  .header-actions {
    width: auto;
    gap: 16px;
    flex-direction: row;
  }

  .header-actions .btn {
    width: auto;
    min-width: 0;
  }

  .btn,
  button {
    width: auto;
  }

  .kpis {
    grid-template-columns: repeat(2, 1fr);
  }

  .grid-2 {
    grid-template-columns: repeat(2, 1fr);
  }

  .filters {
    flex-direction: row;
    align-items: flex-end;
  }

  .filters>div {
    flex: 1;
  }

  .chart-wrap {
    height: 300px;
  }

  .chart-wrap.tall {
    height: 400px;
  }

  .footer-links {
    flex-direction: row;
    justify-content: center;
    gap: 32px;
  }

  .action-buttons,
  .delete-form {
    flex-direction: row;
  }
}

/* Desktop Breakpoint (1024px+) */
@media (min-width: 1024px) {
  .kpis {
    grid-template-columns: repeat(4, 1fr);
  }

  .container {
    padding: 0 24px;
  }
}

/* Monitor View (Light Theme) */
.monitor-body {
  background-color: var(--bg-color);
  color: var(--text-main);
}

.monitor-view {
  background: var(--bg-color);
  min-height: 100vh;
  padding-bottom: 50px;
}

.monitor-header {
  padding: 20px 0;
  border-bottom: 1px solid var(--border-light);
  margin-bottom: 30px;
}

.monitor-title {
  font-size: 1.5rem;
  font-weight: 800;
  color: var(--brand-red);
  margin: 0;
}

.monitor-board {
  max-width: 1000px;
  margin: 0 auto;
  padding: 0 10px;
  background: var(--card-bg);
  border-radius: var(--border-radius-md);
  box-shadow: var(--shadow-md);
  border: 1px solid var(--border-light);
  overflow: hidden;
}

.monitor-row {
  display: grid;
  grid-template-columns: minmax(80px, auto) 1fr 100px;
  align-items: center;
  padding: 15px 20px;
  border-bottom: 1px solid var(--border-light);
  font-family: 'Inter', sans-serif;
  letter-spacing: -0.02em;
  background: var(--card-bg);
  gap: 15px;
}

.monitor-row:last-child {
  border-bottom: none;
}

.monitor-line {
  font-weight: 800;
  font-size: 1.1rem;
  color: white;
  background: var(--brand-red);
  padding: 6px 12px;
  border-radius: 6px;
  text-align: center;
  width: fit-content;
  white-space: nowrap;
  min-width: 60px;
}

.monitor-dest-plat {
  padding-left: 0;
  min-width: 0;
}

.monitor-destination {
  font-size: 1.25rem;
  font-weight: 700;
  display: block;
  color: var(--text-main);
}

.monitor-platform {
  font-size: 0.85rem;
  color: var(--text-muted);
  font-weight: 600;
}

.monitor-time-block {
  text-align: right;
}

.monitor-time {
  font-size: 1.4rem;
  font-weight: 800;
  display: block;
  color: var(--text-main);
}

.monitor-delay {
  font-size: 0.85rem;
  font-weight: 700;
  color: #D62828;
}

.monitor-delay.red {
  color: var(--brand-red);
}

.monitor-empty {
  text-align: center;
  padding: 50px 0;
  color: var(--text-muted);
}

.monitor-controls {
  margin-bottom: 20px;
  background: var(--card-bg);
  padding: 20px;
  border-radius: var(--border-radius-md);
  border: 1px solid var(--border-light);
  box-shadow: var(--shadow-sm);
}

.monitor-controls input {
  background: #fff;
  border-color: var(--border-light);
  color: var(--text-main);
  margin-bottom: 0;
}

.monitor-controls input:focus {
  background: #fff;
  border-color: var(--brand-red);
}

@media (max-width: 600px) {
  .monitor-row {
    grid-template-columns: 60px 1fr 80px;
    padding: 12px 15px;
  }

  .monitor-destination {
    font-size: 1rem;
  }

  .monitor-line {
    font-size: 0.9rem;
    padding: 2px 6px;
  }

  .monitor-time {
    font-size: 1.1rem;
  }
}

/* ÖBB Hardware Monitor Mode */
.oebb-hw-body {
  background-color: #0d1b4a;
  /* Dark border outside the screen */
  margin: 0;
  padding: 0;
  overflow: hidden;
  font-family: 'Inter', sans-serif;
}

.oebb-hw-view {
  width: 100vw;
  height: 100vh;
  background-color: #173DB4;
  /* Vibrant ÖBB Blue */
  display: flex;
  flex-direction: column;
  padding: 4vw 4vw 2vw 4vw;
  box-sizing: border-box;
}

.oebb-hw-top {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 2vh;
}

.oebb-hw-clock {
  color: #fff;
  font-size: 6vw;
  font-weight: 400;
  opacity: 0.9;
  letter-spacing: -0.02em;
}

.oebb-hw-primary {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
  justify-content: center;
  border-bottom: 3px solid rgba(255, 255, 255, 0.2);
  padding-bottom: 2vh;
  margin-bottom: 2vh;
}

.oebb-hw-primary-dest {
  color: #fff;
  font-size: 11vw;
  font-weight: 700;
  line-height: 1.1;
  letter-spacing: -0.02em;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.oebb-hw-primary-via {
  color: #E0E0E0;
  font-size: 3.5vw;
  font-weight: 400;
  margin-top: 1vh;
}

.oebb-hw-secondary-container {
  display: flex;
  flex-direction: column;
  gap: 1vh;
}

.oebb-hw-secondary-row {
  display: flex;
  align-items: center;
  background-color: #102A7A;
  /* Darker navy for bottom rows */
  padding: 1.5vh 2vw;
  border-radius: 4px;
}

.oebb-hw-secondary-dest {
  color: #E0E0E0;
  font-size: 4vw;
  font-weight: 500;
  flex-grow: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-left: 2vw;
}

.oebb-hw-secondary-time {
  color: #fff;
  font-size: 4vw;
  font-weight: 600;
  margin-left: 2vw;
  white-space: nowrap;
  text-align: right;
  display: flex;
  align-items: center;
}

/* Line Badges */
.oebb-line-badge {
  background-color: #fff;
  color: #173DB4;
  font-weight: 800;
  border-radius: 50%;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  letter-spacing: -0.05em;
  box-shadow: inset 0 0 0 2px #fff;
}

.oebb-line-badge-large {
  width: 9vw;
  height: 9vw;
  font-size: 5vw;
  margin-right: 2vw;
}

.oebb-line-badge-small {
  width: 5.5vw;
  height: 5.5vw;
  font-size: 3vw;
  background-color: #E0E0E0;
  color: #102A7A;
  box-shadow: inset 0 0 0 2px #E0E0E0;
}