/* DAM System — Main Stylesheet */
/* Design: Clean editorial, Scandinavian minimal, dark accents */

/* DM Sans — SJÄLVHOSTAD variabel font (assets/fonts/), preladdas i layoutens
   <head>. font-display: optional = typsnittet byts ALDRIG mitt i en sidvisning;
   är det inte klart vid första uppritningen (kall cache) används reservtypsnitt
   den sidvisningen och DM Sans från nästa. Googles CDN gav synliga
   storleksväxlingar vid omladdning — och självhostat är dessutom GDPR-snyggt. */
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: optional;
  src: url('../fonts/dmsans-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  font-style: normal;
  font-weight: 100 1000;
  font-display: optional;
  src: url('../fonts/dmsans-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}
@font-face {
  font-family: 'DM Sans';
  font-style: italic;
  font-weight: 100 1000;
  font-display: optional;
  src: url('../fonts/dmsans-italic-latin.woff2') format('woff2');
  unicode-range: U+0000-00FF, U+0131, U+0152-0153, U+02BB-02BC, U+02C6, U+02DA, U+02DC, U+0304, U+0308, U+0329, U+2000-206F, U+20AC, U+2122, U+2191, U+2193, U+2212, U+2215, U+FEFF, U+FFFD;
}
@font-face {
  font-family: 'DM Sans';
  font-style: italic;
  font-weight: 100 1000;
  font-display: optional;
  src: url('../fonts/dmsans-italic-latin-ext.woff2') format('woff2');
  unicode-range: U+0100-02BA, U+02BD-02C5, U+02C7-02CC, U+02CE-02D7, U+02DD-02FF, U+0304, U+0308, U+0329, U+1D00-1DBF, U+1E00-1E9F, U+1EF2-1EFF, U+2020, U+20A0-20AB, U+20AD-20C0, U+2113, U+2C60-2C7F, U+A720-A7FF;
}

*, *::before, *::after { box-sizing: border-box; }

:root {
  --black: #0a0a0a;
  --near-black: #111;
  --dark: #1c1c1e;
  --mid: #3a3a3c;
  --subtle: #6e6e73;
  --light: #aeaeb2;
  --border: #e5e5e7;
  --bg: #f5f5f7;
  --white: #ffffff;
  --accent: #1a56ff;
  --accent-hover: #0038e0;
  --accent-light: #eef2ff;
  --red: #e53e3e;
  --green: #38a169;
  --orange: #dd6b20;
  --yellow: #d69e2e;
  
  --font-body: 'DM Sans', -apple-system, sans-serif;
  
  --radius: 0px;
  --radius-lg: 0px;
  --radius-pill: 40px;
  --shadow-sm: 0 1px 3px rgba(0,0,0,0.08);
  --shadow: 0 4px 16px rgba(0,0,0,0.1);
  --shadow-lg: 0 12px 40px rgba(0,0,0,0.15);
  
  --header-h: 60px;
  --sidebar-w: 260px;
}

html { font-size: 15px; }
body {
  font-family: var(--font-body);
  background: var(--bg);
  color: var(--black);
  margin: 0;
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
}

/* ── Layout ──────────────────────────────────────────────────────────────── */

.layout {
  display: flex;
  min-height: 100vh;
}

.sidebar {
  width: var(--sidebar-w);
  background: var(--sidebar-bg, #005023);
  color: var(--sidebar-text, var(--white));
  display: flex;
  flex-direction: column;
  position: fixed;
  top: 0;
  left: 0;
  height: 100vh;
  overflow-y: auto;
  z-index: 100;
  flex-shrink: 0;
}

.main {
  margin-left: var(--sidebar-w);
  flex: 1;
  min-width: 0; /* annars växer flex-item med breda tabeller och trycker ut topbaren */
  display: flex;
  flex-direction: column;
  min-height: 100vh;
  border-radius: 8px 0 0 8px;
}

.topbar {
  height: var(--header-h);
  background: var(--white);
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  padding: 0 24px;
  gap: 16px;
  position: sticky;
  top: 0;
  z-index: 50;
}

.page-content {
  padding: 28px 32px;
  flex: 1;
}

/* ── Sidebar ─────────────────────────────────────────────────────────────── */

.sidebar-logo {
  padding: 38px 36px 32px;
}

.sidebar-logo a {
  text-decoration: none;
  color: var(--white);
}

.sidebar-logo .logo-text {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 1.4rem;
  letter-spacing: -0.02em;
  display: block;
}

.sidebar-logo .logo-sub {
  font-size: 0.72rem;
  color: var(--subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
}

.sidebar-nav {
  padding: 16px 0;
  flex: 1;
}

.nav-section {
  padding: 8px 16px 4px;
  font-size: 0.68rem;
  font-weight: 600;
  letter-spacing: 0.1em;
  text-transform: uppercase;
  color: #fafbed;
  margin-top: 8px;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 10px;
  padding: 9px 24px;
  color: var(--light);
  text-decoration: none;
  font-size: 0.94rem;
  font-weight: 500;
  border-left: 3px solid transparent;
  transition: all 0.15s ease;
}

.nav-link:hover {
  color: var(--white);
  background: rgba(255,255,255,0.06);
}

.nav-link.active {
  color: var(--white);
  border-left-color: var(--accent);
  background: rgba(26,86,255,0.12);
}

.nav-link svg { flex-shrink: 0; opacity: 0.7; }
.nav-link.active svg { opacity: 1; }

.sidebar-user {
  padding: 16px 24px;
  border-top: 1px solid rgba(255,255,255,0.08);
  display: flex;
  align-items: center;
  gap: 12px;
}

.user-avatar {
  width: 34px;
  height: 34px;
  border-radius: 50%;
  background: var(--accent);
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 600;
  font-size: 0.8rem;
  color: white;
  flex-shrink: 0;
}

.user-info { min-width: 0; }
.user-name { font-size: 0.85rem; font-weight: 500; color: var(--white); white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.user-role { font-size: 0.72rem; color: var(--subtle); text-transform: capitalize; }

/* ── Topbar ──────────────────────────────────────────────────────────────── */

.topbar-search {
  flex: 1;
  max-width: 480px;
  position: relative;
}

.topbar-search input {
  width: 100%;
  padding: 8px 16px 8px 38px;
  border: 1.5px solid var(--border);
  border-radius: 40px;
  font-size: 0.88rem;
  font-family: var(--font-body);
  background: var(--bg);
  transition: all 0.2s;
  outline: none;
}

.topbar-search input:focus {
  border-color: var(--accent);
  background: var(--white);
  box-shadow: 0 0 0 3px rgba(26,86,255,0.12);
}

.topbar-search .search-icon {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  color: var(--light);
  pointer-events: none;
}

.topbar-actions {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-left: auto;
}

/* ── Page header ─────────────────────────────────────────────────────────── */

.page-header {
  margin-bottom: 28px;
  display: flex;
  align-items: flex-end;
  justify-content: space-between;
  gap: 16px;
}

.page-title {
  font-family: var(--font-body);
  font-size: 2rem;
  font-weight: 500;
  letter-spacing: -0.03em;
  line-height: 1.1;
  margin: 0 0 4px;
}

.page-subtitle {
  color: var(--subtle);
  font-size: 0.9rem;
  margin: 0;
}

/* ── Buttons ─────────────────────────────────────────────────────────────── */

.btn {
  display: inline-flex;
  align-items: center;
  gap: 7px;
  padding: 9px 18px;
  border-radius: 8px;
  font-family: var(--font-body);
  font-size: 0.88rem;
  font-weight: 500;
  cursor: pointer;
  border: none;
  text-decoration: none;
  transition: all 0.15s ease;
  white-space: nowrap;
  line-height: 1;
}

.btn-primary {
  background: var(--accent);
  color: var(--white);
}
.btn-primary:hover { background: var(--accent-hover); }

.btn-secondary {
  background: var(--white);
  color: var(--dark);
  border: 1.5px solid var(--border);
}
.btn-secondary:hover { border-color: var(--light); background: var(--bg); }

.btn-dark {
  background: var(--black);
  color: var(--white);
}
.btn-dark:hover { background: var(--dark); }

.btn-danger {
  background: var(--red);
  color: var(--white);
}
.btn-danger:hover { background: #c53030; }

.btn-success {
  background: var(--green);
  color: var(--white);
}
.btn-success:hover { background: #2f855a; }

.btn-sm { padding: 6px 12px; font-size: 0.82rem; }
.btn-lg { padding: 12px 24px; font-size: 0.95rem; }

.btn-icon {
  padding: 8px;
  border-radius: var(--radius);
  background: transparent;
  border: none;
  cursor: pointer;
  color: var(--subtle);
  display: inline-flex;
  align-items: center;
  justify-content: center;
  transition: all 0.15s;
}
.btn-icon:hover { background: var(--bg); color: var(--black); }
#menu-btn { display: none; }

/* ── Cards ───────────────────────────────────────────────────────────────── */

.card {
  background: var(--white);
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  overflow: hidden;
}

.card-header {
  padding: 18px 24px;
  border-bottom: 1px solid var(--border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-title {
  font-weight: 600;
  font-size: 0.95rem;
  margin: 0;
}

.card-body { padding: 24px; }

/* ── Stats cards ─────────────────────────────────────────────────────────── */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 16px;
  margin-bottom: 28px;
}

.stat-card {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 20px 24px;
}

.stat-label {
  font-size: 0.78rem;
  color: var(--subtle);
  font-weight: 500;
  letter-spacing: 0.04em;
  text-transform: uppercase;
  margin-bottom: 8px;
}

.stat-value {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 2.2rem;
  line-height: 1;
  letter-spacing: -0.02em;
}

.stat-sub {
  font-size: 0.78rem;
  color: var(--subtle);
  margin-top: 4px;
}

/* ── Asset grid ──────────────────────────────────────────────────────────── */

.asset-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(220px, 1fr));
  gap: 16px;
}

.asset-card {
  background: var(--white);
  border-radius: 0;
  overflow: hidden;
  border: 1px solid var(--border);
  cursor: pointer;
  transition: all 0.2s ease;
  text-decoration: none;
  color: inherit;
  display: block;
}

.asset-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow);
  border-color: var(--light);
}

.asset-thumb {
  aspect-ratio: 4/3;
  background: var(--bg);
  overflow: hidden;
  position: relative;
}

.asset-thumb img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}
.asset-thumb--contain img {
  object-fit: contain;
  padding: 12px;
  background: #f8f8f8;
}

.asset-card:hover .asset-thumb img {
  transform: scale(1.04);
}

.video-play-icon {
  position: absolute;
  inset: 0;
  display: flex;
  align-items: center;
  justify-content: center;
  pointer-events: none;
  transition: opacity 0.2s;
}
.asset-card:hover .video-play-icon { opacity: 0.7; }

.asset-delete-btn {
  position: absolute;
  top: 8px;
  right: 8px;
  background: rgba(0,0,0,0.55);
  border: none;
  border-radius: 6px;
  color: white;
  width: 28px;
  height: 28px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s;
  z-index: 2;
  padding: 0;
}
.asset-card:hover .asset-delete-btn { opacity: 1; }
.asset-delete-btn:hover { background: var(--red); }

/* ── Batch selection ────────────────────────────────────────────────────────── */

.select-check {
  position: absolute;
  top: 8px;
  left: 8px;
  width: 22px;
  height: 22px;
  border-radius: 50%;
  background: rgba(0,0,0,0.3);
  border: 2px solid rgba(255,255,255,0.85);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 4;
  cursor: pointer;
  opacity: 0;
  transition: opacity 0.15s, background 0.15s, border-color 0.15s;
}
.asset-card:hover .select-check { opacity: 1; }

.asset-card.selected .select-check {
  opacity: 1;
  background: var(--accent);
  border-color: var(--accent);
}
.asset-card.selected .select-check::after {
  content: '';
  width: 5px;
  height: 9px;
  border-right: 2px solid white;
  border-bottom: 2px solid white;
  transform: rotate(45deg) translateY(-1px);
  display: block;
}
.asset-card.selected {
  border-color: var(--accent);
  box-shadow: 0 0 0 2px var(--accent);
}

.batch-bar {
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background: #004a1e;
  color: white;
  padding: 12px 24px;
  display: flex;
  align-items: center;
  gap: 10px;
  z-index: 200;
  box-shadow: 0 -4px 24px rgba(0,0,0,0.3);
  flex-wrap: wrap;
}
.batch-bar .form-control option { color: #333; background: white; }

.btn-delete {
  color: var(--red);
  background: transparent;
  border: 1px solid var(--red);
  padding: 0 8px;
}
.btn-delete:hover { background: var(--red); color: white; }

.asset-thumb-placeholder {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100%;
  height: 100%;
  color: var(--light);
  background: var(--bg);
}

.asset-meta {
  padding: 12px 14px;
}

.asset-title {
  font-size: 0.85rem;
  font-weight: 500;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
  margin-bottom: 4px;
}

.asset-info {
  font-size: 0.75rem;
  color: var(--subtle);
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
}

.asset-tags {
  display: flex;
  gap: 8px;
  flex-wrap: wrap;
  padding: 0 14px 12px;
}

/* ── Tags / badges ───────────────────────────────────────────────────────── */

.tag {
  display: inline-flex;
  align-items: center;
  padding: 2px 8px;
  border-radius: 40px;
  font-size: 0.72rem;
  font-weight: 500;
  background: var(--bg);
  color: var(--mid);
  text-decoration: none;
  border: 1px solid var(--border);
  transition: all 0.15s;
  white-space: nowrap;
}

.tag:hover { background: var(--accent-light); color: var(--accent); border-color: #c7d2fe; }
.tag-ai { border-style: dashed; }
.tag-remove { margin-left: 6px; padding: 0 3px; cursor: pointer; opacity: 0.6; line-height: 1; background: none; border: none; font: inherit; color: inherit; }
.tag-remove:hover { opacity: 1; color: var(--red); }

.badge {
  display: inline-block;
  padding: 2px 8px;
  border-radius: 40px;
  font-size: 0.72rem;
  font-weight: 600;
}

.badge-blue { background: var(--accent-light); color: var(--accent); }
.badge-green { background: #f0fff4; color: var(--green); }
.badge-red { background: #fff5f5; color: var(--red); }
.badge-yellow { background: #fffff0; color: var(--yellow); }
.badge-gray { background: var(--bg); color: var(--subtle); }

/* ── Forms ───────────────────────────────────────────────────────────────── */

.form-group { margin-bottom: 20px; }

.form-label {
  display: block;
  font-size: 0.84rem;
  font-weight: 500;
  margin-bottom: 6px;
  color: var(--dark);
}

.form-hint {
  font-size: 0.78rem;
  color: var(--subtle);
  margin-top: 4px;
}

.form-control {
  display: block;
  width: 100%;
  padding: 9px 14px;
  border: 1.5px solid var(--border);
  border-radius: var(--radius);
  font-size: 0.9rem;
  font-family: var(--font-body);
  background: var(--white);
  transition: all 0.2s;
  outline: none;
  color: var(--black);
}

.form-control:focus {
  border-color: var(--accent);
  box-shadow: 0 0 0 3px rgba(26,86,255,0.1);
}

textarea.form-control { min-height: 100px; resize: vertical; }

select.form-control { cursor: pointer; }

.form-control::placeholder { color: var(--light); }

/* ── Tables ──────────────────────────────────────────────────────────────── */

.table-wrap {
  overflow-x: auto;
  border-radius: var(--radius-lg);
  border: 1px solid var(--border);
  background: var(--white);
}

table {
  width: 100%;
  border-collapse: collapse;
}

th {
  font-size: 0.75rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--subtle);
  text-align: left;
  padding: 12px 16px;
  background: var(--bg);
  border-bottom: 1px solid var(--border);
}

td {
  padding: 12px 16px;
  border-bottom: 1px solid var(--border);
  font-size: 0.88rem;
  vertical-align: middle;
}

tr:last-child td { border-bottom: none; }
tbody tr:hover { background: rgba(0,0,0,0.015); }

/* ── Filters bar ─────────────────────────────────────────────────────────── */

.filters-bar {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius-lg);
  padding: 16px 20px;
  margin-bottom: 20px;
  display: flex;
  flex-wrap: wrap;
  gap: 12px;
  align-items: flex-end;
}

.filter-group {
  display: flex;
  flex-direction: column;
  gap: 4px;
  min-width: 150px;
}

.filter-label {
  font-size: 0.72rem;
  font-weight: 600;
  letter-spacing: 0.05em;
  text-transform: uppercase;
  color: var(--subtle);
}

.filter-group .form-control {
  padding: 7px 12px;
  font-size: 0.84rem;
}

/* ── Alerts ──────────────────────────────────────────────────────────────── */

.alert {
  padding: 12px 16px;
  border-radius: var(--radius);
  font-size: 0.88rem;
  margin-bottom: 16px;
  display: flex;
  align-items: flex-start;
  gap: 10px;
}

.alert-success { background: #f0fff4; color: #276749; border-left: 3px solid var(--green); }
.alert-error   { background: #fff5f5; color: #9b2c2c; border-left: 3px solid var(--red); }
.alert-info    { background: var(--accent-light); color: #2b4acb; border-left: 3px solid var(--accent); }
.alert-warning { background: #fffff0; color: #744210; border-left: 3px solid var(--yellow); }

/* ── Upload zone ─────────────────────────────────────────────────────────── */

.upload-zone {
  border: 2px dashed var(--border);
  border-radius: var(--radius-lg);
  padding: 48px 32px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s;
  background: var(--white);
  position: relative;
}

.upload-zone:hover, .upload-zone.drag-over {
  border-color: var(--accent);
  background: var(--accent-light);
}

.upload-zone input[type="file"] {
  position: absolute;
  inset: 0;
  width: 100%;
  height: 100%;
  opacity: 0;
  cursor: pointer;
}

.upload-icon {
  width: 56px;
  height: 56px;
  background: var(--bg);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 16px;
  color: var(--subtle);
}

.upload-title {
  font-size: 1.05rem;
  font-weight: 600;
  margin-bottom: 6px;
}

.upload-hint {
  font-size: 0.84rem;
  color: var(--subtle);
}

/* ── Upload queue ────────────────────────────────────────────────────────── */

.upload-queue {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-top: 16px;
}

.upload-item {
  background: var(--white);
  border: 1px solid var(--border);
  border-radius: var(--radius);
  padding: 10px 14px;
  display: flex;
  align-items: center;
  gap: 12px;
}

.upload-item-name { flex: 1; font-size: 0.85rem; font-weight: 500; min-width: 0; overflow: hidden; text-overflow: ellipsis; white-space: nowrap; }
.upload-item-size { font-size: 0.78rem; color: var(--subtle); flex-shrink: 0; }

.upload-progress {
  width: 100%;
  height: 3px;
  background: var(--border);
  border-radius: 99px;
  margin-top: 6px;
  overflow: hidden;
}

.upload-progress-bar {
  height: 100%;
  background: var(--accent);
  border-radius: 99px;
  transition: width 0.3s ease;
}

.meta-section { margin-bottom: 20px; }

.meta-section-title {
  font-size: 0.72rem;
  font-weight: 700;
  letter-spacing: 0.08em;
  text-transform: uppercase;
  color: var(--subtle);
  margin-bottom: 10px;
}

.meta-row {
  display: flex;
  gap: 8px;
  margin-bottom: 6px;
  font-size: 0.84rem;
}

.meta-key { color: var(--subtle); flex-shrink: 0; width: 110px; }
.meta-val { font-weight: 500; word-break: break-word; }


/* ── Pagination ──────────────────────────────────────────────────────────── */

.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 6px;
  padding: 28px 0 8px;
}

.pagination a, .pagination span {
  display: flex;
  align-items: center;
  justify-content: center;
  min-width: 34px;
  height: 34px;
  border-radius: var(--radius);
  font-size: 0.85rem;
  text-decoration: none;
  color: var(--mid);
  transition: all 0.15s;
}

.pagination a:hover { background: var(--bg); color: var(--black); }
.pagination .current { background: var(--accent); color: var(--white); font-weight: 600; }
.pagination .disabled { color: var(--light); cursor: default; }

/* ── Login page ──────────────────────────────────────────────────────────── */

.auth-page {
  min-height: 100vh;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 40px 20px;
  background: linear-gradient(160deg, #1d1f24 0%, var(--black) 45%, #141d33 100%);
  position: relative;
  overflow: hidden;
}

.auth-page::before {
  content: '';
  position: absolute;
  width: 600px;
  height: 600px;
  background: radial-gradient(circle, rgba(26,86,255,0.15) 0%, transparent 70%);
  top: -100px;
  right: -100px;
  pointer-events: none;
}

.auth-box {
  background: var(--white);
  border-radius: var(--radius-lg);
  padding: 60px 48px 44px;
  width: 100%;
  max-width: 420px;
  box-shadow: var(--shadow-lg);
  position: relative;
  z-index: 1;
}

.auth-logo {
  text-align: center;
  margin-bottom: 48px;
}

.auth-logo .logo-text {
  font-family: var(--font-body);
  font-weight: 500;
  font-size: 2rem;
  letter-spacing: -0.03em;
}

.auth-logo .logo-sub {
  display: block;
  font-size: 0.78rem;
  color: var(--subtle);
  letter-spacing: 0.08em;
  text-transform: uppercase;
  margin-top: 2px;
}

.auth-title {
  font-size: 1.35rem;
  font-weight: 600;
  margin: 0 0 6px;
}

.auth-sub {
  color: var(--subtle);
  font-size: 0.88rem;
  margin-bottom: 28px;
}

/* ── Responsive ──────────────────────────────────────────────────────────── */

/* ── Sidebar overlay (mobile) ─────────────────────────────────────────────── */

.sidebar-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0,0,0,.45);
  z-index: 99;
}

.users-table-desktop { display: block; }
.users-cards-mobile  { display: none; }

/* Grön bock vid fält som just sparats (flash med ankare) */
.save-check {
  display: inline-flex;
  align-items: center;
  gap: 4px;
  margin-left: 10px;
  color: var(--green);
  font-size: .8rem;
  font-weight: 600;
  opacity: 1;
  transition: opacity .8s ease;
}
.save-check.fade { opacity: 0; }

/* Mobil loggrad — visas bara under 900px (regler i mediablocket) */
.mobile-brand { display: none; }

/* Blädderpilar på bildytan (bildsidan) — tonas fram vid hover, alltid synliga på pekskärm */
.stage-nav {
  position: absolute;
  top: 50%;
  transform: translateY(-50%);
  width: 48px;
  height: 48px;
  border-radius: 50%;
  background: rgba(0, 0, 0, .45);
  border: 1.5px solid rgba(255, 255, 255, .35);
  color: #fff;
  display: flex;
  align-items: center;
  justify-content: center;
  text-decoration: none;
  z-index: 5;
  opacity: 0;
  transition: opacity .18s ease, background .15s;
}
.stage-nav-prev { left: 14px; }
.stage-nav-next { right: 14px; }
.asset-stage:hover .stage-nav { opacity: 1; }
.stage-nav:hover { background: rgba(0, 0, 0, .7); }
@media (hover: none) {
  .stage-nav { opacity: 1; width: 42px; height: 42px; }
}

.asset-nav-arrow {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  width: 28px;
  height: 28px;
  background-color: var(--arrow-bg, var(--sidebar-bg, #005023)) !important;
  color: var(--arrow-fg, #ffffff) !important;
  border: none;
  border-radius: 8px;
  text-decoration: none;
  cursor: pointer;
  flex-shrink: 0;
  transition: filter .15s;
}
.asset-nav-arrow:hover {
  filter: brightness(1.15);
}

.admin-overview-grid {
  display: grid;
  grid-template-columns: 1fr 340px;
  gap: 24px;
}

.admin-recent-grid {
  display: grid;
  grid-template-columns: repeat(4, 1fr);
  gap: 1px;
  background: var(--border);
}

.asset-detail-layout {
  display: block;
}
.asset-detail-meta {
  display: grid;
  grid-template-columns: 1fr 360px;
  gap: 28px;
  align-items: start;
  margin-top: 20px;
}
@media (max-width: 900px) {
  .asset-detail-meta { grid-template-columns: 1fr; }
}

@media (max-width: 900px) {
  .asset-detail-layout { grid-template-columns: 1fr; }
  :root { --sidebar-w: 0px; }

  .sidebar {
    transform: translateX(-260px);
    width: 260px;
    transition: transform .25s ease;
    z-index: 200;
  }
  .sidebar.open { transform: translateX(0); }

  .sidebar-overlay.open { display: block; }

  .main { margin-left: 0; }

  #menu-btn { display: flex !important; }

  /* Brandad loggrad överst på mobil — sidopanelens logga syns ju inte där */
  .mobile-brand {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 12px 16px;
    background: var(--sidebar-bg, #005023);
    color: var(--sidebar-text, #ffffff);
    text-decoration: none;
  }
  .mobile-brand img { max-height: 28px; max-width: 60%; object-fit: contain; }
  .mobile-brand span { font-weight: 600; font-size: 1.05rem; letter-spacing: -0.01em; }

  .topbar { padding: 0 12px; gap: 8px; }
  .topbar-search { min-width: 0; }
  .topbar-actions .btn span { display: none; }
  .topbar-actions .btn { padding: 9px 12px; }
  .topbar-actions { gap: 8px; min-width: 0; }
  /* Taggmolnet: max ~två rader ihopfällt, resten bakom Visa fler */
  .tag-cloud.collapsed { max-height: 72px; overflow: hidden; }

  .page-content { padding: 20px 16px; }

  .asset-grid { grid-template-columns: repeat(auto-fill, minmax(150px, 1fr)); gap: 10px; }

  .upload-layout { grid-template-columns: 1fr !important; }
  .upload-layout .upload-sidebar { position: static !important; }
  .upload-info-grid { grid-template-columns: 1fr !important; }
  #cs-panel { width: calc(100vw - 32px); right: 16px; left: 16px; }

.auth-box { padding: 28px 24px; }

  /* Admin overview */
  .admin-overview-grid { grid-template-columns: 1fr !important; }
  .admin-recent-grid { grid-template-columns: repeat(2,1fr) !important; }
  .stats-grid { grid-template-columns: repeat(2, 1fr); }

  /* Users page */
  .users-table-desktop { display: none; }
  .users-cards-mobile  { display: block; }
}

/* ── Utilities ───────────────────────────────────────────────────────────── */

.text-muted { color: var(--subtle); }
.text-small { font-size: 0.82rem; }
.text-center { text-align: center; }
.text-right { text-align: right; }
.fw-500 { font-weight: 500; }
.fw-600 { font-weight: 600; }
.mt-0 { margin-top: 0; }
.mb-0 { margin-bottom: 0; }
.mb-7  { margin-bottom: 7px; }
.mb-16 { margin-bottom: 16px; }
.mb-20 { margin-bottom: 7px; }
.mb-24 { margin-bottom: 24px; }
.d-flex { display: flex; }
.align-center { align-items: center; }
.gap-8 { gap: 8px; }
.gap-12 { gap: 12px; }
.gap-16 { gap: 16px; }
.flex-1 { flex: 1; }
.w-100 { width: 100%; }
.hidden { display: none !important; }

/* Lightbox nav arrows */
#fs-prev:hover, #fs-next:hover {
  background: rgba(0,0,0,.8) !important;
  border-color: rgba(255,255,255,.7) !important;
}

/* ── Modaler ──────────────────────────────────────────────────────────────── */
.modal-overlay {
  display: none;
  position: fixed;
  inset: 0;
  background: rgba(0, 0, 0, .5);
  z-index: 1000;
  align-items: flex-start;
  justify-content: center;
  padding: 56px 16px;
  overflow-y: auto;
}
.modal-overlay.open { display: flex; }
.modal {
  background: var(--card-bg, #fff);
  border: 1px solid var(--border);
  border-radius: 12px;
  width: 100%;
  max-width: 480px;
  box-shadow: 0 12px 40px rgba(0, 0, 0, .22);
}
.modal-header {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 16px 20px;
  border-bottom: 1px solid var(--border);
}

/* ─── Sömlösa sidbyten (View Transitions) ────────────────────────────────────
   Nya sidan tonar in i stället för att klippa — identiska delar (sidopanel,
   topplist) ser helt stilla ut, bara det som skiljer tonas. Bildytan får ett
   eget snabbt övergångsspår så bildbyten känns som att bara bilden byts.
   Webbläsare utan stöd (t.ex. Firefox) navigerar precis som vanligt. */
@media (prefers-reduced-motion: no-preference) {
  @view-transition { navigation: auto; }
  .asset-stage { view-transition-name: asset-stage; }
  /* Rotens korstoning AV: text som tonar över sig själv ser ut att
     fetstils-blinka. Sidan byts direkt — bara bildytan tonar mjukt. */
  ::view-transition-old(root), ::view-transition-new(root) { animation: none; }
  ::view-transition-group(asset-stage) { animation-duration: .18s; }
}

/* SUPERsmart sök — pulserande ram medan AI:n tolkar frågan */
#main-search.ai-thinking {
  animation: ai-pulse 1.1s ease-in-out infinite;
}
@keyframes ai-pulse {
  0%, 100% { box-shadow: 0 0 0 2px rgba(26, 86, 255, .18); }
  50%      { box-shadow: 0 0 0 4px rgba(26, 86, 255, .38); }
}
