/* Calculator Page Styles */

/* Top Bar Navbar Buttons - Ensure Bootstrap styles apply */
.navbar .btn {
  display: inline-block !important;
  margin-bottom: 0 !important;
  font-weight: normal !important;
  text-align: center !important;
  white-space: nowrap !important;
  vertical-align: middle !important;
  cursor: pointer !important;
  background-image: none !important;
  border: 1px solid transparent !important;
  font-size: 14px !important;
  line-height: 1.42857143 !important;
  border-radius: 4px !important;
  -webkit-user-select: none !important;
  -moz-user-select: none !important;
  -ms-user-select: none !important;
  user-select: none !important;
}

.navbar .btn:hover,
.navbar .btn:focus,
.navbar .btn.focus {
  color: #ffffff !important;
  text-decoration: none !important;
}

.navbar .btn-success.navbar-btn {
  color: #ffffff !important;
  background-color: #03ac00 !important;
  border-color: #03ac00 !important;
}

.navbar .btn-success.navbar-btn:hover {
  color: #ffffff !important;
  background-color: #558000 !important;
  border-color: #4e7600 !important;
}

.navbar .btn-danger.navbar-btn {
  color: #ffffff !important;
  background-color: #cc0000 !important;
  border-color: #cc0000 !important;
}

.navbar .btn-danger.navbar-btn:hover {
  color: #ffffff !important;
  background-color: #990000 !important;
  border-color: #8f0000 !important;
}

.navbar .navbar-btn {
  margin-top: 6px !important;
  margin-bottom: 6px !important;
}

/* Position top bar buttons more towards the center */
.navbar-fixed-top .container {
  padding-left: 15px;
  padding-right: 15px;
}

.navbar-btn.left {
  margin-left: 2px;
}

.navbar-btn.right {
  margin-right: 2px;
}

/* Prirast calculator top bar — bar height for AppTopBarSpacer (see mobile-safe-area.css) */
.prirast-screen {
  --AppTopBarHeight: 62px;
}

.prirast-topbar {
  display: flex;
  align-items: center;
  margin-bottom: 0;
  /* Do not use padding shorthand — it overrides AppFixedTop's padding-top: var(--SafeAreaInsetTop) */
  padding-top: calc(8px + var(--SafeAreaInsetTop));
  padding-right: 0;
  padding-bottom: 9px;
  padding-left: 0;
}

/* Loading line on Prirast top chrome (no fixed bottom menu on this screen) */
.prirast-topbar > #loading {
  position: absolute;
  left: 0;
  right: 0;
  bottom: 0;
  height: 3px;
  pointer-events: none;
}

.prirast-topbar > #loading .browser-loading {
  position: absolute;
  top: 0;
  bottom: auto;
  left: 0;
  right: 0;
  z-index: 1055;
  height: 3px;
  width: 100%;
}

.prirast-topbar-inner {
  display: grid;
  grid-template-columns: 1fr auto 1fr;
  align-items: center;
  width: 100%;
  min-height: 45px;
  margin: 0;
  padding: 0 15px;
  box-sizing: border-box;
}

.prirast-topbar-inner .btn {
  margin: 0 !important;
}

