@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@300;400;500;600;700&display=swap');

*, *::before, *::after { box-sizing: border-box; margin: 0; padding: 0; }

:root {
  --bg:        #f0f2f5;
  --surface:   #ffffff;
  --sidebar:   #141c28;
  --sidebar2:  #1e2a3a;
  --accent:    #2563eb;
  --accent-h:  #1d4ed8;
  --danger:    #dc2626;
  --success:   #16a34a;
  --text:      #111827;
  --muted:     #6b7280;
  --border:    #e5e7eb;
  --radius:    10px;
  --font:      'Montserrat', sans-serif;

  /* Category colours */
  --cat-social:  #7c3aed;
  --cat-display: #0891b2;
  --cat-copy:    #059669;

  /* Platform colours */
  --pl-instagram: #e1306c;
  --pl-meta:      #1877f2;
  --pl-snapchat:  #f59e0b;
  --pl-schibsted: #003087;
  --pl-aller:     #e4002b;
  --pl-general:   #4b5563;
}

html, body {
  font-family: var(--font);
  background: var(--bg);
  color: var(--text);
  font-size: 14px;
  line-height: 1.6;
  min-height: 100vh;
}

/* ── App shell ───────────────────────────── */
.app {
  display: flex;
  min-height: 100vh;
}

/* ── Sidebar ─────────────────────────────── */
.sidebar {
  width: 220px;
  min-width: 220px;
  background: var(--sidebar);
  display: flex;
  flex-direction: column;
  position: sticky;
  top: 0;
  height: 100vh;
  overflow-y: auto;
}

.sidebar-logo {
  padding: 28px 20px 20px;
  border-bottom: 1px solid rgba(255,255,255,.08);
}

.sidebar-logo h1 {
  font-size: 17px;
  font-weight: 700;
  color: #fff;
  letter-spacing: .5px;
  text-transform: uppercase;
}

.sidebar-logo span {
  display: block;
  font-size: 10px;
  font-weight: 400;
  color: rgba(255,255,255,.4);
  letter-spacing: 1px;
  margin-top: 2px;
  text-transform: uppercase;
}

.sidebar-nav {
  flex: 1;
  padding: 12px 0;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 10px;
  font-weight: 600;
  color: rgba(255,255,255,.3);
  letter-spacing: 1.2px;
  text-transform: uppercase;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 20px;
  color: rgba(255,255,255,.65);
  text-decoration: none;
  font-size: 13px;
  font-weight: 500;
  transition: all .15s;
  border-left: 3px solid transparent;
}

.nav-link:hover, .nav-link.active {
  color: #fff;
  background: rgba(255,255,255,.07);
  border-left-color: var(--accent);
}

.nav-link .dot {
  width: 8px; height: 8px;
  border-radius: 50%;
  flex-shrink: 0;
}

.sidebar-user {
  padding: 14px 16px;
  border-top: 1px solid rgba(255,255,255,.08);
  display: flex;
  align-items: center;
  gap: 10px;
}

.user-avatar {
  width: 32px; height: 32px;
  border-radius: 50%;
  background: var(--accent);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 13px;
  font-weight: 600;
  flex-shrink: 0;
}

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

.user-name {
  font-size: 12px;
  font-weight: 600;
  color: #fff;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.user-email {
  font-size: 10px;
  color: rgba(255,255,255,.4);
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.logout-btn {
  color: rgba(255,255,255,.35);
  text-decoration: none;
  font-size: 12px;
  flex-shrink: 0;
  padding: 4px;
  border-radius: 4px;
  transition: color .15s;
}

.logout-btn:hover { color: rgba(255,255,255,.8); }

/* ── Main content ────────────────────────── */
.main {
  flex: 1;
  min-width: 0;
  display: flex;
  flex-direction: column;
}

.topbar {
  background: var(--surface);
  border-bottom: 1px solid var(--border);
  padding: 0 28px;
  height: 56px;
  display: flex;
  align-items: center;
  justify-content: space-between;
  flex-shrink: 0;
}

.topbar-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text);
}

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

.content {
  padding: 28px;
  flex: 1;
}

/* ── Buttons ─────────────────────────────── */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 16px;
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 13px;
  font-weight: 600;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all .15s;
  white-space: nowrap;
}

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

