/* 
  UK Rail Helper Portal Style System
  Theme: Clean Web Portal / Timetable Directory
*/

:root {
  --portal-bg: #e5ecf4;
  --header-blue-start: #1d5987;
  --header-blue-end: #3a7bb0;
  --header-border: #143d5c;
  
  --nav-bg: #ccd9e8;
  --nav-active-tab: #ffffff;
  --nav-inactive-tab: #e2ecf7;
  --nav-border: #9cb6d4;
  
  --panel-border: #a6c9e2;
  --panel-header-start: #477bb0;
  --panel-header-end: #2d5a88;
  --panel-body-bg: #ffffff;
  
  --text-primary: #333333;
  --text-link: #1d5987;
  --text-active-tab: #1d5987;
  
  --table-th-start: #f2f7fc;
  --table-th-end: #d4e3f0;
  --table-th-border: #a6c9e2;
  --table-td-border: #c5dbec;
  --table-row-even: #f7fafc;
  --table-row-hover: #edf4fa;
  
  --btn-start: #f5f9fd;
  --btn-end: #d9e6f2;
  --btn-border: #a6c9e2;
  --btn-primary-start: #e9643b;
  --btn-primary-end: #c44018;
}

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

body {
  background-color: var(--portal-bg);
  font-family: Arial, Helvetica, sans-serif;
  font-size: 12px;
  color: var(--text-primary);
  line-height: 1.4;
  padding: 0;
}

/* Links */
a {
  color: var(--text-link);
  text-decoration: underline;
}

a:hover {
  text-decoration: none;
}

/* Layout Container */
.portal-container {
  width: 100%;
  margin: 0 auto;
  background-color: #ffffff;
  min-height: 100vh;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
  display: flex;
  flex-direction: column;
}

/* 1. Portal Header Banner */
.portal-header {
  background: linear-gradient(to bottom, var(--header-blue-start) 0%, var(--header-blue-end) 100%);
  border-bottom: 3px solid var(--header-border);
  padding: 10px 20px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  color: #ffffff;
}

.header-left {
  display: flex;
  align-items: center;
  gap: 12px;
}

.logo-box {
  background-color: #d94a1a;
  color: #ffffff;
  font-size: 20px;
  font-weight: bold;
  padding: 4px 10px;
  border: 2px solid #ffffff;
  border-radius: 4px;
  letter-spacing: 0.5px;
}

.header-text-container h1 {
  font-size: 16px;
  font-weight: bold;
  margin: 0;
}

.header-text-container .subtitle {
  font-size: 10px;
  color: #c9ddf0;
  margin-top: 1px;
}

.header-right {
  display: flex;
  align-items: center;
}

/* 2. Top Navigation Tabs */
.portal-nav {
  background-color: var(--nav-bg);
  border-bottom: 1px solid var(--nav-border);
  display: flex;
  align-items: flex-end;
  padding: 6px 20px 0 20px;
  gap: 4px;
  position: relative;
}

