/* app.css — Worka app UI (matches theme.css design tokens) */

/* ===== APP LAYOUT ===== */
.app-layout {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex;
  flex-direction: column;
}

.app-nav {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
  position: sticky;
  top: 0;
  z-index: 100;
}

.app-nav-inner {
  max-width: 1100px;
  margin: 0 auto;
  padding: 0 20px;
  height: 60px;
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.app-logo {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--fg-primary);
  text-decoration: none;
  display: flex;
  align-items: center;
  gap: 8px;
}

.app-logo .logo-dot {
  width: 8px;
  height: 8px;
  background: var(--accent);
  border-radius: 50%;
  display: inline-block;
}

.app-nav-actions {
  display: flex;
  align-items: center;
  gap: 12px;
}

.nav-user {
  font-size: 14px;
  color: var(--fg-secondary);
}

.app-content {
  max-width: 1100px;
  margin: 0 auto;
  padding: 32px 20px;
  width: 100%;
  flex: 1;
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 10px 20px;
  border-radius: 6px;
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
}

.btn-primary {
  background: var(--accent);
  color: #0a0a0a;
}

.btn-primary:hover {
  background: var(--accent-soft);
}

.btn-secondary {
  background: transparent;
  color: var(--fg-secondary);
  border: 1px solid var(--border);
}

.btn-secondary:hover {
  border-color: rgba(245,240,232,0.2);
  color: var(--fg-primary);
}

.btn-danger {
  background: transparent;
  color: #e05c5c;
  border: 1px solid rgba(224,92,92,0.3);
}

.btn-danger:hover {
  background: rgba(224,92,92,0.1);
}

.btn-success {
  background: transparent;
  color: #4caf7d;
  border: 1px solid rgba(76,175,125,0.3);
}

.btn-success:hover {
  background: rgba(76,175,125,0.1);
}

.btn-sm {
  padding: 6px 12px;
  font-size: 12px;
}

.btn-lg {
  padding: 14px 28px;
  font-size: 15px;
}

/* ===== CARDS ===== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

/* ===== STAT CARDS ===== */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 16px;
  margin-bottom: 32px;
}

.stat-card {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  padding: 24px;
}

.stat-card.outstanding { border-top: 2px solid var(--accent); }
.stat-card.paid        { border-top: 2px solid #4caf7d; }
.stat-card.overdue     { border-top: 2px solid #e05c5c; }

.stat-card-label {
  font-size: 12px;
  font-weight: 600;
  letter-spacing: 1.5px;
  color: var(--fg-muted);
  text-transform: uppercase;
  margin-bottom: 12px;
}

.stat-card-amount {
  font-family: var(--font-display);
  font-size: 28px;
  font-weight: 700;
  color: var(--fg-primary);
  margin-bottom: 4px;
  line-height: 1.1;
}

.stat-card-count {
  font-size: 13px;
  color: var(--fg-secondary);
}

/* ===== INVOICE TABLE ===== */
.section-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 16px;
}

.section-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-primary);
}

.filter-tabs {
  display: flex;
  gap: 4px;
  background: var(--bg-secondary);
  padding: 4px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.filter-tab {
  padding: 6px 14px;
  font-size: 13px;
  font-weight: 500;
  color: var(--fg-muted);
  border-radius: 5px;
  cursor: pointer;
  transition: all 0.15s;
  border: none;
  background: transparent;
}

.filter-tab.active {
  background: var(--bg-card);
  color: var(--fg-primary);
}

.invoice-table-wrap {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 12px;
  overflow: hidden;
}

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

.invoice-table th {
  text-align: left;
  padding: 12px 16px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--fg-muted);
  text-transform: uppercase;
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border);
}

.invoice-table td {
  padding: 14px 16px;
  font-size: 14px;
  color: var(--fg-secondary);
  border-bottom: 1px solid var(--border);
  vertical-align: middle;
}

.invoice-table tr:last-child td {
  border-bottom: none;
}

.invoice-table tr:hover td {
  background: rgba(245,240,232,0.02);
}

.invoice-number {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--fg-primary);
}

.invoice-client {
  color: var(--fg-primary);
}

.invoice-amount {
  font-family: var(--font-display);
  font-weight: 600;
  color: var(--fg-primary);
}

/* Status badges */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 20px;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 0.5px;
  text-transform: uppercase;
}

.badge::before {
  content: '';
  width: 5px;
  height: 5px;
  border-radius: 50%;
  background: currentColor;
}

.badge-sent {
  background: rgba(232,168,56,0.12);
  color: var(--accent);
}

