:root {
  --primary_color: #ffffff;
  --accent_color: #4a649f;
  --accent_light: #4a649fee;
  --border_color: #999;
  --border_light: #d1d5db;
  --text_primary: #333;
  --text_secondary: #555;
  --text_muted: #6c757d;
  --gray_light: #f5f5f5;
  --gray_hover: #f0f0f0;
}

* {
  box-sizing: border-box;
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Open Sans', Helvetica, Arial, sans-serif;
}

html { font-size: clamp(15.5px, 1.5vw, 21px); }
html, body { height: 100%; margin: 0; padding: 0; }
table { border-collapse: collapse; }

body {
  background-color: var(--primary_color);
  color: var(--text_primary);
  display: flex;
  flex-direction: column;
  align-items: center;
  padding: 1rem;
}

header {
  display: flex;
  justify-content: space-between;
  padding: 1rem;
  width: 100%;
  max-width: 1000px;
}

.hide { visibility: hidden; }

.logo {
  float: left;
  background: url('delphi_cargo_logo.webp') no-repeat;
  background-size: contain;
  width: 150px;
  height: 50px;
}

header ul {
  display: flex;
  list-style: none;
  gap: 2rem;
}

a {
  color: var(--accent_color);
  text-decoration: none;
}

a:hover { text-decoration: underline; }

.nav {
  margin-left: auto;
  position: relative;
}
.nav span { margin-left: 1rem; }
.info { margin-left: 1.5rem; }

main {
  flex-direction: column;
  justify-content: center;
  width: 100%;
  max-width: 1000px;
  margin: 0 auto;
}

#cargo_form {
  width: 100%;
  max-width: 1000px;
}

#incoterm, #postal_code { max-width: 9rem; }

.form_row {
  display: flex;
  gap: 1rem;
  margin-bottom: 1.5rem;
  flex-wrap: wrap;
  position: relative;
}

.remove_piece {
  flex: unset !important;
  min-width: 0 !important;
}

.remove_piece .dims {
  align-items: center;
  height: 100%;
}

.remove_piece button {
  width: 1.5rem;
  height: 1.5rem;
  border: 1px solid #f97979;
  color: #f97979;
  background: white;
  font-size: 1.2rem;
  border-radius: 9%;
  cursor: pointer;
}

.remove_piece button:hover {
  background: #f44336;
  color: white;
  border-color: #f44336;
}

.form_group {
  display: flex;
  flex-direction: column;
  flex: 1;
  min-width: 4rem;
}

label {
  font-weight: 500;
  text-wrap: nowrap;
}

.form_group label,
input[type=radio] {
  margin-bottom: 0.2rem;
}

input, select {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border_color);
  border-radius: 4px;
  font-size: 16px;
}

select {
  appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='currentColor' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6 9 12 15 18 9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 1rem;
}

.dims_group { flex: 2; }

.dims {
  display: flex;
  gap: 0.5rem;
}

.dims input { width: 100%; }

.radios {
  display: flex;
  gap: 0.8rem;
  margin-top: 0.4rem;
  justify-content: flex-end;
}

.radios label { margin-right: auto; }

.cargo_options {
  display: flex;
  flex-wrap: wrap;
  gap: 1.0rem;
  width: 100%;
  font-size: 0.94rem;
}

.cargo_options>div {
  display: flex;
  align-items: center;
}

.cargo_options input {
  margin-left: 1.3rem;
}

.cargo_options input:first-child {
  margin-left: 0;
}

#rates {
  background-color: var(--accent_color);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 4px;
  font-size: 1rem;
  cursor: pointer;
  /*transition: background-color 0.1s;*/
  margin-left: auto;
}

#rates:hover { background-color: #2488cb; }
#rates:disabled {
  background-color: #95a5a6;
  cursor: not-allowed;
}

.off { display: none; }
.no_click { pointer-events: none; }

.user_icon {
  display: inline-block;
  width: 1.8rem;
  height: 1.8rem;
  line-height: 1.7rem;
  text-align: center;
  color: var(--accent_color);
  border: 1px solid var(--accent_color);
  border-radius: 50%;
  font-weight: bold;
  position: relative;
}