.btn-ghost {
  background: transparent;
  color: var(--muted);
  border: 1.5px solid var(--border);
}
.btn-ghost:hover { border-color: var(--accent); color: var(--accent); }

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

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

/* ── Category sections ───────────────────── */
.category-section { margin-bottom: 36px; }

.category-header {
  display: flex;
  align-items: center;
  gap: 10px;
  margin-bottom: 16px;
}

.category-label {
  font-size: 11px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--muted);
}

.category-count {
  font-size: 11px;
  color: var(--muted);
  background: var(--border);
  padding: 1px 7px;
  border-radius: 20px;
}

/* ── Spec grid ───────────────────────────── */
.spec-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 16px;
}

.spec-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 18px;
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: box-shadow .15s, border-color .15s;
  position: relative;
}

.spec-card:hover {
  box-shadow: 0 4px 16px rgba(0,0,0,.08);
  border-color: #d1d5db;
}

.spec-card-top {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: 8px;
}

.spec-card-title {
  font-size: 14px;
  font-weight: 700;
  color: var(--text);
  line-height: 1.3;
}

.spec-card-id {
  font-size: 11px;
  color: var(--muted);
  font-weight: 400;
  font-family: 'Courier New', monospace;
  margin-top: 2px;
}

.platform-badge {
  font-size: 10px;
  font-weight: 700;
  padding: 3px 8px;
  border-radius: 20px;
  white-space: nowrap;
  flex-shrink: 0;
}

.spec-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 6px;
}

.spec-tag {
  font-size: 11px;
  padding: 3px 8px;
  background: var(--bg);
  border-radius: 4px;
  color: var(--muted);
  font-weight: 500;
}

.spec-tag strong {
  color: var(--text);
  font-weight: 600;
}

.spec-card-notes {
  font-size: 12px;
  color: var(--muted);
  line-height: 1.5;
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.spec-card-actions {
  display: flex;
  gap: 6px;
  margin-top: auto;
  padding-top: 12px;
  border-top: 1px solid var(--border);
}

.spec-api-id {
  font-size: 10px;
  color: var(--muted);
  font-family: 'Courier New', monospace;
  background: var(--bg);
  padding: 2px 6px;
  border-radius: 4px;
  margin-top: auto;
}

/* Inactive overlay */
.spec-card.inactive { opacity: .55; }
.spec-card.inactive::after {
  content: 'inaktiv';
  position: absolute;
  top: 10px;
  right: 10px;
  font-size: 9px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--danger);
  border: 1px solid var(--danger);
  padding: 2px 6px;
  border-radius: 4px;
}