.nav-tab {
  background: linear-gradient(to bottom, #f2f7fc 0%, var(--nav-inactive-tab) 100%);
  border: 1px solid var(--nav-border);
  border-bottom: none;
  border-radius: 4px 4px 0 0;
  padding: 5px 14px;
  font-family: inherit;
  font-size: 12px;
  font-weight: normal;
  color: #333333;
  cursor: pointer;
  outline: none;
  position: relative;
  top: 1px;
}

.nav-tab:hover {
  background: #ffffff;
}

.nav-tab.active {
  background: var(--nav-active-tab);
  border-bottom: 1px solid var(--nav-active-tab);
  border-top: 3px solid #d94a1a;
  font-weight: bold;
  color: var(--text-active-tab);
  top: 2px;
  z-index: 2;
}

.last-login {
  color: #cbdbeb;
  font-size: 11px;
}

/* 4. Portal Main Layout Grid (2 Columns) */
.portal-grid {
  display: grid;
  grid-template-columns: 260px 1fr;
  gap: 15px;
  padding: 15px;
  flex-grow: 1;
}

.grid-col {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

/* 5. Portal Panel Container */
.portal-panel {
  background-color: var(--panel-body-bg);
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.panel-header {
  background: linear-gradient(to bottom, var(--panel-header-start) 0%, var(--panel-header-end) 100%);
  color: #ffffff;
  font-weight: bold;
  font-size: 12px;
  padding: 6px 10px;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.panel-body {
  padding: 10px;
}

/* Center main timetable panel adjustments */
.panel-main {
  flex-grow: 1;
}

.header-main {
  background: linear-gradient(to bottom, #1d5987 0%, #15466b 100%);
  font-size: 13px;
  padding: 8px 12px;
}

.badge-status {
  background-color: #666666;
  color: #ffffff;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
}

.badge-status.online {
  background-color: #4cae4c;
}

.badge-status.mock {
  background-color: #f0ad4e;
}

.badge-status.offline {
  background-color: #d9534f;
}

/* 6. Form Controls & Buttons */
.search-form-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  margin-bottom: 10px;
}

.field-label {
  font-weight: bold;
  color: #444;
}

.search-input-wrapper {
  position: relative;
}

input[type="text"] {
  width: 100%;
  padding: 5px 24px 5px 6px;
  font-family: inherit;
  font-size: 12px;
  border: 1px solid #7f9db9;
  border-radius: 2px;
  outline: none;
}

input[type="text"]:focus {
  border-color: #1d5987;
  box-shadow: 0 0 2px rgba(29, 89, 135, 0.4);
}

.clear-input-btn {
  position: absolute;
  right: 6px;
  top: 5px;
  background: none;
  border: none;
  font-size: 14px;
  font-weight: bold;
  cursor: pointer;
  color: #999;
}

.clear-input-btn:hover {
  color: black;
}

/* Autocomplete Suggestion Dropdown */
.autocomplete-dropdown {
  position: absolute;
  border: 1px solid #7f9db9;
  background-color: #ffffff;
  z-index: 99;
  top: 100%;
  left: 0;
  right: 0;
  max-height: 180px;
  overflow-y: auto;
  box-shadow: 0 2px 5px rgba(0,0,0,0.15);
}

.autocomplete-dropdown div {
  padding: 6px 8px;
  cursor: pointer;
  border-bottom: 1px solid #f0f0f0;
}

.autocomplete-dropdown div:hover {
  background-color: #31708f;
  color: #ffffff;
}

/* Buttons style */
.btn-row {
  display: flex;
  gap: 6px;
}

.portal-btn {
  padding: 5px 12px;
  font-family: inherit;
  font-size: 11px;
  background: linear-gradient(to bottom, var(--btn-start) 0%, var(--btn-end) 100%);
  border: 1px solid var(--btn-border);
  border-radius: 3px;
  color: #333333;
  cursor: pointer;
  outline: none;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 4px;
}

.portal-btn:hover {
  background: #ffffff;
  border-color: #1d5987;
}

.portal-btn:active {
  background: #d9e6f2;
}

.btn-primary {
  background: linear-gradient(to bottom, var(--btn-primary-start) 0%, var(--btn-primary-end) 100%);
  border-color: #a02c0b;
  color: #ffffff;
  font-weight: bold;
}

.btn-primary:hover {
  background: linear-gradient(to bottom, #f37d57 0%, #d94a1a 100%);
  border-color: #b03612;
  color: #ffffff;
}

.btn-primary:active {
  background: #b03612;
}

/* 7. Tab Display Toggling */
.tab-content {
  display: none;
}

.tab-content.active {
  display: block;
}

/* Tab Lists (Favorites & History in Center Panel) */
.list-panel-body {
  padding: 0;
  background-color: #ffffff;
}

.empty-list-text {
  padding: 30px;
  color: #777;
  font-style: italic;
  text-align: center;
}

/* Tab content grid of card options */
.list-panel-body .station-list-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 10px;
  padding: 15px;
}

.station-item-card {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border: 1px solid var(--panel-border);
  background: #f5f8fc;
  border-radius: 3px;
  cursor: pointer;
}

.station-item-card:hover {
  background-color: #edf4fa;
  border-color: var(--text-link);
}

.station-item-info {
  display: flex;
  flex-direction: column;
  gap: 2px;
}

.station-item-name {
  font-weight: bold;
  color: var(--text-link);
  font-size: 12px;
}

.station-item-crs {
  font-size: 10px;
  color: #666666;
  font-family: monospace;
}

.station-remove-btn {
  background: none;
  border: none;
  color: #b0b0b0;
  font-size: 16px;
  font-weight: bold;
  cursor: pointer;
  padding: 0 4px;
}

.station-remove-btn:hover {
  color: #c43030;
}

/* 8. Timetable Table Styling */
.timetable-wrapper {
  overflow-x: auto;
}

.timetable {
  width: 100%;
  border-collapse: collapse;
  text-align: left;
}

.timetable th {
  background: linear-gradient(to bottom, var(--table-th-start) 0%, var(--table-th-end) 100%);
  border: 1px solid var(--table-th-border);
  color: var(--text-link);
  font-weight: bold;
  font-size: 11px;
  padding: 6px 8px;
}

.timetable td {
  border: 1px solid var(--table-td-border);
  padding: 7px 8px;
  font-size: 12px;
}

.timetable tr:nth-child(even) {
  background-color: var(--table-row-even);
}

.timetable tr:hover:not(:first-child) {
  background-color: var(--table-row-hover);
  cursor: pointer;
}

.timetable tr:hover td {
  color: #000;
}

.empty-table-cell {
  text-align: center;
  padding: 30px 10px;
  color: #888888;
  font-style: italic;
}

.timetable td strong {
  color: #1d5987;
}

.timetable-calling-points {
  font-size: 10px;
  color: #666;
  margin-top: 3px;
  line-height: 1.3;
}

/* Status badge pills */
.pill-status {
  display: inline-block;
  padding: 2px 6px;
  border-radius: 3px;
  font-size: 10px;
  font-weight: bold;
  text-align: center;
  min-width: 65px;
}

.pill-status.status-ok {
  background-color: #e2f2e2;
  border: 1px solid #4cae4c;
  color: #2b702b;
}

.pill-status.status-error {
  background-color: #f9e2e2;
  border: 1px solid #d9534f;
  color: #a94442;
}

.pill-status.status-warning {
  background-color: #fcf8e3;
  border: 1px solid #f0ad4e;
  color: #8a6d3b;
}

/* 9. Portal Footer */
.portal-footer {
  background-color: var(--nav-inactive-tab);
  border-top: 1px solid var(--nav-border);
  padding: 6px 20px;
  display: flex;
  justify-content: space-between;
  font-size: 11px;
  color: #555555;
  margin-top: auto;
}

#footer-connection-status {
  font-weight: bold;
}

#footer-connection-status.online { color: green; }
#footer-connection-status.offline { color: red; }

/* 10. Modal Detail Dialog (Popup window) */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-color: rgba(0, 0, 0, 0.4);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 999;
  padding: 15px;
}

.modal-dialog {
  background-color: #ffffff;
  border: 1px solid var(--panel-border);
  border-radius: 4px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.3);
  width: 100%;
  max-width: 500px;
  overflow: hidden;
}

.modal-header {
  background: linear-gradient(to bottom, var(--header-blue-start) 0%, var(--header-blue-end) 100%);
  color: #ffffff;
  padding: 8px 12px;
  font-weight: bold;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-close-btn {
  background: none;
  border: none;
  color: #ffffff;
  font-size: 20px;
  font-weight: bold;
  cursor: pointer;
  line-height: 1;
}

.modal-body {
  padding: 15px;
}

.service-summary-card {
  border: 1px solid var(--panel-border);
  background-color: #f5f8fc;
  padding: 10px;
  border-radius: 3px;
  margin-bottom: 12px;
}

.service-summary-card h3 {
  font-size: 13px;
  color: var(--text-link);
  margin-bottom: 6px;
  border-bottom: 1px dotted #ccc;
  padding-bottom: 4px;
}

.summary-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 6px 15px;
}

.delay-reason-box {
  background-color: #f9e2e2;
  border: 1px solid #d9534f;
  color: #a94442;
  padding: 6px 8px;
  margin-top: 8px;
  font-weight: bold;
}

.calling-points-section h4 {
  font-size: 12px;
  font-weight: bold;
  margin-bottom: 6px;
}

.calling-points-table-container {
  max-height: 200px;
  overflow-y: auto;
  border: 1px solid var(--table-td-border);
}

.calling-points-table {
  width: 100%;
  border-collapse: collapse;
}

.calling-points-table th {
  background-color: var(--table-th-end);
  border-bottom: 1px solid var(--table-td-border);
  padding: 6px 8px;
  font-weight: bold;
  font-size: 11px;
  position: sticky;
  top: 0;
  text-align: left;
}

.calling-points-table td {
  padding: 6px 8px;
  border-bottom: 1px solid #e1e7f0;
}

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

.calling-points-table tr:nth-child(even) {
  background-color: var(--table-row-even);
}

.modal-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 15px;
}