.prirast-topbar-inner .btn-success {
  grid-column: 2;
  justify-self: center;
  min-width: 280px;
  padding: 10px 40px;
  font-size: 16px;
  font-weight: bold !important;
  border-radius: 8px !important;
  background-color: #03ac00 !important;
  background-image: linear-gradient(to top, #029800 0%, #04c204 100%) !important;
  border: 1px solid #028f00 !important;
  text-shadow: 0 -1px 0 rgba(0, 0, 0, 0.5) !important;
  box-shadow:
    0 1px 0 #028a00,
    0 1px 4px rgba(0, 0, 0, 0.25),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 0 3px rgba(255, 255, 255, 0.45);
  transition: all 0.2s ease-in-out;
}

.prirast-topbar-inner .btn-success:hover,
.prirast-topbar-inner .btn-success:focus {
  background-color: #04c204 !important;
  background-image: linear-gradient(to top, #02a800 0%, #05d405 100%) !important;
  border-color: #028f00 !important;
  color: #fff !important;
}

.prirast-topbar-inner .btn-success:active {
  background-color: #029800 !important;
  background-image: linear-gradient(to top, #04c204 0%, #03ac00 100%) !important;
  border-color: #028f00 !important;
  box-shadow:
    0 0 0 #028a00,
    0 1px 2px rgba(0, 0, 0, 0.22),
    inset 0 1px 0 rgba(255, 255, 255, 0.3),
    inset 0 0 3px rgba(255, 255, 255, 0.4);
  transform: translate(0, 1px);
}

.prirast-topbar-inner .btn-danger {
  grid-column: 3;
  justify-self: end;
  padding: 5px 10px;
}

.btn-close-calc {
  background: linear-gradient(to bottom, #6a6a6a 0%, #5a5a5a 50%, #4a4a4a 100%);
  color: white;
  border: 1px solid rgba(255, 255, 255, 0.2);
  padding: 8px 18px;
  font-size: 18px;
  font-weight: bold;
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.3s ease;
  min-width: 50px;
}

.btn-close-calc:hover {
  background: linear-gradient(to bottom, #5a5a5a 0%, #4a4a4a 50%, #3a3a3a 100%);
}

/* Card Container */
.calc-card {
  background: white;
  border-radius: 10px;
  padding: 30px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
  margin-bottom: 20px;
}

/* Equal card heights: both columns match the taller side */
.calc-columns-equal {
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
}

.calc-columns-equal > [class*='col-'] {
  display: flex;
  flex-direction: column;
}

.calc-columns-equal > [class*='col-'] > .calc-card {
  flex: 1 1 auto;
  width: 100%;
  margin-bottom: 0;
}

.calc-card.calc-co2-section {
  margin-top: 0;
}

/* Tree Header */
.calc-tree-header {
  display: flex;
  align-items: center;
  margin-bottom: 27px;
  padding-bottom: 20px;
  border-bottom: 3px solid #4caf50;
}

.calc-tree-image {
  height: 90px;
  object-fit: contain;
  margin-right: 20px;
}

.calc-tree-info {
  display: flex;
  flex-direction: column;
}

.calc-tree-label {
  font-size: 14px;
  color: #666;
  margin-bottom: 5px;
}

.calc-tree-name {
  font-size: 28px;
  font-weight: bold;
  color: #4caf50;
  line-height: 1.2;
  /* Reserve BG+EN (two lines) so EN one-line name does not shrink the left column */
  min-height: calc(2 * 1.2em);
}

.calc-tree-name-english {
  display: inline;
}

.calc-tree-origin {
  font-size: 16px;
  color: #666;
  margin-top: 5px;
  font-weight: 500;
}

/* Input Rows */
.calc-input-row {
  padding: 15px 20px;
  margin-bottom: 10px;
  background: #f5f5f5;
  border-radius: 8px;
  /* border-left: 4px solid #4CAF50; */
  transition: all 0.3s ease;
  display: flex;
  justify-content: space-between;
  align-items: center;
  position: relative;
}

.calc-input-row:hover {
  background: #eeeeee;
  border-left-color: #45a049;
}

.calc-input-row.text-center {
  justify-content: center;
}

/* Always reserve two text lines so BG wrap and EN one-line keep the same height */
.calc-input-row.calc-example-values-btn {
  min-height: calc(2 * 1.3em + 30px); /* 2 lines + desktop padding */
  justify-content: center;
  align-items: center;
  text-align: center;
}

.calc-input-row.calc-example-values-btn strong {
  display: block;
  line-height: 1.3;
  text-align: center;
}

.calc-input-row label {
  font-size: 16px;
  color: #333;
  margin: 0;
  font-weight: 500;
  flex: 1;
}

/* Info Button */
.calc-info-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 20px;
  height: 20px;
  border-radius: 50%;
  background-color: transparent;
  color: #4caf50;
  font-size: 12px;
  font-weight: bold;
  cursor: pointer;
  margin-left: 10px;
  flex-shrink: 0;
  transition: all 0.3s ease;
  border: 2px solid #4caf50;
  padding: 0;
  line-height: 1;
  z-index: 1000;
}

.calc-info-button:hover {
  background-color: transparent;
  border-color: #45a049;
  color: #45a049;
  transform: scale(1.1);
}

.calc-info-button:focus {
  outline: none;
}

.calc-copy-on-hold {
  position: relative;
  display: inline;
}

.calc-input-row--readonly {
  cursor: default;
}

.calc-input-row--readonly:hover {
  background: #f5f5f5;
}

.calc-input-row--readonly label {
  cursor: default;
}

.calc-copy-on-hold--enabled {
  cursor: pointer;
  -webkit-touch-callout: none;
  user-select: none;
  -webkit-user-select: none;
}

.calc-copy-on-hold--enabled strong {
  border-radius: 4px;
  padding: 0 2px;
  transition: background-color 0.2s ease;
}

.calc-copy-on-hold--enabled:active strong,
.calc-copy-on-hold--copied strong {
  background-color: rgba(3, 172, 0, 0.18);
}

.calc-copy-on-hold__badge {
  position: absolute;
  left: 50%;
  bottom: calc(100% + 4px);
  transform: translateX(-50%);
  background: rgba(40, 40, 40, 0.92);
  color: #fff;
  font-size: 11px;
  font-weight: 600;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  pointer-events: none;
  z-index: 2;
}

/* Tooltip Font Size - Target both tooltip container and inner element */
.tooltip,
.tooltip .tooltip-inner,
body .tooltip,
body .tooltip-inner {
  font-size: 16px !important;
}

/* CO2 Section */
.calc-co2-section {
  background: linear-gradient(to bottom, #ffffff 0%, #f9f9f9 100%);
  overflow: visible;
}

.calc-co2-header {
  text-align: center;
  font-size: 24px;
  font-weight: bold;
  color: #4caf50;
  margin-bottom: 25px;
  padding-bottom: 15px;
  border-bottom: 3px solid #4caf50;
  position: relative;
  z-index: 0;
}

/* Keep field rows (and info tooltips) above the CO2 title bar when tooltips open upward */
.calc-co2-section > .row {
  position: relative;
  z-index: 1;
  overflow: visible;
}

/* Responsive */
@media (max-width: 768px) {
  .prirast-topbar-inner .btn-success {
    min-width: 200px;
    max-width: calc(100% - 70px);
    padding: 10px 24px;
    font-size: 14px;
  }

  .calc-tree-header {
    flex-direction: column;
    text-align: center;
  }

  .calc-tree-image {
    margin-right: 0;
    margin-bottom: 15px;
  }

  .calc-tree-name-english {
    display: block;
    margin-top: 4px;
    font-size: 0.85em;
  }

  .calc-tree-name {
    /* Second line is smaller (0.85em) + 4px gap when EN is shown under BG */
    min-height: calc(1.2em + 4px + 0.85em * 1.2);
  }

  .calc-card {
    padding: 8px;
  }

  .calc-input-row {
    padding: 8px 6px;
    flex-direction: column;
    align-items: flex-start;
    margin-bottom: 8px;
  }

  .calc-input-row.text-center {
    align-items: center;
    text-align: center;
    justify-content: center;
  }

  .calc-input-row.calc-example-values-btn {
    min-height: calc(2 * 1.4em + 16px); /* 2 lines + mobile padding */
    align-items: center;
  }

  .calc-input-row label {
    display: block;
    width: 100%;
    line-height: 1.4;
  }

  .calc-value-measurement {
    display: block;
    margin-top: 3px;
  }

  .calc-input-row label strong {
    font-weight: bold;
  }

  .calc-info-button {
    position: absolute;
    top: 8px;
    right: 6px;
    margin-left: 0;
  }

  /* Reduce column padding on mobile */
  .row .col-xs-6.p2 {
    padding-left: 2px;
    padding-right: 2px;
  }

  .row .col-xs-6 {
    padding-left: 2px;
    padding-right: 2px;
  }

  /* Ensure row doesn't overflow - override Bootstrap negative margins */
  .row {
    margin-left: 0 !important;
    margin-right: 0 !important;
    max-width: 100%;
    overflow-x: clip;
  }

  /* Prirast cards: allow info tooltips to extend above rows (e.g. CO2 block under header) */
  .calc-card,
  .calc-co2-section,
  .calc-co2-section .row,
  .calc-co2-section .calc-input-row {
    overflow: visible;
  }

  .calc-co2-section .calc-input-row {
    z-index: 1;
  }

  .calc-co2-section .calc-input-row:focus-within {
    z-index: 2;
  }

  /* Ensure columns fit within viewport */
  .row [class*='col-'] {
    max-width: 100%;
  }
}
