/* ============================================================
   Annonsesystem – Stylesheet
   Palette: #002652 (navy) · #eaeaea (light gray) · #fff (white)
   ============================================================ */

:root {
  --navy:          #002652;
  --navy-dark:     #001a3d;
  --navy-hover:    #003373;
  --navy-tint:     #e6eaf1;
  --gray-light:    #eaeaea;
  --gray-mid:      #d0d4db;
  --gray-border:   #dde1e7;
  --gray-bg:       #f4f5f7;
  --white:         #ffffff;
  --text:          #1c2333;
  --text-muted:    #6b7588;
  --radius-sm:     3px;
  --radius:        5px;
  --radius-md:     7px;
  --shadow-sm:     0 1px 2px rgba(0,38,82,.07);
  --shadow:        0 2px 6px rgba(0,38,82,.10);
  --shadow-lg:     0 6px 20px rgba(0,38,82,.14);
  --transition:    150ms ease;
}

/* ── Reset & base ────────────────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

html { font-size: 15px; }

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', system-ui, sans-serif;
  background: var(--gray-bg);
  color: var(--text);
  line-height: 1.5;
  -webkit-font-smoothing: antialiased;
}

/* ── Typography ──────────────────────────────────────────── */
h2 { font-size: 1.1rem; font-weight: 600; }
small { font-size: .8em; color: var(--text-muted); }
label { font-size: .85rem; font-weight: 500; color: var(--text); }

/* ── Buttons ─────────────────────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: .35rem;
  padding: .42rem .9rem;
  border: 1px solid transparent;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  font-weight: 500;
  cursor: pointer;
  transition: background var(--transition), border-color var(--transition), color var(--transition);
  white-space: nowrap;
  text-decoration: none;
}
.btn:disabled { opacity: .55; cursor: not-allowed; }

.btn-primary {
  background: var(--navy);
  color: var(--white);
  border-color: var(--navy);
}
.btn-primary:hover:not(:disabled) { background: var(--navy-hover); border-color: var(--navy-hover); }

.btn-secondary {
  background: var(--white);
  color: var(--text);
  border-color: var(--gray-border);
}
.btn-secondary:hover:not(:disabled) { background: var(--gray-light); }

.btn-ghost {
  background: transparent;
  color: rgba(255,255,255,.82);
  border-color: rgba(255,255,255,.25);
  font-size: .82rem;
}
.btn-ghost:hover:not(:disabled) {
  background: rgba(255,255,255,.12);
  color: var(--white);
  border-color: rgba(255,255,255,.4);
}

.btn-danger {
  background: #b91c1c;
  color: var(--white);
  border-color: #b91c1c;
}
.btn-danger:hover:not(:disabled) { background: #991b1b; border-color: #991b1b; }

.btn-block { width: 100%; justify-content: center; padding: .6rem 1rem; }

/* ── Forms ───────────────────────────────────────────────── */
.form-group {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  flex: 1;
  min-width: 0;
}

.form-row {
  display: flex;
  gap: 1rem;
  flex-wrap: wrap;
}
.form-row-3 > .form-group { flex-basis: calc(33.33% - .7rem); min-width: 120px; }

.form-section {
  border: none;
  padding: 0;
  margin-bottom: 1.1rem;
}
.form-section legend {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .05em;
  color: var(--text-muted);
  margin-bottom: .65rem;
  padding-bottom: .35rem;
  border-bottom: 1px solid var(--gray-border);
  width: 100%;
}

input[type="text"],
input[type="email"],
input[type="tel"],
input[type="number"],
input[type="password"],
input[type="search"],
select,
textarea {
  width: 100%;
  padding: .42rem .6rem;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: .88rem;
  font-family: inherit;
  color: var(--text);
  background: var(--white);
  transition: border-color var(--transition), box-shadow var(--transition);
  appearance: none;
  -webkit-appearance: none;
}
input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--navy);
  box-shadow: 0 0 0 2px rgba(0,38,82,.12);
}
textarea { resize: vertical; min-height: 80px; }

select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' viewBox='0 0 12 8'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%236b7588' stroke-width='1.5' fill='none' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right .6rem center;
  padding-right: 2rem;
}

