/* --- Importer Fonter --- */
@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600&family=Playfair+Display:wght@600;700&display=swap');

/*
==========================================
  CSS Variabler (Roter)
==========================================
*/
:root {
  /* Fonter */
  --font-body: 'Inter', sans-serif;
  --font-display: 'Playfair Display', serif;

  /* --- Ny Fargepalett --- */
  --palette-autumn-ember: #b45309;
  --palette-burnt-caramel: #bd6829;
  --palette-shadow-grey: #292524;
  --palette-gunmetal: #3f3f46;
  --palette-white: #fefefe;

  /* --- Funksjonelle Variabler --- */
  --color-primary: var(--palette-autumn-ember);
  --color-primary-hover: var(--palette-burnt-caramel);

  --color-bg-body: #f5f5f4;
  --color-bg-surface: #ffffff;
  --color-bg-subtle: #fafaf9;
  --color-bg-dark: var(--palette-shadow-grey);
  --color-bg-header: rgba(255, 255, 255, 0.9);

  --color-text-main: #1c1917;
  --color-text-muted: #57534e;
  --color-text-light: #fafaf9;
  --color-text-inverse: #ffffff;

  --color-border: #e7e5e4;
  --color-border-dark: #d6d3d1;

  --color-error: #dc2626;
  --color-success: #16a34a;

  /* Skygger & Effekter */
  --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
  --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
  --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
  --shadow-xl: 0 20px 25px -5px rgb(0 0 0 / 0.1), 0 8px 10px -6px rgb(0 0 0 / 0.1);

  --radius-sm: 0.375rem;
  --radius-md: 0.5rem;
  --radius-lg: 0.75rem;
  --radius-xl: 1rem;
  --radius-full: 9999px;

  --transition-base: all 0.2s ease-in-out;
}

/* --- Dark Mode Overrides --- */
[data-theme="dark"] {
  --color-bg-body: var(--palette-shadow-grey);
  --color-bg-surface: var(--palette-gunmetal);
  --color-bg-subtle: #1c1917;
  /* Darker than body */

  --color-text-main: var(--palette-white);
  --color-text-muted: #a1a1aa;

  --color-border: #52525b;
  /* zinc-600 */
  --color-border-dark: #71717a;
  /* zinc-500 */

  --color-bg-white: var(--palette-shadow-grey);
  --color-bg-header: rgba(41, 37, 36, 0.9);

  --color-bg-input: #18181b;
  /* Darker background for inputs */
}

/* Custom Scrollbar Styles */
::-webkit-scrollbar {
  width: 10px;
  height: 10px;
}

::-webkit-scrollbar-track {
  background: var(--color-bg-body);
}

::-webkit-scrollbar-thumb {
  background: var(--color-border);
  border-radius: 5px;
  border: 2px solid var(--color-bg-body);
}

::-webkit-scrollbar-thumb:hover {
  background: var(--color-primary);
}

/* Firefox Scrollbar */
* {
  scrollbar-width: thin;
  scrollbar-color: var(--color-border) var(--color-bg-body);
}

/* --- Theme Helpers --- */
[data-theme="dark"] .logo-light-only {
  display: none !important;
}

[data-theme="light"] .logo-dark-only {
  display: none !important;
}

[data-theme="dark"] .logo-dark-only {
  display: block !important;
}

/* --- Quill Editor Dark Mode --- */
[data-theme="dark"] .ql-toolbar.ql-snow,
[data-theme="dark"] .ql-container.ql-snow {
  border-color: var(--color-border) !important;
  background-color: var(--color-bg-input) !important;
  color: var(--color-text-main) !important;
}

