/* ═══════════════════════════════════════════════════════════
   ScriptLK Invoice Generator – Frontend CSS v4
═══════════════════════════════════════════════════════════ */

* { box-sizing: border-box; }

.sl-wrap {
  max-width: 900px;
  margin: 30px auto;
  padding: 0 16px;
  font-family: Arial, Helvetica, sans-serif;
}

/* ── Form Box ──────────────────────────────────────────── */
.sl-form-box {
  background: #fff;
  border-radius: 12px;
  box-shadow: 0 4px 28px rgba(0,0,0,.10);
  overflow: hidden;
}

/* ── Header ────────────────────────────────────────────── */
.sl-form-head {
  background: linear-gradient(135deg, #0a5f7a, #00b4d8);
  color: #fff;
  padding: 24px 32px;
}
.sl-form-head h2 { font-size: 22px; margin-bottom: 4px; }
.sl-form-head p  { font-size: 13px; opacity: .85; margin: 0; }

/* ── Sections ──────────────────────────────────────────── */
.sl-section {
  padding: 24px 32px;
  border-bottom: 1px solid #eef0f3;
}
.sl-section h3 {
  font-size: 15px;
  color: #0a5f7a;
  margin-bottom: 16px;
  display: flex;
  align-items: center;
  gap: 7px;
  font-weight: 700;
}
.sl-hint { font-size: 12px; color: #999; margin: -6px 0 12px; }

/* ── 2-col grid ────────────────────────────────────────── */
.sl-grid2 {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}
@media(max-width:600px){ .sl-grid2 { grid-template-columns: 1fr; } }

/* ── Field ─────────────────────────────────────────────── */
.sl-field { display: flex; flex-direction: column; }
.sl-field label {
  font-size: 12px;
  font-weight: 700;
  color: #555;
  margin-bottom: 5px;
  text-transform: uppercase;
  letter-spacing: .3px;
}
.sl-field input,
.sl-field textarea,
.sl-field select {
  padding: 10px 13px;
  border: 1.5px solid #dde0e7;
  border-radius: 7px;
  font-size: 14px;
  width: 100%;
  background: #fff;
  transition: border-color .2s, box-shadow .2s;
  color: #222;
}
.sl-field input:focus,
.sl-field textarea:focus,
.sl-field select:focus {
  outline: none;
  border-color: #00b4d8;
  box-shadow: 0 0 0 3px rgba(0,180,216,.12);
}
.req { color: #e74c3c; }
.sl-hint-sm { color: #aaa; font-weight: normal; font-size: 11px; text-transform: none; }

/* ── Item card ─────────────────────────────────────────── */
.sl-item {
  background: #f8f9fb;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
  margin-bottom: 12px;
  overflow: hidden;
}
.sl-item-hd {
  display: flex;
  align-items: center;
  gap: 10px;
  flex-wrap: wrap;
  background: #edf2f7;
  padding: 10px 14px;
  border-bottom: 1px solid #dde;
}
.sl-item-lbl { font-size: 13px; color: #0a5f7a; font-weight: 700; flex: 1; }
.sl-manual-lbl {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: #0a5f7a; cursor: pointer; font-weight: 600;
}
.sl-manual-lbl input { cursor: pointer; accent-color: #0a5f7a; }
.sl-rm {
  background: #fff; border: 1.5px solid #e74c3c; color: #e74c3c;
  padding: 4px 10px; border-radius: 5px; cursor: pointer;
  font-size: 12px; font-weight: 700; transition: all .2s;
}
.sl-rm:hover:not(:disabled) { background: #e74c3c; color: #fff; }
.sl-rm:disabled { opacity: .3; cursor: not-allowed; }
.sl-item-bd { padding: 14px; }

/* ── Price field ───────────────────────────────────────── */
.sl-price-wrap { display: flex; }
.sl-rs {
  background: #0a5f7a; color: #fff; padding: 10px 12px;
  border-radius: 7px 0 0 7px; font-size: 13px; font-weight: 700;
  display: flex; align-items: center;
}
.sl-price-wrap input {
  border-radius: 0 7px 7px 0 !important;
  border-left: none !important; flex: 1;
}
.sl-free-lbl {
  display: flex; align-items: center; gap: 5px;
  font-size: 12px; color: #666; margin-top: 7px;
  font-weight: normal; cursor: pointer; text-transform: none; letter-spacing: 0;
}
.sl-free-lbl input { accent-color: #0a5f7a; cursor: pointer; }

/* ── Add item btn ──────────────────────────────────────── */
#sl-add-item {
  width: 100%; padding: 11px; background: #fff;
  border: 2px dashed #00b4d8; color: #00b4d8;
  border-radius: 7px; cursor: pointer; font-size: 14px;
  font-weight: 700; margin-top: 4px; transition: background .2s;
}
#sl-add-item:hover { background: #e8f8fc; }

/* Error highlight */
.sl-err { border-color: #e74c3c !important; box-shadow: 0 0 0 3px rgba(231,76,60,.10) !important; }

/* ═══ TOTALS ══════════════════════════════════════════════ */
.sl-totals {
  margin-top: 20px;
  border-top: 2px solid #eef0f3;
  padding-top: 16px;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

/* Discount / Advance rows */
.sl-tot-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 12px;
  padding: 11px 16px;
  background: #f8f9fb;
  border: 1.5px solid #e2e8f0;
  border-radius: 8px;
}
.sl-tot-label {
  font-size: 14px;
  font-weight: 700;
  color: #444;
  display: flex;
  align-items: center;
  gap: 8px;
  white-space: nowrap;
  flex-shrink: 0;
}
.sl-tot-label select {
  padding: 5px 8px;
  border: 1.5px solid #ddd;
  border-radius: 5px;
  font-size: 13px;
  background: #fff;
  cursor: pointer;
  font-weight: normal;
}
.sl-tot-input {
  width: 160px;
  padding: 9px 13px;
  border: 1.5px solid #ddd;
  border-radius: 7px;
  font-size: 16px;
  font-weight: 700;
  text-align: right;
  color: #c0392b;
  background: #fff;
  display: block;
  flex-shrink: 0;
}
.sl-tot-input:focus {
  outline: none;
  border-color: #e74c3c;
  box-shadow: 0 0 0 3px rgba(231,76,60,.10);
}

/* Grand Total bar */
.sl-tot-grand {
  display: flex;
  justify-content: space-between;
  align-items: center;
  background: linear-gradient(135deg, #0a5f7a, #00b4d8);
  color: #fff;
  border-radius: 9px;
  padding: 16px 20px;
  font-size: 15px;
  font-weight: 700;
  letter-spacing: 0.5px;
  margin-top: 4px;
  box-shadow: 0 4px 14px rgba(0,180,216,.25);
}
#sl-grand {
  font-size: 24px;
  font-weight: 900;
  letter-spacing: 0;
}

@media(max-width:500px){
  .sl-tot-row { flex-direction: column; align-items: flex-start; }
  .sl-tot-input { width: 100%; }
  #sl-grand { font-size: 20px; }
}

/* ═══ ACTIONS ════════════════════════════════════════════ */
.sl-actions {
  display: flex;
  gap: 10px;
  padding: 24px 32px;
  flex-wrap: wrap;
}
.sl-btn {
  flex: 1;
  min-width: 120px;
  padding: 13px 12px;
  border: none;
  border-radius: 8px;
  font-size: 14px;
  font-weight: 700;
  cursor: pointer;
  transition: all .2s;
  text-align: center;
  text-decoration: none;
  display: inline-block;
  line-height: 1.3;
}
.sl-btn:disabled { opacity: .5; cursor: not-allowed; transform: none !important; }
.sl-btn-outline {
  background: #fff;
  border: 2px solid #0a5f7a;
  color: #0a5f7a;
}
.sl-btn-outline:hover:not(:disabled) { background: #0a5f7a; color: #fff; }
.sl-btn-teal {
  background: linear-gradient(135deg,#00b4d8,#0096c7);
  color: #fff;
  box-shadow: 0 3px 12px rgba(0,180,216,.28);
}
.sl-btn-teal:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(0,180,216,.4); }
.sl-btn-dark {
  background: linear-gradient(135deg,#0a5f7a,#084a5e);
  color: #fff;
  box-shadow: 0 3px 12px rgba(10,95,122,.28);
}
.sl-btn-dark:hover:not(:disabled) { transform: translateY(-2px); box-shadow: 0 5px 18px rgba(10,95,122,.4); }
.sl-btn-ghost {
  background: none; border: 1.5px solid #00b4d8; color: #00b4d8;
  padding: 6px 14px; border-radius: 6px; cursor: pointer;
  font-size: 12px; font-weight: 700; margin-top: 8px; transition: background .2s;
}
.sl-btn-ghost:hover { background: #e8f8fc; }

@media(max-width:600px){
  .sl-actions { padding: 18px 20px; flex-direction: column; }
  .sl-btn { min-width: unset; width: 100%; }
}

/* ═══ MESSAGE ════════════════════════════════════════════ */
#sl-msg { border-radius: 7px; font-size: 14px; line-height: 1.5; }
.sl-msg-ok  { background: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
.sl-msg-err { background: #fde8e8; color: #c0392b; border: 1px solid #f5c6cb; }

/* ═══ LINK BOX ═══════════════════════════════════════════ */
#sl-link-box { padding: 0 32px 24px; }
.sl-link-inner {
  background: #f0f9ff;
  border: 2px solid #00b4d8;
  border-radius: 8px;
  padding: 16px 18px;
}
.sl-link-inner p { font-size: 14px; color: #0a5f7a; margin-bottom: 10px; }
.sl-link-row { display: flex; gap: 8px; }
#sl-link-url {
  flex: 1; padding: 9px 12px; border: 1.5px solid #ddd;
  border-radius: 6px; font-size: 13px; color: #333; background: #fff;
}
#sl-copy-btn {
  padding: 9px 14px; background: #0a5f7a; color: #fff; border: none;
  border-radius: 6px; cursor: pointer; font-size: 13px; font-weight: 700;
}
#sl-copy-btn:hover { background: #084a5e; }

/* ═══ MODAL ══════════════════════════════════════════════ */
#sl-modal {
  position: fixed; inset: 0; z-index: 999999;
  background: rgba(0,0,0,.65);
  display: flex; align-items: flex-start; justify-content: center;
  overflow-y: auto; padding: 20px 12px;
}
.sl-modal-box {
  background: #fff; border-radius: 10px; width: 100%; max-width: 820px;
  box-shadow: 0 8px 40px rgba(0,0,0,.3); overflow: hidden;
  animation: slIn .25s ease;
}
@keyframes slIn {
  from { transform: translateY(-30px); opacity: 0; }
  to   { transform: translateY(0); opacity: 1; }
}
.sl-modal-top {
  display: flex; justify-content: space-between; align-items: center;
  padding: 14px 22px;
  background: linear-gradient(135deg,#0a5f7a,#00b4d8); color: #fff;
}
.sl-modal-top span { font-size: 15px; font-weight: 700; }
.sl-modal-x { background: none; border: none; color: #fff; font-size: 24px; cursor: pointer; }
#sl-modal-body {
  padding: 22px; max-height: 72vh; overflow-y: auto;
  font-family: Arial, Helvetica, sans-serif;
}
.sl-modal-foot {
  display: flex; gap: 10px; padding: 14px 22px;
  border-top: 1px solid #eee; justify-content: flex-end; flex-wrap: wrap;
}

/* ── Invoice preview inside modal ──────────────────────── */
#sl-modal-body .inv { color: #1a1a1a; }
#sl-modal-body .inv-hd { display:flex; justify-content:space-between; align-items:flex-start; margin-bottom:12px; }
#sl-modal-body .inv-logo img { max-width:120px; max-height:65px; object-fit:contain; }
#sl-modal-body .inv-logo-fb { background:#0a1128; color:#00b4d8; font-size:12px; font-weight:700; width:65px; height:65px; border-radius:50%; display:flex; align-items:center; justify-content:center; text-align:center; }
#sl-modal-body .inv-big { font-size:36px; font-weight:900; color:#00b4d8; line-height:1; }
#sl-modal-body .inv-co { font-size:10px; color:#666; text-align:right; margin-top:3px; }
#sl-modal-body .inv-rule { height:3px; background:linear-gradient(to right,#0a5f7a,#00b4d8); margin-bottom:14px; border-radius:2px; }
#sl-modal-body .inv-row2 { display:flex; justify-content:space-between; gap:16px; margin-bottom:14px; flex-wrap:wrap; }
#sl-modal-body .inv-customer-col { flex:1; }
#sl-modal-body .inv-lbl { font-size:9px; text-transform:uppercase; letter-spacing:1px; color:#999; margin-bottom:4px; }
#sl-modal-body .inv-cname { font-size:15px; font-weight:700; color:#0a5f7a; margin-bottom:4px; }
#sl-modal-body .inv-cd { font-size:11px; color:#555; margin-bottom:2px; }
#sl-modal-body .inv-meta { text-align:right; }
#sl-modal-body .inv-meta table { font-size:11px; border-collapse:collapse; margin-left:auto; }
#sl-modal-body .inv-meta td { padding:3px 0 3px 14px; color:#444; }
#sl-modal-body .inv-meta-k { color:#999; }
#sl-modal-body .inv-tbl { width:100%; border-collapse:collapse; margin-bottom:14px; font-size:12px; }
#sl-modal-body .inv-tbl thead tr { background:linear-gradient(135deg,#0a5f7a,#00b4d8); }
#sl-modal-body .inv-tbl thead th { color:#fff; padding:8px 11px; text-align:left; font-size:10px; }
#sl-modal-body .th-total { text-align:right; }
#sl-modal-body .inv-tbl tbody tr:nth-child(even) { background:#f7fbfc; }
#sl-modal-body .inv-tbl td { padding:8px 11px; border-bottom:1px solid #ebebeb; vertical-align:top; }
#sl-modal-body .inv-iname { font-weight:600; }
#sl-modal-body .inv-idesc { color:#555; font-size:11px; }
#sl-modal-body .inv-iprice { text-align:right; font-weight:700; color:#0a5f7a; white-space:nowrap; }
#sl-modal-body .inv-free { background:#d4edda; color:#155724; padding:1px 6px; border-radius:20px; font-size:10px; font-weight:600; }
#sl-modal-body .inv-ft { display:flex; gap:14px; justify-content:space-between; margin-bottom:12px; flex-wrap:wrap; }
#sl-modal-body .inv-pay { flex:1; min-width:140px; }
#sl-modal-body .inv-pay-hd { background:#0a5f7a; color:#fff; padding:7px 10px; font-size:10px; font-weight:700; border-radius:4px 4px 0 0; }
#sl-modal-body .inv-pay-bd { border:1px solid #dde; border-top:none; padding:8px 10px; border-radius:0 0 4px 4px; }
#sl-modal-body .inv-pay-bd p { font-size:11px; color:#444; margin-bottom:2px; }
#sl-modal-body .inv-acct { font-weight:700; color:#0a5f7a; font-size:12px; }
#sl-modal-body .inv-tots { min-width:180px; }
#sl-modal-body .inv-tot-r { display:flex; justify-content:space-between; padding:5px 9px; background:#f5f5f5; margin-bottom:2px; font-size:11px; border-radius:3px; }
#sl-modal-body .inv-tot-disc { background:#fff3cd; color:#856404; }
#sl-modal-body .inv-tot-after { background:#e8f5e9; color:#2e7d32; }
#sl-modal-body .inv-tot-adv { background:#e3f2fd; color:#1565c0; }
#sl-modal-body .inv-tot-g { background:#0a5f7a !important; color:#fff !important; font-size:13px !important; font-weight:700; padding:9px 10px !important; border-radius:4px !important; }
#sl-modal-body .inv-note { background:#f0f9ff; border-left:4px solid #00b4d8; padding:10px 12px; margin-bottom:12px; border-radius:0 5px 5px 0; }
#sl-modal-body .inv-note p { font-size:11px; color:#333; margin-bottom:3px; line-height:1.6; }
#sl-modal-body .inv-sig-row { display:flex; justify-content:space-between; align-items:flex-end; margin-bottom:14px; flex-wrap:wrap; gap:10px; }
#sl-modal-body .inv-ty { font-size:11px; font-weight:700; color:#0a5f7a; }
#sl-modal-body .inv-sig { text-align:right; }
#sl-modal-body .inv-sig img { max-width:120px; max-height:60px; display:block; margin-left:auto; margin-bottom:3px; object-fit:contain; }
#sl-modal-body .inv-sname { font-size:12px; font-weight:700; }
#sl-modal-body .inv-stitle { font-size:10px; color:#888; }
#sl-modal-body .inv-bar { display:flex; justify-content:space-around; padding:9px; border-top:3px solid #00b4d8; font-size:10px; color:#555; flex-wrap:wrap; gap:6px; }

@media(max-width:600px){
  .sl-section { padding: 18px 20px; }
  .sl-form-head { padding: 20px 20px; }
  #sl-link-box { padding: 0 20px 20px; }
  #sl-modal-body .inv-hd,
  #sl-modal-body .inv-row2,
  #sl-modal-body .inv-ft,
  #sl-modal-body .inv-sig-row { flex-direction:column; gap:10px; }
  #sl-modal-body .inv-meta,
  #sl-modal-body .inv-sig { text-align:left; }
  #sl-modal-body .inv-meta table { margin-left:0; }
  #sl-modal-body .inv-tots { width:100%; }
}