.user_icon a {
  display: block;
  width: 100%;
  height: 100%;
  text-decoration: none;
  color: inherit;
}

.user_icon:hover {
  background-color: var(--accent_color);
  cursor: pointer;
}

.user_icon:hover a {
  color: white;
}

.user_popup {
  display: none;
  position: absolute;
  top: 100%;
  right: 0;
  margin-top: 0.5rem;
  background: white;
  border: 1px solid #ddd;
  border-radius: 0.5rem;
  box-shadow: 0 2px 10px rgba(0,0,0,0.1);
  padding: 0.5rem;
  z-index: 1000;
}

.user_popup button {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid var(--accent_color);
  border-radius: 0.25rem;
  color: var(--accent_color);
  font-size: 0.9rem;
  cursor: pointer;
  /*transition: all 0.2s;*/
}

.user_popup button:hover {
  background: var(--accent_color);
  color: white;
}

.user_popup .admin_link {
  display: block;
  width: 100%;
  padding: 0.5rem 1rem;
  background: white;
  border: 1px solid var(--accent_color);
  border-radius: 0.25rem;
  color: var(--accent_color);
  text-decoration: none;
  text-align: center;
  margin-bottom: 0.5rem;
  font-size: 0.9rem;
}

.user_popup .admin_link:hover {
  background: var(--accent_color);
  color: white;
}

.user a {
  color: var(--accent_color);
  text-decoration: none;
  cursor: pointer;
}

.user a:hover {
  text-decoration: underline;
}

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;
}

/* Tooltip styles */
.form_group {
  position: relative;
}

.tooltip {
  position: absolute;
  top: -30px;
  left: 50%;
  transform: translateX(-50%);
  background: #333;
  color: white;
  padding: 0.4rem 0.8rem;
  border-radius: 4px;
  font-size: 0.85rem;
  white-space: nowrap;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.3s ease;
}

.tooltip::after {
  content: '';
  position: absolute;
  top: 100%;
  left: 50%;
  transform: translateX(-50%);
  border: 5px solid transparent;
  border-top-color: #333;
}

.country_from input:hover + .tooltip,
.country_from input:focus + .tooltip {
  opacity: 1;
}

#result {
  margin: 1rem auto;
  width: 100%;
  max-width: 1000px;
}

#result ul { margin: .5rem 1rem; }
#result li { padding: .2rem 0; }

#result hr {
  height: 1px;
  border: none;
  background-color: #ccc;
  margin: 1rem auto;
  width: 96%;
  max-width: 840px;
}

#result table { width: 96%; }

#result td {
  text-align: left;
  vertical-align: top;
  padding: .2rem .5rem;
}

#result th { color: var(--accent_light); }

#result u {
  text-decoration: none;
  padding: 0 .3rem;
  color: #3056ab;
}

.exw {
  color: var(--accent_light) !important;
  padding-right: .3rem;
}

#result s {
  text-decoration: none !important;
  padding-right: .23rem;
  font-size: 90%;
  color: #888;
}

#result th i {
  font-style: normal;
  padding: 0 .8rem;
}

#result td i {
  font-style: normal;
  font-size: 90%;
  color: #888;
}

#result td.num {
  padding-right: .2rem;
  text-align: right;
}

#result td.tot {
  border-left: 1px solid #ccc;
  text-align: right;
}

label:disabled, input:disabled {
  opacity: 0.7;
  pointer-events: none;
}

#add_piece {
  padding: 10px 20px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  background-color: var(--text_muted);
  /*transition: background-color 0.1s;*/
  align-self: flex-start;
  margin: 0;
}

#add_piece:hover { background-color: #7f93a8; }

.book {
  padding: 4px 20px;
  color: white;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  background-color: #38b8ce;
  align-self: flex-start;
}

.book:hover { background-color: #38b8ced8; }

#overlay {
  display: none;
  position: fixed;
  z-index: 998;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
}

#sign_up {
  display: none;
  position: fixed;
  z-index: 999;
  left: 50%;
  top: 53%;
  transform: translate(-50%, -50%);
  width: 85%;
  height: unset;
  max-width: 33rem;
  background-color: #fefefe;
  border-radius: 8px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.3);
}