/* Force all icons to be themed in dark mode */
[data-theme="dark"] .ql-snow.ql-toolbar button .ql-stroke,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-label .ql-stroke,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-item .ql-stroke,
[data-theme="dark"] .ql-snow .ql-stroke {
  stroke: var(--color-text-main) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar button .ql-fill,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-label .ql-fill,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-item .ql-fill,
[data-theme="dark"] .ql-snow .ql-fill {
  fill: var(--color-text-main) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar button .ql-thin,
[data-theme="dark"] .ql-snow .ql-thin {
  stroke: var(--color-text-main) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker {
  color: var(--color-text-main) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-label {
  color: var(--color-text-main) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-options {
  background-color: var(--color-bg-surface) !important;
  border-color: var(--color-border) !important;
}

/* Hover and Active states */
[data-theme="dark"] .ql-snow.ql-toolbar button:hover .ql-stroke,
[data-theme="dark"] .ql-snow.ql-toolbar button.ql-active .ql-stroke,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-label:hover .ql-stroke,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-label .ql-stroke {
  stroke: var(--color-primary) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar button:hover .ql-fill,
[data-theme="dark"] .ql-snow.ql-toolbar button.ql-active .ql-fill,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-label:hover .ql-fill,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-label .ql-fill {
  fill: var(--color-primary) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker-label:hover,
[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-label {
  color: var(--color-primary) !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-options .ql-picker-item {
  color: #ffffff !important;
}

[data-theme="dark"] .ql-snow.ql-toolbar .ql-picker.ql-expanded .ql-picker-options .ql-picker-item:hover {
  color: var(--color-primary) !important;
}

[data-theme="dark"] .ql-editor {
  color: var(--color-text-main) !important;
}

/* Very aggressive fix to ensure all text within content areas is readable in dark mode */
[data-theme="dark"] .ql-editor,
[data-theme="dark"] .ql-editor *,
[data-theme="dark"] .feed-item-content,
[data-theme="dark"] .feed-item-content *,
[data-theme="dark"] #documents-list-container,
[data-theme="dark"] #documents-list-container * {
  color: var(--color-text-main) !important;
}

/*
==========================================
  Nullstilling (Reset) & Basis
==========================================
*/
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

html {
  scroll-behavior: smooth;
  font-size: 16px;
  width: 100%;
  overflow-x: hidden;
}

body {
  font-family: var(--font-body);
  color: var(--color-text-main);
  background-color: var(--color-bg-body);
  line-height: 1.6;
  -webkit-font-smoothing: antialiased;
  overflow-wrap: break-word;
  word-wrap: break-word;
  width: 100%;
  overflow-x: hidden;
}

.hidden {
  display: none !important;
}

img {
  max-width: 100%;
  height: auto;
  display: block;
}

a {
  color: var(--color-primary);
  text-decoration: none;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

a:hover {
  color: var(--color-primary-hover);
}

ul,
ol {
  list-style: none;
}

/*
==========================================
  Typografi
==========================================
*/
h1,
h2,
h3,
h4,
h5,
h6 {
  font-family: var(--font-display);
  color: var(--color-text-main);
  font-weight: 700;
  line-height: 1.2;
  margin-top: 0;
  margin-bottom: 1rem;
}

h1 {
  font-size: 3rem;
}

h2 {
  font-size: 2.25rem;
}

h3 {
  font-size: 1.5rem;
}

h4 {
  font-size: 1.25rem;
}

p {
  margin-bottom: 1rem;
  color: var(--color-text-muted);
}

.text-sm {
  font-size: 0.875rem;
}

.text-lg {
  font-size: 1.125rem;
}

.font-medium {
  font-weight: 500;
}

.font-semibold {
  font-weight: 600;
}

.text-center {
  text-align: center;
}

.text-right {
  text-align: right;
}

/*
==========================================
  Komponenter
==========================================
*/

/* Container */
.container {
  width: 100%;
  max-width: 1280px;
  margin: 0 auto;
  padding: 0 1rem;
  overflow-x: hidden;
  /* Safety */
}

/* Buttons */
.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  border: none;
  gap: 0.5rem;
}

.btn:hover {
  transform: translateY(-1px);
}

.btn:active {
  transform: translateY(0);
}

.btn-primary {
  background-color: var(--color-primary);
  color: white;
  box-shadow: var(--shadow-md);
}

.btn-primary:hover {
  background-color: var(--color-primary-hover);
  box-shadow: var(--shadow-lg);
  color: white;
}

.btn-secondary {
  background-color: var(--color-bg-body);
  color: var(--color-text-main);
  border: 1px solid var(--color-border-dark);
}

.btn-secondary:hover {
  background-color: var(--color-bg-subtle);
  border-color: var(--color-primary);
}

.btn-ghost {
  background-color: transparent;
  color: var(--color-text-muted);
}

.btn-ghost:hover {
  background-color: var(--color-bg-subtle);
  color: var(--color-primary);
}

#forgot-password-btn {
  background: none !important;
  border: none !important;
  box-shadow: none !important;
  padding: 0 !important;
  font-weight: 500;
  text-decoration: underline;
  text-underline-offset: 2px;
}

#forgot-password-btn:hover {
  color: var(--color-primary-hover);
  transform: none;
}

/* 
==========================================
  Dark Mode Toggle Button (Shared)
==========================================
*/
.theme-toggle {
  position: fixed;
  bottom: 2rem;
  right: 2rem;
  z-index: 1000;
  width: 50px;
  height: 50px;
  border-radius: 50%;
  background: var(--color-primary);
  color: white;
  display: flex !important;
  align-items: center;
  justify-content: center;
  border: none;
  box-shadow: var(--shadow-lg);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.theme-toggle:hover {
  transform: scale(1.1) rotate(15deg);
  background: var(--color-primary-hover);
  box-shadow: var(--shadow-xl);
}

/* Skjul "Bytt tema" tekst på floating knapp */
.theme-toggle span {
  display: none;
}

@media (max-width: 768px) {
  .theme-toggle {
    bottom: 1.5rem;
    right: 1.5rem;
    width: 45px;
    height: 45px;
  }
}

.btn-full {
  width: 100%;
}

/* Cards */
.card {
  background-color: var(--color-bg-surface);
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-sm);
  border: 1px solid var(--color-border);
  overflow: hidden;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.card:hover {
  box-shadow: var(--shadow-md);
}

.card-header {
  padding: 1.25rem;
  border-bottom: 1px solid var(--color-border);
  display: flex;
  align-items: center;
  justify-content: space-between;
}

.card-header h1,
.card-header h2,
.card-header h3,
.card-header h4,
.card-header h5,
.card-header h6 {
  margin: 0 !important;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  padding: 1rem 1.25rem;
  background-color: var(--color-bg-subtle);
  border-top: 1px solid var(--color-border);
}

/* Forms */
.form-group {
  margin-bottom: 1rem;
}

.form-label {
  display: block;
  font-size: 0.9rem;
  font-weight: 500;
  color: var(--color-text-main);
  margin-bottom: 0.5rem;
}

.form-input {
  width: 100%;
  padding: 0.75rem 1rem;
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-md);
  font-family: var(--font-body);
  font-size: 1rem;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  background-color: var(--color-bg-input, var(--color-bg-surface));
  color: var(--color-text-main);
}

.form-input::placeholder {
  color: var(--color-text-muted);
  opacity: 1;
}

.form-input:focus {
  outline: none;
  border-color: var(--color-primary);
  box-shadow: 0 0 0 3px rgba(180, 83, 9, 0.1);
}

.form-error {
  color: var(--color-error);
  font-size: 0.85rem;
  margin-top: 0.5rem;
}

/*
==========================================
  Feed Items (The "Bubbles")
==========================================
*/
.feed-item {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  padding: 1.5rem;
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.feed-item:hover {
  box-shadow: var(--shadow-md);
}

.feed-item h3 {
  font-size: 1.25rem;
  margin-top: 1rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-main);
}

.feed-item-content {
  color: var(--color-text-muted);
  line-height: 1.6;
}

/*
==========================================
  Layout & Header
==========================================
*/
.header {
  background-color: var(--color-bg-header);
  backdrop-filter: blur(12px);
  -webkit-backdrop-filter: blur(12px);
  position: sticky;
  top: 0;
  z-index: 100;
  border-bottom: 1px solid var(--color-border);
  transition: background-color 0.3s ease;
}

.header-inner {
  display: flex;
  align-items: center;
  justify-content: space-between;
  height: 4.5rem;
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  font-family: var(--font-display);
  font-weight: 700;
  font-size: 1.25rem;
  color: var(--color-text-main);
}

.logo img {
  height: 2.5rem;
  width: 2.5rem;
  border-radius: var(--radius-full);
}

.nav-desktop {
  display: none;
  align-items: center;
  gap: 2rem;
}

.nav-link {
  font-weight: 500;
  color: var(--color-text-muted);
  font-size: 0.95rem;
}

.nav-link:hover,
.nav-link.active {
  color: var(--color-primary);
}

/* Mobile Menu (Premium Overlay) */
.mobile-toggle {
  display: block;
  background: none;
  border: none;
  cursor: pointer;
  color: var(--color-text-main);
  z-index: 101;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.mobile-toggle:hover {
  color: var(--color-primary);
  transform: scale(1.1);
}

.mobile-toggle svg {
  width: 1.5rem;
  height: 1.5rem;
  display: block;
}

.mobile-menu {
  position: fixed;
  top: 0;
  right: 0;
  width: 100%;
  height: 100vh;
  background-color: rgba(255, 255, 255, 0.8);
  backdrop-filter: blur(15px);
  -webkit-backdrop-filter: blur(15px);
  z-index: 100;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 2rem;
  padding: 2rem;
  transform: translateX(100%);
  transition: transform 0.4s cubic-bezier(0.16, 1, 0.3, 1);
  opacity: 0;
  pointer-events: none;
}

[data-theme="dark"] .mobile-menu {
  background-color: rgba(41, 37, 36, 0.8);
}

.mobile-menu.show {
  transform: translateX(0);
  opacity: 1;
  pointer-events: auto;
  display: flex;
}

.mobile-menu a {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  font-family: var(--font-display);
  color: var(--color-text-main);
  text-align: center;
  padding: 0;
  border: none !important;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

.mobile-menu a:hover,
.mobile-menu a.active {
  color: var(--color-primary);
  transform: translateY(-5px);
}

.mobile-menu .btn {
  margin-top: 1rem;
  width: auto;
  min-width: 200px;
}

@media (min-width: 768px) {
  .nav-desktop {
    display: flex;
  }

  .mobile-toggle {
    display: none;
  }

  .mobile-menu {
    display: none !important;
  }
}

/*
==========================================
  Login Page (Split Screen)
==========================================
*/
.login-layout {
  display: grid;
  min-height: 100vh;
  grid-template-columns: 1fr;
}

.login-visual {
  display: none;
  background-image: url('Media/Bilder/Login_New.png');
  /* Bytt bilde */
  /* Keramikk-bilde */
  background-size: cover;
  background-position: center;
  position: relative;
}

.login-visual::after {
  content: '';
  position: absolute;
  inset: 0;
  background: linear-gradient(to bottom, rgba(0, 0, 0, 0.3), rgba(0, 0, 0, 0.6));
}

.login-visual-content {
  position: relative;
  z-index: 10;
  height: 100%;
  display: flex;
  flex-direction: column;
  justify-content: flex-end;
  padding: 4rem;
  color: #ffffff !important;
}

.login-visual-content h1,
.login-visual-content p {
  color: #ffffff !important;
}

.login-form-section {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
  background-color: var(--color-bg-surface);
}

.login-wrapper {
  width: 100%;
  max-width: 400px;
}

@media (min-width: 1024px) {
  .login-layout {
    grid-template-columns: 1.2fr 1fr;
    /* Mer plass til bildet */
  }

  .login-visual {
    display: block;
  }
}

.login-logo {
  display: flex;
  justify-content: center;
  align-items: center;
  margin-bottom: 0.5rem;
}

.login-logo img {
  height: 10rem;
  width: 10rem;
  object-fit: contain;
  border-radius: var(--radius-full);
}

/*
==========================================
  Dashboard (Medlemsside)
==========================================
*/
/*
==========================================
  Dashboard (Medlemsside)
==========================================
*/
.dashboard-grid {
  display: flex;
  flex-direction: column;
  gap: 2rem;
  padding: 1rem 0;
  width: 100%;
  max-width: 100%;
}

.dashboard-sidebar,
.dashboard-sidebar-right,
.dashboard-main {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
  width: 100%;
  min-width: 0;
  margin-top: 0 !important;
  padding-top: 0 !important;
}

.dashboard-main {
  gap: 2rem;
}

.profile-card {
  text-align: center;
}

.profile-avatar {
  width: 6rem;
  height: 6rem;
  border-radius: var(--radius-full);
  object-fit: cover;
  margin: 0 auto 1rem;
  border: 4px solid var(--color-bg-body);
  box-shadow: var(--shadow-md);
}

.profile-stats {
  display: flex;
  justify-content: center;
  gap: 1.5rem;
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.stat-item {
  display: flex;
  flex-direction: column;
}

.stat-value {
  font-weight: 700;
  font-size: 1.1rem;
  color: var(--color-primary);
}

.stat-label {
  font-size: 0.75rem;
  color: var(--color-text-muted);
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.section-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 1.5rem;
}

.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  gap: 0.5rem;
}

.gallery-preview-item {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
}

.gallery-preview-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s;
}

.gallery-preview-item:hover img {
  transform: scale(1.1);
}

.dashboard-sidebar-right {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

@media (min-width: 1024px) {
  .dashboard-grid {
    display: grid;
    grid-template-columns: 300px minmax(0, 1fr) 300px;
    gap: 2rem;
    align-items: start;
    padding-top: 1rem;
    padding-bottom: 2rem;
  }

  .dashboard-sidebar,
  .dashboard-sidebar-right {
    position: sticky;
    top: 5.5rem;
    /* Matches Header 4.5rem + Grid padding 1rem */
    height: fit-content;
    margin-top: 0 !important;
  }
}

/* Admin Control Modal & Trigger */
.admin-trigger-container {
  margin-top: 1rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  display: flex;
  justify-content: center;
}

.admin-panel-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 1rem;
}

@media (min-width: 640px) {
  .admin-panel-grid {
    grid-template-columns: 1fr 1fr;
  }
}

.admin-tool-item {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
  padding: 1.25rem;
  background-color: var(--color-bg-subtle);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-lg);
  transition: var(--transition-base);
  text-align: left;
  gap: 0.5rem;
}

.admin-tool-item:hover {
  border-color: var(--color-primary);
  background-color: var(--color-bg-surface);
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.admin-tool-icon {
  width: 32px;
  height: 32px;
  color: var(--color-primary);
  margin-bottom: 0.5rem;
}

.admin-tool-title {
  font-weight: 600;
  font-size: 1rem;
  color: var(--color-text-main);
  margin: 0;
}

.admin-tool-desc {
  font-size: 0.8rem;
  color: var(--color-text-muted);
  margin: 0;
}

/*
==========================================
  Utilities
==========================================
*/
.hidden {
  display: none !important;
}

.mb-2 {
  margin-bottom: 0.5rem;
}

.mb-4 {
  margin-bottom: 1rem;
}

.mb-6 {
  margin-bottom: 1.5rem;
}

.mt-2 {
  margin-top: 0.5rem;
}

.mt-4 {
  margin-top: 1rem;
}

.mt-6 {
  margin-top: 1.5rem;
}

.mt-8 {
  margin-top: 2rem;
}

/* Modal Tabs */
.modal-tabs-container {
  display: flex;
  gap: 0.75rem;
  margin: 1.5rem 0;
  width: 100%;
  overflow-x: auto;
  scrollbar-width: none;
  -ms-overflow-style: none;
  padding-bottom: 0.5rem;
}

.modal-tabs-container::-webkit-scrollbar {
  display: none;
}

.tab-btn {
  white-space: nowrap;
  flex-shrink: 0;
  background-color: var(--color-bg-subtle) !important;
  border-color: var(--color-border) !important;
}

.tab-btn.active {
  background-color: var(--color-primary) !important;
  color: white !important;
  border-color: var(--color-primary) !important;
}

#tab-add-member {
  margin-left: auto;
}

.bg-subtle {
  background-color: var(--color-bg-subtle);
}

.gallery-delete-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(255, 0, 0, 0.7);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 18px;
  line-height: 1;
  z-index: 10;
}

.gallery-delete-btn:hover {
  background: rgba(255, 0, 0, 0.9);
}

.feed-item {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-xl);
  padding: 1.5rem;
  padding-bottom: 0.75rem;
  /* Less padding to accommodate footer */
  margin-bottom: 2rem;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
  max-width: 100%;
  overflow-wrap: break-word;
}

/* Post Actions (Like/Comment) */
.post-actions {
  display: flex;
  align-items: center;
  gap: 1.5rem;
  padding: 0.75rem 0;
  border-top: 1px solid var(--color-border);
  margin-top: 1rem;
}

.action-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  font-size: 0.9rem;
  font-weight: 500;
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  padding: 0.25rem 0.5rem;
  border-radius: var(--radius-sm);
}

.action-btn:hover {
  background-color: var(--color-bg-body);
  color: var(--color-primary);
}

.action-btn.active {
  color: var(--color-primary);
}

.action-btn i {
  font-size: 1.1rem;
}

/* Quick Comment Bar */
.quick-comment-wrapper {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.75rem 0;
}

.comment-avatar {
  width: 2rem;
  height: 2rem;
  border-radius: var(--radius-full);
  object-fit: cover;
}

.comment-input-bar {
  flex: 1;
  background-color: var(--color-bg-body);
  border: 1px solid var(--color-border-dark);
  border-radius: var(--radius-full);
  padding: 0.5rem 1rem;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: space-between;
  cursor: text;
}

.comment-input-bar input {
  background: none;
  border: none;
  outline: none;
  width: 100%;
  color: var(--color-text-main);
}

.comment-input-bar input::placeholder {
  color: var(--color-text-muted);
}

/* Inline Comments List */
.inline-comments-container {
  padding: 0.5rem 0;
  border-top: 1px solid var(--color-border);
  margin-top: 0.5rem;
  max-height: 400px;
  overflow-y: auto;
}

.inline-comments-container.hidden {
  display: none !important;
}

/* Comment Preview */
.comment-preview {
  font-size: 0.85rem;
  padding: 0.5rem 0;
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.comment-item {
  display: flex;
  gap: 0.75rem;
  margin-bottom: 0.75rem;
}

.comment-content {
  background-color: var(--color-bg-body);
  padding: 0.5rem 0.75rem;
  border-radius: var(--radius-lg);
  flex: 1;
}

.comment-author {
  font-weight: 600;
  margin-right: 0.5rem;
  color: var(--color-text-main);
}

.comment-text {
  color: var(--color-text-muted);
}

.show-more-comments {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 2.5rem;
  height: 2.5rem;
  background: none;
  border: none;
  color: var(--color-text-muted);
  cursor: pointer;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  border-radius: var(--radius-full);
}

.show-more-comments:hover {
  background-color: var(--color-bg-body);
  color: var(--color-primary);
}

.show-more-comments.active svg {
  transform: rotate(180deg);
}

.show-more-comments svg {
  transition: transform 0.3s ease;
}

/* Delete Buttons (Admin) */
.post-delete-btn {
  margin-left: auto;
  background: none;
  border: none;
  cursor: pointer;
  font-size: 1.1rem;
  opacity: 0.4;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  padding: 0.5rem;
  border-radius: var(--radius-md);
}

.post-delete-btn:hover {
  opacity: 1;
  background-color: rgba(220, 38, 38, 0.1);
}

.comment-delete-btn {
  background: none;
  border: none;
  cursor: pointer;
  font-size: 0.8rem;
  opacity: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  padding: 0.25rem;
  border-radius: var(--radius-sm);
  align-self: flex-start;
  margin-top: 0.25rem;
}

.comment-item:hover .comment-delete-btn {
  opacity: 0.4;
}

.comment-item:hover .comment-delete-btn:hover {
  opacity: 1;
  background-color: rgba(220, 38, 38, 0.1);
}

/* Modal Overlay Styling */
div[id$="-modal-overlay"] {
  backdrop-filter: blur(8px) !important;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
}

/* Modal Card Animation */
div[id$="-modal"]:not(.hidden) .card {
  animation: modalAppear 0.3s cubic-bezier(0.34, 1.56, 0.64, 1);
}

@keyframes modalAppear {
  from {
    opacity: 0;
    transform: scale(0.9) translateY(20px);
  }

  to {
    opacity: 1;
    transform: scale(1) translateY(0);
  }
}

/* Modal Scroll Fix */
body.modal-open {
  overflow: hidden;
}

/* 
==========================================
  Gallery & Upload UI Improvements
==========================================
*/

.upload-drop-zone {
  width: 100%;
  min-height: 150px;
  border: 2px dashed var(--color-border);
  border-radius: var(--radius-lg);
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  text-align: center;
  position: relative;
  cursor: pointer;
  background-color: var(--color-bg-subtle);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  padding: 1.5rem;
}

.upload-drop-zone:hover,
.upload-drop-zone.dragover {
  border-color: var(--color-primary);
  background-color: rgba(180, 83, 9, 0.05);
}

.upload-drop-zone input[type="file"] {
  position: absolute;
  inset: 0;
  opacity: 0;
  cursor: pointer;
}

.pending-uploads-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 1rem;
  margin-top: 2rem;
}

.pending-upload-card {
  background-color: var(--color-bg-surface);
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  overflow: hidden;
  display: flex;
  flex-direction: column;
  box-shadow: var(--shadow-sm);
}

.pending-upload-preview {
  width: 100%;
  aspect-ratio: 16/9;
  object-fit: cover;
  border-bottom: 1px solid var(--color-border);
}

.pending-upload-info {
  padding: 0.75rem;
}

.pending-upload-info textarea {
  width: 100%;
  padding: 0.5rem;
  border: 1px solid var(--color-border);
  border-radius: var(--radius-md);
  font-size: 0.8rem;
  line-height: 1.4;
  resize: none;
  background-color: var(--color-bg-subtle);
  color: var(--color-text-main);
}

/* Updated Gallery Grid */
.gallery-preview-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.gallery-item {
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  box-shadow: var(--shadow-sm);
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  position: relative;
}

.gallery-item:hover {
  transform: scale(1.02);
  box-shadow: var(--shadow-md);
}

.gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-delete-btn {
  position: absolute;
  top: 5px;
  right: 5px;
  background: rgba(220, 38, 38, 0.9);
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  opacity: 0;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  z-index: 10;
}

.gallery-item:hover .gallery-delete-btn {
  opacity: 1;
}

/* Lightbox listeners handled in script.js */


/* --- Utility: Subtle Background --- */
.bg-subtle {
  background-color: var(--color-bg-subtle, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--color-border);
}

/* --- Admin List Styles --- */
.admin-list-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 1rem;
  border-radius: var(--radius-md);
  margin-bottom: 0.75rem;
  background-color: var(--color-bg-subtle, rgba(255, 255, 255, 0.05));
  border: 1px solid var(--color-border);
  transition: border-color 0.2s ease, background-color 0.2s ease;
}

.admin-list-item:hover {
  border-color: var(--color-primary);
  background-color: rgba(255, 255, 255, 0.08);
}

/* Custom Checkbox for Gallery Admin */
.admin-gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--radius-md);
  overflow: hidden;
  cursor: pointer;
  border: 2px solid transparent;
  transition: all 0.2s ease;
}

