/* =========================================
   Handover Certificate – Complete Styles
   ========================================= */

/* ---------- Theme variables ---------- */
:root{
  --hc-font-family: system-ui, -apple-system, "Segoe UI", Roboto, Arial, sans-serif;
  --hc-font-size: 15px;      /* base body + input size (bigger than the old 13px) */
  --hc-text: #111;
  --hc-muted: #4b5563;
  --hc-border: #cbd5e1;
  --hc-border-strong: #9aa1a8;
  --hc-bg: #ffffff;
  --hc-soft: #f8fafc;
  --hc-shadow: 0 1px 3px rgba(0,0,0,.06);

  --hc-btn-bg: #111;
  --hc-btn-fg: #fff;
}

/* ---------- Wrapper / Card ---------- */
.hc-wrap{
  max-width: 720px;
  margin: 24px auto;
  padding: 0 12px;
  font: var(--hc-font-size)/1.5 var(--hc-font-family);
  color: var(--hc-text);
}

.hc-card{
  border: 1px solid var(--hc-border);
  background: var(--hc-bg);
  border-radius: 10px;
  box-shadow: var(--hc-shadow);
  padding: 18px;
}

/* ---------- Header (logo + details in page view) ---------- */
.hc-headtable{ width:100%; border-collapse:collapse; margin-bottom:10px; }
.hc-headtable td{ border:none; padding:0; vertical-align:middle; }
.hc-headtable .logo{ width:150px; }
.hc-headtable .logo img{ display:block; max-width:140px; height:auto; }
.hc-headtable .details{ padding-left:12px; font-size:14px; line-height:1.45; }

/* ---------- Title chip ---------- */
.hc-title{
  border: 1px solid #94a3b8;
  text-align: center;
  font-weight: 700;
  padding: 8px;
  margin: 8px 0 14px;
  font-size: 16px;
  letter-spacing: .2px;
  border-radius: 8px;
}

/* ---------- Section headings (form view) ---------- */
.hc-card h4{
  margin: 14px 0 8px;
  font-size: 16px;
  font-weight: 600;    /* change to 400 if you want headings not bold in the form */
}

/* ---------- Data table (form view) ---------- */
.hc-table{
  width:100%;
  border-collapse: collapse;
  margin: 10px 0;
  table-layout: fixed;
}
.hc-table th,
.hc-table td{
  border: 1px solid var(--hc-border-strong);
  padding: 8px 9px;
  vertical-align: top;
  word-break: break-word;
}
.hc-table th{
  background: #f1f5f9;
  text-align: left;
  font-weight: 400;    /* labels NOT bold in the form, as requested earlier */
  width: 220px;
  font-size: 14px;
}

/* ---------- Inputs (bigger form text) ---------- */
.hc-input,
.hc-textarea,
.hc-select{
  width: 100%;
  box-sizing: border-box;
  padding: 8px 10px;
  border: 1px solid var(--hc-border);
  border-radius: 8px;
  font: 15px/1.45 var(--hc-font-family); /* match base size, comfortable on mobile */
  color: var(--hc-text);
  background: #fff;
}
.hc-textarea{ min-height: 72px; }

/* Read-only look blocks */
.hc-fixed{
  padding: 8px 10px;
  background: var(--hc-soft);
  border: 1px solid var(--hc-border);
  border-radius: 8px;
}

/* Small muted helper text */
.hc-muted{ color: var(--hc-muted); margin: 6px 0; font-size: 13px; }

/* ---------- Signature UI ---------- */
.sig-tools{ display:flex; gap:8px; margin: 4px 0 10px; }
.sig-pad{
  border: 1px solid var(--hc-border);
  border-radius: 8px;
  height: 120px;
  width: 100%;
  background: #fff;
  display: block;

  /* prevent browser gestures from stealing input */
  touch-action: none;
  -ms-touch-action: none;
  user-select: none;
  -webkit-user-select: none;
  -webkit-touch-callout: none;

  cursor: crosshair;
  position: relative;
  z-index: 1;
}

