/* Roko ERP styles. Colors, fonts and buttons come from theme/. */

:root {
  /* Same Latin fonts as the site, with the brand Arabic font as fallback for Arabic text. */
  --font-display: "Space Grotesk", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, sans-serif;
  --font-body: "Inter", "IBM Plex Sans Arabic", ui-sans-serif, system-ui, "Segoe UI", sans-serif;
}

body { font-size: 1rem; }
main { padding: 36px 0 96px; }
h1 { font-size: 2rem; margin: 0; }
h2 { font-size: 1.2rem; letter-spacing: -0.01em; margin: 0; }
h3 { font: 500 0.75rem/1 var(--font-mono); letter-spacing: 0.08em; text-transform: uppercase; color: var(--color-text-muted); margin: 0 0 10px; }

.muted { color: var(--color-text-muted); }
.mono { font-family: var(--font-mono); font-size: 0.9em; }
.num { text-align: end; font-variant-numeric: tabular-nums; white-space: nowrap; }
.nowrap { white-space: nowrap; }

/* Header */
.app-nav { display: flex; gap: clamp(16px, 4vw, 28px); }
.app-nav a { padding: 8px 0; color: var(--ink-300); text-decoration: none; font-size: 0.95rem; font-weight: 500; border-bottom: 2px solid transparent; }
.app-nav button { padding: 8px 0; border: 0; background: none; color: var(--ink-300); font: 500 0.95rem/1.6 var(--font-body); cursor: pointer; }
.app-nav a:hover, .app-nav button:hover { color: var(--paper); }
@media (max-width: 480px) { .app-nav { gap: 12px; } .app-nav a, .app-nav button { font-size: 0.85rem; white-space: nowrap; } .nav { gap: 12px; } .nav-logo img { height: 26px; } }
.app-nav a[aria-current] { color: var(--paper); border-color: var(--ember-500); }