.admin-gallery-item.selected {
  border-color: var(--color-primary);
  box-shadow: 0 0 0 2px var(--color-primary);
}

.admin-gallery-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: opacity 0.2s ease;
}

.admin-gallery-item.selected img {
  opacity: 0.7;
}

.admin-gallery-check {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  width: 1.5rem;
  height: 1.5rem;
  background: rgba(0, 0, 0, 0.5);
  border: 2px solid white;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  color: transparent;
  transition: all 0.2s ease;
  z-index: 5;
}

.admin-gallery-item.selected .admin-gallery-check {
  background: var(--color-primary);
  border-color: var(--color-primary);
  color: white;
}

.modal-container {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 1rem;
}

.modal-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  -webkit-backdrop-filter: blur(8px);
  z-index: -1;
  transition: opacity 0.3s ease;
}

.modal-content {
  position: relative;
  width: 100%;
  max-height: 90vh;
  z-index: 10;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  /* Prevent the card itself from scrolling */
}

/* Ensure the body within a modal card is the scrollable part */
.modal-content .card-body {
  flex: 1;
  overflow-y: auto;
  min-height: 0;
  /* Important for flex scrolling */
}

/* Hide scrollbar ONLY for the document editor as requested */
#doc-entry-modal .modal-content {
  scrollbar-width: none;
  -ms-overflow-style: none;
}

