/* === UKFuel PWA — App Shell === */

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

html, body {
  height: 100%;
  font-family: "Helvetica Neue", Helvetica, Arial, sans-serif;
  background: #f5f5f5;
  color: #333;
}

/* --- Header --- */

.app-header {
  position: fixed;
  top: 0; left: 0; right: 0;
  height: 50px;
  background: #337ab7;
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 100;
  font-size: 18px;
  font-weight: 600;
  box-shadow: 0 2px 4px rgba(0,0,0,0.15);
}

.app-header .header-left,
.app-header .header-right {
  position: absolute;
  top: 0; bottom: 0;
  display: flex;
  align-items: center;
  padding: 0 12px;
}

.app-header .header-left  { left: 0; }
.app-header .header-right { right: 0; }

.app-header button {
  background: none;
  border: none;
  color: #fff;
  font-size: 20px;
  padding: 6px;
  cursor: pointer;
  opacity: 0.85;
}

.app-header button:hover { opacity: 1; }

/* --- Views --- */

.app-body {
  position: fixed;
  top: 50px;
  bottom: 56px;
  left: 0; right: 0;
  overflow: hidden;
}

.view {
  display: none;
  height: 100%;
}

.view.active-view {
  display: flex;
  flex-direction: column;
}

.scroll-area {
  flex: 1;
  overflow-y: auto;
  -webkit-overflow-scrolling: touch;
  padding: 12px;
}

/* --- Bottom Nav --- */

.bottom-nav {
  position: fixed;
  bottom: 0; left: 0; right: 0;
  height: 56px;
  background: #fff;
  display: flex;
  border-top: 1px solid #ddd;
  z-index: 100;
  box-shadow: 0 -2px 4px rgba(0,0,0,0.08);
}

.nav-tab {
  flex: 1;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: none;
  border: none;
  color: #888;
  font-size: 10px;
  padding: 4px 0;
  cursor: pointer;
  transition: color 0.15s;
  -webkit-tap-highlight-color: transparent;
}

.nav-tab .nav-icon {
  font-size: 22px;
  margin-bottom: 2px;
}

.nav-tab.active-tab {
  color: #337ab7;
}

.nav-tab:active {
  opacity: 0.7;
}

/* --- Station Table --- */

.station-table {
  width: 100%;
  border-collapse: collapse;
  background: #fff;
  border-radius: 8px;
  overflow: hidden;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.station-table thead th {
  background: #337ab7;
  color: #fff;
  padding: 10px 8px;
  font-size: 13px;
  font-weight: 600;
  text-align: left;
}

.station-table tbody tr {
  border-bottom: 1px solid #eee;
  cursor: pointer;
  transition: background 0.1s;
}

.station-table tbody tr:active {
  background: #e9f0f7;
}

.station-table td {
  padding: 10px 8px;
  font-size: 14px;
  vertical-align: middle;
}

.station-brand {
  display: flex;
  align-items: center;
  gap: 8px;
}

.station-brand img {
  width: 40px;
  height: 20px;
  object-fit: contain;
}

.station-brand p {
  margin: 0;
  font-weight: 500;
  font-size: 13px;
}

.station-price {
  font-weight: 700;
  color: #337ab7;
  font-size: 15px;
}

.station-dist {
  color: #666;
  font-size: 13px;
}

/* --- Price Diff Cards --- */

.diff-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
  padding: 4px 0;
}

.diff-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.diff-card h3 {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 6px;
}

.diff-card .diff-label {
  font-size: 11px;
  padding: 2px 8px;
  border-radius: 10px;
  color: #fff;
  font-weight: 600;
}

