/* ===== Fonts ===== */
@font-face {
  font-family: 'Safira March';
  src: url('fonts/Safira March Personal Use Only.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Kingred Modern';
  src: url('fonts/kingred.otf') format('opentype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'Antic Didone';
  src: url('fonts/AnticDidone-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}
@font-face {
  font-family: 'ABeeZee';
  src: url('fonts/ABeeZee-Regular.ttf') format('truetype');
  font-weight: normal;
  font-style: normal;
}

/* ===== Brand color variables ===== */
:root {
  --pink:        #E91E8C;
  --pink-medium: #D991BA;
  --pink-light:  #FF6BA6;
  --pink-pale:   #FFB3B3;
  --pink-pastel: #FFB8C6;
  --pink-bg:     #F5E6F7;

  --blue:        #2196F3;
  --blue-dark:   #1976D2;
  --blue-light:  #64B5F6;
  --blue-bg:     #F5F9FF;

  --bg-page:     #f0f0f4;
  --text-dark:   #333;
  --text-mid:    #666;
  --text-weak:   #999;
  --border:      #ddd;
}

/* ===== Bootstrap primary overrides ===== */
.btn-primary,
.bg-primary,
.navbar.bg-primary {
  background-color: var(--pink) !important;
  border-color: var(--pink) !important;
}
.btn-primary:hover,
.btn-primary:focus,
.btn-primary:active {
  background-color: var(--pink-light) !important;
  border-color: var(--pink-light) !important;
}
.btn-outline-primary {
  color: var(--pink) !important;
  border-color: var(--pink) !important;
}
.btn-outline-primary:hover {
  background-color: var(--pink) !important;
  color: #fff !important;
}
.text-primary { color: var(--pink) !important; }
.border-primary { border-color: var(--pink) !important; }
.badge.bg-primary { background-color: var(--pink) !important; }
.nav-link.active { color: var(--pink) !important; }

/* Bottom nav active */
.bottom-nav-item.active { color: var(--pink); }
.bottom-nav-item.bottom-nav-add { background: var(--pink); }
.bottom-nav-item.bottom-nav-add:hover { background: var(--pink-light); }

/* ===== Typography ===== */
body {
  font-family: 'ABeeZee', 'Segoe UI', Tahoma, Verdana, sans-serif;
  background-color: var(--bg-page);
  color: var(--text-dark);
}

/* Section titles (h1, h2, h3, card-header) */
h1, h2, h3,
.card-header,
.offcanvas-title {
  font-family: 'Safira March', 'Segoe UI', sans-serif;
}

/* Form subtitles / labels */
.form-label,
.card-header.fw-semibold {
  font-family: 'Kingred Modern', 'Segoe UI', sans-serif;
}

/* SKU / codes */
code, .font-monospace { font-family: monospace; }

/* ===== Page background ===== */
.main-content {
  background-color: var(--bg-page);
  padding-bottom: 90px;
}

/* ===== Mobile-first custom styles ===== */

/* ===== Bottom navigation bar ===== */
.bottom-nav {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: 1030;
  background: #fff;
  border-top: 1px solid var(--border);
  height: 60px;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -2px 8px rgba(0, 0, 0, 0.08);
}

.bottom-nav-item {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  color: #6c757d;
  font-size: 0.65rem;
  flex: 1;
  height: 100%;
  gap: 2px;
  transition: color 0.15s;
}

.bottom-nav-item i {
  font-size: 1.35rem;
  line-height: 1;
}

.bottom-nav-item.bottom-nav-add {
  color: #fff;
  border-radius: 50%;
  width: 50px;
  height: 50px;
  flex: unset;
  box-shadow: 0 2px 8px rgba(233, 30, 140, 0.4);
  margin-bottom: 10px;
}

.bottom-nav-item.bottom-nav-add i {
  font-size: 1.5rem;
}

/* ===== Dashboard stat cards ===== */
.revenue-chart-wrap {
  position: relative;
  width: 100%;
  height: 100%;
  min-height: 180px;
}

.stat-icon {
  font-size: 1.25rem;
  line-height: 1;
  margin-bottom: 2px;
}

.stat-value {
  font-size: 1.4rem;
  font-weight: 700;
  line-height: 1;
}

.stat-label {
  font-size: 0.68rem;
  margin-top: 1px;
}

/* ===== Mini KPI grid (dashboard) ===== */
.kpi-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 6px;
}
.kpi {
  background: #fff;
  border-radius: 10px;
  padding: 0.45rem 0.25rem;
  text-align: center;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.06);
}
.kpi .stat-value { font-size: 1.15rem; }
.kpi .stat-label {
  font-size: 0.6rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}
.kpi .stat-value i { font-size: 0.85rem; margin-right: 2px; }
.kpi-accent { background: #d1e7dd; }
@media (min-width: 768px) { .kpi-grid { grid-template-columns: repeat(6, 1fr); } }

/* ===== Compact deadline rows (dashboard) ===== */
.deadline-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.4rem 0.6rem;
  font-size: 0.8rem;
}
.deadline-row .dl-name { flex: 1; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.deadline-row .dl-date { font-weight: 600; white-space: nowrap; }
.deadline-row .dl-badge { font-size: 0.6rem; padding: 0.15em 0.45em; }
.deadline-dot { width: 9px; height: 9px; border-radius: 50%; flex-shrink: 0; }
.dl-group {
  font-size: 0.65rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: 0.03em;
  padding: 0.3rem 0.6rem 0.15rem;
  background: #f8f9fa;
}

/* ===== Collapsible section header ===== */
.section-toggle {
  display: flex;
  align-items: center;
  width: 100%;
  background: none;
  border: 0;
  padding: 0.25rem 0;
  font-weight: 600;
  color: inherit;
}
.section-toggle::after {
  content: '\F282';
  font-family: 'bootstrap-icons';
  margin-left: auto;
  font-weight: normal;
  transition: transform 0.2s;
}
.section-toggle[aria-expanded="true"]::after { transform: rotate(180deg); }

/* ===== Order images grid ===== */
.order-img {
  width: 100%;
  aspect-ratio: 1 / 1;
  object-fit: cover;
  border: 1px solid var(--border);
}

/* ===== Form tweaks ===== */
.form-control, .form-select {
  font-size: 1rem; /* prevent iOS zoom on focus (needs >= 16px) */
}

/* ===== List group hover ===== */
.list-group-item-action:active {
  background-color: var(--pink-bg);
}

/* ===== Status history timeline ===== */
.timeline { padding-left: 4px; }

.timeline-item { position: relative; }
.timeline-item:not(:last-child)::before {
  content: '';
  position: absolute;
  left: 7px;
  top: 18px;
  bottom: 0;
  width: 1px;
  background: #dee2e6;
}

.timeline-dot {
  flex-shrink: 0;
  width: 16px;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  padding-top: 2px;
}

/* ===== Deadline calendar ===== */
.cal-layout {
  display: flex;
  flex-wrap: wrap;
  align-items: flex-start;
  gap: 1rem;
}
.cal-left {
  flex: 0 0 auto;
}
.cal-detail {
  flex: 1 1 220px;
  min-width: 200px;
}
.cal-detail h3 {
  font-size: 0.8rem;
  color: var(--text-mid);
}
.cal-detail-item {
  padding: 0.35rem 0.5rem;
  font-size: 0.72rem;
  line-height: 1.25;
}
.cal-detail-badge {
  font-size: 0.6rem;
  padding: 0.15em 0.45em;
  margin-top: 2px;
}

/* Compact "orders this month" list */
.order-row {
  padding: 0.4rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.3;
}
.order-row .badge {
  font-size: 0.6rem;
  padding: 0.15em 0.45em;
}
.order-row .text-muted {
  font-size: 0.7rem;
}
.calendar-grid {
  display: grid;
  grid-template-columns: repeat(7, 1fr);
  gap: 1px;
  width: 300px;
  max-width: 100%;
}
.cal-dow {
  text-align: center;
  font-size: 0.65rem;
  font-weight: 600;
  color: var(--text-weak);
  text-transform: uppercase;
}
.cal-cell {
  position: relative;
  min-height: 30px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  border: 1px solid var(--border);
  border-radius: 6px;
  background: #fff;
  font-size: 0.68rem;
  color: var(--text-dark);
  padding: 1px;
}
.cal-empty {
  border: none;
  background: transparent;
}
.cal-num {
  line-height: 1;
}
.cal-has-orders {
  cursor: pointer;
  font-weight: 600;
  transition: background-color 0.15s, box-shadow 0.15s;
}
.cal-has-orders:hover {
  background: var(--pink-bg);
}
.cal-has-orders.cal-selected {
  background: var(--pink-bg);
  box-shadow: 0 0 0 2px var(--pink);
}
.cal-today {
  border-color: var(--pink);
  box-shadow: inset 0 0 0 1px var(--pink);
}
.cal-count {
  position: absolute;
  top: 1px;
  right: 1px;
  font-size: 0.55rem;
  padding: 0.1em 0.35em;
}
.cal-dots {
  display: flex;
  gap: 2px;
  margin-top: 2px;
}
.cal-dot {
  width: 5px;
  height: 5px;
  border-radius: 50%;
}

/* ===== Kanban board ===== */
.board {
  display: flex;
  gap: 0.5rem;
  overflow-x: auto;
  padding-bottom: 0.5rem;
  -webkit-overflow-scrolling: touch;
}
.board-col {
  flex: 0 0 82%;
  max-width: 300px;
  background: #eceef2;
  border-radius: 10px;
  padding: 0.5rem;
}
.board-col-header {
  font-weight: 600;
  font-size: 0.85rem;
  padding: 0.1rem 0.25rem 0.5rem;
}
.board-list {
  min-height: 48px;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.board-card {
  background: #fff;
  border-radius: 8px;
  padding: 0.5rem 0.6rem;
  font-size: 0.78rem;
  line-height: 1.3;
  box-shadow: 0 1px 2px rgba(0, 0, 0, 0.08);
  border-left: 3px solid var(--blue-light);
  cursor: grab;
}
.board-card-order {
  border-left-color: var(--pink);
}
/* Prazo próximo (até 3 dias) */
.board-card-soon {
  border-left-color: #f59e0b;
  background: #fff8ec;
}
/* Prazo ultrapassado */
.board-card-overdue {
  border-left-color: #dc3545;
  background: #fdecea;
}
.board-card-title {
  word-break: break-word;
}
/* Dashboard "Tarefas pendentes" quick list */
.task-quicklist .task-item {
  border: none;
  border-bottom: 1px solid var(--bs-border-color, #e9ecef);
  padding-top: 0.4rem;
  padding-bottom: 0.4rem;
}
.task-quicklist .task-item:last-child {
  border-bottom: none;
}
.task-item-title {
  word-break: break-word;
  line-height: 1.3;
}
.task-complete {
  font-size: 1.15rem;
  line-height: 1;
}
/* Encomenda atrasada (lista) */
.order-row-overdue {
  border-left: 4px solid #dc3545;
  background: #fdecea;
}
.board-card-notes {
  font-size: 0.72rem;
  margin-top: 2px;
  white-space: pre-wrap;
}
.board-card-meta {
  margin-top: 3px;
}
.board-card .badge {
  font-size: 0.58rem;
  padding: 0.15em 0.45em;
}
.board-card-actions .btn-link {
  font-size: 0.8rem;
  line-height: 1;
}
.board-card-ghost {
  opacity: 0.4;
}

/* ===== Seletor de produtos por categoria (/orders/new) ===== */

/* Grelha em vez de lista horizontal: no telemóvel uma tira que se arrasta
   esconde metade das categorias e obriga a apontar a alvos pequenos. */
.cat-grid {
  display: grid;
  /* minmax(0, 1fr) e não 1fr: com 1fr a coluna nunca encolhe abaixo do conteúdo,
     e um nome comprido ("Estampagem/Sublimação") alargava a primeira coluna
     deixando as outras estreitas. */
  grid-template-columns: repeat(2, minmax(0, 1fr));
  gap: 8px;
}
.cat-card {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2px;
  min-height: 92px;          /* bem acima do alvo mínimo de toque */
  padding: 10px 8px;
  text-align: center;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 10px;
  cursor: pointer;
  transition: border-color .12s, background-color .12s;
}
.cat-card:hover {
  border-color: var(--pink);
  background: var(--pink-bg);
}
.cat-card:focus-visible {
  outline: 2px solid var(--pink);
  outline-offset: 2px;
}
.cat-card-icon { font-size: 1.7rem; line-height: 1.1; }
.cat-card-name {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text-dark);
  line-height: 1.2;
  /* Quebra só quando não há mesmo alternativa, e de preferência num sítio natural
     (a barra de "Estampagem/Sublimação"). A largura da coluna já não depende
     disto — quem a fixa é o minmax(0, 1fr) acima. */
  overflow-wrap: break-word;
}
.cat-card-count { font-size: .68rem; color: var(--text-weak); }

/* Linha de produto: miniatura à esquerda (hoje o emoji da categoria, amanhã uma
   imagem), texto ao centro, botão de adicionar sempre no mesmo sítio. */
.prod-thumb {
  flex: 0 0 auto;
  width: 38px;
  height: 38px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.2rem;
  background: var(--pink-bg);
  border-radius: 8px;
  overflow: hidden;
}
.prod-thumb img { width: 100%; height: 100%; object-fit: cover; }
.prod-row:last-child { border-bottom: 0 !important; }
.prod-row .btn { min-width: 38px; min-height: 34px; }
.min-w-0 { min-width: 0; }

/* A barra de pesquisa é input-group-sm (28px de origem) — no telemóvel isso é
   pequeno de mais para acertar com o polegar. */
#productSearch, #productSearch + .btn, #searchClear, #catalogNav .btn {
  min-height: 38px;
}

/* Cada linha escolhida é um bloco com contorno próprio — com três ou quatro
   topos na mesma encomenda, sem isto não se percebe onde acaba um e começa outro. */
.sel-line {
  padding: 8px;
  background: #fff;
  border: 1px solid var(--border);
  border-radius: 8px;
}
.sel-line .btn-sm { min-height: 32px; }

/* ===== Tablet & desktop ===== */
@media (min-width: 768px) {
  .main-content {
    padding-bottom: 24px;
    max-width: 720px;
    margin: 0 auto;
  }
  .board-col {
    flex: 1 1 0;
    max-width: none;
  }
  .cat-grid {
    grid-template-columns: repeat(4, minmax(0, 1fr));
  }
}