#doc-entry-modal .modal-content::-webkit-scrollbar {
  display: none;
}

/* Scroll Lock */
body.modal-open {
  overflow: hidden !important;
}

/* Modal sizing utilities */
.maxWidth-600 {
  max-width: 600px;
}

.maxWidth-800 {
  max-width: 800px;
}

.lightbox {
  position: fixed;
  inset: 0;
  z-index: 2000;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 2rem;
}

.lightbox-overlay {
  position: absolute;
  inset: 0;
  background-color: rgba(0, 0, 0, 0.85);
  backdrop-filter: blur(8px);
}

.lightbox-content {
  position: relative;
  z-index: 10;
  max-width: 1000px;
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
}

.lightbox-close {
  position: absolute;
  top: 1.5rem;
  right: 1.5rem;
  background: rgba(0, 0, 0, 0.5);
  border: none;
  color: white;
  cursor: pointer;
  opacity: 0.7;
  transition: border-color 0.15s ease, background-color 0.15s ease, box-shadow 0.15s ease;
  width: 44px;
  height: 44px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  z-index: 100;
}

.lightbox-close:hover {
  opacity: 1;
  transform: scale(1.1);
  background: rgba(0, 0, 0, 0.8);
}

.lightbox-image-container {
  max-height: 80vh;
  width: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  border-radius: var(--radius-lg);
  box-shadow: var(--shadow-xl);
}