.modal>div {
  padding: 2rem 4rem 3rem;
  position: relative;
}

.modal .from_group { margin-bottom: 1rem; }
.modal h2 { text-align: center; }

#sign_in {
  background-color: var(--accent_color);
  color: white;
  margin-top: 2rem;
  padding: 1rem 2rem;
  border: none;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  display: block;
  width: 100%;
  /*transition: background-color 0.2s ease;*/
}

#sign_in:hover { background-color: var(--accent_light); }

.tbl_container {
  font-size: 0.9rem;
  background-color: white;
  border-radius: 0.5rem;
  box-shadow: 0 0.06rem 0.18rem rgba(0, 0, 0, 0.4);
  overflow: hidden;
  margin-bottom: 1rem;
  width: 100%;
  max-width: 1000px;
}

.hdr { font-size: 0.9rem; }

.tbl_hdr, .tbl_row {
  display: flex;
  flex-wrap: wrap;
  padding: 0.75rem;
  border-bottom: 0.062rem solid #aaa;
}

.tbl_hdr {
  background-color: #d5d5d7;
  font-weight: 500;
  color: #222;
  font-size: .9rem;
}

.tbl_hdr u {
  text-decoration: none;
  padding: 0 .3rem;
}

.tbl_hdr th, .tbl_hdr td { vertical-align: middle !important; }

.tbl_hdr td {
  width: 100%;
  padding: 0 !important;
}

.tbl_row { cursor: pointer; }
.tbl_row:hover { background-color: var(--gray_hover); }
.tbl_row:last-child { border-bottom: none; }

.col {
  padding: 0.1rem 0.4rem;
  text-wrap: nowrap;
}

.hdr { overflow: hidden; }

.hdr > div {
  float: left;
  line-height: 1;
  padding: 0.3rem 0.7rem;
}

.hdr > div:first-child { margin-top: 0; }

.col_tt { font-weight: 400; }

.col_total {
  font-weight: 500;
  text-align: right;
}

.col_total b { font-size: 1.1rem; }

.col_exw, .col_af, .col_valid { color: var(--text_secondary); }

