/* ==========================================================================
   Certificate & Offer Letter Generator - admin theme
   ========================================================================== */

:root {
  --navy: #12365c;
  --navy-dark: #0d2843;
  --navy-light: #1c4a78;
  --gold: #d4a017;
  --ink: #1f2430;
  --muted: #6b7787;
  --line: #e2e8f0;
  --bg: #f4f6f9;
  --white: #ffffff;
  --green: #0f7b4f;
  --green-bg: #e7f5ee;
  --red: #b42318;
  --red-bg: #fdeceb;
  --amber: #a15c07;
  --amber-bg: #fdf3e2;
  --blue-bg: #e8f0fa;
  --radius: 10px;
  --shadow: 0 1px 2px rgba(16, 24, 40, .06), 0 4px 14px rgba(16, 24, 40, .05);
}

* { box-sizing: border-box; }

html, body {
  margin: 0;
  padding: 0;
  background: var(--bg);
  color: var(--ink);
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Arial, sans-serif;
  font-size: 14px;
  line-height: 1.55;
  -webkit-font-smoothing: antialiased;
}

a { color: var(--navy); text-decoration: none; }
a:hover { text-decoration: underline; }
h1, h2, h3, h4 { margin: 0 0 .4rem; line-height: 1.25; }

/* ------------------------------------------------------------------ layout */
.layout { display: flex; min-height: 100vh; }

.sidebar {
  width: 248px;
  flex: 0 0 248px;
  background: var(--navy-dark);
  color: #c9d6e4;
  display: flex;
  flex-direction: column;
  position: fixed;
  inset: 0 auto 0 0;
  z-index: 40;
  overflow-y: auto;
}