.lightbox-image-container img {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
}

.lightbox-caption {
  margin-top: 1.5rem;
  color: white;
  text-align: center;
  max-width: 600px;
}

.lightbox-caption p {
  color: white !important;
  font-size: 1.125rem;
  line-height: 1.5;
}

@media (max-width: 768px) {
  .lightbox {
    padding: 1rem;
  }

  .lightbox-close {
    top: 0;
    right: 0;
    background: rgba(0, 0, 0, 0.5);
    padding: 0.5rem;
    border-radius: 0 0 0 10px;
  }
}

/* Global Textarea Resizing Fix (Snappy Resizing & Grip) */
textarea {
  resize: vertical !important;
  min-height: 80px;
  transition: none !important;
  /* Custom Grip Handle */
  background-image: linear-gradient(-45deg, var(--color-text-muted) 1px, transparent 1px, transparent 4px, var(--color-text-muted) 4px, var(--color-text-muted) 5px, transparent 5px, transparent 8px, var(--color-text-muted) 8px, var(--color-text-muted) 9px, transparent 9px);
  background-repeat: no-repeat;
  background-position: bottom 4px right 4px;
  background-size: 12px 12px;
}

/*
 ==========================================
   Arrangementer (Events) Styles
 ==========================================
 */
.tab-header {
  font-size: 1.5rem;
  transition: var(--transition-base);
  padding-bottom: 0.5rem;
  border-bottom: 3px solid transparent;
}

