/* bazarehesami — mobile-first invoice UI v1 */

:root {
  --primary: #0d6efd;
  --danger: #dc3545;
  --border: #ccc;
  --bg: #f5f5f5;
  --text: #222;
  --header-h: 52px;
  --actions-h: 64px;
}

*, *::before, *::after { box-sizing: border-box; }

html { -webkit-text-size-adjust: 100%; }

body {
  margin: 0;
  font-family: Arial, sans-serif;
  font-size: 14px;
  color: var(--text);
  background: #fff;
  overflow-x: hidden;
}

img { max-width: 100%; height: auto; }

a { color: var(--primary); text-decoration: none; }

.app-header {
  position: sticky;
  top: 0;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  min-height: var(--header-h);
  padding: 8px 12px;
  background: #fff;
  border-bottom: 1px solid var(--border);
}

.brand {
  font-weight: 700;
  color: var(--primary);
  white-space: nowrap;
}

.app-nav {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
  justify-content: flex-end;
}

.app-nav a {
  padding: 8px 10px;
  min-height: 44px;
  display: inline-flex;
  align-items: center;
  border-radius: 6px;
  color: var(--text);
}

.app-nav a.active { background: #e7f1ff; color: var(--primary); font-weight: 600; }

.inline-form { display: inline; margin: 0; }

.link-btn {
  background: none;
  border: none;
  color: var(--text);
  padding: 8px 10px;
  min-height: 44px;
  cursor: pointer;
  font-size: 14px;
}

.app-main { padding-bottom: calc(var(--actions-h) + 16px); }

.padded { padding: 16px; max-width: 900px; margin: 0 auto; }

.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 16px;
}

.login-card {
  width: 100%;
  max-width: 360px;
  background: #fff;
  padding: 24px;
  border-radius: 12px;
  box-shadow: 0 2px 12px rgba(0,0,0,.08);
  text-align: center;
}

.login-logo { width: 120px; margin-bottom: 16px; }

.login-card label {
  display: block;
  text-align: left;
  margin: 12px 0 6px;
  font-weight: 600;
}

.login-card input[type="password"],
.settings-form input,
.settings-form textarea,
.invoice-form .meta-input,
.invoice-form input[type="date"]:not(.line-table input) {
  width: 100%;
  min-height: 44px;
  padding: 10px 12px;
  font-size: 16px;
  border: 1px solid var(--border);
  border-radius: 8px;
  background: #fff;
}

.invoice-form .meta-input,
.invoice-form .meta-date {
  border: none;
  border-radius: 0;
  background: transparent;
  min-height: 40px;
  padding: 6px 8px;
}

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  min-height: 44px;
  padding: 10px 16px;
  border-radius: 8px;
  border: 1px solid transparent;
  font-size: 16px;
  cursor: pointer;
  text-align: center;
}

.btn-block { width: 100%; }