/* ---------- Photo grid (if used) ---------- */
.hc-photos{
  display:grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 8px;
}
.hc-photos .hc-photo{
  border: 1px solid #e5e7eb;
  border-radius: 10px;
  overflow: hidden;
  background: #fafafa;
}
.hc-photos .hc-photo img{
  display:block;
  width: 100%;
  height: 140px;
  object-fit: cover;
}

/* ---------- Actions ---------- */
.hc-actions{
  display:flex;
  gap: 10px;
  flex-wrap: wrap;
  margin: 16px 0;
  justify-content: center;
}
.hc-actions button{
  padding: 10px 14px;
  border: 1px solid var(--hc-btn-bg);
  border-radius: 10px;
  background: var(--hc-btn-bg);
  color: var(--hc-btn-fg);
  cursor: pointer;
  font-weight: 600;
}
.hc-actions button.secondary{
  background: #fff;
  color: var(--hc-btn-bg);
}

/* Hidden until JS shows after "Generate" */
.hc-post-actions{ display:none; }

/* Preview container (shown by JS after "Generate") */
.hc-print-view{ display:none; }

/* ---------- Collapsible form toggle (added by JS) ---------- */
/* JS injects inline styles for immediate usability; these rules are safe defaults */
.hc-form-toggle{
  display:none; /* only appears on small screens via media query */
}

/* ---------- Mobile layout (≤640px) ---------- */
@media (max-width: 640px){

  /* Stack header: logo on top, address/details underneath */
  .hc-headtable,
  .hc-headtable tbody,
  .hc-headtable tr{
    display: block !important;
    width: 100% !important;
  }
  .hc-headtable td{
    display: block !important;
    width: 100% !important;
    border: 0 !important;
    padding: 0 !important;
  }
  .hc-headtable .logo{
    width: 100% !important;
    margin: 0 0 10px 0 !important;
  }
  .hc-headtable .logo img{
    display:block;
    max-width: 100%;
    height: auto;
  }
  .hc-headtable .details{
    padding-left: 0 !important;   /* remove desktop gutter */
    font-size: 13px;
    line-height: 1.45;
  }

  /* Show the collapsible toggle bar (JS inserts the element) */
  .hc-form-toggle{
    display:flex !important;
  }

  /* Stack table rows to blocks for easier reading */
  .hc-table,
  .hc-table thead,
  .hc-table tbody,
  .hc-table tr,
  .hc-table th,
  .hc-table td{
    display:block; width:100%;
  }
  .hc-table tr{
    border: 1px solid var(--hc-border-strong);
    margin-bottom: 10px;
    border-radius: 8px;
    overflow: hidden;
  }
  .hc-table th{
    background: #f1f5f9;
    border-bottom: 1px solid var(--hc-border-strong);
    width: 100%;
    font-size: 14px;
  }
  .hc-table td{ border:none; padding: 10px; }

  .hc-photos{ grid-template-columns: repeat(2, 1fr); }
  .hc-photos .hc-photo img{ height: 120px; }
}

