html {
  font-size: 14px;
}

@media (min-width: 768px) {
  html {
    font-size: 16px;
  }
}

body {
  background: #f4f6fb;
  margin-bottom: 60px;
}

.header-logo {
  display: flex;
  align-items: center;
  margin-right: 1rem;
}

.header-logo-image {
  height: 2.0rem;
  width: auto;
  display: block;
}

.container {
  max-width: none;
  margin-left: 10px;
  margin-right: 10px;
}

.btn:focus, .btn:active:focus, .btn-link.nav-link:focus, .form-control:focus, .form-check-input:focus {
  box-shadow: 0 0 0 0.1rem white, 0 0 0 0.25rem #258cfb;
}

.icon-button {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  /* 20% larger than before (2.25rem * 1.2 = 2.7rem) */
  width: 2.7rem;
  min-width: 2.7rem;
  height: 2.7rem;
  padding: 0;
  /* scale font-size by 20% */
  font-size: 1.5rem;
  line-height: 1;
  /* remove visible framing from bootstrap btn classes */
  background: transparent !important;
  border: none !important;
  box-shadow: none !important;
  /* stronger default contrast */
  color: #212529;
}

/* Icon styling: use currentColor so SVGs follow text color. Default icon color
   is dark; when a row is selected the color becomes white. On hover use orange. */
.icon-button .icon {
  /* scale inner SVG by 20% as well */
  width: 1.2em;
  height: 1.2em;
  display: block;
  fill: currentColor;
}

.icon-button:hover { color: #ff9800; }

/* Selected rows: make action icons white for contrast on blue background */
.customer-row.active .icon-button,
.customer-row.selected .icon-button,
.order-row.selected .icon-button,
.open-item-row.selected .icon-button {
  color: #ffffff !important;
}

.icon-button-small {
  /* Reduced to ~50% of original icon-button size for compact action icons */
  width: 1.35rem;
  min-width: 1.35rem;
  height: 1.35rem;
  font-size: 0.75rem;
}

/* Override Bootstrap's btn-group-sm shrinking for standalone icon buttons (e.g. add '+')
   Keep small action buttons (icon-button-small) unaffected by the generic rule below by
   providing a more specific selector that targets icon-button-small inside a btn-group.
   The second rule uses !important to counter the generic override above. */
.btn-group.btn-group-sm > .btn.icon-button {
  width: 2.7rem !important;
  min-width: 2.7rem !important;
  height: 2.7rem !important;
  font-size: 1.5rem !important;
  padding: 0 !important;
}

/* Specific override: ensure small action icons inside btn-group.btn-group-sm stay compact */
.btn-group.btn-group-sm > .btn.icon-button.icon-button-small {
  width: 1.35rem !important;
  min-width: 1.35rem !important;
  height: 1.35rem !important;
  font-size: 0.75rem !important;
  padding: 0 !important;
}

.manager-shell {
  padding: 1rem 0;
}

.manager-layout {
  display: grid;
  grid-template-columns: minmax(0, 1fr) minmax(0, 1fr);
  gap: 1rem;
  min-height: calc(100vh - 10rem);
  align-items: start;
}

.manager-sidebar,
.manager-content {
  min-width: 0;
}

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

.manager-sidebar .panel-box {
  padding: 0.75rem;
}

.customer-list .customer-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  min-width: 0;
  margin-bottom: 0;
  padding: 0.35rem 0.5rem;
  border-radius: 6px;
}

.customer-list .customer-link {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 0.5rem;
  min-width: 0;
  flex: 1;
  color: inherit;
  text-decoration: none;
}

.customer-list .customer-link small {
  flex: 0 0 auto;
  opacity: 0.75;
}

.customer-list .customer-actions {
  flex: 0 0 auto;
}

.customer-list .customer-actions .btn {
  padding: 0.2rem 0.4rem;
  font-size: 0.75rem;
}

.manager-content > .panel-box {
  min-height: calc(100vh - 10rem);
}

.manager-content .nav-tabs .nav-link {
  color: #212529;
}

.manager-content .nav-tabs .nav-link.active {
  font-weight: 700;
}

.note-row {
  cursor: pointer;
}
.note-row:hover {
  background-color: #f8f9fa;
}

