/* ══ Base ══ */
html, body { height: 100%; overflow: hidden; }
body { display: flex; flex-direction: column; }

.result-card.card-ok  { border-left-color: #58d68d; }
.result-card.card-bad { border-left-color: #ff5757; }

/* ══ Greda sub-header ══ */
.greda-page-header {
  display: flex; align-items: center; justify-content: space-between;
  padding: 0.55rem 1.5rem;
  border-bottom: 1px solid var(--border);
  background: var(--navy-800);
  flex-shrink: 0;
}
.greda-page-header-left  { display: flex; align-items: center; gap: 0.75rem; }
.greda-page-header-right { display: flex; align-items: center; gap: 0.75rem; }
.greda-page-header-center {
  flex: 1; display: flex; align-items: center; gap: 0.5rem;
  padding: 0 2rem; min-width: 0;
}
.greda-page-header-center label {
  font-size: 0.78rem; color: var(--text-dim); font-family: var(--font-mono);
  white-space: nowrap; flex-shrink: 0;
}
.greda-page-header-center input {
  flex: 1; min-width: 0;
  background: transparent; border: none; border-bottom: 1px solid var(--border);
  color: var(--text); font-size: 0.85rem; font-family: var(--font-mono);
  padding: 0.1rem 0.25rem; outline: none; transition: border-color 0.15s;
}
.greda-page-header-center input:focus { border-bottom-color: var(--accent); }
.greda-context { font-size: 0.8rem; color: var(--text-dim); font-family: var(--font-mono); }

/* ══ Responsive — MUST be after base styles ══ */

/* ── Tablet + mobile (≤900px) ── */
@media (max-width: 900px) {
  /* Scrollable page */
  html, body { height: auto; overflow-x: hidden; overflow-y: auto; }
  body { display: block; }

  /* Show hamburger (overrides inline display:none) */
  #btn-panel-toggle { display: flex !important; }

  /* Sub-header: hide title + context to fit on one row */
  .greda-title-text { display: none; }
  .greda-context    { display: none; }
  .greda-header-sep { display: none; }

  /* ── Input panel → fixed slide-in drawer ── */
  #input-panel {
    position: fixed !important;
    left: 0; top: 0; bottom: 0;
    width: min(300px, 85vw);
    z-index: 500;
    transform: translateX(-100%);
    transition: transform 0.28s cubic-bezier(0.4, 0, 0.2, 1),
                box-shadow 0.28s ease;
    overflow-y: auto;
    overflow-x: hidden;
    background: var(--navy-800);
    border-right: 1px solid var(--border);
    /* Restore padding that was removed by collapse animation */
    padding: 0.85rem 0.75rem !important;
    max-height: unset !important;
    opacity: 1 !important;
  }
  #input-panel.panel-open {
    transform: translateX(0);
    box-shadow: 6px 0 32px rgba(0, 0, 0, 0.55);
  }

  /* ── Backdrop ── */
  #panel-backdrop {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 490;
    background: rgba(0, 0, 0, 0.55);
    backdrop-filter: blur(2px);
    -webkit-backdrop-filter: blur(2px);
    cursor: pointer;
  }
  #panel-backdrop.open { display: block; }
}

/* ── Phone (≤768px): Naziv input on its own row ── */
@media (max-width: 768px) {
  .greda-page-header {
    display: grid;
    grid-template-areas: "left right" "center center";
    grid-template-columns: auto 1fr;
    align-items: center;
    padding: 0.4rem 0.75rem;
    gap: 0.3rem 0.5rem;
  }
  .greda-page-header-left   { grid-area: left;  gap: 0.5rem; }
  .greda-page-header-right  { grid-area: right; justify-self: end; gap: 0.25rem !important; }
  .greda-page-header-center {
    grid-area: center;
    flex: unset;
    padding: 0.2rem 0 0;
    border-top: 1px solid var(--border);
  }
}

/* ══ Deflection tab layout ══ */
/* Flex row: kartice lijevo (2 reda × 4 stup), SVG desno span oba reda */
#tab-deflection.active {
  flex-wrap: nowrap;
  align-items: stretch;
}
.defl-sections-wrap {
  flex: 1 1 0;
  min-width: 0;
  display: flex;
  flex-direction: column;
  gap: 0.4rem;
}
.defl-section {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}
.defl-sec-title {
  font-size: 0.65rem;
  color: var(--text-dim);
  font-family: var(--font-mono);
  text-transform: uppercase;
  letter-spacing: 0.05em;
  padding: 0 0.1rem;
}
.defl-cards {
  display: flex;
  gap: 0.4rem;
}
.defl-cards .result-card { flex: 1; min-width: 60px; }
/* SVG — zadnji stupac, span oba reda */
#card-defl-svg {
  flex: 0 0 220px;
  min-width: 0;
  padding: 0;
  display: none;
}
#card-defl-svg svg { width: 100%; height: 100%; min-height: 120px; }
@media (max-width: 700px) {
  #tab-deflection.active { flex-wrap: wrap; }
  #card-defl-svg { flex: 1 0 100%; }
  #card-defl-svg svg { height: auto; min-height: unset; }
}

/* ── Mobile S/M (≤600px): input panel inline above drawing ── */
@media (max-width: 600px) {
  /* Undo fixed drawer → show inline in page flow */
  #input-panel {
    position: static !important;
    width: auto !important;
    transform: none !important;
    box-shadow: none !important;
    border-right: none !important;
    border-bottom: 1px solid var(--border);
    padding: 0.6rem 0.75rem !important;
    overflow-y: visible !important;
    max-height: none !important;
  }
  #btn-panel-toggle { display: none !important; }
  #panel-backdrop   { display: none !important; }

  /* Compact form: label + input side by side */
  #input-panel .form-row {
    flex-direction: row;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 0.25rem;
    gap: 0.5rem;
  }
  #input-panel .form-row label { flex: 1; font-size: 0.78rem; margin-bottom: 0; }
  #input-panel .form-row > div { width: 88px; flex-shrink: 0; }
  #input-panel .form-row input,
  #input-panel .form-row select { padding: 0.25rem 0.4rem; font-size: 0.8rem; }
  #input-panel .form-row-2col input,
  #input-panel .form-row-2col select { padding: 0.25rem 0.4rem; font-size: 0.8rem; }
  #input-panel .form-row-2col { margin-bottom: 0.25rem; }
  #input-panel .input-section { margin-bottom: 0; }
  #input-panel .input-section-title {
    padding: 0.3rem 0 0.2rem;
    margin: 0.2rem 0 0.2rem;
    border-top: 1px solid var(--border);
  }
  #input-panel .input-section:first-child .input-section-title {
    border-top: none; padding-top: 0; margin-top: 0;
  }
}
