/**
 * AFROTOOLS — Invoice Generator Styles
 * ═══════════════════════════════════════
 */

/* ── FOUNDATION ── */
.inv-page {
  background: var(--color-bg, #FAFAF8);
  min-height: 100vh;
  font-family: var(--font-body, 'DM Sans', system-ui, sans-serif);
}

/* ── HERO ── */
.inv-hero { background: var(--color-bg-dark, #0A1628); padding: 40px 0 36px; }
.breadcrumb { display: flex; align-items: center; gap: 6px; font-size: 0.72rem; font-weight: 500; letter-spacing: 0.06em; color: rgba(255,255,255,0.35); margin-bottom: 12px; }
.breadcrumb a { color: rgba(255,255,255,0.35); text-decoration: none; }
.breadcrumb a:hover { color: var(--color-primary); }
.breadcrumb span { color: rgba(255,255,255,0.15); }
.inv-hero h1 { font-size: clamp(1.6rem, 3vw, 2.2rem); font-weight: 800; color: #fff; margin-bottom: 10px; letter-spacing: -0.02em; line-height: 1.15; }
.inv-hero h1 em { color: var(--color-primary); font-style: normal; }
.inv-hero-sub { font-size: 0.9rem; color: rgba(255,255,255,0.55); line-height: 1.65; max-width: 600px; }
.hero-badges { display: flex; flex-wrap: wrap; gap: 7px; margin-top: 14px; }
.badge { display: inline-flex; align-items: center; gap: 4px; padding: 4px 10px; border-radius: 4px; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.05em; }
.badge-green { background: rgba(0,122,255,0.15); color: var(--color-primary); border: 1px solid rgba(0,122,255,0.3); }
.badge-blue { background: rgba(52,152,219,0.15); color: #7ec8e3; border: 1px solid rgba(52,152,219,0.3); }
.badge-grey { background: rgba(255,255,255,0.07); color: rgba(255,255,255,0.45); border: 1px solid rgba(255,255,255,0.12); }

/* ── LAYOUT ── */
.inv-main { padding: 28px 0 60px; }
.inv-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; align-items: start; }

/* ── CARD ── */
.card {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 12px;
  overflow: hidden;
  box-shadow: 0 1px 8px rgba(0,0,0,0.05);
  margin-bottom: 20px;
}
.card-head {
  padding: 16px 24px;
  border-bottom: 1px solid #E2E8F0;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.card-title { font-size: 0.72rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #3D5A80; }
.card-sub { font-size: 0.72rem; color: #8B9CB8; }
.card-body { padding: 24px; }

/* ── FORM ── */
.field { margin-bottom: 18px; }
.field:last-child { margin-bottom: 0; }

.f-label {
  display: block;
  font-size: 0.78rem;
  font-weight: 700;
  color: #2D3A5A;
  margin-bottom: 7px;
  line-height: 1.3;
}

.f-input {
  width: 100%;
  padding: 12px 14px;
  background: #F4F7FA;
  border: 1.5px solid #CBD5E1;
  border-radius: 9px;
  font-size: 0.88rem;
  font-weight: 500;
  color: #1E293B;
  outline: none;
  transition: border-color 0.18s, box-shadow 0.18s, background 0.18s;
  font-family: inherit;
  box-sizing: border-box;
  -webkit-appearance: none;
  appearance: none;
}
.f-input:focus {
  border-color: var(--color-primary);
  background: #fff;
  box-shadow: 0 0 0 3px rgba(0,122,255,0.12);
}
.f-input:hover:not(:focus) {
  border-color: #94A3B8;
}
.f-input::placeholder {
  color: #94A3B8;
  font-weight: 400;
}
.f-input:disabled, .f-input[readonly] {
  opacity: 0.6;
  cursor: not-allowed;
}

/* Select specific overrides */
select.f-input {
  padding-right: 36px;
  background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238B9CB8' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 12px;
  cursor: pointer;
}

textarea.f-input {
  resize: vertical;
  min-height: 72px;
  line-height: 1.6;
}

.f-row { display: grid; grid-template-columns: 1fr 1fr; gap: 14px; }
.f-row-3 { display: grid; grid-template-columns: 1fr 1fr 1fr; gap: 14px; }
.f-note { font-size: 0.7rem; color: #8B9CB8; margin-top: 5px; }

/* ── FILE INPUT ── */
input[type="file"].f-input {
  padding: 10px 12px;
  font-size: 0.82rem;
  cursor: pointer;
}
input[type="file"].f-input::file-selector-button {
  padding: 6px 14px;
  background: #E8EFF8;
  border: 1px solid #CBD5E1;
  border-radius: 6px;
  font-size: 0.78rem;
  font-weight: 600;
  color: #3D5A80;
  cursor: pointer;
  margin-right: 10px;
  font-family: inherit;
}
input[type="file"].f-input::file-selector-button:hover {
  background: #D1DDEF;
}

/* ── CHECKBOX ── */
.field-checkbox {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 10px 0;
}
.field-checkbox input[type="checkbox"] {
  width: 18px;
  height: 18px;
  accent-color: var(--color-primary, #007AFF);
  cursor: pointer;
  flex-shrink: 0;
}
.field-checkbox label {
  font-size: 0.85rem;
  font-weight: 600;
  color: #2D3A5A;
  cursor: pointer;
  line-height: 1.3;
}

/* ── TEMPLATE SELECTOR ── */
.tpl-bar {
  display: flex;
  gap: 4px;
  background: #F0F5FF;
  padding: 4px;
  border-radius: 9px;
  margin-bottom: 0;
  flex-wrap: wrap;
}
.tpl-btn {
  flex: 1;
  padding: 9px 10px;
  font-size: 0.74rem;
  font-weight: 700;
  border: none;
  background: transparent;
  border-radius: 7px;
  cursor: pointer;
  color: #8B9CB8;
  transition: all 0.15s;
  text-align: center;
  min-width: 70px;
  font-family: inherit;
}
.tpl-btn:hover { background: rgba(255,255,255,0.5); color: #3D5A80; }
.tpl-btn:focus-visible {
  outline: 2px solid var(--color-primary);
  outline-offset: -2px;
}
.tpl-btn.on { background: #fff; color: var(--color-brand); box-shadow: 0 1px 5px rgba(0,0,0,0.09); }

/* ── LINE ITEMS TABLE ── */
.items-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin: 14px 0; }
.items-table th {
  text-align: left;
  font-size: 0.65rem;
  font-weight: 700;
  letter-spacing: 0.06em;
  text-transform: uppercase;
  color: #8B9CB8;
  padding: 8px 10px;
  border-bottom: 1.5px solid #E2E8F0;
  white-space: nowrap;
}
.items-table td {
  padding: 8px 6px;
  border-bottom: 1px solid #F1F5F9;
  vertical-align: middle;
}
.items-table input {
  width: 100%;
  padding: 9px 10px;
  border: 1.5px solid #CBD5E1;
  border-radius: 7px;
  font-size: 0.85rem;
  font-family: inherit;
  background: #F4F7FA;
  box-sizing: border-box;
  transition: border-color 0.18s, box-shadow 0.18s;
  -webkit-appearance: none;
  appearance: none;
}
.items-table input:focus {
  border-color: var(--color-brand);
  background: #fff;
  outline: none;
  box-shadow: 0 0 0 3px rgba(0,122,255,0.1);
}
.items-table input:hover:not(:focus) {
  border-color: #94A3B8;
}
.items-table input::placeholder {
  color: #94A3B8;
  font-weight: 400;
}

/* Remove spinner arrows for number inputs in table for cleaner look */
.items-table input[type="number"]::-webkit-inner-spin-button,
.items-table input[type="number"]::-webkit-outer-spin-button {
  opacity: 0.5;
}

.btn-remove {
  background: #FF3B30;
  color: #fff;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  font-size: 0.72rem;
  cursor: pointer;
  font-weight: 600;
  transition: background 0.15s;
  white-space: nowrap;
}
.btn-remove:hover { background: #E0342B; }
.btn-remove:focus-visible { outline: 2px solid #FF3B30; outline-offset: 2px; }

.btn-add {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  padding: 10px 18px;
  background: #F0F5FF;
  border: 1.5px solid #CBD5E1;
  border-radius: 8px;
  font-size: 0.78rem;
  font-weight: 700;
  color: #3D5A80;
  cursor: pointer;
  font-family: inherit;
  transition: all 0.15s;
}
.btn-add:hover { border-color: var(--color-brand); background: #E8EFF8; }
.btn-add:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }

/* ── TOTALS ── */
.totals { margin-top: 16px; border-top: 2px solid #E2E8F0; padding-top: 14px; }
.totals-row { display: flex; justify-content: space-between; align-items: center; padding: 7px 0; font-size: 0.88rem; }
.totals-row.total { font-size: 1.1rem; font-weight: 800; color: var(--color-brand); border-top: 2px solid #CBD5E1; margin-top: 8px; padding-top: 12px; }

/* Inline discount input */
.totals-row .discount-inline {
  display: inline-flex;
  align-items: center;
  gap: 4px;
}
.totals-row .discount-inline input[type="number"] {
  width: 56px;
  padding: 5px 8px;
  border: 1.5px solid #CBD5E1;
  border-radius: 6px;
  font-size: 0.8rem;
  font-family: inherit;
  background: #F4F7FA;
  text-align: center;
  box-sizing: border-box;
  transition: border-color 0.18s;
}
.totals-row .discount-inline input[type="number"]:focus {
  border-color: var(--color-primary);
  outline: none;
  box-shadow: 0 0 0 2px rgba(0,122,255,0.1);
}

/* ── BUTTONS ── */
.btn-row { display: flex; gap: 10px; flex-wrap: wrap; margin-top: 20px; }
.btn {
  padding: 11px 18px;
  font-size: 0.8rem;
  font-weight: 700;
  border-radius: 8px;
  cursor: pointer;
  border: 1.5px solid #CBD5E1;
  background: #F4F7FA;
  color: #3D5A80;
  transition: all 0.15s;
  font-family: inherit;
}
.btn:hover { border-color: var(--color-brand); background: #E8EFF8; }
.btn:focus-visible { outline: 2px solid var(--color-primary); outline-offset: 2px; }
.btn-primary { background: var(--color-brand); color: #fff; border-color: var(--color-brand); }
.btn-primary:hover { filter: brightness(1.08); }

/* ── INVOICE PREVIEW ── */
.invoice-preview {
  background: #fff;
  border: 1px solid #E2E8F0;
  border-radius: 10px;
  padding: 36px;
  min-height: 500px;
  position: relative;
  overflow: hidden;
}
.inv-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 28px; gap: 16px; }
.inv-logo { max-width: 120px; max-height: 60px; object-fit: contain; }
.inv-title { text-align: right; flex-shrink: 0; }
.inv-title h2 { font-size: 1.8rem; font-weight: 800; color: var(--color-brand); letter-spacing: -0.02em; margin: 0; }
.inv-title .inv-no { font-size: 0.8rem; color: #8B9CB8; margin-top: 2px; }
.inv-parties { display: grid; grid-template-columns: 1fr 1fr; gap: 24px; margin-bottom: 24px; }
.inv-party-label { font-size: 0.65rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #8B9CB8; margin-bottom: 6px; }
.inv-party-name { font-size: 0.95rem; font-weight: 700; color: #1E293B; margin-bottom: 4px; }
.inv-party-detail { font-size: 0.8rem; color: #3D5A80; line-height: 1.7; word-break: break-word; }
.inv-meta { display: grid; grid-template-columns: repeat(3, 1fr); gap: 14px; margin-bottom: 24px; }
.inv-meta-item { background: #F4F7FA; border-radius: 8px; padding: 10px 12px; }
.inv-meta-label { font-size: 0.6rem; font-weight: 700; letter-spacing: 0.08em; text-transform: uppercase; color: #8B9CB8; margin-bottom: 2px; }
.inv-meta-value { font-size: 0.85rem; font-weight: 600; color: #1E293B; }
.inv-items-table { width: 100%; border-collapse: collapse; font-size: 0.85rem; margin-bottom: 20px; }
.inv-items-table th { text-align: left; padding: 10px 12px; border-bottom: 2px solid #E2E8F0; font-size: 0.7rem; font-weight: 700; letter-spacing: 0.06em; text-transform: uppercase; color: #8B9CB8; }
.inv-items-table th:last-child { text-align: right; }
.inv-items-table td { padding: 10px 12px; border-bottom: 1px solid #F1F5F9; }
.inv-items-table td:last-child { text-align: right; font-weight: 600; }
.inv-totals { margin-left: auto; width: 260px; }
.inv-total-row { display: flex; justify-content: space-between; padding: 6px 0; font-size: 0.88rem; }
.inv-total-row.grand { font-size: 1.1rem; font-weight: 800; color: var(--color-brand); border-top: 2px solid #CBD5E1; margin-top: 6px; padding-top: 10px; }
.inv-notes { margin-top: 24px; padding-top: 18px; border-top: 1px solid #E2E8F0; font-size: 0.82rem; color: #64748B; line-height: 1.7; word-break: break-word; }
.inv-notes strong { color: #3D5A80; }
.inv-paid-stamp { position: absolute; top: 50%; left: 50%; transform: translate(-50%,-50%) rotate(-30deg); font-size: 4rem; font-weight: 800; color: rgba(0,99,209,0.12); letter-spacing: 0.1em; pointer-events: none; user-select: none; }
.inv-overdue { background: #fef2f2; border: 1px solid #fecaca; border-radius: 8px; padding: 10px 14px; font-size: 0.8rem; color: #991b1b; font-weight: 600; margin-bottom: 16px; }

/* ── CLIENT DATABASE ── */
.client-list { max-height: 200px; overflow-y: auto; }
.client-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 10px 12px;
  border-bottom: 1px solid #F1F5F9;
  cursor: pointer;
  font-size: 0.82rem;
  transition: background 0.15s;
  border-radius: 6px;
}
.client-item:hover { background: #F0F5FF; }
.client-item:focus-visible { outline: 2px solid var(--color-primary); outline-offset: -2px; }
.client-item-name { font-weight: 600; color: #2D3A5A; }
.client-item-co { color: #8B9CB8; }

/* ── FAQ ── */
.faq-sec { padding: 52px 0; background: #fff; border-top: 1px solid #E2E8F0; }
.faq-grid { display: grid; grid-template-columns: 1fr 1fr; gap: 20px; margin-top: 28px; }
.faq-item { padding: 20px 22px; background: #F4F7FA; border: 1px solid #D1D9E6; border-radius: 10px; }
.faq-q { font-size: 0.88rem; font-weight: 700; color: #1E293B; margin-bottom: 8px; }
.faq-a { font-size: 0.84rem; color: #3D5A80; line-height: 1.7; }
.eyebrow { display: block; font-size: 0.68rem; font-weight: 700; letter-spacing: 0.1em; text-transform: uppercase; color: var(--color-brand); margin-bottom: 6px; }
.sec-title { font-size: clamp(1.3rem, 2.5vw, 1.7rem); font-weight: 800; color: #1E293B; letter-spacing: -0.02em; }

/* ── FORM VALIDATION ── */
.f-input:invalid:not(:placeholder-shown):not(:focus) {
  border-color: #f87171;
}
.f-input:valid:not(:placeholder-shown) {
  border-color: #86EFAC;
}
.field-error {
  font-size: 0.72rem;
  color: #DC2626;
  margin-top: 4px;
  display: none;
}
.field.has-error .field-error { display: block; }
.field.has-error .f-input { border-color: #f87171; }

/* ── PRINT ── */
@media print {
  .inv-hero, .btn-row, .faq-sec, afro-navbar, afro-footer, .card-head,
  .tpl-bar, .client-list, #inv-saved-section { display: none !important; }
  .inv-grid { grid-template-columns: 1fr !important; }
  .inv-form-col { display: none !important; }
  .invoice-preview { border: none !important; box-shadow: none !important; padding: 0 !important; }
  body { background: #fff !important; }
}

/* ── DARK MODE ── */
@media (prefers-color-scheme: dark) {
  .inv-page { background: #0B1120; }
  .card { background: #131D2E; border-color: #1E2D40; }
  .card-head { border-color: #1E2D40; }
  .card-title { color: #8BA8D0; }
  .f-label { color: #C1D1E8; }
  .f-input { background: #0F1A2A; border-color: #1E2D40; color: #E2E8F0; }
  .f-input:focus { background: #162036; border-color: var(--color-primary); }
  .f-input:hover:not(:focus) { border-color: #2D4060; }
  select.f-input {
    background-image: url("data:image/svg+xml,%3Csvg width='12' height='8' viewBox='0 0 12 8' fill='none' xmlns='http://www.w3.org/2000/svg'%3E%3Cpath d='M1 1.5L6 6.5L11 1.5' stroke='%238BA8D0' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  }
  .items-table input { background: #0F1A2A; border-color: #1E2D40; color: #E2E8F0; }
  .items-table input:focus { background: #162036; }
  .items-table th { color: #6B8AB0; border-color: #1E2D40; }
  .items-table td { border-color: #162036; }
  .invoice-preview { background: #131D2E; border-color: #1E2D40; color: #E2E8F0; }
  .inv-party-name { color: #E2E8F0; }
  .inv-party-detail { color: #8BA8D0; }
  .inv-meta-item { background: #0F1A2A; }
  .inv-meta-value { color: #E2E8F0; }
  .inv-items-table th { color: #6B8AB0; border-color: #1E2D40; }
  .inv-items-table td { border-color: #162036; color: #C1D1E8; }
  .inv-notes { border-color: #1E2D40; color: #8BA8D0; }
  .totals { border-color: #1E2D40; }
  .totals-row.total { border-color: #1E2D40; }
  .btn { background: #162036; border-color: #1E2D40; color: #8BA8D0; }
  .btn:hover { border-color: var(--color-primary); background: #1A2840; }
  .btn-add { background: #0F1A2A; border-color: #1E2D40; color: #8BA8D0; }
  .tpl-bar { background: #0F1A2A; }
  .tpl-btn { color: #6B8AB0; }
  .tpl-btn:hover { background: rgba(255,255,255,0.05); }
  .tpl-btn.on { background: #1A2840; color: var(--color-primary); }
  .client-item:hover { background: #162036; }
  .client-item-name { color: #C1D1E8; }
  .faq-sec { background: #0B1120; border-color: #1E2D40; }
  .faq-item { background: #131D2E; border-color: #1E2D40; }
  .faq-q { color: #E2E8F0; }
  .faq-a { color: #8BA8D0; }
}

/* ── RESPONSIVE ── */
@media (max-width: 880px) {
  .inv-grid { grid-template-columns: 1fr; }
  .inv-preview-col { position: static !important; }
  .faq-grid { grid-template-columns: 1fr; }
  .inv-parties { grid-template-columns: 1fr; }
  .inv-meta { grid-template-columns: 1fr 1fr; }
}

@media (max-width: 600px) {
  .f-row { grid-template-columns: 1fr; gap: 0; }
  .f-row-3 { grid-template-columns: 1fr; gap: 0; }

  .card-body { padding: 18px; }
  .card-head { padding: 14px 18px; }
  .invoice-preview { padding: 20px; }
  .inv-header { flex-direction: column; gap: 12px; }
  .inv-title { text-align: left; }
  .inv-totals { width: 100%; }
  .inv-meta { grid-template-columns: 1fr; }

  /* Line items: horizontal scroll with min-width */
  .items-table-wrap { overflow-x: auto; -webkit-overflow-scrolling: touch; margin: 0 -18px; padding: 0 18px; }
  .items-table { min-width: 520px; }
  .items-table input { padding: 8px; font-size: 0.82rem; }

  .btn-row { flex-direction: column; }
  .btn-row .btn { width: 100%; text-align: center; }

  .hero-badges { gap: 5px; }
  .badge { font-size: 0.62rem; padding: 3px 8px; }
}

@media (max-width: 380px) {
  .card-body { padding: 14px; }
  .card-head { padding: 12px 14px; }
  .invoice-preview { padding: 16px; }
  .f-input { padding: 10px 12px; font-size: 0.85rem; }
  .items-table input { padding: 7px; font-size: 0.8rem; }
}

/* ── ACCESSIBILITY ── */
@media (prefers-reduced-motion: reduce) {
  *, *::before, *::after {
    transition-duration: 0.01ms !important;
    animation-duration: 0.01ms !important;
  }
}

/* Skip-to-content for keyboard users */
.sr-only {
  position: absolute;
  width: 1px;
  height: 1px;
  padding: 0;
  margin: -1px;
  overflow: hidden;
  clip: rect(0, 0, 0, 0);
  white-space: nowrap;
  border: 0;
}