.note-summary {
  max-width: 20rem;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
}

.note-editor {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
  min-height: 0;
}

.note-editor textarea,
.note-editor .note-preview {
  flex: 1 1 auto;
  min-height: 0;
  overflow: auto;
}

.note-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}

.panel-box {
  background: #fff;
  border: 1px solid #e5e7eb;
  border-radius: 12px;
  padding: 1rem;
  box-shadow: 0 1px 2px rgba(15, 23, 42, 0.04);
}

.customer-list .customer-row {
  cursor: pointer;
  border-radius: 8px;
  margin-bottom: 0.35rem;
}

.customer-row:hover {
  background-color: #f8f9fa;
}

.user-table > tbody > tr.user-row {
  cursor: pointer;
}

.user-table > tbody > tr.user-row:hover {
  --bs-table-accent-bg: #f8f9fa;
  --bs-table-hover-bg: #f8f9fa;
  --bs-table-hover-color: #212529;
}

.compact-page > .d-flex > .icon-button {
  padding: 0;
  font-size: 1.5rem;
}

/* Table-based selected customer row (use same styling as orders table) */
.customer-row.selected > td {
  background-color: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

.customer-row.selected:hover > td {
  background-color: #b0cdeb;
    color: #000;
}

/* Keep legacy list-style active styling for backwards compatibility */
.customer-list .customer-row.active {
  background: #0d6efd;
  color: #fff;
}

.rounded-table {
  border: 1px solid #e5e7eb;
  border-radius: 8px;
  overflow: hidden;
}

.order-row {
  cursor: pointer;
  transition: background-color 0.15s ease;
}

.order-row.open-item-new > td {
  background-color: #f9b65e;
}

.order-row.open-item-warning > td {
  background-color: #eed8bb;
}

.order-row.open-item-closed > td {
  background-color: #aff1b4;
  border-color: #c8e6c9;
}

.order-row.open-item-new:hover > td {
  background-color: #f8f9fa;
}

.order-row.open-item-warning:hover > td {
  background-color: #fffffe;
}

.order-row.open-item-closed:hover > td {
  background-color: #e8f5e9;
}

.order-row.selected > td {
  background-color: #0d6efd;
  color: #fff;
  border-color: #0d6efd;
}

.order-row.selected:hover > td {
  background-color: #b0cdeb;
  color: #000;
}

.order-row:hover {
  background-color: #f8f9fa;
}

.open-item-new {
  background-color: #f9b65e;
}


.open-item-new.open-item-closed:hover > td {
  background-color: #f7d7b4;
}

.open-item-warning {
  background-color: #eed8bb;
}
.open-item-warning:hover > td {
  background-color: #fffffe;
}


.open-item-closed,
.open-item-closed td {
  background-color: #aff1b4;
}

.open-item-row.open-item-closed:hover > td {
  background-color: #e8f5e9;
}

.open-item-closed td {
  border-color: #c8e6c9;
}

.open-item-name-badge {
  display: inline-block;
  padding: 0.15rem 0.6rem;
  border-radius: 0.5rem;
  color: #000;
}

.badge-color-toggle {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.2rem 0.5rem;
  font-size: 0.875rem;
}

.badge-color-swatch {
  display: inline-block;
  width: 1.5rem;
  height: 1.2rem;
  border-radius: 0.35rem;
  border: 1px solid #adb5bd;
  background-color: transparent;
}

.badge-color-menu {
  grid-template-columns: repeat(5, 1.6rem);
  gap: 0.3rem;
  padding: 0.5rem;
  min-width: 0;
}

/* display: grid jen u otevřené nabídky, jinak by byla vždy vidět */
.badge-color-menu.show {
  display: grid;
}

.badge-color-option {
  width: 1.6rem;
  height: 1.6rem;
  border-radius: 0.35rem;
  border: 1px solid #adb5bd;
  padding: 0;
  background-color: #fff;
}

.badge-color-option:hover {
  outline: 2px solid #0d6efd;
}

.badge-color-none {
  background: linear-gradient(135deg, #fff 45%, #dc3545 45%, #dc3545 55%, #fff 55%);
}

.open-item-row {
  position: relative;
}

.open-item-row:hover {
  background-color: #f8f9fa;
}

.open-item-row .open-item-action {
  position: relative;
  z-index: 1;
  pointer-events: auto;
}

.modal-content {
  border-radius: 14px;
}

@media (max-width: 991.98px) {
  .manager-layout {
    grid-template-columns: 1fr;
  }

  .manager-content > .panel-box {
    min-height: auto;
  }
}

/* Make compact warning/count badges smaller in lists (override inline styles) */
.rounded-table .badge.bg-warning.rounded-circle,
.customer-list .badge.bg-warning.rounded-circle {
  min-width: 18px !important;
  height: 18px !important;
  font-size: 0.75rem !important;
  display: inline-flex !important;
  align-items: center !important;
  justify-content: center !important;
  padding: 0 !important;
}

/* Comments modal: two-column layout with right-side new-comment area */
.comments-modal-body {
  display: flex;
  gap: 1rem;
  align-items: flex-start;
}
.comments-list {
  flex: 1 1 auto;
  max-height: 80vh;
  overflow-y: auto;
  font-size: 0.875rem;
}
.comment-new {
  flex: 0 0 60%;
  max-width: 60%;
}

@media (max-width: 767.98px) {
  .comments-modal-body {
    flex-direction: column;
  }
  .comment-new {
    flex: none;
    max-width: none;
    width: 100%;
  }
}
/* Make the comments modal wider while keeping mobile fallback */
#openItemCommentsModal .modal-dialog {
  max-width: 95vw;
  width: 95vw;
  margin: 1.75rem auto;
}

@media (max-width: 991.98px) {
  #openItemCommentsModal .modal-dialog {
    max-width: 100vw;
    width: 100vw;
    margin: 0.5rem auto;
  }
}

