/* ============================================================
   FreelanceCRM – Stylesheet
   ============================================================ */

:root {
  --accent:        #6366f1;
  --accent-hover:  #4f52d9;
  --accent-light:  #eef2ff;
  --success:       #10b981;
  --success-light: #d1fae5;
  --warning:       #f59e0b;
  --warning-light: #fef3c7;
  --danger:        #ef4444;
  --danger-light:  #fee2e2;
  --info:          #3b82f6;
  --info-light:    #dbeafe;

  --bg:            #f4f6fb;
  --surface:       #ffffff;
  --border:        #e5e7eb;
  --border-light:  #f3f4f6;

  --text:          #111827;
  --text-secondary:#6b7280;
  --text-muted:    #9ca3af;

  --sidebar-w:     230px;
  --sidebar-bg:    #1e1e2e;
  --sidebar-text:  rgba(255,255,255,0.7);
  --sidebar-active:#6366f1;

  --radius-sm:  6px;
  --radius:     10px;
  --radius-lg:  14px;
  --shadow-sm:  0 1px 3px rgba(0,0,0,.06), 0 1px 2px rgba(0,0,0,.04);
  --shadow:     0 4px 16px rgba(0,0,0,.08);
  --shadow-lg:  0 12px 40px rgba(0,0,0,.14);
  --trans:      0.18s ease;
}

/* ─── Reset ─────────────────────────────── */
*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }
html { font-size: 15px; }
body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
  background: var(--bg);
  color: var(--text);
  line-height: 1.6;
  display: flex;
  min-height: 100vh;
}
a { color: inherit; text-decoration: none; }
ul { list-style: none; }
button { cursor: pointer; font: inherit; border: none; background: none; }
input, select, textarea { font: inherit; }

/* ─── Layout ─────────────────────────────── */
.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg);
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0; left: 0; bottom: 0;
  z-index: 100;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-height: 100vh;
  padding: 32px;
  max-width: 1300px;
}

/* ─── Sidebar ────────────────────────────── */
.sidebar-logo {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 24px 20px;
  border-bottom: 1px solid rgba(255,255,255,.06);
}

.sidebar-logo span {
  font-size: .95rem;
  font-weight: 700;
  color: #fff;
  letter-spacing: -.01em;
}

.sidebar-nav {
  padding: 16px 12px;
  display: flex;
  flex-direction: column;
  gap: 4px;
  flex: 1;
}

.nav-btn {
  display: flex;
  align-items: center;
  gap: 10px;
  width: 100%;
  padding: 10px 12px;
  border-radius: var(--radius-sm);
  color: var(--sidebar-text);
  font-size: .875rem;
  font-weight: 500;
  transition: var(--trans);
  text-align: left;
}

.nav-btn:hover {
  background: rgba(255,255,255,.07);
  color: #fff;
}

.nav-btn.active {
  background: var(--accent);
  color: #fff;
}

.nav-btn svg { flex-shrink: 0; opacity: .85; }
.nav-btn.active svg { opacity: 1; }

.sidebar-footer {
  padding: 16px 20px;
  border-top: 1px solid rgba(255,255,255,.06);
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.sidebar-version {
  font-size: .75rem;
  color: rgba(255,255,255,.25);
}

/* ─── Views ──────────────────────────────── */
.view { display: none; }
.view.active { display: block; }

/* ─── View header ────────────────────────── */
.view-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 28px;
  gap: 16px;
}

.view-header h1 {
  font-size: 1.6rem;
  font-weight: 700;
  letter-spacing: -.02em;
  color: var(--text);
}

.view-subtitle {
  font-size: .85rem;
  color: var(--text-muted);
  margin-top: 2px;
}

.header-actions {
  display: flex;
  align-items: center;
  gap: 10px;
}

