@import url("https://fonts.googleapis.com/css2?family=Onest:wght@300;400;500;600;700&family=Newsreader:opsz,wght@6..72,400;500;600;700&display=swap");

:root {
  --ink: #0f1115;
  --sand: #f6f5f0;
  --mist: #ebe7df;
  --accent: #c46b2a;
  --accent-soft: #f1d8c6;
}

body {
  font-family: "Onest", sans-serif;
  background: #fafafa;
  color: var(--ink);
}

p {
  word-wrap: break-word;
  overflow-wrap: break-word;
}

.brand-gradient {
  background: linear-gradient(135deg, #ffffff 0%, #f7efe7 40%, #f2d3c1 100%);
}

.card {
  background: #ffffff;
  border: 1px solid rgba(15, 17, 21, 0.06);
  border-radius: 4px;
}

input,
select,
textarea {
  border-radius: 4px;
}

label {
  display: block;
}

input:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
textarea {
  transition: border-color 0.2s ease, box-shadow 0.2s ease;
}

input:focus:not([type="submit"]):not([type="button"]):not([type="checkbox"]):not([type="radio"]),
textarea:focus {
  outline: none;
  border-color: rgb(144 144 144 / 35%);
}

textarea {
  font-family: inherit;
  line-height: 1.6;
  resize: vertical;
}

.is-loading {
  opacity: 0.75;
  cursor: wait;
}

.doc-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  gap: 1.5rem;
  border-bottom: 1px solid #e5e7eb;
  padding-bottom: 1rem;
}

.doc-brand {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.doc-logo {
  width: 40px;
  height: 40px;
  object-fit: contain;
}

.doc-title {
  letter-spacing: 0.04em;
  text-transform: uppercase;
}

.signature-block {
  display: flex;
  flex-direction: column;
}

.signature-meta {
  min-height: 1.25rem;
}

.signature-line {
  border-bottom: 1px solid #1f2937;
  height: 2rem;
  margin-top: 1.5rem;
}

@media print {
  body {
    background: #ffffff;
  }

  .no-print {
    display: none !important;
  }

  .card {
    border: none;
    box-shadow: none;
    padding: 0 !important;
  }

  p {
    hyphens: auto;
    word-wrap: break-word;
  }

  .print-two-cols {
    display: grid !important;
    grid-template-columns: 1fr 1fr !important;
    gap: 1.5rem !important;
  }

  .doc-header {
    border-bottom: 1px solid #111827;
  }
}

select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-color: #ffffff;
  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' fill='none' stroke='%230f1115' stroke-width='1.5' stroke-linecap='round' stroke-linejoin='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 1rem center;
  background-size: 12px 8px;
  padding-right: 2.5rem !important;
  transition:
    border-color 0.2s ease,
    box-shadow 0.2s ease,
    background-color 0.2s ease;
}

select:focus {
  outline: none;
  border-color: rgb(144 144 144 / 35%);
}

select:disabled {
  background-color: #f3f4f6;
  color: #9ca3af;
  cursor: not-allowed;
}

th {
  text-align: left;
  font-weight: 400;
  color: #6b7280;
  text-transform: uppercase;
  font-size: 0.75rem;
}

.badge {
  border: 1px solid rgba(15, 17, 21, 0.1);
  padding: 0.25rem 0.75rem;
  border-radius: 999px;
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.08em;
}

.badge.paid {
  background: #e6f5ea;
  color: #1b6e3b;
}

.badge.issued {
  background: #eef1f7;
  color: #2d3e63;
}

.badge.overdue {
  background: #ffe8e5;
  color: #b63126;
}

.btn-accent {
  background: var(--ink);
  color: #ffffff;
  padding: 0.55rem 1.1rem;
  border-radius: 999px;
}

.nav-menu {
  display: flex;
  flex-wrap: nowrap;
  gap: 1.5rem;
  width: 100%;
  padding: 0;
  border-bottom: 1px solid #e3e3e3;
  margin-bottom: 0;
  overflow-x: auto;
  -ms-overflow-style: none;
  scrollbar-width: none;
}

.nav-menu::-webkit-scrollbar {
  display: none;
}

@media (min-width: 640px) {
  .nav-menu {
    flex-wrap: wrap;
    overflow-x: visible;
    gap: 2rem;
  }
}

.nav-link {
  position: relative;
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 0;
  font-size: 0.85rem;
  color: #6b7280;
  transition: color 0.2s ease;
  white-space: nowrap;
  flex-shrink: 0;
}

.nav-link:hover {
  color: var(--ink);
}

.nav-link.active {
  color: var(--ink);
}

.nav-link.active::after {
  content: "";
  position: absolute;
  bottom: -1px;
  left: 0;
  width: 100%;
  height: 1px;
  background: var(--ink);
}

.invoice-page {
  font-family: "Onest", sans-serif;
}

.invoice-title {
  letter-spacing: 0.06em;
  text-transform: uppercase;
}

.responsive-table {
  width: 100%;
  border-collapse: collapse;
}

.doc-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 0.85rem;
}

.doc-table th,
.doc-table td {
  border: 1px solid #1f2937;
  padding: 0.4rem 0.5rem;
  vertical-align: top;
}

.doc-table th {
  font-weight: 600;
  text-transform: none;
  color: #111827;
}