.btn-primary { background: var(--primary); color: #fff; }

.btn-secondary { background: #6c757d; color: #fff; }

.btn-outline { background: #fff; border-color: var(--border); color: var(--text); }

.btn-danger { background: var(--danger); color: #fff; }

.btn-sm { min-height: 36px; padding: 6px 12px; font-size: 14px; }

.error-msg { color: var(--danger); }

.success-msg { color: #198754; }

.empty-state { color: #666; }

.invoice-form { padding-bottom: var(--actions-h); }

.invoice-doc {
  position: relative;
  max-width: 800px;
  margin: 0 auto;
  padding: 12px 12px 80px;
  display: flex;
  flex-direction: column;
}

.invoice-bottom {
  margin-top: 20px;
  flex-shrink: 0;
}

.invoice-bottom .tax-fields {
  display: flex;
  justify-content: space-between;
  flex-wrap: nowrap;
  gap: 8px;
  margin-top: 0;
}

.invoice-bottom .tax-field {
  flex: 0 0 150px;
  min-width: 0;
}

.invoice-bottom .payment-terms {
  margin: 12px 0 0;
}

.invoice-bottom .payment-method {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-top: 20px;
  margin-bottom: 0;
}

.payment-method-readonly {
  margin: 20px 0 0;
}

.logo {
  position: absolute;
  top: 8px;
  right: 8px;
  width: 100px;
  height: auto;
}

.business-header { padding-right: 110px; }

.smaller-info { font-size: 8px; color: #444; }

.small-text { font-size: 14px; }

.invoice-title-row {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 20px;
}

.invoice-number { font-size: 14px; text-align: left; }

.invoice-number .hint { display: block; font-size: 11px; color: #666; font-weight: normal; }

.meta-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  flex-wrap: wrap;
  gap: 10px;
  margin: 16px 0 10px;
}

.meta-left,
.meta-right {
  flex: 1 1 280px;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.meta-right { align-items: flex-end; text-align: right; }

.meta-inline {
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.meta-input {
  flex: 1 1 140px;
  min-width: 120px;
  min-height: 40px;
  padding: 6px 8px;
  font-size: 16px;
  border: none;
  background: transparent;
}

.meta-date {
  min-width: 150px;
}

.line-table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 10px;
  table-layout: fixed;
}

.line-table thead tr { border-bottom: 2px solid #000; }

.line-table th {
  text-align: left;
  padding: 8px 5px;
  font-size: 13px;
}

.line-table td {
  padding: 6px 5px;
  text-align: left;
  vertical-align: middle;
}

.line-table tbody tr:nth-child(odd) { background-color: #f7f7f7; }

.line-table input,
.line-table select {
  width: 100%;
  border: none;
  background: transparent;
  padding: 4px 2px;
  font-size: 16px;
  min-height: 36px;
}

.line-table select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  color: #000;
  cursor: pointer;
}

.line-table .line-total {
  font-size: 14px;
}

.line-table th:nth-child(1),
.line-table td:nth-child(1) { width: 34%; }

.line-table th:nth-child(2),
.line-table td:nth-child(2) { width: 12%; }

.line-table th:nth-child(3),
.line-table td:nth-child(3) { width: 18%; }

.line-table th:nth-child(4),
.line-table td:nth-child(4) { width: 14%; }

.line-table th:nth-child(5),
.line-table td:nth-child(5) { width: 22%; }

.vat-select.hidden-vat { display: none; }
.vat-select.visible { display: inline-block; }

.bank-account-card { margin-bottom: 12px; }

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: normal !important;
}

.checkbox-label input { width: auto !important; min-height: auto !important; }

.hint { font-size: 12px; color: #666; }

.btn-block { width: 100%; margin-top: 8px; }

.tax-fields {
  display: flex;
  justify-content: space-between;
  flex-wrap: wrap;
  gap: 10px;
  margin-top: 20px;
}

.tax-field {
  flex: 1 1 140px;
  min-width: 120px;
}

.tax-field label { display: block; font-size: 12px; margin-bottom: 4px; }

.tax-field input,
.tax-field span {
  display: block;
  width: 100%;
  min-height: 32px;
  padding: 4px 2px;
  border: none;
  background: transparent;
  font-size: 14px;
}

.payment-terms { margin: 0; }

.payment-method {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
  margin-bottom: 16px;
}

.payment-method label {
  display: inline-flex;
  align-items: center;
  gap: 8px;
  min-height: 44px;
}

.footer-info {
  display: flex;
  flex-direction: column;
  gap: 12px;
  margin-top: 30px;
  padding-top: 15px;
  border-top: 1px solid var(--border);
  font-size: 12px;
  flex-shrink: 0;
}

.footer-right { text-align: left; }

.footer-info p { margin: 3px 0; }

.sticky-actions {
  position: fixed;
  left: 0;
  right: 0;
  bottom: 0;
  z-index: 200;
  display: flex;
  gap: 8px;
  padding: 10px 12px calc(10px + env(safe-area-inset-bottom));
  background: rgba(255,255,255,.96);
  border-top: 1px solid var(--border);
  backdrop-filter: blur(6px);
}

.sticky-actions .btn,
.sticky-actions a.btn { flex: 1; min-width: 0; }

.archiv-item {
  border: 1px solid var(--border);
  background: #fff;
  padding: 12px 14px;
  margin-bottom: 12px;
  border-radius: 10px;
  box-shadow: 0 1px 4px rgba(0,0,0,.06);
}

.archiv-actions {
  display: flex;
  flex-wrap: wrap;
  gap: 8px;
  margin-top: 10px;
}

.settings-form fieldset {
  border: 1px solid var(--border);
  border-radius: 10px;
  margin-bottom: 16px;
  padding: 12px;
}

.settings-form label {
  display: block;
  margin-bottom: 12px;
  font-weight: 600;
  font-size: 13px;
}

.settings-logo-preview {
  display: block;
  width: 120px;
  margin-bottom: 12px;
  border-radius: 8px;
}

.readonly-doc .meta-col p { margin: 6px 0; }

@media (min-width: 640px) {
  .invoice-title-row {
    flex-direction: row;
    justify-content: space-between;
    align-items: flex-start;
  }
  .invoice-number { text-align: right; }
  .meta-right { align-items: flex-end; }
  .tax-fields { flex-wrap: nowrap; }
  .footer-info { flex-direction: row; justify-content: space-between; }
  .footer-info > div { width: 48%; }
  .footer-right { text-align: right; }
  .logo { width: 150px; }
  .business-header { padding-right: 160px; }
}

@media (max-width: 600px) {
  .invoice-bottom .tax-fields {
    flex-wrap: wrap;
  }
  .invoice-bottom .tax-field {
    flex: 1 1 100%;
    width: 100%;
  }
  .tax-fields { flex-direction: column; }
  .tax-field { width: 100%; }
  .line-table th,
  .line-table td { padding: 5px 3px; font-size: 12px; }
  .line-table input,
  .line-table select { font-size: 16px; min-height: 40px; }
  .meta-right { align-items: flex-start; text-align: left; }
}

@media print {
  .app-header, .sticky-actions, .archiv-actions { display: none !important; }
  .invoice-doc { padding: 0; max-width: none; }
}

/* Bank accounts in settings */
.hint {
  font-size: 13px;
  color: #666;
  margin: 0 0 12px;
}

.bank-account-card {
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 12px;
  background: #fafafa;
}

.bank-account-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 8px;
  margin-bottom: 10px;
}

.bank-account-label {
  font-weight: 700;
  font-size: 13px;
}

.bank-account-actions {
  display: flex;
  gap: 6px;
  flex-wrap: wrap;
}

.btn-sm {
  min-height: 36px;
  padding: 6px 10px;
  font-size: 13px;
}

.checkbox-label {
  display: flex !important;
  align-items: center;
  gap: 8px;
  font-weight: 600;
}

.checkbox-label input[type="checkbox"] {
  width: 18px;
  height: 18px;
}

.success-msg {
  color: #198754;
  background: #d1e7dd;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}

.error-msg {
  color: #842029;
  background: #f8d7da;
  padding: 10px 12px;
  border-radius: 8px;
  margin-bottom: 12px;
}