/* 11. Responsive Style Adjustments */
@media (max-width: 800px) {
  /* Collapse Grid to a single column stack on mobile/tablet */
  .portal-grid {
    grid-template-columns: 1fr;
    grid-template-rows: auto auto; /* Explicitly size rows */
    align-content: start; /* Force packed rows, preventing stretching gaps */
    padding: 8px;
    gap: 8px;
  }

  .grid-col {
    gap: 8px;
  }
  
  .portal-header {
    padding: 10px;
  }

  .portal-nav {
    padding: 6px 10px 0 10px;
    overflow-x: auto;
    white-space: nowrap;
    -webkit-overflow-scrolling: touch;
  }

  /* Table collapses for mobile layout */
  .timetable th, .timetable td {
    padding: 5px;
    font-size: 11px;
  }
}

/* Announcement Bulletin Box */
.announcement-box {
  background-color: #ffffe1;
  border: 1px solid #e6db55;
  border-radius: 4px;
  margin-bottom: 12px;
  padding: 8px 12px;
  box-shadow: inset 0 1px 2px rgba(0,0,0,0.05);
}

.announcement-header {
  color: #a94442;
  font-weight: bold;
  font-size: 11px;
  margin-bottom: 4px;
  letter-spacing: 0.5px;
}

.announcement-body {
  font-size: 11px;
  color: #555;
  line-height: 1.4;
}