/* Mobile: hide thead and make table rows look like cards */
@media (max-width: 639px) {
  .responsive-table thead {
    display: none;
  }

  .responsive-table tbody tr {
    display: block;
    border: 1px solid #e5e7eb;
    border-radius: 0.75rem;
    padding: 1rem;
    margin-bottom: 1rem;
    background: #ffffff;
  }

  .responsive-table td {
    display: block;
    padding: 0.5rem 0 !important;
    text-align: left !important;
    border: none !important;
    word-break: break-word;
  }

  .responsive-table td.text-right {
    text-align: right !important;
  }

  .responsive-table td.text-center {
    text-align: center !important;
  }

  .responsive-table td::before {
    content: attr(data-label);
    display: block;
    font-weight: 600;
    text-transform: uppercase;
    font-size: 0.75rem;
    color: #6b7280;
    text-align: left;
    margin-bottom: 0.25rem;
  }

  /* Hide empty label for colspan rows */
  .responsive-table td[data-label=""]::before {
    display: none;
  }

  /* Hide colspan rows on mobile */
  .responsive-table td[colspan] {
    display: none !important;
  }
}

/* Desktop: normal table layout */
@media (min-width: 640px) {
  .responsive-table thead {
    display: table-header-group;
  }

  .responsive-table tbody tr {
    display: table-row;
    border: none;
    padding: 0;
    margin: 0;
    background: transparent;
  }

  .responsive-table td {
    display: table-cell;
    padding: 1rem 0 !important;
    border: none;
    word-break: normal;
    vertical-align: middle;
  }

  .responsive-table td::before {
    display: none;
  }

  .responsive-table tbody tr:not(:last-child) td {
    border-bottom: 1px solid #f0f0f0;
  }
}

@media print {
  @page {
    margin: 5mm 5mm;
  }

  /* Force table layout for print even on small paper */
  .responsive-table thead {
    display: table-header-group !important;
  }

  .responsive-table tbody {
    display: table-row-group !important;
  }

  .responsive-table tbody tr {
    display: table-row !important;
    border: none !important;
    margin: 0 !important;
    padding: 0 !important;
  }

  .responsive-table td {
    display: table-cell !important;
    width: auto !important;
    text-align: inherit !important;
    padding: 0.75rem !important;
    border: 1px solid #ddd !important;
  }

  .responsive-table td::before {
    display: none !important;
  }

  body {
    background: #ffffff;
  }

  .no-print {
    display: none !important;
  }

  .card {
    box-shadow: none;
    border: none;
  }

  .invoice-page {
    padding: 0 !important;
  }
}

/* Dropdown Menu Styles */
.dropdown {
  position: relative;
  display: inline-flex;
  align-items: center;
  justify-content: flex-end;
}

.dropdown-toggle {
  background: none;
  border: none;
  cursor: pointer;
  padding: 4px 8px;
  color: #6b7280;
  font-size: 20px;
  line-height: 1;
  border-radius: 4px;
  transition: background-color 0.2s, color 0.2s;
}

.dropdown-toggle:hover {
  background-color: #f3f4f6;
  color: var(--ink);
}

.dropdown-toggle:focus {
  outline: none;
}

.dropdown-menu {
  position: absolute;
  right: 0;
  top: 100%;
  margin-top: 4px;
  background: #ffffff;
  border: 1px solid rgba(15, 17, 21, 0.1);
  border-radius: 8px;
  box-shadow: 0 4px 12px rgba(15, 17, 21, 0.1);
  min-width: 140px;
  z-index: 1000;
  opacity: 0;
  visibility: hidden;
  transform: translateY(-8px);
  transition: opacity 0.2s ease, transform 0.2s ease, visibility 0.2s;
}

.dropdown-menu.active {
  opacity: 1;
  visibility: visible;
  transform: translateY(0);
}

.dropdown-menu a,
.dropdown-menu button {
  display: block;
  width: 100%;
  padding: 8px 16px;
  text-align: left;
  border: none;
  background: none;
  color: var(--ink);
  font-size: 14px;
  cursor: pointer;
  transition: background-color 0.15s;
  text-decoration: none;
}

.dropdown-menu a:hover,
.dropdown-menu button:hover {
  background-color: #f9fafb;
}

.dropdown-menu a:first-child,
.dropdown-menu button:first-child {
  border-top-left-radius: 8px;
  border-top-right-radius: 8px;
}

.dropdown-menu a:last-child,
.dropdown-menu button:last-child {
  border-bottom-left-radius: 8px;
  border-bottom-right-radius: 8px;
}

.dropdown-menu .dropdown-divider {
  height: 1px;
  background-color: #e5e7eb;
  margin: 4px 0;
}

.dropdown-menu .text-red {
  color: #dc2626;
}

.dropdown-menu .text-red:hover {
  background-color: #fef2f2;
}

/* Mobile adaptations for dropdown */
@media (max-width: 639px) {
  .dropdown {
    width: 100%;
    justify-content: flex-end;
    margin-top: 0.5rem;
  }
  
  .dropdown-toggle {
    padding: 8px 12px;
  }
  
  .dropdown-menu {
    right: 0;
    left: auto;
    min-width: 160px;
  }
  
  /* For responsive tables on mobile */
  .responsive-table td[data-label=""] .dropdown {
    margin-top: 0;
  }
}