.req { color: #b91c1c; }

/* ── Alerts ──────────────────────────────────────────────── */
.alert {
  padding: .5rem .75rem;
  border-radius: var(--radius-sm);
  font-size: .85rem;
  margin-top: .5rem;
}
.alert-error { background: #fef2f2; color: #b91c1c; border: 1px solid #fecaca; }

/* ── Header ──────────────────────────────────────────────── */
.site-header {
  background: var(--navy);
  height: 48px;
  position: sticky;
  top: 0;
  z-index: 100;
  box-shadow: 0 1px 4px rgba(0,0,0,.18);
}
.header-inner {
  max-width: 1400px;
  margin: 0 auto;
  padding: 0 1.25rem;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: space-between;
}
.header-brand {
  color: var(--white);
  font-weight: 600;
  font-size: .95rem;
  letter-spacing: .02em;
}
.header-meta {
  display: flex;
  align-items: center;
  gap: .75rem;
}
.header-user {
  color: rgba(255,255,255,.7);
  font-size: .82rem;
}

/* ── Main layout ─────────────────────────────────────────── */
.main {
  max-width: 1400px;
  margin: 0 auto;
  padding: 1.25rem;
}

/* ── Toolbar ─────────────────────────────────────────────── */
.page-toolbar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1rem;
  flex-wrap: wrap;
  margin-bottom: .85rem;
}
.toolbar-right {
  display: flex;
  align-items: center;
  gap: .6rem;
}
.search-input {
  width: 220px;
  padding: .38rem .6rem;
}

/* ── Filter tabs ─────────────────────────────────────────── */
.filter-tabs {
  display: flex;
  gap: .25rem;
  flex-wrap: wrap;
}
.tab {
  padding: .32rem .75rem;
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  background: var(--white);
  color: var(--text-muted);
  font-size: .82rem;
  font-weight: 500;
  cursor: pointer;
  transition: all var(--transition);
}
.tab:hover { border-color: var(--navy); color: var(--navy); }
.tab.active {
  background: var(--navy);
  border-color: var(--navy);
  color: var(--white);
}

/* ── Stats bar ───────────────────────────────────────────── */
.stats-bar {
  display: flex;
  gap: .6rem;
  flex-wrap: wrap;
  margin-bottom: .85rem;
}
.stat-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius);
  padding: .55rem .9rem;
  display: flex;
  flex-direction: column;
  gap: .1rem;
  min-width: 110px;
  box-shadow: var(--shadow-sm);
}
.stat-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.stat-value {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--navy);
  line-height: 1.2;
}
.stat-card.highlight .stat-value { color: #15803d; }

/* ── Table ───────────────────────────────────────────────── */
.table-wrap {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-sm);
  overflow-x: auto;
}
.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .86rem;
}
.data-table thead tr {
  background: var(--gray-bg);
  border-bottom: 2px solid var(--gray-border);
}
.data-table th {
  padding: .6rem .85rem;
  text-align: left;
  font-size: .75rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
  white-space: nowrap;
}
.data-table td {
  padding: .6rem .85rem;
  border-bottom: 1px solid var(--gray-border);
  vertical-align: middle;
}
.data-table tbody tr:last-child td { border-bottom: none; }
.data-table tbody tr:hover { background: var(--navy-tint); }
.data-table tbody tr { cursor: default; }

.num-col { text-align: right; }
.num-col td { text-align: right; }
td.num-col { text-align: right; }

.action-col { width: 48px; text-align: center; }

.table-empty {
  text-align: center;
  padding: 2.5rem;
  color: var(--text-muted);
  font-style: italic;
}

.company-name { font-weight: 600; }
.contact-sub { font-size: .8rem; color: var(--text-muted); margin-top: .1rem; }

/* Inline status select in admin table */
.inline-select {
  border: 1px solid transparent;
  background: transparent;
  padding: .18rem .4rem;
  border-radius: var(--radius-sm);
  font-size: .83rem;
  cursor: pointer;
  appearance: none;
  -webkit-appearance: none;
  background-image: none;
  padding-right: .4rem;
  font-weight: 500;
}
.inline-select:hover, .inline-select:focus {
  border-color: var(--gray-border);
  background: var(--white);
  outline: none;
}

/* ── Status badges ───────────────────────────────────────── */
.badge {
  display: inline-block;
  padding: .15rem .5rem;
  border-radius: var(--radius-sm);
  font-size: .78rem;
  font-weight: 600;
  white-space: nowrap;
}