/* Sign-in page */
.login { min-height: 100vh; display: grid; place-items: center; padding: 16px; background: var(--ink-950); }
.login-card { width: min(100%, 400px); padding: 40px; background: var(--white); border-radius: var(--radius-lg); }
.login-card h1 { margin: 32px 0 8px; }
.login-card .btn { width: 100%; margin-top: 8px; }
.login-error { padding: 12px 14px; border-radius: var(--radius-sm); background: var(--ember-50); color: #8A2807; font-size: 0.9rem; }

/* Page parts */
.page-head { display: flex; flex-wrap: wrap; align-items: center; justify-content: space-between; gap: 16px; margin-bottom: 24px; }
.actions { display: flex; flex-wrap: wrap; align-items: center; gap: 10px; }
.back { text-decoration: none; color: var(--color-text-muted); }
.back:hover { color: var(--color-text); }
.panel { background: var(--color-surface); border: 1px solid var(--color-border); border-radius: var(--radius-md); padding: 24px; margin-bottom: 20px; }
.empty { padding: 48px 24px; text-align: center; color: var(--color-text-muted); border: 1px dashed var(--color-border); border-radius: var(--radius-md); }
.table-wrap { overflow-x: auto; }
.btn:disabled { opacity: 0.5; cursor: default; }

/* Forms */
.form-grid { display: grid; grid-template-columns: repeat(auto-fit, minmax(min(100%, 240px), 1fr)); gap: 18px 20px; }
.field { display: grid; gap: 6px; align-content: start; }
.field.wide { grid-column: 1 / -1; }
.field > span { font-size: 0.875rem; font-weight: 500; color: var(--color-text-muted); }
input, select, textarea {
  width: 100%; min-height: 42px; padding: 8px 12px;
  font: 400 1rem/1.4 var(--font-body); color: var(--color-text);
  background: var(--white); border: 1px solid var(--ink-300); border-radius: var(--radius-sm);
}
input::placeholder { color: var(--ink-500); opacity: 0.8; }
input:focus-visible, select:focus-visible, textarea:focus-visible { outline: 2px solid var(--ember-500); outline-offset: 0; border-color: transparent; border-radius: var(--radius-sm); }
.actions input { width: auto; }
/* Hide number spinners so right-aligned figures line up. */
input[type="number"] { -moz-appearance: textfield; appearance: textfield; }
input[type="number"]::-webkit-inner-spin-button, input[type="number"]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

/* Tables */
table { width: 100%; border-collapse: collapse; }
th { font: 500 0.75rem/1.2 var(--font-mono); letter-spacing: 0.06em; text-transform: uppercase; color: var(--color-text-muted); text-align: start; white-space: nowrap; }
.num, th.num { text-align: end; }
.panel.table-wrap { padding: 0; }
.list th, .list td { padding: 14px 20px; border-top: 1px solid var(--color-border); }
.list thead th { border-top: 0; background: var(--paper-200); }
.list a { font-weight: 600; color: var(--color-accent-text); text-decoration: none; }
.list a:hover { text-decoration: underline; }

.badge { display: inline-block; padding: 3px 10px; border-radius: var(--radius-pill); font: 500 0.75rem/1.6 var(--font-mono); background: var(--paper-200); color: var(--ink-700); }
.badge-sent { background: var(--ember-100); color: #8A2807; }
.badge-paid { background: var(--circuit-100); color: #075E56; }

/* Bill editor */
.section-title { display: flex; flex-wrap: wrap; justify-content: space-between; align-items: baseline; gap: 8px; margin-bottom: 14px; }
.subtotal { font-variant-numeric: tabular-nums; color: var(--color-text-muted); }
.lines { min-width: 560px; table-layout: fixed; margin-bottom: 14px; }
.lines-expenses { min-width: 360px; }
.lines th { padding: 0 6px 8px; }
.lines td { padding: 4px 6px; }
.lines th:first-child, .lines td:first-child { padding-inline-start: 0; width: auto; }
.lines th:nth-child(n + 2) { width: 120px; }
.lines th:last-child { width: 52px; }
.icon-btn { width: 40px; height: 40px; border: 0; border-radius: var(--radius-sm); background: none; color: var(--ink-500); font-size: 0.9rem; cursor: pointer; }
.icon-btn:hover { background: var(--paper-200); color: var(--ink-900); }
.grand { display: flex; justify-content: flex-end; align-items: baseline; gap: 24px; padding: 20px 24px; border-radius: var(--radius-md); background: var(--ink-900); color: var(--ink-300); }
.grand strong { font: 700 1.6rem/1 var(--font-display); color: var(--paper); font-variant-numeric: tabular-nums; }

/* Printable bill */
.doc { max-width: 820px; margin: 0 auto; padding: clamp(24px, 6vw, 56px); background: var(--white); border: 1px solid var(--color-border); border-radius: var(--radius-md); font-size: 0.9375rem; line-height: 1.5; }
.doc-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 24px; padding-bottom: 28px; border-bottom: 2px solid var(--ink-900); }
.doc-title { text-align: end; }
.doc-title h1 { margin-bottom: 6px; }
.doc-meta { display: grid; grid-template-columns: repeat(auto-fit, minmax(180px, 1fr)); gap: 24px; padding: 28px 0; }
.doc-meta div { overflow-wrap: anywhere; }
.doc-meta div[dir] { white-space: pre-line; } /* keeps line breaks in addresses */
/* Arabic lines read right-to-left but stay in the left-hand column. */
.doc-meta div[dir], .doc td[dir] { text-align: left; }
.doc-project { font: 600 1.15rem/1.3 var(--font-display); margin: 0 0 4px; }
.doc-section { margin-top: 24px; }
.doc-section h2 { font-size: 1.05rem; margin-bottom: 8px; break-after: avoid; }
.doc th { padding: 8px 0; border-bottom: 1px solid var(--ink-300); }
.doc td { padding: 8px 0; border-bottom: 1px solid var(--color-border); vertical-align: top; overflow-wrap: anywhere; }
.doc th.num, .doc td.num { width: 110px; padding-inline-start: 16px; overflow-wrap: normal; }
.doc tr { break-inside: avoid; }
.doc-sub td { font-weight: 600; border-bottom: 0; }
.doc-totals { width: min(100%, 360px); margin: 28px 0 0 auto; break-inside: avoid; font-variant-numeric: tabular-nums; }
.doc-totals div { display: flex; justify-content: space-between; gap: 24px; padding: 5px 0; }
.doc-totals .doc-total { margin-top: 8px; padding-top: 12px; border-top: 2px solid var(--ink-900); font: 700 1.3rem/1.3 var(--font-display); }
.doc-note { margin-top: 28px; break-inside: avoid; }
.doc-note p { margin: 0; white-space: pre-line; overflow-wrap: anywhere; }

.toast { position: fixed; left: 50%; bottom: 24px; transform: translate(-50%, 20px); opacity: 0; padding: 12px 20px; border-radius: var(--radius-pill); background: var(--ink-900); color: var(--paper); font-size: 0.9rem; pointer-events: none; transition: 0.2s ease; z-index: 100; }
.toast.show { opacity: 1; transform: translate(-50%, 0); }
.toast.is-error { background: #B42318; color: var(--white); }

@media screen and (max-width: 640px) {
  .doc-section { overflow-x: auto; }
  .doc-section table { min-width: 480px; }
}

@page { size: A4; margin: 16mm; }
@media print {
  .site-header, .toast, .no-print { display: none; }
  body { background: none; }
  main { width: 100%; padding: 0; }
  .doc { max-width: none; padding: 0; border: 0; font-size: 10pt; }
  .doc th, .doc td { padding-block: 5px; }
  .doc-section { margin-top: 18px; }
}