/* ─── Buttons ────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 9px 18px;
  border-radius: var(--radius-sm);
  font-size: .875rem;
  font-weight: 600;
  border: 1.5px solid transparent;
  transition: var(--trans);
  white-space: nowrap;
  cursor: pointer;
}

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

.btn-secondary {
  background: var(--surface);
  color: var(--text);
  border-color: var(--border);
}
.btn-secondary:hover { background: var(--border-light); }

.btn-danger {
  background: var(--danger-light);
  color: var(--danger);
  border-color: transparent;
}
.btn-danger:hover { background: var(--danger); color: #fff; }

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

.btn-link {
  background: none;
  border: none;
  color: var(--accent);
  font-size: .8rem;
  font-weight: 600;
  cursor: pointer;
  padding: 0;
}
.btn-link:hover { text-decoration: underline; }

.btn-back {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--text-secondary);
  font-size: .875rem;
  font-weight: 500;
  padding: 6px 0;
  border: none;
  background: none;
  cursor: pointer;
  transition: var(--trans);
}
.btn-back:hover { color: var(--text); }

/* ─── Cards ──────────────────────────────── */
.card {
  background: var(--surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  box-shadow: var(--shadow-sm);
  overflow: hidden;
}

.card-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 18px 22px;
  border-bottom: 1px solid var(--border-light);
}

.card-header h2 {
  font-size: 1rem;
  font-weight: 700;
}
.card-header h3 {
  font-size: .9rem;
  font-weight: 700;
}

/* ─── Dashboard stats ────────────────────── */
.stats-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 16px;
  margin-bottom: 24px;
}

/* 2-kolonne variant til abonnementssiden */
.stats-grid-sm {
  grid-template-columns: repeat(2, 1fr);
  max-width: 580px;
}

.stat-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 22px;
  box-shadow: var(--shadow-sm);
}

.stat-label {
  font-size: .78rem;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  margin-bottom: 10px;
}

.stat-value {
  font-size: 1.75rem;
  font-weight: 800;
  color: var(--text);
  letter-spacing: -.02em;
  line-height: 1;
}

.stat-sub {
  font-size: .78rem;
  color: var(--text-muted);
  margin-top: 6px;
}

.stat-icon {
  width: 40px;
  height: 40px;
  border-radius: var(--radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  margin-bottom: 14px;
}

/* ─── Dashboard bottom ───────────────────── */
.dashboard-bottom {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 16px;
}

.simple-list { padding: 4px 0; }

.simple-list-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border-light);
  transition: background var(--trans);
  cursor: pointer;
}
.simple-list-item:last-child { border-bottom: none; }
.simple-list-item:hover { background: var(--border-light); }

.simple-list-item-left { display: flex; align-items: center; gap: 12px; }

.avatar-sm {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: .8rem;
  font-weight: 700;
  flex-shrink: 0;
  color: #fff;
}

.item-name { font-size: .875rem; font-weight: 600; }
.item-sub  { font-size: .775rem; color: var(--text-muted); }

.simple-empty {
  padding: 28px 22px;
  text-align: center;
  color: var(--text-muted);
  font-size: .85rem;
}

/* ─── Search ─────────────────────────────── */
.search-wrap {
  position: relative;
  display: flex;
  align-items: center;
}
.search-icon {
  position: absolute;
  left: 10px;
  color: var(--text-muted);
  pointer-events: none;
}
.search-input {
  padding: 8px 12px 8px 34px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  width: 220px;
  background: var(--surface);
  transition: var(--trans);
  outline: none;
  color: var(--text);
}
.search-input:focus { border-color: var(--accent); box-shadow: 0 0 0 3px rgba(99,102,241,.12); }

/* ─── Data table ─────────────────────────── */
.table-card { overflow: visible; }

.data-table {
  width: 100%;
  border-collapse: collapse;
  font-size: .875rem;
}

.data-table th {
  padding: 12px 18px;
  text-align: left;
  font-size: .75rem;
  font-weight: 700;
  text-transform: uppercase;
  letter-spacing: .06em;
  color: var(--text-secondary);
  background: var(--border-light);
  border-bottom: 1px solid var(--border);
}

.data-table td {
  padding: 14px 18px;
  border-bottom: 1px solid var(--border-light);
  color: var(--text);
  vertical-align: middle;
}

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