.col_actions {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.btn_info {
  background-color: white;
  border: 0.062rem solid var(--border_light);
  border-radius: 0.37rem;
  padding: 0.5rem 0.62rem;
  font-size: 0.9rem;
  color: #374151;
  cursor: pointer;
  /*transition: all 0.1s;*/
  min-width: 2rem;
  height: 2rem;
  display: flex;
  align-items: center;
  justify-content: center;
}

.btn_info:hover {
  background-color: #f3f4f6;
  border-color: #9ca3af;
}

.btn_book {
  background-color: white;
  border: 0.12rem solid var(--accent_color);
  border-radius: 0.37rem;
  padding: 0.5rem 1rem;
  font-size: 0.85rem;
  color: var(--accent_color);
  cursor: pointer;
  /*transition: all 0.1s;*/
  height: 2rem;
  display: flex;
  align-items: center;
}

.btn_book:hover {
  background-color: var(--accent_light);
  color: white;
}

.arrow_indicator {
  display: inline-block;
  font-size: 1.5rem;
  color: #6b7280;
  opacity: 0;
  line-height: 1;
  transform: rotate(0deg);
}

.tbl_row:hover .arrow_indicator { opacity: 1; }

.tbl_row.expanded .arrow_indicator {
  opacity: 1;
  transform: rotate(90deg);
}

.tbl_detail_row {
  display: none;
  background-color: #cbd8f7a3;
  border-bottom: 0.062rem solid #aaa;
  padding: 1rem;
  width: 100%;
  max-width: 1000px;
}

.detail_content {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.detail_info {
  display: flex;
  flex-wrap: wrap;
  gap: 0.9rem;
  align-items: center;
}

.detail_info .col { flex: 1 1 0; }

.col_airline {
  display: flex;
  flex-direction: column;
  gap: 0.3rem;
}

.col_airline label {
  font-weight: 500;
  font-size: 0.9rem;
}

.airline_input {
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border_color);
  border-radius: 4px;
  font-size: 16px;
  width: 100%;
}

.detail_actions {
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.question_row {
  display: flex;
  position: relative;
  width: 100%;
  align-items: center;
  gap: 0.5rem;
}

.question_textarea {
  flex: 1;
  padding: 0.5rem;
  border: 1px solid var(--border_color);
  border-radius: 4px;
  font-size: 16px;
  resize: none;
  min-height: 2.5rem;
  height: 2.5rem;
  line-height: 1.5rem;
  overflow: hidden;
}

.action_buttons {
  display: flex;
  gap: 0.5rem;
  align-items: center;
  justify-content: flex-end;
}

.btn_submit_question {
  display: none;
  background-color: var(--text_muted);
  color: white;
  border: none;
  border-radius: 0.37rem;
  padding: 0.35rem 0.8rem;
  font-size: 0.85rem;
  cursor: pointer;
  /*transition: all 0.13s;*/
  height: 2rem;
}

.btn_submit_question.show { display: block; }
.btn_submit_question:hover { background-color: #5a6268; }

.btn_book_detail {
  background-color: var(--accent_color);
  border: 0.12rem solid var(--accent_color);
  border-radius: 0.37rem;
  padding: 0.5rem 1.5rem;
  font-size: 0.85rem;
  color: white;
  cursor: pointer;
  /*transition: all 0.13s;*/
}

.btn_book_detail:hover {
  background-color: var(--accent_light);
  color: white;
}

.notice_line {
  font-size: 0.85rem;
  color: #28a745;
  padding: 0.5rem;
  background-color: #d1f5d3;
  border-radius: 0.25rem;
  text-align: center;
}

.modal {
  display: none;
  position: fixed;
  z-index: 1000;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  backdrop-filter: blur(0.25rem);
}

.modal_content {
  position: relative;
  background-color: #fff;
  margin: 10% auto;
  padding: 2rem;
  border-radius: 0.5rem;
  width: 90%;
  max-width: 30rem;
  box-shadow: 0 0.25rem 1rem rgba(0, 0, 0, 0.2);
}

.modal_close {
  position: absolute;
  right: 1rem;
  top: 1rem;
  font-size: 1.75rem;
  font-weight: bold;
  line-height: 1;
  color: #999;
  cursor: pointer;
  /*transition: color 0.13s;*/
}

.modal_close:hover { color: var(--text_primary); }

.modal h3 {
  margin: 0 0 1rem 0;
  color: var(--text_primary);
  font-size: 1.25rem;
}

#info_form textarea {
  width: 100%;
  padding: 0.75rem;
  border: 0.0625rem solid var(--border_light);
  border-radius: 0.375rem;
  font-family: inherit;
  font-size: 0.875rem;
  resize: vertical;
  min-height: 8rem;
  margin-bottom: 1rem;
}

#info_form textarea:focus {
  outline: none;
  border-color: #3b82f6;
  box-shadow: 0 0 0 0.125rem rgba(59, 130, 246, 0.1);
}

#info_form button[type="submit"] {
  background-color: var(--accent_color);
  color: white;
  border: none;
  border-radius: 0.375rem;
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
  cursor: pointer;
  /*transition: background-color 0.13s;*/
}

#info_form button[type="submit"]:hover { background-color: var(--accent_light); }

.btn_book_detail.loading,
.btn_book_hist.loading {
  animation: pulse 1s ease-in-out infinite;
  cursor: not-allowed;
}

@keyframes pulse {
  0% { background-color: var(--accent_color); }
  50% {
    background-color: var(--accent_light);
    transform: scale(1.02);
  }
  100% { background-color: var(--accent_color); }
}

.btn_book_detail:disabled,
.btn_book_hist:disabled {
  opacity: 0.9;
}

tr.booked { cursor: default; }
tr.booked:hover { background-color: inherit; }

.modal_ok {
  background-color: var(--accent_color);
  color: white;
  border: none;
  border-radius: 0.375rem;
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
  cursor: pointer;
  /*transition: background-color 0.13s;*/
  margin-top: 1rem;
  width: auto;
  margin-right: 0.5rem;
}