.tab-header.active {
  color: var(--color-primary) !important;
  border-bottom-color: var(--color-primary);
}

.event-card {
  display: flex;
  flex-direction: column;
  background: var(--color-bg-surface);
  border-radius: var(--radius-lg);
  border: 1px solid var(--color-border);
  overflow: hidden;
  transition: var(--transition-base);
  box-shadow: var(--shadow-sm);
}

.event-card:hover {
  box-shadow: var(--shadow-md);
  transform: translateY(-2px);
}

.event-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  background-color: var(--color-bg-subtle);
}

.event-body {
  padding: 1.5rem;
}

.event-meta {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  margin-bottom: 1rem;
  font-size: 0.875rem;
  color: var(--color-text-muted);
}

.event-meta-item {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.event-meta-item svg {
  width: 16px;
  height: 16px;
  opacity: 0.7;
}

.event-title {
  font-size: 1.25rem;
  margin-bottom: 0.75rem;
  color: var(--color-text-main);
}

.event-description {
  font-size: 0.95rem;
  line-height: 1.6;
  color: var(--color-text-muted);
  margin-bottom: 1.5rem;
}

.event-actions {
  display: flex;
  gap: 0.75rem;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
}

.rsvp-status {
  font-size: 0.85rem;
  font-weight: 600;
  padding: 0.35rem 0.75rem;
  border-radius: var(--radius-full);
  margin-left: auto;
  display: flex;
  align-items: center;
  justify-content: center;
  line-height: 1;
}

.rsvp-status.coming {
  background-color: rgba(22, 163, 74, 0.1);
  color: var(--color-success);
}

.rsvp-status.not-coming {
  background-color: rgba(220, 38, 38, 0.1);
  color: var(--color-error);
}

.past-event-card {
  display: grid;
  grid-template-columns: 80px 1fr auto;
  align-items: center;
  gap: 1rem;
  padding: 1rem;
  background: var(--color-bg-subtle);
  border-radius: var(--radius-md);
  border: 1px solid var(--color-border);
}

.past-event-img {
  width: 60px;
  height: 60px;
  object-fit: cover;
  border-radius: var(--radius-sm);
}

.past-event-info h4 {
  font-size: 1rem;
  margin-bottom: 0.25rem;
}

.past-event-info p {
  font-size: 0.8rem;
  margin-bottom: 0;
}

@media (max-width: 640px) {
  .event-card {
    flex-direction: column;
  }

  .event-actions {
    flex-direction: column;
  }

  .rsvp-status {
    margin-left: 0;
    text-align: center;
  }
}

/* --- Collapsible Documents (Referater) --- */
.collapsible-item .collapsible-content {
  display: none;
  padding-top: 1rem;
  border-top: 1px solid var(--color-border);
  margin-top: 1rem;
}

.collapsible-item.expanded .collapsible-content {
  display: block;
  animation: fadeIn 0.3s ease;
}

.collapsible-item .toggle-arrow {
  transition: transform 0.3s ease;
}

.collapsible-item.expanded .toggle-arrow {
  transform: rotate(180deg);
}

.collapsible-header {
  cursor: pointer;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(-5px);
  }

  to {
    opacity: 1;
    transform: translateY(0);
  }
}