.data-table tbody tr {
  transition: background var(--trans);
  cursor: pointer;
}
.data-table tbody tr:hover td { background: #f9fafb; }

.text-right { text-align: right !important; }

.client-name-cell {
  display: flex;
  align-items: center;
  gap: 10px;
}

.td-actions {
  display: flex;
  gap: 6px;
  justify-content: flex-end;
  opacity: 0;
  transition: opacity var(--trans);
}
.data-table tbody tr:hover .td-actions { opacity: 1; }

.icon-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  border: 1.5px solid var(--border);
  background: var(--surface);
  color: var(--text-secondary);
  transition: var(--trans);
  cursor: pointer;
}
.icon-btn:hover { background: var(--border-light); color: var(--text); }
.icon-btn.icon-btn-danger:hover { background: var(--danger-light); color: var(--danger); border-color: transparent; }

/* ─── Empty state ────────────────────────── */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
  padding: 64px 24px;
  text-align: center;
}
.empty-icon {
  width: 64px;
  height: 64px;
  border-radius: 50%;
  background: var(--border-light);
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-muted);
  margin-bottom: 4px;
}
.empty-state p { font-weight: 600; font-size: .95rem; }
.empty-state span { font-size: .85rem; color: var(--text-muted); margin-bottom: 6px; }

.empty-state-sm {
  padding: 32px 24px;
}
.empty-state-sm p { font-size: .875rem; color: var(--text-muted); font-weight: 400; }

/* ─── Status badges ──────────────────────── */
.badge {
  display: inline-flex;
  align-items: center;
  gap: 5px;
  padding: 3px 10px;
  border-radius: 100px;
  font-size: .73rem;
  font-weight: 700;
  letter-spacing: .03em;
  white-space: nowrap;
}
.badge::before {
  content: '';
  width: 6px;
  height: 6px;
  border-radius: 50%;
  background: currentColor;
}
.badge-paid     { background: var(--success-light); color: #065f46; }
.badge-unpaid   { background: var(--danger-light);  color: #991b1b; }
.badge-pending  { background: var(--warning-light); color: #92400e; }
.badge-invoiced { background: var(--info-light);    color: #1e40af; }

/* ─── Total row ──────────────────────────── */
.total-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 22px;
  border-top: 2px solid var(--border);
  background: var(--border-light);
  font-size: .875rem;
}
.total-row span { color: var(--text-secondary); font-weight: 600; }
.total-row strong { font-size: 1.1rem; font-weight: 800; color: var(--text); }

/* ─── Client detail layout ───────────────── */
.detail-layout {
  display: grid;
  grid-template-columns: 280px 1fr;
  gap: 20px;
  align-items: start;
}

.detail-left {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.detail-right { display: flex; flex-direction: column; gap: 16px; }

/* ─── Profile card ───────────────────────── */
.profile-card {
  text-align: center;
  padding: 28px 22px;
}

.avatar-lg {
  width: 72px;
  height: 72px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  font-weight: 800;
  color: #fff;
  margin: 0 auto 16px;
}

.profile-card h2 {
  font-size: 1.1rem;
  font-weight: 700;
  margin-bottom: 4px;
}

.text-muted { color: var(--text-muted); font-size: .875rem; }

.contact-rows {
  margin-top: 18px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  text-align: left;
}

.contact-row {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  font-size: .82rem;
}
.contact-row svg { color: var(--text-muted); flex-shrink: 0; margin-top: 1px; }
.contact-row span { color: var(--text); line-height: 1.5; }

/* ─── Stat rows ──────────────────────────── */
.stat-rows { padding: 6px 0; }

.stat-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 12px 22px;
  border-bottom: 1px solid var(--border-light);
}
.stat-row:last-child { border-bottom: none; }
.stat-row-label { font-size: .82rem; color: var(--text-secondary); }
.stat-row-value { font-size: .9rem; font-weight: 700; }

/* ─── Notes ──────────────────────────────── */
.notes-body {
  padding: 14px 22px 18px;
  font-size: .85rem;
  line-height: 1.7;
  white-space: pre-wrap;
}

/* ─── Modal ──────────────────────────────── */
.modal-overlay {
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 500;
  padding: 20px;
  backdrop-filter: blur(2px);
}

.modal {
  background: var(--surface);
  border-radius: var(--radius-lg);
  width: 100%;
  max-width: 560px;
  box-shadow: var(--shadow-lg);
  animation: modal-in .18s ease;
}

.modal-sm { max-width: 400px; }

@keyframes modal-in {
  from { opacity: 0; transform: scale(.96) translateY(8px); }
  to   { opacity: 1; transform: scale(1) translateY(0); }
}

.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 20px 24px;
  border-bottom: 1px solid var(--border);
}
.modal-header h2 { font-size: 1rem; font-weight: 700; }

.modal-close {
  width: 30px;
  height: 30px;
  border-radius: var(--radius-sm);
  background: var(--border-light);
  color: var(--text-secondary);
  font-size: 1.1rem;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: var(--trans);
}
.modal-close:hover { background: var(--border); color: var(--text); }

.modal-body { padding: 22px 24px; }

.modal-footer {
  display: flex;
  justify-content: flex-end;
  gap: 10px;
  padding: 16px 24px;
  border-top: 1px solid var(--border);
}

/* ─── Form elements ──────────────────────── */
.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 14px;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 5px;
  margin-bottom: 14px;
}

.form-group label {
  font-size: .8rem;
  font-weight: 600;
  color: var(--text);
}

.req { color: var(--danger); }

.form-group input,
.form-group select,
.form-group textarea {
  padding: 9px 12px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius-sm);
  font-size: .875rem;
  color: var(--text);
  background: var(--surface);
  transition: var(--trans);
  outline: none;
}