.brand {
  display: flex; align-items: center; gap: 10px;
  padding: 18px 18px 16px;
  border-bottom: 1px solid rgba(255, 255, 255, .08);
}
.brand-mark {
  width: 38px; height: 38px; border-radius: 9px;
  background: var(--gold); color: #23200d;
  font-weight: 800; font-size: 15px;
  display: flex; align-items: center; justify-content: center;
}
.brand-text { color: #fff; font-weight: 700; font-size: 14px; line-height: 1.15; }
.brand-text small { font-weight: 400; font-size: 11px; color: #9db3c9; letter-spacing: .5px; }

.nav { padding: 10px 10px 20px; flex: 1; }
.nav-group {
  display: block; padding: 14px 10px 6px;
  font-size: 10px; letter-spacing: 1.2px; text-transform: uppercase; color: #6f8aa6;
}
.nav a {
  display: block; padding: 9px 12px; margin-bottom: 2px;
  border-radius: 8px; color: #c9d6e4; font-size: 13.5px; text-decoration: none;
  transition: background .15s, color .15s;
}
.nav a:hover { background: rgba(255, 255, 255, .07); color: #fff; text-decoration: none; }
.nav a.active { background: var(--navy-light); color: #fff; font-weight: 600; }

.sidebar-foot {
  padding: 14px 18px 18px;
  border-top: 1px solid rgba(255, 255, 255, .08);
}
.who { color: #fff; font-size: 13px; font-weight: 600; }
.who small { display: block; font-weight: 400; font-size: 11px; color: #8fa6bd; text-transform: capitalize; }
.logout {
  display: inline-block; margin-top: 8px; font-size: 12.5px;
  color: #ffd8a8; border: 1px solid rgba(255, 216, 168, .35);
  padding: 5px 12px; border-radius: 7px;
}
.logout:hover { background: rgba(255, 216, 168, .12); text-decoration: none; }

.main { flex: 1; margin-left: 248px; display: flex; flex-direction: column; min-width: 0; }

.topbar {
  background: var(--white);
  border-bottom: 1px solid var(--line);
  padding: 14px 24px;
  display: flex; align-items: center; gap: 14px;
  position: sticky; top: 0; z-index: 20;
}
.topbar-title h1 { font-size: 19px; margin: 0; }
.topbar-title p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.topbar-right { margin-left: auto; }
.org-chip {
  background: var(--blue-bg); color: var(--navy);
  padding: 6px 12px; border-radius: 20px; font-size: 12px; font-weight: 600;
  white-space: nowrap; max-width: 260px; overflow: hidden; text-overflow: ellipsis; display: inline-block;
}

.hamburger { display: none; background: none; border: 0; cursor: pointer; padding: 6px; }
.hamburger span { display: block; width: 22px; height: 2px; background: var(--ink); margin: 4px 0; border-radius: 2px; }

.content { padding: 22px 24px 40px; flex: 1; }
.pagefoot { padding: 14px 24px; color: #9aa5b1; font-size: 11.5px; border-top: 1px solid var(--line); background: var(--white); }
.backdrop { display: none; }

/* ------------------------------------------------------------------- cards */
.card {
  background: var(--white); border: 1px solid var(--line);
  border-radius: var(--radius); box-shadow: var(--shadow);
  margin-bottom: 20px;
}
.card-head {
  padding: 14px 18px; border-bottom: 1px solid var(--line);
  display: flex; align-items: center; gap: 12px; flex-wrap: wrap;
}
.card-head h2 { font-size: 15px; margin: 0; }
.card-head p { margin: 2px 0 0; font-size: 12.5px; color: var(--muted); }
.card-head .spacer { margin-left: auto; }
.card-body { padding: 18px; }
.card-foot { padding: 14px 18px; border-top: 1px solid var(--line); background: #fafbfc; border-radius: 0 0 var(--radius) var(--radius); }

.grid { display: grid; gap: 16px; }
.grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
.grid-3 { grid-template-columns: repeat(3, minmax(0, 1fr)); }
.grid-4 { grid-template-columns: repeat(4, minmax(0, 1fr)); }

/* --------------------------------------------------------------- stat tile */
.stat {
  background: var(--white); border: 1px solid var(--line); border-radius: var(--radius);
  padding: 16px 18px; box-shadow: var(--shadow);
}
.stat .label { font-size: 11.5px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); }
.stat .value { font-size: 26px; font-weight: 700; color: var(--navy); margin-top: 4px; }
.stat .hint { font-size: 12px; color: var(--muted); margin-top: 2px; }

/* ------------------------------------------------------------------ forms */
label { display: block; font-size: 12.5px; font-weight: 600; color: #3c4858; margin-bottom: 5px; }
.hint { font-size: 12px; color: var(--muted); margin-top: 4px; }
input[type=text], input[type=password], input[type=email], input[type=number],
input[type=date], input[type=search], select, textarea {
  width: 100%; padding: 9px 11px; font: inherit; font-size: 13.5px;
  border: 1px solid #cfd8e3; border-radius: 8px; background: #fff; color: var(--ink);
}
input:focus, select:focus, textarea:focus {
  outline: none; border-color: var(--navy-light); box-shadow: 0 0 0 3px rgba(28, 74, 120, .12);
}
textarea { resize: vertical; min-height: 90px; line-height: 1.5; }
.field { margin-bottom: 14px; }
.inline-check { display: flex; align-items: center; gap: 8px; font-size: 13px; font-weight: 500; }
.inline-check input { width: auto; }
.code { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; }

/* ---------------------------------------------------------------- buttons */
.btn {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  padding: 9px 16px; font-size: 13.5px; font-weight: 600; line-height: 1.2;
  border: 1px solid transparent; border-radius: 8px; cursor: pointer;
  background: var(--navy); color: #fff; text-decoration: none;
}
.btn:hover { background: var(--navy-light); text-decoration: none; color: #fff; }
.btn:disabled, .btn.disabled { opacity: .55; cursor: not-allowed; }
.btn-outline { background: #fff; color: var(--navy); border-color: #cfd8e3; }
.btn-outline:hover { background: #f2f6fb; color: var(--navy); }
.btn-danger { background: var(--red); }
.btn-danger:hover { background: #932014; }
.btn-gold { background: var(--gold); color: #2a2308; }
.btn-gold:hover { background: #e5b02c; color: #2a2308; }
.btn-sm { padding: 5px 10px; font-size: 12.5px; border-radius: 7px; }
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; align-items: center; }

/* ----------------------------------------------------------------- tables */
.table-wrap { overflow-x: auto; }
table.data { width: 100%; border-collapse: collapse; font-size: 13px; }
table.data th {
  text-align: left; padding: 10px 12px; background: #f7f9fc; color: #55627a;
  font-size: 11.5px; letter-spacing: .5px; text-transform: uppercase;
  border-bottom: 1px solid var(--line); white-space: nowrap;
}
table.data td { padding: 10px 12px; border-bottom: 1px solid #eef2f6; vertical-align: middle; }
table.data tr:last-child td { border-bottom: none; }
table.data tbody tr:hover { background: #fbfcfe; }
table.data td.nowrap, table.data th.nowrap { white-space: nowrap; }
.row-invalid { background: var(--red-bg) !important; }
.row-duplicate { background: var(--amber-bg) !important; }
.row-excluded { opacity: .45; }

/* ---------------------------------------------------------------- badges */
.badge {
  display: inline-block; padding: 3px 9px; border-radius: 20px;
  font-size: 11px; font-weight: 700; letter-spacing: .3px; text-transform: uppercase;
}
.badge-valid { background: var(--green-bg); color: var(--green); }
.badge-invalid { background: var(--red-bg); color: var(--red); }
.badge-duplicate { background: var(--amber-bg); color: var(--amber); }
.badge-neutral { background: #eef1f5; color: #55627a; }
.badge-info { background: var(--blue-bg); color: var(--navy); }

/* ---------------------------------------------------------------- alerts */
.alert {
  position: relative; padding: 11px 38px 11px 14px; border-radius: 9px;
  margin-bottom: 14px; font-size: 13.5px; border: 1px solid transparent;
}
.alert-success { background: var(--green-bg); color: #0b5c3b; border-color: #b7e2cd; }
.alert-danger, .alert-error { background: var(--red-bg); color: #8c1c13; border-color: #f4c3bf; }
.alert-warning { background: var(--amber-bg); color: #82490a; border-color: #f2ddb4; }
.alert-info { background: var(--blue-bg); color: var(--navy); border-color: #c6dbf2; }
.alert-x { position: absolute; right: 8px; top: 6px; background: none; border: 0; font-size: 19px; cursor: pointer; color: inherit; opacity: .6; }
.alert-x:hover { opacity: 1; }

/* -------------------------------------------------------------- dropzone */
.dropzone {
  border: 2px dashed #b9c6d6; border-radius: 12px; background: #fbfdff;
  padding: 38px 20px; text-align: center; cursor: pointer; transition: .15s;
}
.dropzone:hover, .dropzone.dragover { border-color: var(--navy-light); background: #f1f7fd; }
.dropzone .dz-icon { font-size: 34px; }
.dropzone h3 { margin: 8px 0 4px; font-size: 15px; }
.dropzone p { margin: 0; color: var(--muted); font-size: 12.5px; }
.dz-file {
  margin-top: 14px; padding: 10px 14px; background: var(--blue-bg);
  border-radius: 8px; font-size: 13px; display: none;
}

/* -------------------------------------------------------------- progress */
.progress { height: 10px; background: #e6ebf1; border-radius: 20px; overflow: hidden; }
.progress-bar { height: 100%; width: 0; background: var(--navy); transition: width .25s; }
.progress-bar.done { background: var(--green); }

/* ---------------------------------------------------------------- modal */
.modal {
  display: none; position: fixed; inset: 0; z-index: 60;
  background: rgba(16, 24, 40, .55); padding: 24px;
  overflow-y: auto;
}
.modal.open { display: block; }
.modal-box {
  background: #fff; border-radius: 12px; max-width: 900px; margin: 20px auto;
  box-shadow: 0 20px 50px rgba(16, 24, 40, .25);
}
.modal-box.wide { max-width: 1180px; }
.modal-head { padding: 14px 18px; border-bottom: 1px solid var(--line); display: flex; align-items: center; }
.modal-head h3 { margin: 0; font-size: 15px; }
.modal-head .close { margin-left: auto; background: none; border: 0; font-size: 22px; cursor: pointer; color: var(--muted); }
.modal-body { padding: 18px; }
.modal-body iframe { width: 100%; height: 70vh; border: 1px solid var(--line); border-radius: 8px; background: #525659; }
.modal-foot { padding: 14px 18px; border-top: 1px solid var(--line); text-align: right; }

/* --------------------------------------------------------------- toolbar */
.toolbar {
  display: flex; gap: 10px; flex-wrap: wrap; align-items: flex-end;
  margin-bottom: 16px;
}
.toolbar .field { margin-bottom: 0; }
.toolbar .grow { flex: 1 1 220px; }

.pagination { display: flex; gap: 6px; flex-wrap: wrap; margin-top: 16px; align-items: center; }
.pagination a, .pagination span {
  padding: 6px 11px; border: 1px solid var(--line); border-radius: 7px;
  font-size: 12.5px; background: #fff; color: var(--navy);
}
.pagination .current { background: var(--navy); color: #fff; border-color: var(--navy); font-weight: 600; }
.pagination .muted { color: var(--muted); border: none; background: none; }

.empty { text-align: center; padding: 46px 20px; color: var(--muted); }
.empty .big { font-size: 34px; }
.empty h3 { margin: 8px 0 4px; color: var(--ink); font-size: 16px; }

.meta-list { list-style: none; margin: 0; padding: 0; font-size: 13px; }
.meta-list li { display: flex; justify-content: space-between; gap: 12px; padding: 7px 0; border-bottom: 1px solid #eef2f6; }
.meta-list li:last-child { border-bottom: none; }
.meta-list span:first-child { color: var(--muted); }
.meta-list span:last-child { font-weight: 600; text-align: right; word-break: break-word; }

.asset-preview {
  border: 1px solid var(--line); border-radius: 9px; background: #fbfcfe;
  padding: 14px; text-align: center; min-height: 110px;
  display: flex; align-items: center; justify-content: center;
}
.asset-preview img { max-width: 100%; max-height: 90px; }
.asset-preview .none { color: var(--muted); font-size: 12.5px; }

/* --------------------------------------------------------- template edit */
.editor-grid { display: grid; grid-template-columns: minmax(0, 1fr) 250px; gap: 16px; }
.editor-grid textarea { font-family: ui-monospace, SFMono-Regular, Consolas, monospace; font-size: 12.5px; min-height: 320px; }
.ph-list { max-height: 460px; overflow-y: auto; }
.ph-group { font-size: 11px; letter-spacing: .6px; text-transform: uppercase; color: var(--muted); margin: 12px 0 6px; }
.ph-chip {
  display: inline-block; margin: 0 4px 5px 0; padding: 3px 8px;
  background: #eef2f7; border: 1px solid #dde5ee; border-radius: 6px;
  font-family: ui-monospace, Consolas, monospace; font-size: 11.5px; cursor: pointer; color: var(--navy);
}
.ph-chip:hover { background: var(--navy); color: #fff; }

.preview-frame { width: 100%; height: 62vh; border: 1px solid var(--line); border-radius: 8px; background: #525659; }

/* ---------------------------------------------------------------- login */
.login-wrap {
  min-height: 100vh; display: flex; align-items: center; justify-content: center;
  padding: 24px; background: linear-gradient(135deg, #0d2843 0%, #17436e 55%, #1c4a78 100%);
}
.login-card {
  width: 100%; max-width: 400px; background: #fff; border-radius: 14px;
  padding: 30px 28px; box-shadow: 0 24px 60px rgba(5, 20, 38, .38);
}
.login-card .lock { width: 46px; height: 46px; border-radius: 12px; background: var(--navy); color: #fff;
  display: flex; align-items: center; justify-content: center; font-size: 21px; margin-bottom: 14px; }
.login-card h1 { font-size: 19px; margin-bottom: 3px; }
.login-card .sub { color: var(--muted); font-size: 13px; margin: 0 0 20px; }
.login-card .btn { width: 100%; padding: 11px; margin-top: 4px; }
.login-note { margin-top: 18px; padding-top: 14px; border-top: 1px solid var(--line); font-size: 12px; color: var(--muted); }

/* --------------------------------------------------------------- helpers */
.text-muted { color: var(--muted); }
.text-right { text-align: right; }
.text-center { text-align: center; }
.mt-0 { margin-top: 0; } .mt-1 { margin-top: 8px; } .mt-2 { margin-top: 16px; } .mt-3 { margin-top: 24px; }
.mb-0 { margin-bottom: 0; } .mb-1 { margin-bottom: 8px; } .mb-2 { margin-bottom: 16px; }
.nowrap { white-space: nowrap; }
.small { font-size: 12px; }
.divider { height: 1px; background: var(--line); margin: 18px 0; }
.flex { display: flex; gap: 10px; align-items: center; flex-wrap: wrap; }
.summary-chips { display: flex; gap: 10px; flex-wrap: wrap; }
.summary-chip {
  padding: 8px 14px; border-radius: 9px; background: #f2f5f9; font-size: 12.5px; font-weight: 600; color: #45536b;
}
.summary-chip b { display: block; font-size: 18px; color: var(--ink); }
.summary-chip.ok { background: var(--green-bg); color: var(--green); }
.summary-chip.bad { background: var(--red-bg); color: var(--red); }
.summary-chip.warn { background: var(--amber-bg); color: var(--amber); }

/* ----------------------------------------------------------- responsive */
@media (max-width: 1100px) {
  .grid-4 { grid-template-columns: repeat(2, minmax(0, 1fr)); }
  .editor-grid { grid-template-columns: 1fr; }
}
@media (max-width: 900px) {
  .grid-3, .grid-2 { grid-template-columns: 1fr; }
}
@media (max-width: 820px) {
  .sidebar { transform: translateX(-100%); transition: transform .22s ease; box-shadow: 0 0 40px rgba(0,0,0,.3); }
  .sidebar.open { transform: translateX(0); }
  .main { margin-left: 0; }
  .hamburger { display: block; }
  .backdrop { display: none; position: fixed; inset: 0; background: rgba(16,24,40,.45); z-index: 30; }
  .backdrop.show { display: block; }
  .content { padding: 16px 14px 32px; }
  .topbar { padding: 12px 14px; }
  .org-chip { max-width: 130px; }
}
@media (max-width: 520px) {
  .grid-4 { grid-template-columns: 1fr; }
  .topbar-title h1 { font-size: 16px; }
  .modal { padding: 10px; }
  .btn { padding: 8px 13px; }
}

/* --------------------------------------------- reveal-password button */
.pw-wrap { position: relative; display: block; }
.pw-wrap input[type=password], .pw-wrap input[type=text] { padding-right: 40px; }
.pw-toggle {
  position: absolute; top: 0; right: 0; height: 100%; width: 38px;
  display: flex; align-items: center; justify-content: center;
  padding: 0; border: 0; background: none; cursor: pointer;
  color: var(--muted); border-radius: 0 8px 8px 0;
}
.pw-toggle:hover { color: var(--navy); }
.pw-toggle:focus-visible { outline: 2px solid var(--navy-light); outline-offset: -2px; }