/* ---------- Print (certificate view only) ---------- */
@media print{
  @page{ size: A4 portrait; margin: 10mm; }
  body{ background: #fff; }
  .hc-form,
  .hc-post-actions{ display:none !important; }
  .hc-print-view{
    display:block !important;
    width: 170mm;
    transform: scale(0.98);
    transform-origin: top left;
  }
  /* cleaner print borders */
  .hc-table, .hc-table th, .hc-table td{ border: none !important; }
  .hc-table th{ background: transparent !important; }
  .hc-card{ border: none !important; box-shadow: none !important; }
}

/* ---------- Focus states (accessibility) ---------- */
.hc-input:focus,
.hc-textarea:focus,
.hc-select:focus,
.hc-actions button:focus,
.hc-form-toggle:focus{
  outline: 2px solid #0ea5e9;
  outline-offset: 2px;
}

/* ---------- v1.4 updates ---------- */
.hc-headtable .logo{ width:105px; }
.hc-headtable .logo img{ max-width:95px; max-height:95px; object-fit:contain; }
.hc-hs-box{
  margin-top:16px;
  padding:14px 16px;
  border:1px solid #9aa1a8;
  background:#f8f8f8;
  text-align:left;
  font-size:13px;
  line-height:1.45;
}
.hc-hs-box strong{ display:block; margin-bottom:10px; font-size:15px; }
.hc-hs-box p{ margin:0 0 8px; }
.hc-hs-box p:last-child{ margin-bottom:0; }
.hc-photo{ position:relative; }
.hc-remove-photo{
  display:block;
  width:100%;
  border:0;
  border-top:1px solid #e5e7eb;
  padding:6px;
  background:#fff;
  cursor:pointer;
}

/* Frontend manager shortcode */
.hca-front-manager{background:#fff;border:1px solid #e5e7eb;border-radius:12px;padding:20px;margin:20px 0;box-shadow:0 8px 24px rgba(15,23,42,.06)}
.hca-front-table-wrap{overflow-x:auto}
.hca-front-table{width:100%;border-collapse:collapse;font-size:14px;background:#fff;table-layout:fixed}
.hca-front-table th,.hca-front-table td{border-bottom:1px solid #e5e7eb;text-align:left;padding:10px;vertical-align:top}
.hca-front-table th{background:#f8fafc;font-weight:700}
.hca-front-table th:nth-child(1),.hca-front-table td:nth-child(1){width:150px}
.hca-front-table th:nth-child(2),.hca-front-table td:nth-child(2){width:105px}
.hca-front-table th:nth-child(3),.hca-front-table td:nth-child(3){width:120px}
.hca-front-table th:nth-child(4),.hca-front-table td:nth-child(4){width:auto}
.hca-front-table th:nth-child(5),.hca-front-table td:nth-child(5){width:110px}
.hca-front-table th:nth-child(6),.hca-front-table td:nth-child(6){width:130px}
.hca-site-cell span{display:-webkit-box;-webkit-line-clamp:2;-webkit-box-orient:vertical;overflow:hidden;line-height:1.35;max-height:2.7em}
.hca-front-view,.hca-front-download,.hca-front-modal-actions a,.hca-front-modal-actions button{display:inline-block;border:0;border-radius:6px;padding:8px 12px;margin:2px;text-decoration:none;cursor:pointer;background:#111827;color:#fff;font-size:14px;line-height:1.2}
.hca-front-download,.hca-front-modal-actions a{background:#2563eb;color:#fff}
#hca-front-modal-delete{background:#dc2626;color:#fff}
#hca-front-modal-close{background:#6b7280;color:#fff}
.hca-front-modal{position:fixed;inset:0;background:rgba(0,0,0,.70);z-index:999999;padding:20px;box-sizing:border-box;display:flex;align-items:center;justify-content:center}
.hca-front-modal-box{background:#fff;border-radius:12px;max-width:1050px;width:100%;height:88vh;display:flex;flex-direction:column;overflow:hidden}
.hca-front-modal-header{padding:12px 14px;border-bottom:1px solid #ddd;display:flex;gap:12px;justify-content:space-between;align-items:center;background:#fff;flex-shrink:0}
.hca-front-modal-header strong{font-size:16px;color:#111827}
.hca-front-modal-actions{padding:10px 14px;border-bottom:1px solid #ddd;display:flex;gap:8px;justify-content:flex-end;flex-wrap:wrap;background:#fff;flex-shrink:0}
#hca-front-modal-close{background:#111827;color:#fff;border:0;border-radius:6px;padding:8px 14px;cursor:pointer;font-size:14px;line-height:1.2}
#hca-front-modal-frame{border:0;width:100%;height:100%;min-height:420px;flex:1}
@media(max-width:700px){.hca-front-manager{padding:14px}.hca-front-modal{padding:8px;align-items:flex-start}.hca-front-modal-box{height:94vh;margin-top:8px}.hca-front-table{font-size:13px;table-layout:auto}.hca-front-table th:nth-child(4),.hca-front-table td:nth-child(4){min-width:170px}.hca-front-modal-actions{justify-content:flex-start}.hca-front-view,.hca-front-download{display:block;text-align:center;margin:3px 0}}

/* ---------- v1.7 organised Health & Safety notice - no icons ---------- */
.hc-hs-main{
  display:block;
  margin-bottom:12px;
  font-size:16px;
  font-weight:700;
}
.hc-hs-section{
  border-top:1px solid #d1d5db;
  padding-top:9px;
  margin-top:9px;
}
.hc-hs-section:first-of-type{
  border-top:0;
  padding-top:0;
  margin-top:0;
}
.hc-hs-section h5{
  margin:0 0 5px;
  font-size:13.5px;
  font-weight:700;
}
.hc-hs-section p{
  margin:0;
  font-size:12.5px;
  line-height:1.45;
}


/* v1.9 popup visibility fixes */
.hca-front-modal{
  position:fixed !important;
  left:0 !important;
  right:0 !important;
  top:0 !important;
  bottom:0 !important;
  padding:12px !important;
  box-sizing:border-box !important;
  align-items:flex-start !important;
  justify-content:center !important;
  overflow:auto !important;
}
.admin-bar .hca-front-modal{top:32px !important;}
.hca-front-modal-box{
  margin:0 auto !important;
  height:calc(100vh - 24px) !important;
  max-height:calc(100vh - 24px) !important;
  display:flex !important;
  flex-direction:column !important;
  overflow:hidden !important;
}
.admin-bar .hca-front-modal-box{
  height:calc(100vh - 56px) !important;
  max-height:calc(100vh - 56px) !important;
}
.hca-front-modal-header,
.hca-front-modal-actions{
  position:relative !important;
  z-index:2 !important;
  flex-shrink:0 !important;
}
#hca-front-modal-frame{
  flex:1 1 auto !important;
  min-height:0 !important;
  height:auto !important;
}
@media(max-width:782px){
  .admin-bar .hca-front-modal{top:46px !important;}
  .admin-bar .hca-front-modal-box{height:calc(100vh - 70px) !important;max-height:calc(100vh - 70px) !important;}
}

/* v1.9 manager table address tidy */
.hca-front-table td:nth-child(4){
  max-width:260px;
  overflow:hidden;
  text-overflow:ellipsis;
  white-space:nowrap;
}
@media(max-width:700px){
  .hca-front-table td:nth-child(4),
  .hca-front-table th:nth-child(4){max-width:120px;min-width:120px;white-space:nowrap;}
}


/* v1.10 manager popup buttons in one top row + 10 character site address */
.hca-site-cell span{
  display:inline-block !important;
  max-width:11ch !important;
  white-space:nowrap !important;
  overflow:hidden !important;
  text-overflow:ellipsis !important;
  vertical-align:middle !important;
}
.hca-front-table th:nth-child(4),
.hca-front-table td:nth-child(4){
  width:90px !important;
  max-width:90px !important;
  min-width:90px !important;
  white-space:nowrap !important;
}
.hca-front-modal-header{
  display:flex !important;
  align-items:center !important;
  justify-content:space-between !important;
  gap:12px !important;
  padding:12px 14px !important;
}
.hca-front-modal-header strong{
  flex:1 1 auto !important;
  min-width:0 !important;
}
.hca-front-modal-header .hca-front-modal-actions{
  border:0 !important;
  padding:0 !important;
  margin:0 !important;
  display:flex !important;
  align-items:center !important;
  justify-content:flex-end !important;
  gap:8px !important;
  flex:0 0 auto !important;
  background:transparent !important;
}
@media(max-width:700px){
  .hca-front-modal-header{align-items:flex-start !important;}
  .hca-front-modal-header .hca-front-modal-actions{gap:5px !important;flex-wrap:wrap !important;}
  .hca-front-modal-actions a,.hca-front-modal-actions button,#hca-front-modal-close{padding:7px 9px !important;font-size:12px !important;}
}


/* v1.11 Manager create certificate button */
.hca-front-manager-top{
  display:flex;
  align-items:flex-start;
  justify-content:space-between;
  gap:16px;
  margin-bottom:14px;
}
.hca-front-manager-top h2{margin-bottom:6px;}
.hca-create-certificate-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#0b2d4a;
  color:#fff !important;
  text-decoration:none !important;
  border-radius:8px;
  padding:11px 16px;
  font-weight:700;
  white-space:nowrap;
}
.hca-create-certificate-btn:hover{opacity:.92;}
.hca-front-create-panel,
.hca-manager-create-panel{
  margin:18px 0 24px;
  padding:16px;
  border:1px solid #dbe3ea;
  border-radius:12px;
  background:#f8fafc;
}
.hca-create-panel-head{
  display:flex;
  align-items:center;
  justify-content:space-between;
  gap:12px;
  margin-bottom:12px;
}
.hca-create-panel-head h3{margin:0;}
@media(max-width:700px){
  .hca-front-manager-top,
  .hca-create-panel-head{
    display:block;
  }
  .hca-create-certificate-btn{
    width:100%;
    margin-top:10px;
  }
}

/* v1.13 staff login shortcode */
.hca-login-box{max-width:430px;background:#fff;border:1px solid #e5e7eb;border-radius:14px;padding:22px;margin:20px auto;box-shadow:0 8px 24px rgba(15,23,42,.08)}
.hca-login-box h3{margin:0 0 14px;font-size:24px;color:#003b63}
.hca-login-box label{font-weight:700;display:block;margin-bottom:6px;color:#111827}
.hca-login-box input[type="text"],.hca-login-box input[type="password"]{width:100%;box-sizing:border-box;border:1px solid #cbd5e1;border-radius:8px;padding:11px;margin-bottom:12px;font-size:16px}
.hca-login-box .login-remember label{display:flex;gap:8px;align-items:center;font-weight:400}
.hca-login-box input[type="submit"],.hca-login-manager,.hca-login-logout{display:inline-block;border:0;border-radius:8px;padding:10px 16px;text-decoration:none;cursor:pointer;background:#003b63;color:#fff;font-weight:700;font-size:15px;line-height:1.2}
.hca-login-logout{background:#111827;margin-left:8px}
.hca-login-actions{display:flex;gap:8px;flex-wrap:wrap;margin-top:12px}
.hca-login-welcome{margin:0 0 10px;color:#111827}
@media(max-width:520px){.hca-login-box{margin:15px 0;padding:16px}.hca-login-actions a{width:100%;text-align:center}.hca-login-logout{margin-left:0}}

/* v1.14 - centred manager login page */
.hca-manager-login-page{
  max-width:560px;
  margin:40px auto 60px;
  padding:10px;
}
.hca-manager-login-intro{
  text-align:center;
  margin-bottom:18px;
}
.hca-manager-login-intro h2{
  margin:0 0 8px;
  font-size:32px;
  color:#003b63;
  line-height:1.2;
}
.hca-manager-login-intro p{
  margin:0;
  color:#334155;
  font-size:17px;
}
.hca-manager-login-page .hca-login-box{
  max-width:460px;
  margin:0 auto;
  padding:28px;
  border-radius:18px;
  box-shadow:0 18px 45px rgba(15,23,42,.12);
}
.hca-manager-login-page .hca-login-box h3{
  text-align:center;
  font-size:26px;
  margin-bottom:22px;
}
.hca-manager-login-page .hca-login-box input[type="text"],
.hca-manager-login-page .hca-login-box input[type="password"]{
  min-height:48px;
  border-radius:10px;
}
.hca-manager-login-page .hca-login-box input[type="submit"]{
  width:100%;
  min-height:46px;
  border-radius:10px;
}
@media(max-width:600px){
  .hca-manager-login-page{margin:25px auto 40px;padding:0 12px;}
  .hca-manager-login-intro h2{font-size:26px;}
  .hca-manager-login-page .hca-login-box{padding:20px;}
}

/* v1.16 - mobile manager cards and wider mobile form */
.hca-back-manager-btn{
  display:inline-flex;
  align-items:center;
  justify-content:center;
  background:#111827;
  color:#fff !important;
  text-decoration:none !important;
  border-radius:8px;
  padding:11px 16px;
  font-weight:700;
  white-space:nowrap;
}
.hca-front-create-panel .hc-wrap{
  margin-top:0;
  margin-bottom:0;
}
.hca-is-creating .hca-front-create-panel{
  padding:10px;
  background:#fff;
}
@media(max-width:700px){
  .hca-front-manager{
    padding:14px 10px !important;
    border-radius:14px;
  }
  .hca-front-manager-top h2{
    font-size:28px;
    line-height:1.15;
  }
  .hca-front-manager-top p{
    font-size:17px;
    line-height:1.45;
  }
  .hca-front-table-wrap{
    overflow-x:visible !important;
  }
  .hca-front-table,
  .hca-front-table thead,
  .hca-front-table tbody,
  .hca-front-table tr,
  .hca-front-table td{
    display:block;
    width:100% !important;
  }
  .hca-front-table{
    border-collapse:separate !important;
    border-spacing:0 12px !important;
    table-layout:auto !important;
    background:transparent !important;
  }
  .hca-front-table thead{
    display:none !important;
  }
  .hca-front-table tr{
    background:#fff;
    border:1px solid #e5e7eb;
    border-radius:12px;
    padding:12px;
    box-shadow:0 6px 18px rgba(15,23,42,.06);
    box-sizing:border-box;
  }
  .hca-front-table td{
    border:0 !important;
    padding:7px 0 !important;
    display:flex;
    align-items:flex-start;
    justify-content:space-between;
    gap:12px;
    font-size:15px;
    white-space:normal !important;
    max-width:none !important;
    min-width:0 !important;
  }
  .hca-front-table td::before{
    content:attr(data-label);
    flex:0 0 112px;
    color:#475569;
    font-weight:700;
  }
  .hca-site-cell span{
    max-width:10ch !important;
  }
  .hca-options-cell{
    display:flex !important;
    gap:8px !important;
    align-items:center !important;
    justify-content:flex-start !important;
    padding-top:12px !important;
    border-top:1px solid #eef2f7 !important;
  }
  .hca-options-cell::before{display:none !important;}
  .hca-front-view,
  .hca-front-download{
    flex:1 1 0;
    display:inline-flex !important;
    justify-content:center;
    align-items:center;
    margin:0 !important;
    padding:11px 10px !important;
    font-size:15px !important;
  }
  .hca-is-creating{
    padding:8px 4px !important;
    margin-left:-8px;
    margin-right:-8px;
  }
  .hca-is-creating .hca-front-manager-top{
    padding:0 6px;
  }
  .hca-is-creating .hca-front-create-panel{
    padding:0 !important;
    border:0 !important;
    background:transparent !important;
  }
  .hca-is-creating .hc-wrap{
    max-width:100% !important;
    width:100% !important;
    padding-left:2px !important;
    padding-right:2px !important;
    margin-left:0 !important;
    margin-right:0 !important;
  }
  .hca-is-creating .hc-card{
    padding:10px !important;
    border-radius:10px !important;
  }
  .hca-is-creating .hc-table,
  .hca-is-creating .hc-table tbody,
  .hca-is-creating .hc-table tr,
  .hca-is-creating .hc-table th,
  .hca-is-creating .hc-table td{
    display:block;
    width:100% !important;
    box-sizing:border-box;
  }
  .hca-is-creating .hc-table th{
    border-bottom:0;
    border-radius:10px 10px 0 0;
    padding:10px 12px;
    font-size:15px;
  }
  .hca-is-creating .hc-table td{
    border-top:0;
    border-radius:0 0 10px 10px;
    padding:10px 12px;
    margin-bottom:12px;
  }
  .hca-is-creating .hc-headtable .logo{width:90px !important;}
  .hca-is-creating .hc-headtable .logo img{max-width:80px !important;}
  .hca-is-creating .hc-headtable .details{font-size:12px;}
}