/* ── Platform badge colours ──────────────── */
.pl-instagram { background: #fce7f3; color: #9d174d; }
.pl-meta      { background: #dbeafe; color: #1e40af; }
.pl-snapchat  { background: #fef3c7; color: #92400e; }
.pl-schibsted { background: #dbeafe; color: #1e3a8a; }
.pl-aller     { background: #fee2e2; color: #991b1b; }
.pl-copy      { background: #d1fae5; color: #065f46; }
.pl-display   { background: #e0e7ff; color: #3730a3; }
.pl-generic   { background: #f3f4f6; color: #374151; }

/* ── Flash message ───────────────────────── */
.flash {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 13px;
  font-weight: 500;
  margin-bottom: 20px;
}
.flash-success { background: #d1fae5; color: #065f46; border: 1px solid #6ee7b7; }
.flash-error   { background: #fee2e2; color: #991b1b; border: 1px solid #fca5a5; }

/* ── Empty state ─────────────────────────── */
.empty-state {
  text-align: center;
  padding: 60px 20px;
  color: var(--muted);
}
.empty-state h3 { font-size: 15px; margin-bottom: 6px; color: var(--text); }
.empty-state p  { font-size: 13px; margin-bottom: 20px; }

/* ── Form (spec form) ────────────────────── */
.form-wrap {
  max-width: 780px;
}

.form-section {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  margin-bottom: 20px;
  overflow: hidden;
}

.form-section-header {
  padding: 14px 20px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
  font-size: 12px;
  font-weight: 700;
  letter-spacing: .5px;
  text-transform: uppercase;
  color: var(--muted);
}

.form-grid {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 0;
}

.form-field {
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
  border-right: 1px solid var(--border);
}

.form-field:nth-child(even) { border-right: none; }
.form-field:last-child, .form-field:nth-last-child(2):nth-child(odd) { border-bottom: none; }
.form-field.full-width {
  grid-column: 1 / -1;
  border-right: none;
}
.form-field.full-width:last-child { border-bottom: none; }

label {
  display: block;
  font-size: 11px;
  font-weight: 700;
  color: var(--muted);
  letter-spacing: .3px;
  text-transform: uppercase;
  margin-bottom: 6px;
}

label .required { color: var(--danger); margin-left: 2px; }
label .hint { font-weight: 400; text-transform: none; letter-spacing: 0; color: var(--muted); font-size: 11px; }

input[type="text"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 8px 11px;
  border: 1.5px solid var(--border);
  border-radius: 6px;
  font-family: var(--font);
  font-size: 13px;
  color: var(--text);
  background: #fff;
  transition: border-color .15s;
  appearance: none;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(37,99,235,.1);
}

textarea { resize: vertical; min-height: 100px; }

.checkbox-row {
  display: flex;
  align-items: center;
  gap: 8px;
}

input[type="checkbox"] {
  width: 16px;
  height: 16px;
  accent-color: var(--accent);
  cursor: pointer;
}

.form-actions {
  display: flex;
  gap: 10px;
  align-items: center;
  padding-top: 4px;
}

/* ── API docs panel ──────────────────────── */
.api-panel {
  background: var(--sidebar);
  border-radius: var(--radius);
  padding: 20px;
  color: rgba(255,255,255,.8);
  font-size: 13px;
  margin-top: 28px;
}
.api-panel h3 { color: #fff; font-size: 14px; margin-bottom: 12px; }
.api-url {
  font-family: 'Courier New', monospace;
  font-size: 12px;
  background: rgba(255,255,255,.07);
  padding: 8px 12px;
  border-radius: 6px;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}
.api-method {
  font-size: 10px;
  font-weight: 700;
  background: var(--accent);
  color: #fff;
  padding: 2px 6px;
  border-radius: 4px;
}
.api-copy {
  margin-left: auto;
  background: none;
  border: none;
  color: rgba(255,255,255,.4);
  cursor: pointer;
  font-size: 12px;
  padding: 2px 6px;
  border-radius: 4px;
  font-family: var(--font);
  transition: color .15s;
}
.api-copy:hover { color: #fff; }

/* ── Login page ──────────────────────────── */
.login-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg);
  padding: 20px;
}

.login-card {
  background: var(--surface);
  border: 1px solid var(--border);
  border-radius: 16px;
  padding: 48px 40px;
  width: 100%;
  max-width: 400px;
  text-align: center;
  box-shadow: 0 8px 32px rgba(0,0,0,.06);
}

.login-logo {
  font-size: 22px;
  font-weight: 700;
  letter-spacing: 1px;
  text-transform: uppercase;
  color: var(--text);
  margin-bottom: 4px;
}

.login-sub {
  font-size: 12px;
  color: var(--muted);
  margin-bottom: 36px;
}

.ms-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: 100%;
  padding: 13px 20px;
  background: #fff;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-family: var(--font);
  font-size: 14px;
  font-weight: 600;
  color: var(--text);
  text-decoration: none;
  cursor: pointer;
  transition: all .15s;
}

.ms-btn:hover {
  border-color: #2563eb;
  background: #f0f5ff;
  color: #1d4ed8;
}

.ms-icon {
  width: 20px;
  height: 20px;
  flex-shrink: 0;
}

.login-domain-note {
  font-size: 11px;
  color: var(--muted);
  margin-top: 16px;
}

/* ── Utilities ───────────────────────────── */
.divider { border: none; border-top: 1px solid var(--border); margin: 0; }

@media (max-width: 768px) {
  .sidebar { display: none; }
  .spec-grid { grid-template-columns: 1fr; }
  .form-grid { grid-template-columns: 1fr; }
  .form-field { border-right: none; }
  .content { padding: 16px; }
  .topbar { padding: 0 16px; }
}