/* --- Retningslinjer Tabs --- */
/* --- Retningslinjer Tabs --- */
.tab-btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 0.75rem 1.5rem;
  border-radius: var(--radius-full);
  font-weight: 600;
  font-size: 0.95rem;
  cursor: pointer;
  transition: all 0.2s ease;
  gap: 0.5rem;
  min-width: 120px;
  white-space: nowrap;

  /* Inactive: Clear outline */
  background-color: var(--color-bg-surface) !important;
  color: var(--color-text-main) !important;
  border: 2px solid var(--color-text-muted) !important;
  opacity: 0.7;
}

#retningslinjer-tabs {
  gap: 0.75rem;
}

.tab-btn:hover {
  background-color: var(--color-bg-subtle) !important;
  border-color: var(--color-primary) !important;
  color: var(--color-primary) !important;
  opacity: 1;
  transform: translateY(-1px);
}

.tab-btn.active {
  /* Active: Solid Primary */
  background-color: var(--color-primary) !important;
  color: #ffffff !important;
  border-color: var(--color-primary) !important;
  box-shadow: var(--shadow-md);
  opacity: 1;
  font-weight: 700;
}

.tab-btn.active:hover {
  background-color: var(--color-primary-hover) !important;
  box-shadow: var(--shadow-lg);
}