.badge-paid {
  background: rgba(76,175,125,0.12);
  color: #4caf7d;
}

.badge-overdue {
  background: rgba(224,92,92,0.12);
  color: #e05c5c;
}

.badge-draft {
  background: rgba(107,101,96,0.2);
  color: var(--fg-muted);
}

.badge-cancelled {
  background: rgba(107,101,96,0.15);
  color: var(--fg-muted);
}

.invoice-actions {
  display: flex;
  gap: 6px;
}

/* Empty state */
.empty-state {
  text-align: center;
  padding: 60px 24px;
}

.empty-state-icon {
  font-size: 48px;
  margin-bottom: 16px;
  opacity: 0.4;
}

.empty-state-title {
  font-family: var(--font-display);
  font-size: 18px;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-bottom: 8px;
}

.empty-state-sub {
  font-size: 14px;
  color: var(--fg-muted);
  margin-bottom: 24px;
}

/* ===== FORMS ===== */
.form-group {
  margin-bottom: 20px;
}

.form-label {
  display: block;
  font-size: 13px;
  font-weight: 600;
  color: var(--fg-secondary);
  margin-bottom: 6px;
  letter-spacing: 0.3px;
}

.form-input,
.form-select,
.form-textarea {
  width: 100%;
  background: var(--bg-secondary);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 10px 14px;
  font-size: 14px;
  color: var(--fg-primary);
  font-family: var(--font-body);
  transition: border-color 0.15s;
  -webkit-appearance: none;
}

.form-input:focus,
.form-select:focus,
.form-textarea:focus {
  outline: none;
  border-color: var(--accent);
}

.form-input::placeholder,
.form-textarea::placeholder {
  color: var(--fg-muted);
}

.form-select {
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='8' fill='none'%3E%3Cpath d='M1 1l5 5 5-5' stroke='%23a39e93' stroke-width='1.5' stroke-linecap='round'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 12px center;
  padding-right: 32px;
  cursor: pointer;
}

.form-select option {
  background: var(--bg-secondary);
}

.form-textarea {
  resize: vertical;
  min-height: 80px;
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.form-row-3 {
  display: grid;
  grid-template-columns: 2fr 1fr 1fr;
  gap: 12px;
}

/* ===== INVOICE ITEMS TABLE ===== */
.items-table {
  width: 100%;
  border-collapse: collapse;
  margin-bottom: 12px;
}

.items-table th {
  text-align: left;
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1px;
  color: var(--fg-muted);
  text-transform: uppercase;
  padding: 8px 0;
  border-bottom: 1px solid var(--border);
}

.items-table td {
  padding: 8px 6px 8px 0;
  vertical-align: middle;
}

.items-table td:last-child {
  text-align: right;
}

.items-table .item-amount {
  font-family: var(--font-display);
  font-size: 14px;
  font-weight: 600;
  color: var(--fg-primary);
  white-space: nowrap;
}

.item-remove-btn {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  padding: 4px;
  font-size: 16px;
  line-height: 1;
  transition: color 0.15s;
}

.item-remove-btn:hover {
  color: #e05c5c;
}

.add-item-btn {
  background: none;
  border: 1px dashed var(--border);
  color: var(--fg-muted);
  cursor: pointer;
  padding: 10px;
  border-radius: 6px;
  width: 100%;
  font-size: 13px;
  font-family: var(--font-body);
  transition: all 0.15s;
  margin-bottom: 16px;
}

.add-item-btn:hover {
  border-color: var(--accent);
  color: var(--accent);
}

/* ===== INVOICE TOTALS ===== */
.invoice-totals {
  border-top: 1px solid var(--border);
  padding-top: 16px;
}

.total-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 6px 0;
  font-size: 14px;
  color: var(--fg-secondary);
}

.total-row.grand-total {
  font-size: 18px;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--fg-primary);
  padding-top: 12px;
  border-top: 1px solid var(--border);
  margin-top: 4px;
}

.total-row.grand-total .total-amount {
  color: var(--accent);
}

/* ===== INVOICE DETAIL ===== */
.invoice-detail-header {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 32px;
  gap: 24px;
}

.invoice-detail-meta {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 24px;
  margin-bottom: 32px;
}

.meta-group label {
  font-size: 11px;
  font-weight: 600;
  letter-spacing: 1.2px;
  color: var(--fg-muted);
  text-transform: uppercase;
  display: block;
  margin-bottom: 4px;
}

.meta-group p {
  font-size: 15px;
  color: var(--fg-primary);
}