.announcement-body p {
  margin-bottom: 6px;
}

.announcement-body p:last-child {
  margin-bottom: 0;
}

/* Platform Indicators styling */
.platform-badge {
  display: inline-block;
  padding: 2px 6px;
  background-color: #f1f5f9;
  border: 1px solid #cbd5e1;
  color: #334155;
  font-weight: bold;
  border-radius: 3px;
  font-family: monospace;
}

.platform-badge.confirmed {
  background-color: #e2f2e2;
  border-color: #4cae4c;
  color: #2b702b;
}

/* TfL Line Cards Styles */
.tfl-line-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.tfl-line-card {
  border: 1px solid var(--panel-border);
  background-color: #f8fafc;
  border-radius: 4px;
  overflow: hidden;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.03);
}

.tfl-line-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 8px 12px;
}

.tfl-line-card.disrupted .tfl-line-header {
  cursor: pointer;
}

.tfl-line-card.disrupted:hover {
  background-color: #edf4fa;
}

.tfl-line-stripe {
  width: 8px;
  height: 18px;
  border-radius: 1px;
}

.tfl-line-name {
  font-size: 12px;
  color: #333;
}

.tfl-toggle-icon {
  margin-left: 8px;
  color: #777;
  font-size: 8px;
  display: inline-block;
  transition: transform 0.2s;
}

.tfl-toggle-icon.expanded {
  transform: rotate(180deg);
}

.tfl-line-reason {
  background-color: #fff9e6;
  border-top: 1px solid #ffe699;
  padding: 10px 12px;
  font-size: 11px;
  color: #666;
  line-height: 1.4;
}

/* Bulletin Announcement Item Styling */
.announcement-item {
  border-bottom: 1px dotted #e6db55;
  padding: 8px 0;
}

.announcement-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.announcement-item:first-child {
  padding-top: 0;
}

.announcement-item.delay-bulletin,
.announcement-item.delay-bulletin p {
  font-weight: bold;
  color: #a94442;
}

/* Option 1: Mobile compact labels for tighter navigation bar */
@media (max-width: 600px) {
  .portal-nav {
    overflow-x: hidden !important;
    padding: 6px 15px 0 15px;
    gap: 4px;
  }

  .nav-tab {
    padding: 13px 10px;
    font-size: 13px;
  }

  #tab-favorites {
    font-size: 0 !important;
  }
  #tab-favorites::after {
    content: "Saved";
    font-size: 13px;
  }

  #tab-history {
    font-size: 0 !important;
  }
  #tab-history::after {
    content: "History";
    font-size: 13px;
  }

  #tab-tfl {
    font-size: 0 !important;
  }
  #tab-tfl::after {
    content: "TfL";
    font-size: 13px;
  }

  #tab-faq {
    font-size: 0 !important;
  }
  #tab-faq::after {
    content: "FAQ";
    font-size: 13px;
  }
}

/* FAQ Panel Styling */
.faq-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.faq-item {
  border-bottom: 1px dotted #e6db55;
  padding-bottom: 14px;
}

.faq-item:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.faq-question {
  font-size: 13px;
  font-weight: bold;
  color: #3b5a75;
  margin: 0 0 6px 0;
}

.faq-answer {
  font-size: 12px;
  color: #555;
  line-height: 1.5;
  margin: 0;
}

.faq-answer code {
  font-family: monospace;
  background-color: #f5f8fa;
  border: 1px solid #d1dbe5;
  padding: 1px 4px;
  border-radius: 3px;
}