/* --- Image Cropping & Adjustment --- */
.crop-preview-wrapper {
  position: relative;
  width: 100%;
  max-height: 500px;
  overflow: hidden;
  border-radius: var(--radius-md);
  background-color: var(--color-bg-dark);
  /* Matches site dark elements */
  margin-top: 1rem;
}

.crop-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.7);
  /* Slightly darker for better focus */
  pointer-events: none;
  z-index: 10;
  /* clip-path is updated dynamically by JS */
  clip-path: polygon(0% 0%, 0% 100%, 100% 100%, 100% 0%);
}

.crop-viewport {
  position: absolute;
  left: 0;
  width: 100%;
  border: 2px solid var(--color-primary);
  box-shadow: 0 0 0 1000px rgba(0, 0, 0, 0);
  /* Fallback shadow transparency */
  z-index: 20;
  cursor: ns-resize;
  background: transparent;
  pointer-events: auto;
}

.crop-viewport::after {
  content: "";
  position: absolute;
  inset: 0;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
  pointer-events: none;
}

.crop-viewport.square {
  aspect-ratio: 1 / 1;
}

.crop-viewport.banner {
  aspect-ratio: 2.5 / 1;
}

.crop-viewport.post {
  aspect-ratio: 2 / 1;
}

.crop-hint {
  position: absolute;
  bottom: 0.5rem;
  left: 50%;
  transform: translateX(-50%);
  background: rgba(0, 0, 0, 0.6);
  color: white;
  padding: 0.25rem 0.75rem;
  border-radius: var(--radius-full);
  font-size: 0.75rem;
  z-index: 30;
  pointer-events: none;
}