/* ===== AUTH PAGES ===== */
.auth-page {
  min-height: 100vh;
  background: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 24px;
  background:
    radial-gradient(ellipse 80% 60% at 20% 80%, rgba(232,168,56,0.05) 0%, transparent 60%),
    var(--bg-primary);
}

.auth-card {
  width: 100%;
  max-width: 420px;
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 40px 36px;
}

.auth-logo {
  font-family: var(--font-display);
  font-size: 24px;
  font-weight: 700;
  color: var(--fg-primary);
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.auth-subtitle {
  font-size: 15px;
  color: var(--fg-secondary);
  margin-bottom: 32px;
}

.auth-toggle {
  text-align: center;
  margin-top: 24px;
  font-size: 14px;
  color: var(--fg-muted);
}

.auth-toggle a {
  color: var(--accent);
  text-decoration: none;
  font-weight: 500;
}

.auth-error {
  background: rgba(224,92,92,0.1);
  border: 1px solid rgba(224,92,92,0.3);
  border-radius: 6px;
  padding: 10px 14px;
  font-size: 13px;
  color: #e05c5c;
  margin-bottom: 16px;
  display: none;
}

.auth-error.show { display: block; }

/* ===== PAGE HEADER ===== */
.page-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
}

.page-title {
  font-family: var(--font-display);
  font-size: 26px;
  font-weight: 700;
  color: var(--fg-primary);
}

.page-subtitle {
  font-size: 14px;
  color: var(--fg-muted);
  margin-top: 4px;
}

/* ===== MODAL ===== */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,0.7);
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 20px;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.2s;
}

.modal-overlay.open {
  opacity: 1;
  pointer-events: all;
}

.modal {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 32px;
  width: 100%;
  max-width: 600px;
  max-height: 90vh;
  overflow-y: auto;
  transform: translateY(20px);
  transition: transform 0.2s;
}

.modal-overlay.open .modal {
  transform: translateY(0);
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 24px;
}

.modal-title {
  font-family: var(--font-display);
  font-size: 20px;
  font-weight: 700;
  color: var(--fg-primary);
}

.modal-close {
  background: none;
  border: none;
  color: var(--fg-muted);
  cursor: pointer;
  font-size: 20px;
  padding: 4px;
  line-height: 1;
  transition: color 0.15s;
}

.modal-close:hover { color: var(--fg-primary); }

/* ===== SETTINGS / ONBOARDING ===== */
.onboarding-banner {
  background: var(--accent-glow);
  border: 1px solid rgba(232,168,56,0.25);
  border-radius: 10px;
  padding: 16px 20px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.onboarding-banner p {
  font-size: 14px;
  color: var(--fg-secondary);
}

.onboarding-banner strong {
  color: var(--fg-primary);
}

/* ===== TOAST ===== */
.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  z-index: 300;
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.toast {
  background: var(--bg-card);
  border: 1px solid var(--border);
  border-radius: 8px;
  padding: 12px 18px;
  font-size: 14px;
  color: var(--fg-primary);
  min-width: 240px;
  max-width: 360px;
  box-shadow: 0 8px 32px rgba(0,0,0,0.4);
  animation: toast-in 0.3s ease;
  display: flex;
  align-items: center;
  gap: 10px;
}

.toast.success { border-left: 3px solid #4caf7d; }
.toast.error   { border-left: 3px solid #e05c5c; }

@keyframes toast-in {
  from { transform: translateY(20px); opacity: 0; }
  to   { transform: translateY(0);    opacity: 1; }
}

/* ===== LANDING PAGE CTA ===== */
.hero-cta {
  display: flex;
  gap: 16px;
  flex-wrap: wrap;
}

/* ===== RESPONSIVE ===== */
@media (max-width: 768px) {
  .stats-grid {
    grid-template-columns: 1fr;
  }

  .form-row, .form-row-3 {
    grid-template-columns: 1fr;
  }

  .invoice-detail-meta {
    grid-template-columns: 1fr;
  }

  .invoice-table th:nth-child(3),
  .invoice-table td:nth-child(3) {
    display: none;
  }

  .invoice-detail-header {
    flex-direction: column;
  }

  .app-content {
    padding: 20px 16px;
  }

  .modal {
    padding: 24px 20px;
  }

  .auth-card {
    padding: 32px 24px;
  }

  .section-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .page-header {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .stat-card-amount {
    font-size: 22px;
  }

  .invoice-actions .btn span {
    display: none;
  }
}

@media (max-width: 480px) {
  .filter-tabs {
    width: 100%;
    overflow-x: auto;
  }

  .invoice-table th:nth-child(4),
  .invoice-table td:nth-child(4) {
    display: none;
  }
}