/* Mobile: wrap rows and button groups for all lists so action icons remain visible */
@media (max-width: 767.98px) {
  /* Generic list row wrapping for flex-based lists (customer list and similar) */
  .customer-list .customer-row,
  .manager-sidebar .panel-box .customer-row {
    flex-wrap: wrap;
    align-items: flex-start;
    gap: 0.5rem;
  }

  /* Make primary link content take full width so actions move to their own line */
  .customer-list .customer-link,
  .customer-list .customer-link small {
    flex: 1 1 100%;
    width: 100%;
  }

  .customer-list .customer-actions {
    flex: 0 0 100%;
    display: flex;
    gap: 0.5rem;
    justify-content: flex-end;
    margin-top: 0.25rem;
  }

  /* Table based lists (orders, open items): allow cells to wrap text */
  .rounded-table td,
  .rounded-table th,
  .order-row td,
  .open-item-row td {
    white-space: normal;
    word-break: break-word;
  }

  /* Make button groups wrap so action buttons remain visible */
  .rounded-table .btn-group,
  .btn-group {
    display: flex;
    flex-wrap: wrap;
    gap: 0.25rem;
  }

  .rounded-table .btn-group .btn,
  .btn-group .btn {
    margin-top: 0.25rem;
  }

  /* Slight spacing for icon-buttons on mobile */
  .icon-button {
    margin: 0 0.15rem;
  }
}