.modal_ok:hover { background-color: var(--accent_light); }

.modal_cancel {
  background-color: white;
  color: var(--text_primary);
  border: 1px solid var(--border_light);
  border-radius: 0.375rem;
  padding: 0.75rem 2rem;
  font-size: 0.875rem;
  cursor: pointer;
  margin-top: 1rem;
}

.modal_cancel:hover { background-color: var(--gray_hover); }

#country_from[readonly] {
  background-color: var(--gray_light);
  cursor: not-allowed;
  opacity: 0.8;
}

@media (min-width: 768px) {
  .user { display: inline-block !important; }
  .user_icon { display: none !important; }

  .tbl_hdr, .tbl_row {
    display: flex;
    flex-wrap: nowrap;
    align-items: center;
    gap: 0.9rem;
  }

  .col { flex: 1 1 0; }
  .col_tt { flex: 0.8 1 0; }
  .col_exw { flex: 1 1 0; }
  .col_af { flex: 1 1 0; }
  .col_valid { flex: 1.5 1 0; }
  .col_total { flex: 0.8 1 0; }

  .col_actions {
    flex: 0 0 auto;
    margin-left: auto;
    gap: 0.5rem;
  }
}

@media (max-width: 767px) {
  .cargo_options input:first-child { margin-left: 0.1rem; }
  .user { display: none !important; }
  .user_icon { display: inline-block !important; }

  .form_group { min-width: 100%; }
  .remove_piece { min-width: 0; }
  .pieces { min-width: 0; }
  .dims_group { flex: 1; }

  .tbl_row {
    display: grid;
    grid-template-rows: auto auto;
    gap: 0.5rem;
  }

  .col_tt { grid-column: 1; grid-row: 1; }
  .col_exw { grid-column: 2; grid-row: 1; }
  .col_total { grid-column: 3; grid-row: 1; }
  .col_valid { grid-column: 1; grid-row: 2; }
  .col_af { grid-column: 2; grid-row: 2; }

  .col_actions {
    grid-column: 3;
    grid-row: 2;
    display: flex;
    gap: 0.25rem;
    justify-content: flex-end;
    align-items: center;
  }

  .detail_info {
    flex-direction: column;
    gap: 0.5rem;
  }

  .detail_info .col { width: 100%; }

  .btn_submit_question {
    padding: 0.3rem 0.6rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 480px) {
  .modal_content {
    width: 95%;
    padding: 1.5rem;
    margin: 20% auto;
  }

  .modal h3 { font-size: 1.125rem; }

  #info_form textarea {
    font-size: 16px;
    padding: 0.625rem;
  }
}

@media (max-width: 479px) {
  header { padding: 0 0 1rem 0; }
  .body { padding: 0.5rem; }

  .tbl_hdr, .tbl_row { padding: 0.5rem; }

  .col {
    padding: 0;
    font-size: 0.875rem;
  }

  .btn_info, .btn_book {
    padding: 0.37rem 0.62rem;
    font-size: 0.75rem;
    height: 1.75rem;
  }

  .btn_info {
    min-width: 1.75rem;
    padding: 0.37rem 0.5rem;
  }

  #cargo_form { font-size: 0.875rem; }
  #cargo_form label { font-size: 0.875rem; }

  #cargo_form input,
  #cargo_form select {
    font-size: 16px;
    padding: 0.4rem 0.5rem;
  }

  .cargo_options label { font-size: 0.8rem !important; }
  .cargo_options input { margin-left: .5rem; }

  #cargo_form #rates {
    font-size: 0.875rem;
    padding: 0.6rem 1.5rem;
  }

  #cargo_form #add_piece {
    font-size: 0.875rem;
    padding: 0.5rem 1rem;
  }

  .hdr > div { flex: 1 1 calc(50% - 0.5rem); }
  #result s { padding-right: 0; }
}

.no_result {
    width: 100%;
}
.no_result p {
    text-align: center;
    margin-bottom: 0.6rem;
}
.no_result b {
    font-weight: 500;
    font-size: 1.1rem;
}