.diff-label.cheapest { background: #5cb85c; }
.diff-label.expensive { background: #d9534f; }

.diff-card .diff-station {
  font-size: 16px;
  font-weight: 600;
  margin-bottom: 4px;
}

.diff-card .diff-address {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
}

.diff-card .diff-price {
  font-size: 28px;
  font-weight: 700;
  color: #337ab7;
}

.diff-summary {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.diff-summary .diff-amount {
  font-size: 36px;
  font-weight: 700;
  color: #337ab7;
}

.diff-summary .diff-desc {
  font-size: 13px;
  color: #666;
  margin-top: 4px;
}

.diff-filters {
  display: flex;
  gap: 6px;
  margin-bottom: 12px;
}

.diff-filter {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.diff-filter.active {
  background: #337ab7;
  color: #fff;
  border-color: #337ab7;
}

.diff-scope-label {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
  margin-top: 4px;
}

.region-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.region-row-label {
  font-size: 11px;
  padding: 2px 6px;
  border-radius: 8px;
  color: #fff;
  font-weight: 600;
  flex-shrink: 0;
}

.region-row-label.cheapest { background: #5cb85c; }
.region-row-label.expensive { background: #d9534f; }

.region-row-info {
  text-align: right;
}

.region-row-name {
  font-size: 13px;
  font-weight: 500;
  color: #333;
}

.region-row-price {
  font-size: 16px;
  font-weight: 700;
  color: #337ab7;
}

.region-row-price.price-above { color: #d9534f; }
.region-row-price.price-below { color: #5cb85c; }

.diff-card.regional-highlight,
.diff-card.national-highlight {
  border-left: 4px solid #337ab7;
  background: #f0f7ff;
}

.diff-card .diff-desc {
  font-size: 12px;
  color: #888;
  margin-top: 4px;
}

/* --- Regional Grid --- */

.regional-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 12px;
  padding: 4px 0;
}

.regional-card {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  text-align: center;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  cursor: pointer;
  transition: box-shadow 0.15s;
}

.regional-card:active {
  box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.regional-card .region-name {
  font-size: 14px;
  font-weight: 600;
  margin-bottom: 8px;
}

.regional-card .region-price {
  font-size: 22px;
  font-weight: 700;
  color: #337ab7;
}

.regional-card .region-fuel {
  font-size: 11px;
  color: #888;
  margin-top: 4px;
}

.regional-card .region-count {
  font-size: 11px;
  color: #aaa;
  margin-top: 2px;
}

.regional-card.placeholder {
  border: 2px dashed #ccc;
  background: #fafafa;
  color: #aaa;
}

.regional-card.placeholder .region-name {
  color: #aaa;
}

/* --- Settings --- */

.settings-group {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.settings-group h3 {
  font-size: 13px;
  font-weight: 600;
  color: #888;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 10px;
}

.settings-options {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
}

.settings-options button {
  display: inline-flex;
  align-items: center;
  padding: 8px 14px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 14px;
  cursor: pointer;
  transition: all 0.15s;
  -webkit-tap-highlight-color: transparent;
  background: #fff;
  color: #333;
}

.settings-options button.selected {
  background: #337ab7;
  color: #fff;
  border-color: #337ab7;
}

/* --- Modal --- */

.modal-backdrop {
  display: none;
  position: fixed;
  top: 0; left: 0; right: 0; bottom: 0;
  background: rgba(0,0,0,0.4);
  z-index: 200;
  opacity: 0;
  transition: opacity 0.2s;
}

.modal-backdrop.visible {
  display: block;
  opacity: 1;
}

.modal-sheet {
  position: fixed;
  top: 50px; left: 0; right: 0; bottom: 0;
  background: #fff;
  z-index: 201;
  transform: translateY(100%);
  transition: transform 0.25s ease;
  overflow-y: auto;
}

.modal-sheet.visible {
  transform: translateY(0);
}

.modal-handle {
  text-align: right;
  padding: 10px 16px 0;
  font-size: 18px;
  color: #888;
  cursor: pointer;
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 4px 16px 12px;
  border-bottom: 1px solid #eee;
}

.modal-header h2 {
  font-size: 18px;
  font-weight: 600;
}

.modal-close {
  background: none;
  border: none;
  font-size: 24px;
  color: #888;
  cursor: pointer;
  padding: 4px;
}

.modal-body {
  padding: 16px;
}

.modal-detail-row {
  display: flex;
  justify-content: space-between;
  padding: 8px 0;
  border-bottom: 1px solid #f0f0f0;
  font-size: 14px;
}

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

.modal-detail-label {
  color: #888;
}

.modal-detail-value {
  font-weight: 500;
  text-align: right;
}

.modal-actions {
  display: flex;
  gap: 8px;
  padding: 12px 16px 20px;
}

.modal-actions button {
  flex: 1;
  padding: 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
}

.modal-actions .btn-map {
  background: #337ab7;
  color: #fff;
}

.modal-actions .btn-history {
  background: #f0f0f0;
  color: #333;
}

/* --- Disclaimer --- */

.disclaimer-content {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-size: 14px;
  line-height: 1.6;
}

.disclaimer-content h2 {
  font-size: 18px;
  font-weight: 600;
  color: #0F4761;
  margin: 20px 0 8px;
  text-align: center;
}

.disclaimer-content h2:first-child {
  margin-top: 0;
}

.disclaimer-content p {
  text-align: center;
  margin: 4px 0;
  color: #555;
}

.disclaimer-content a {
  color: #337ab7;
}

/* --- Settings Buttons Row --- */

.settings-buttons-row {
  display: flex;
  gap: 10px;
}

.settings-buttons-row button {
  flex: 1;
}

.btn-version {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 12px 16px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 14px;
  font-weight: 500;
  cursor: pointer;
  transition: all 0.15s;
  color: #333;
  width: 100%;
}

.btn-version:active {
  background: #f0f0f0;
}

/* --- Version Info --- */

.version-content {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  font-size: 14px;
  line-height: 1.6;
}

.version-header {
  text-align: center;
  padding-bottom: 16px;
  border-bottom: 1px solid #eee;
  margin-bottom: 16px;
}

.version-header h2 {
  font-size: 22px;
  font-weight: 700;
  color: #337ab7;
  margin-bottom: 4px;
}

.version-number {
  font-size: 16px;
  font-weight: 600;
  color: #333;
  margin: 0;
}

.version-date {
  font-size: 13px;
  color: #888;
  margin: 4px 0 0;
}

.version-section {
  margin-bottom: 20px;
}

.version-section h3 {
  font-size: 16px;
  font-weight: 600;
  color: #0F4761;
  margin-bottom: 10px;
  padding-bottom: 6px;
  border-bottom: 1px solid #eee;
}

.version-section ul {
  margin: 0;
  padding-left: 20px;
}

.version-section li {
  margin-bottom: 6px;
  color: #555;
}

.version-item {
  margin-bottom: 16px;
}

.version-item h4 {
  font-size: 14px;
  font-weight: 600;
  color: #337ab7;
  margin-bottom: 6px;
}

.version-item ul {
  margin: 0;
  padding-left: 20px;
}

.version-item li {
  font-size: 13px;
  color: #666;
  margin-bottom: 4px;
}

.version-section p {
  margin: 6px 0;
  color: #555;
}

.version-section a {
  color: #337ab7;
}

/* --- History Chart --- */

.history-chart-container {
  background: #fff;
  border-radius: 8px;
  padding: 16px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  margin-bottom: 12px;
}

.history-chart-container h3 {
  text-align: center;
  font-size: 16px;
  margin-bottom: 12px;
  color: #337ab7;
}

#historyChart {
  width: 100%;
  height: 350px;
}

.history-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}

.btn-back {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  color: #337ab7;
  white-space: nowrap;
}

.btn-back:active {
  background: #eee;
}

/* --- Pull to Refresh --- */

.native-ptr {
  height: 0;
  opacity: 0;
  overflow: hidden;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 10px;
  background: #f5f5f5;
  transition: height 0.2s ease;
  flex-shrink: 0;
}

.native-ptr-spinner {
  width: 22px;
  height: 22px;
  border: 3px solid rgba(0, 0, 0, 0.12);
  border-top-color: #337ab7;
  border-radius: 50%;
}

.native-ptr-spinner.spinning {
  animation: ptr-spin 0.7s linear infinite;
}

.native-ptr-text {
  font-size: 13px;
  color: #888;
}

@keyframes ptr-spin {
  from { transform: rotate(0deg); }
  to { transform: rotate(360deg); }
}

/* --- Loading / Empty States --- */

.loading-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 40px;
  color: #888;
}

.loading-state .spinner {
  width: 32px;
  height: 32px;
  border: 3px solid #ddd;
  border-top-color: #337ab7;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  margin-bottom: 12px;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

.empty-state {
  text-align: center;
  padding: 40px;
  color: #888;
}

.empty-state .glyphicon {
  font-size: 40px;
  margin-bottom: 12px;
  display: block;
}

/* --- Section Headers --- */

.view-title {
  font-size: 22px;
  font-weight: 700;
  margin-bottom: 4px;
}

.view-subtitle {
  font-size: 13px;
  color: #888;
  margin-bottom: 16px;
}

/* --- Route Finder --- */

.route-search {
  background: #fff;
  border-radius: 8px;
  padding: 20px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.route-search-desc {
  font-size: 14px;
  color: #666;
  margin-bottom: 12px;
  text-align: center;
}

.route-input {
  width: 100%;
  padding: 12px;
  border: 1px solid #ddd;
  border-radius: 6px;
  font-size: 16px;
  margin-bottom: 12px;
  outline: none;
}

.route-input:focus {
  border-color: #337ab7;
}

.route-btn {
  width: 100%;
  padding: 12px;
  background: #337ab7;
  color: #fff;
  border: none;
  border-radius: 6px;
  font-size: 16px;
  font-weight: 600;
  cursor: pointer;
}

.route-btn:active {
  background: #286090;
}

.route-selection {
  padding: 4px 0;
}

.route-selection-desc {
  font-size: 13px;
  color: #888;
  margin-bottom: 12px;
}

.route-card {
  background: #fff;
  border-radius: 8px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  overflow: hidden;
}

.route-card-top {
  padding: 16px;
  cursor: pointer;
  transition: background 0.1s;
}

.route-card-top:active {
  background: #f5f5f5;
}

.route-card-actions {
  display: flex;
  border-top: 1px solid #eee;
}

.route-card-map-btn,
.route-card-select-btn {
  flex: 1;
  padding: 10px;
  border: none;
  background: none;
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  transition: background 0.1s;
}

.route-card-map-btn {
  color: #666;
  border-right: 1px solid #eee;
}

.route-card-map-btn:active {
  background: #f0f0f0;
}

.route-card-select-btn {
  color: #337ab7;
}

.route-card-select-btn:active {
  background: #e9f0f7;
}

.route-card-label {
  font-size: 14px;
  font-weight: 600;
  color: #337ab7;
  margin-bottom: 8px;
}

.route-card-details {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.route-distance {
  font-size: 18px;
  font-weight: 700;
  color: #333;
}

.route-duration {
  font-size: 14px;
  color: #666;
}

.route-stations-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 12px;
}

.route-back-btn {
  background: none;
  border: 1px solid #ddd;
  border-radius: 6px;
  padding: 6px 12px;
  font-size: 14px;
  cursor: pointer;
  color: #337ab7;
}

.route-back-btn:active {
  background: #eee;
}

.route-stations-count {
  font-size: 13px;
  color: #888;
}

.route-radius {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  margin-bottom: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
}

.route-radius-label {
  font-size: 13px;
  color: #666;
  display: block;
  margin-bottom: 8px;
}

.route-radius-buttons {
  display: flex;
  gap: 6px;
}

.route-radius-btn {
  flex: 1;
  padding: 8px 4px;
  border: 1px solid #ddd;
  border-radius: 6px;
  background: #fff;
  font-size: 12px;
  font-weight: 600;
  cursor: pointer;
  text-align: center;
  transition: all 0.15s;
}

.route-radius-btn.active {
  background: #337ab7;
  color: #fff;
  border-color: #337ab7;
}

.route-stations-list {
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.route-station {
  background: #fff;
  border-radius: 8px;
  padding: 12px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.1);
  display: flex;
  align-items: center;
  gap: 12px;
  cursor: pointer;
}

.route-station:active {
  background: #f5f5f5;
}

.route-station-left {
  flex-shrink: 0;
}

.route-station-brand {
  width: 50px;
  height: 25px;
  object-fit: contain;
}

.route-station-center {
  flex: 1;
  min-width: 0;
}

.route-station-name {
  font-size: 14px;
  font-weight: 600;
  color: #333;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.route-station-addr {
  font-size: 12px;
  color: #666;
  margin-top: 2px;
}

.route-station-dist {
  font-size: 11px;
  color: #888;
  margin-top: 2px;
}

.route-station-right {
  flex-shrink: 0;
  text-align: right;
}

.route-station-price {
  font-size: 16px;
  font-weight: 700;
  color: #337ab7;
}

.route-no-price {
  color: #ccc;
  font-size: 12px;
}

/* --- Responsive (tablet+) --- */

@media (min-width: 768px) {
  .view { padding: 20px; }
  .station-table td { padding: 12px 10px; }
  .modal-sheet { max-width: 480px; margin: 0 auto; }
}