/* --- dvouradkové zobrazení řádku open-item pro úzké Viewports (flex-based) --- */
@media (max-width: 575.98px) {
  /* Přepnout řádek na flexbox, aby se buňky daly zalamovat do dvou řádků */
  .rounded-table tbody tr.open-item-row {
    display: flex;
    flex-wrap: wrap;
    align-items: center;
    gap: 0.25rem 0.5rem;
    padding: 0.5rem 0.6rem;
    border-bottom: 1px solid #eef2f7;
  }

  .rounded-table tbody tr.open-item-row td {
    display: block;
    padding: 0.15rem 0.25rem;
    border: none;
    background: transparent;
    white-space: normal;
    box-sizing: border-box;
  }

  /* Forcing visual order: first row = ID, Name, Actions; second row = Author, Responsibility, Priority/Status */
  .open-item-row td:nth-child(1) { order: 1; flex: 0 0 48px; font-weight: 700; }
  .open-item-row td:nth-child(2) { order: 2; flex: 1 1 auto; min-width: 120px; font-weight: 600; }
  .open-item-row td:nth-child(7) { order: 3; flex: 0 0 auto; margin-left: auto; }

  .open-item-row td:nth-child(3) { order: 4; flex: 1 1 45%; color: #6c757d; font-size: .92rem; }
  .open-item-row td:nth-child(4) { order: 5; flex: 1 1 45%; color: #6c757d; font-size: .92rem; }
  .open-item-row td:nth-child(5) { order: 6; flex: 0 0 auto; color: #6c757d; font-size: .9rem; text-align: right; }
  .open-item-row td:nth-child(6) { order: 7; flex: 0 0 auto; color: #6c757d; font-size: .9rem; text-align: right; margin-left: 0.5rem; }

  /* Slight visual adjustments */
  .open-item-row td:nth-child(3),
  .open-item-row td:nth-child(4),
  .open-item-row td:nth-child(5),
  .open-item-row td:nth-child(6) {
    opacity: 0.95;
  }

  .open-item-row.open-item-warning {
    background-color: #fff7ee;
  }

  .open-item-row.open-item-closed {
    background-color: #e8f5e9;
  }

  .open-item-row .btn,
  .open-item-row .btn-group { z-index: 2; }
  .open-item-row .icon-button { width: 2.2rem; height: 2.2rem; }
}

/* Hide open items table header on very narrow screens */
@media (max-width: 575.98px) {
  /* Hide only the table header inside the open items panel */
  .open-items-panel table thead { display: none !important; }
  /* Ensure table body rows stack nicely (already handled) */
  .open-items-panel .rounded-table td, .open-items-panel .rounded-table th { white-space: normal; }
}


/* Compact forms and tables on account and user management pages */
.compact-page { font-size: 0.875rem; }
.compact-page h1 { font-size: 1.4rem; }
.compact-page h2 { font-size: 1.1rem; }

/* Tooltip for open-item description */
.open-item-tooltip {
  position: absolute;
  background: #ffffff;
  border: 1px solid #e5e7eb;
  box-shadow: 0 6px 16px rgba(15,23,42,0.08);
  padding: 0.5rem 0.75rem;
  border-radius: 8px;
  color: #212529;
  font-size: 0.9rem;
  max-width: 80vw;
  max-height: 80vh;
  overflow: auto;
  white-space: pre-wrap;
  word-break: break-word;
}

.compact-page .form-control,
.compact-page .form-select,
.compact-page .btn { font-size: 0.875rem; padding: 0.2rem 0.5rem; }
.compact-page .table > :not(caption) > * > * { padding: 0.25rem 0.5rem; }

/* Open Item New/Edit modals: 60% viewport width and vertical-stretching description panel */
#openItemModal .modal-dialog,
#openItemEditModal .modal-dialog {
  max-width: 60vw;
  width: 60vw;
  margin: 1.75rem auto;
}
@media (max-width: 991.98px) {
  #openItemModal .modal-dialog,
  #openItemEditModal .modal-dialog {
    max-width: 100vw;
    width: 100vw;
    margin: 0.5rem auto;
  }
}
#openItemModal .modal-content,
#openItemEditModal .modal-content {
  display: flex;
  flex-direction: column;
  max-height: 80vh; /* keep modal from overflowing viewport */
}
#openItemModal .modal-body,
#openItemEditModal .modal-body {
  display: flex;
  gap: 1rem;
  flex: 1 1 auto;
  overflow: hidden; /* inner columns will scroll if needed */
}
#openItemModal .edit-left,
#openItemEditModal .edit-left {
  flex: 0 0 45%;
  overflow: auto;
  padding-right: 0.5rem;
}
#openItemModal .edit-right,
#openItemEditModal .edit-right {
  flex: 1 1 55%;
  display: flex;
  flex-direction: column;
}
#openItemModal .edit-right textarea,
#openItemEditModal textarea#openItemEditDescription,
#openItemEditModal .open-item-description-preview {
  flex: 1 1 auto;
  min-height: 0; /* allow flex to control height */
  overflow: auto;
}
#openItemModal .edit-right textarea,
#openItemEditModal textarea#openItemEditDescription {
  resize: vertical;
}
#openItemEditModal .open-item-description-preview {
  white-space: pre-wrap;
  overflow-wrap: anywhere;
}