.form-group select {
  appearance: none;
  background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='14' height='14' viewBox='0 0 24 24' fill='none' stroke='%236b7280' stroke-width='2'%3E%3Cpolyline points='6 9 12 15 18 9'/%3E%3C/svg%3E");
  background-repeat: no-repeat;
  background-position: right 10px center;
  padding-right: 32px;
}

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

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(99,102,241,.12);
}

/* ─── Confirm modal msg ──────────────────── */
.confirm-msg {
  padding: 6px 24px 18px;
  font-size: .9rem;
  color: var(--text-secondary);
  line-height: 1.6;
}

/* ─── Avatar colors ──────────────────────── */
.av-0  { background: #6366f1; }
.av-1  { background: #10b981; }
.av-2  { background: #f59e0b; }
.av-3  { background: #ef4444; }
.av-4  { background: #3b82f6; }
.av-5  { background: #8b5cf6; }
.av-6  { background: #ec4899; }
.av-7  { background: #14b8a6; }

/* ─── Responsive ─────────────────────────── */
@media (max-width: 1100px) {
  .stats-grid { grid-template-columns: repeat(2, 1fr); }
  .detail-layout { grid-template-columns: 1fr; }
  .detail-left { flex-direction: row; flex-wrap: wrap; }
  .detail-left .card { flex: 1; min-width: 200px; }
}

@media (max-width: 768px) {
  :root { --sidebar-w: 0px; }
  .sidebar { display: none; }
  .main { margin-left: 0; padding: 20px 16px; }
  .stats-grid { grid-template-columns: 1fr 1fr; }
  .dashboard-bottom { grid-template-columns: 1fr; }
  .form-row { grid-template-columns: 1fr; }
}

/* ─── Loading state ─────────────────────── */
body.is-loading { cursor: wait; }
body.is-loading .btn,
body.is-loading .icon-btn { opacity: 0.6; pointer-events: none; }

/* ─── Login screen ───────────────────────── */
#login-screen {
  position: fixed;
  inset: 0;
  z-index: 200;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 44px 40px 36px;
  width: 100%;
  max-width: 400px;
  box-shadow: var(--shadow-lg);
}

.login-logo {
  display: flex;
  flex-direction: column;
  align-items: center;
  text-align: center;
  gap: 10px;
  margin-bottom: 32px;
}

.login-logo h1 {
  font-size: 1.15rem;
  font-weight: 700;
  color: var(--text);
  letter-spacing: -.01em;
}

.login-logo p {
  font-size: .85rem;
  color: var(--text-muted);
  margin: 0;
}

.login-submit-btn {
  width: 100%;
  margin-top: 6px;
  justify-content: center;
}

.login-error {
  font-size: .82rem;
  color: var(--danger);
  background: var(--danger-light);
  border-radius: var(--radius-sm);
  padding: 9px 12px;
  margin-bottom: 12px;
}

/* ─── Logout-knap (sidebar) ──────────────── */
.btn-logout {
  display: flex;
  align-items: center;
  gap: 8px;
  width: 100%;
  padding: 8px 10px;
  background: transparent;
  border: 1px solid rgba(255,255,255,.12);
  border-radius: var(--radius-sm);
  color: rgba(255,255,255,.6);
  font-size: .8rem;
  transition: background var(--trans), color var(--trans);
}

.btn-logout:hover {
  background: rgba(255,255,255,.08);
  color: #fff;
}

/* ─── Subscription notice ────────────────── */
.subscription-notice {
  display: flex;
  align-items: flex-start;
  gap: 10px;
  padding: 12px 14px;
  background: var(--info-light);
  border: 1px solid #bfdbfe;
  border-radius: var(--radius-sm);
  margin-bottom: 14px;
  font-size: .82rem;
  color: #1e3a8a;
  line-height: 1.5;
}
.subscription-notice svg { flex-shrink: 0; margin-top: 1px; color: var(--info); }
.subscription-notice p { margin: 0; }

/* ─── Subscription rows ──────────────────── */
.sub-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 14px 22px;
  border-bottom: 1px solid var(--border-light);
  gap: 12px;
}
.sub-row:last-child { border-bottom: none; }

.sub-row-info { flex: 1; min-width: 0; }

.sub-row-title {
  font-size: .875rem;
  font-weight: 600;
  color: var(--text);
  margin-bottom: 4px;
}

.sub-row-meta {
  font-size: .78rem;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  gap: 8px;
  flex-wrap: wrap;
}

.sub-row-actions { flex-shrink: 0; }

@media (max-width: 480px) {
  .stats-grid { grid-template-columns: 1fr; }
  .view-header { flex-direction: column; align-items: flex-start; }
}

/* ─── 3-kolonne stats-grid ───────────────── */
.stats-grid-3 {
  grid-template-columns: repeat(3, 1fr);
  max-width: 860px;
}

/* ─── 4-kolonne stats-grid (websites m. domæne) */
.stats-grid-4 {
  grid-template-columns: repeat(4, 1fr);
}

/* ─── Alarm-toggle knap (websites-tabel) ──────────────────── */
.alert-toggle {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1rem;
  padding: 2px 4px;
  border-radius: 6px;
  line-height: 1;
  transition: background .15s, transform .1s;
  opacity: .5;
}
.alert-toggle:hover {
  background: var(--border-light);
  opacity: 1;
}
.alert-toggle.alert-on {
  opacity: 1;
}
.alert-toggle.alert-firing {
  animation: bell-shake .5s ease-in-out;
}
@keyframes bell-shake {
  0%,100% { transform: rotate(0); }
  20%      { transform: rotate(-15deg); }
  40%      { transform: rotate(15deg); }
  60%      { transform: rotate(-10deg); }
  80%      { transform: rotate(10deg); }
}

/* ─── Checkbox label (subscription modal) ── */
.check-label {
  display: flex;
  align-items: center;
  gap: 8px;
  font-size: .875rem;
  font-weight: 400;
  color: var(--text);
  cursor: pointer;
  padding: 9px 0 0;
}
.check-label input[type="checkbox"] {
  width: 16px;
  height: 16px;
  cursor: pointer;
  accent-color: var(--accent);
}

/* ─── Website URL-link (tabel) ───────────── */
.website-url-link {
  color: var(--accent);
  font-size: .82rem;
  max-width: 220px;
  display: inline-block;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  vertical-align: middle;
}
.website-url-link:hover { text-decoration: underline; }

/* ─── Responstid-farver ──────────────────── */
.resp-ms     { font-size: .82rem; font-weight: 600; }
.resp-fast   { color: var(--success); }
.resp-medium { color: var(--warning); }
.resp-slow   { color: var(--danger); }