/* Sale status */
.badge-idea        { background: #e8edf4; color: #2d4a6e; }
.badge-contacted   { background: #dbeafe; color: #1e40af; }
.badge-on_hold     { background: #fef3c7; color: #92400e; }
.badge-rejected    { background: #fee2e2; color: #991b1b; }
.badge-done        { background: #d1fae5; color: #065f46; }

/* Publication status */
.badge-not_scheduled { background: #f3f4f6; color: #6b7280; }
.badge-scheduled     { background: #dbeafe; color: #1e40af; }
.badge-published     { background: #d1fae5; color: #065f46; }

/* Billing status */
.badge-not_invoiced  { background: #f3f4f6; color: #6b7280; }
.badge-invoiced      { background: #fef3c7; color: #92400e; }
/* .badge-paid already defined above */

/* Commission status */
.badge-not_due  { background: #f3f4f6; color: #6b7280; }
.badge-pending  { background: #fef3c7; color: #92400e; }
.badge-paid     { background: #d1fae5; color: #065f46; }

/* ── Modal ───────────────────────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,18,50,.45);
  display: none;
  align-items: center;
  justify-content: center;
  z-index: 200;
  padding: 1rem;
}
.modal-overlay.open { display: flex; }

.modal {
  background: var(--white);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow-lg);
  width: 100%;
  max-width: 680px;
  max-height: 90vh;
  display: flex;
  flex-direction: column;
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .9rem 1.25rem;
  border-bottom: 1px solid var(--gray-border);
  flex-shrink: 0;
}
.modal-close {
  background: none;
  border: none;
  font-size: 1.4rem;
  line-height: 1;
  color: var(--text-muted);
  cursor: pointer;
  padding: .1rem .3rem;
  border-radius: var(--radius-sm);
  transition: color var(--transition);
}
.modal-close:hover { color: var(--text); }

.modal-body {
  padding: 1.1rem 1.25rem;
  overflow-y: auto;
  flex: 1;
}
.modal-footer {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: .8rem 1.25rem;
  border-top: 1px solid var(--gray-border);
  flex-shrink: 0;
  background: var(--gray-bg);
  border-radius: 0 0 var(--radius-md) var(--radius-md);
}
.modal-footer-right { display: flex; gap: .5rem; }

/* ── Login page ──────────────────────────────────────────── */
.login-body {
  display: flex;
  align-items: center;
  justify-content: center;
  min-height: 100vh;
  background: var(--gray-bg);
}
.login-wrap {
  width: 100%;
  max-width: 360px;
  padding: 1rem;
}
.login-card {
  background: var(--white);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  padding: 2rem 1.75rem 1.75rem;
}
.login-logo {
  display: flex;
  align-items: center;
  gap: .65rem;
  margin-bottom: 1.75rem;
}
.login-logo-mark {
  display: block;
  width: 28px;
  height: 28px;
  background: var(--navy);
  border-radius: var(--radius-sm);
}
.login-logo-text {
  font-size: 1.05rem;
  font-weight: 700;
  color: var(--navy);
}
.login-card .form-group { margin-bottom: .85rem; }
.login-card .btn-block { margin-top: 1.1rem; }

/* ── Checkbox label ──────────────────────────────────────── */
.checkbox-label {
  display: flex;
  align-items: center;
  gap: .45rem;
  font-size: .88rem;
  font-weight: 500;
  cursor: pointer;
  padding: .42rem 0;
}
.checkbox-label input[type="checkbox"] {
  width: 15px;
  height: 15px;
  accent-color: var(--navy);
  cursor: pointer;
  flex-shrink: 0;
}
.returning-wrap { flex: 0 0 auto; }

/* ── Returning badge ─────────────────────────────────────── */
.badge-returning {
  display: inline-block;
  font-size: .72rem;
  background: #fef3c7;
  color: #92400e;
  border-radius: 3px;
  padding: 0 .3rem;
  margin-left: .3rem;
  vertical-align: middle;
  font-style: normal;
  line-height: 1.4;
}

/* ── Edit button in table ────────────────────────────────── */
.btn-edit {
  background: none;
  border: 1px solid var(--gray-border);
  color: var(--text-muted);
  padding: .22rem .55rem;
  border-radius: var(--radius-sm);
  font-size: .8rem;
  cursor: pointer;
  transition: all var(--transition);
}
.btn-edit:hover { border-color: var(--navy); color: var(--navy); background: var(--navy-tint); }

/* ── Amount formatting ───────────────────────────────────── */
.amount { font-variant-numeric: tabular-nums; }
.amount-empty { color: var(--text-muted); }

/* ── Stat card link ──────────────────────────────────────── */
.stat-card-link {
  cursor: pointer;
  transition: box-shadow var(--transition), transform var(--transition);
}
.stat-card-link:hover {
  box-shadow: var(--shadow);
  transform: translateY(-1px);
}

/* ── Revenue modal ───────────────────────────────────────── */
.modal-wide { max-width: 780px; }

.revenue-footer {
  display: block;
  padding: .9rem 1.25rem;
}
.revenue-totals {
  display: flex;
  gap: 1.5rem;
  flex-wrap: wrap;
  align-items: center;
}
.rev-total-divider {
  width: 1px;
  height: 32px;
  background: var(--gray-border);
  flex-shrink: 0;
}
.rev-total-item {
  display: flex;
  flex-direction: column;
  gap: .1rem;
}
.rev-total-label {
  font-size: .72rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .04em;
  color: var(--text-muted);
}
.rev-total-value {
  font-size: 1rem;
  font-weight: 700;
  font-variant-numeric: tabular-nums;
  color: var(--navy);
}
.rev-total-positive .rev-total-value { color: #15803d; }
.rev-total-pending  .rev-total-value { color: var(--navy); }
.rev-total-warning  .rev-total-value { color: #92400e; }

/* ── Placements (in modal) ───────────────────────────────── */
.placements-list {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: .65rem;
  min-height: 1.5rem;
}
.placements-loading,
.placements-empty {
  font-size: .82rem;
  color: var(--text-muted);
  font-style: italic;
}

.placement-item {
  display: flex;
  align-items: center;
  gap: .5rem;
  padding: .3rem .5rem;
  background: var(--gray-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: .84rem;
  flex-wrap: wrap;
}
.placement-product { font-weight: 600; color: var(--navy); }
.placement-dates   { color: var(--text-muted); font-size: .8rem; }
.placement-note    { color: var(--text-muted); font-size: .8rem; font-style: italic; flex: 1; }
.placement-delete {
  margin-left: auto;
  background: none;
  border: none;
  color: var(--text-muted);
  font-size: 1.1rem;
  line-height: 1;
  cursor: pointer;
  padding: 0 .2rem;
  border-radius: 2px;
  transition: color var(--transition);
}
.placement-delete:hover { color: #b91c1c; }

.placement-add-row {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
  align-items: center;
}
.placement-product-select { flex: 2; min-width: 140px; }
.placement-date           { flex: 1; min-width: 120px; }
.placement-notes-input    { flex: 2; min-width: 120px; }

/* ── Products admin modal ────────────────────────────────── */
.modal-sm { max-width: 480px; }

.products-list {
  display: flex;
  flex-direction: column;
  gap: .3rem;
  margin-bottom: .85rem;
  max-height: 280px;
  overflow-y: auto;
}
.product-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: .5rem;
  padding: .35rem .5rem;
  background: var(--gray-bg);
  border: 1px solid var(--gray-border);
  border-radius: var(--radius-sm);
  font-size: .84rem;
}
.product-inactive { opacity: .6; }
.product-item-info { display: flex; flex-direction: column; gap: .1rem; }
.product-item-name { font-weight: 600; }
.product-item-desc { font-size: .78rem; color: var(--text-muted); }
.product-item-actions { flex-shrink: 0; }

.product-add-form {
  display: flex;
  gap: .4rem;
  flex-wrap: wrap;
}
.product-add-form input { flex: 1; min-width: 120px; }

/* ── Placement chips (seller table) ──────────────────────── */
.phone-col { white-space: nowrap; font-variant-numeric: tabular-nums; }
.placements-cell { max-width: 220px; }
.placement-chip {
  display: inline-flex;
  align-items: center;
  gap: .25rem;
  background: var(--navy-tint);
  color: var(--navy);
  border: 1px solid #c5d3e8;
  border-radius: var(--radius-sm);
  font-size: .75rem;
  font-weight: 600;
  padding: .12rem .4rem;
  margin: .1rem .1rem .1rem 0;
  white-space: nowrap;
}
.chip-dates { font-weight: 400; color: var(--text-muted); }
.placements-empty-cell { color: var(--text-muted); font-size: .82rem; }

/* ── Scrollbar (subtle) ──────────────────────────────────── */
::-webkit-scrollbar { width: 6px; height: 6px; }
::-webkit-scrollbar-track { background: transparent; }
::-webkit-scrollbar-thumb { background: var(--gray-mid); border-radius: 3px; }
::-webkit-scrollbar-thumb:hover { background: #adb5bd; }

/* ── Responsive ──────────────────────────────────────────── */
@media (max-width: 700px) {
  .search-input { width: 140px; }
  .page-toolbar { flex-direction: column; align-items: stretch; }
  .toolbar-right { justify-content: space-between; }
  .modal { max-height: 95vh; }
  .form-row { flex-direction: column; gap: .6rem; }
  .form-row-3 > .form-group { flex-basis: 100%; }
}
