/* Neumorphism Theme for MOD App */

:root {
  /* Brand & Accent Colors */
  --mod-m: #0185C9;
  --mod-o: #0D9488;
  --mod-d: #F3A00A;
  --ps: #F53F5F;
  --primary: #6d5dfc;

  /* Light Theme Tokens */
  --c-bg: #EFF8FE;
  --c-bg-rgb: 239, 248, 254;
  --c-surface: #EFF8FE;
  --c-text-primary: #334155;
  --c-text-secondary: #64748b;
  --c-shadow-light: #FFFFFF;
  --c-shadow-dark: #c8d0e7;

  --shadow-distance: .3rem;
  --shadow: var(--shadow-distance) var(--shadow-distance) calc(var(--shadow-distance) * 2) var(--c-shadow-dark),
            calc(var(--shadow-distance) * -1 / 2) calc(var(--shadow-distance) * -1 / 2) calc(var(--shadow-distance) * 5 / 3) var(--c-shadow-light);
  --inner-shadow: inset var(--shadow-distance) var(--shadow-distance) calc(var(--shadow-distance) * 2) var(--c-shadow-dark),
                  inset calc(var(--shadow-distance) * -1 / 2) calc(var(--shadow-distance) * -1 / 2) calc(var(--shadow-distance) * 5 / 3) var(--c-shadow-light);
}

.dark-mode {
  /* Dark Theme Tokens */
  --c-bg: #1f2937;
  --c-bg-rgb: 31, 41, 55;
  --c-surface: #374151;
  --c-text-primary: #d1d5db;
  --c-text-secondary: #9ca3af;
  --c-shadow-light: #4b5563;
  --c-shadow-dark: #111827;

  --shadow-distance: .2rem;
  --shadow: var(--shadow-distance) var(--shadow-distance) calc(var(--shadow-distance) * 2) var(--c-shadow-dark),
            calc(var(--shadow-distance) * -1) calc(var(--shadow-distance) * -1) calc(var(--shadow-distance) * 2) var(--c-shadow-light);
  --inner-shadow: inset var(--shadow-distance) var(--shadow-distance) calc(var(--shadow-distance) * 2) var(--c-shadow-dark),
                  inset calc(var(--shadow-distance) * -1) calc(var(--shadow-distance) * -1) calc(var(--shadow-distance) * 2) var(--c-shadow-light);
}

.dark-mode .compass-ring-label,
.dark-mode .compass-label {
  fill: var(--c-text-primary);
}

.dark-mode .admin-backdrop {
  background: rgba(var(--c-bg-rgb), 0.8);
}

.dark-mode #admin-title,
.dark-mode .admin-control label,
.dark-mode .admin-questions thead {
  color: var(--c-text-primary);
}


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

html {
  box-sizing: border-box;
  font-size: 62.5%;
  background: var(--c-bg);
}

body {
  font-family: 'Inter', sans-serif;
  color: var(--c-text-primary);
  line-height: 1.6;
}

#app {
  min-height: 100dvh;
  display: grid;
  align-content: start;
}

.container {
  max-width: 90rem;
  margin: 2.5rem auto;
  padding: 4rem;
  border-radius: 3rem;
  background: var(--c-bg);
  box-shadow: var(--shadow);
  position: relative;
}

.stack-lg {
  display: grid;
  gap: 2.5rem;
}

h1, h2, h3 {
  line-height: 1.2;
  margin: 0 0 .5rem;
  color: var(--c-text-primary);
}
h1 { font-size: 2.25rem; color: var(--mod-o); }
h2 { font-size: 1.75rem; }
h3 { font-size: 1.25rem; }
p { margin: 0 0 .75rem; }

.intro-text {
  font-size: 1.6rem;
  max-width: 60ch;
  margin: 2rem auto;
}

/* App Header */
.app-header {
  text-align: center;
  position: relative; /* Add position relative */
}

.dark-mode-toggle {
  position: absolute;
  top: 2rem;
  right: 7rem; /* Adjusted position for more space */
  width: 4rem;
  height: 4rem;
  z-index: 10;
}

.dark-mode-toggle svg {
  width: 2rem;
  height: 2rem;
  fill: var(--c-text-primary);
}

.dark-mode .dark-mode-toggle svg {
  fill: var(--c-text-primary);
}

/* Admin Panel */



.admin-toggle {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  box-shadow: var(--shadow);
  display: none !important; /* Hidden by default, overriding other styles */
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  color: var(--c-text-primary);
  transition: all .5s ease;
  position: absolute;
  top: 2rem;
  right: 2rem;
  border: none;
  background: transparent;
  z-index: 10;
}

.scope-tabs {
  width: 30rem;
  height: 4rem;
  box-shadow: var(--shadow);
  border-radius: 1rem;
  display: flex;
  align-items: center;
  position: relative;
  margin: 2rem auto;
}

.scope-tabs input {
  display: none;
}

.scope-tabs > input:checked + label {
  transition: all .5s ease;
  color: var(--mod-o);
}

.scope-tab {
  width: 10rem;
  height: 3.6rem;
  font-size: 1.4rem;
  display: flex;
  justify-content: center;
  align-items: center;
  cursor: pointer;
  color: var(--c-text-primary);
  transition: all .5s ease;
  z-index: 1;
  background: none;
  border: none;
}

.scope-tab:hover {
  color: var(--mod-o);
}

.scope-tabs-highlight {
  position: absolute;
  height: 3.4rem;
  width: 9.4rem;
  margin-left: .3rem;
  border-radius: .8rem;
  box-shadow: var(--inner-shadow);
  pointer-events: none;
  transition: transform 0.3s cubic-bezier(0.645, 0.045, 0.355, 1);
  z-index: 0;
}

#tab-individ:checked ~ .scope-tabs-highlight {
  transform: translateX(0);
}
#tab-team:checked ~ .scope-tabs-highlight {
  transform: translateX(10rem);
}
#tab-ledning:checked ~ .scope-tabs-highlight {
  transform: translateX(20rem);
}

/* Compass */
.compass-shell {
  display: flex;
  justify-content: center;
  align-items: center;
  padding-block: 1.5rem 1rem; /* Revert padding */
}

.compass {
  width: 20rem;
  height: 20rem;
  justify-self: center;
  border-radius: 50%;
  display: flex;
  justify-content: center;
  align-items: center;
  position: relative;
}

#mod-compass {
  width: 100%;
  height: 100%;
}

.compass-outer { cursor: pointer; }
.compass-ring {
  fill: none;
  stroke: var(--ps);
  stroke-width: 22;
  transition: filter 120ms ease-out, opacity 120ms ease-out, stroke-width 120ms ease-out;
}
.compass-ring-label { font-size: 8px; font-weight: 600; letter-spacing: .14em; text-transform: uppercase; fill: var(--c-shadow-light); }
.compass-segment {
  cursor: pointer;
  transition: filter 120ms ease-out, opacity 120ms ease-out;
  stroke: none; /* Remove stroke */
}

.compass-segment--m { 
  fill: var(--mod-m); 
}
.compass-segment--o { 
  fill: var(--mod-o); 
}
.compass-segment--d { 
  fill: var(--mod-d); 
}

.compass-segment:hover { filter: brightness(1.1); }
.compass-outer:not(.is-disabled):hover .compass-ring {
  stroke-width: 24;
  filter: brightness(1.02) drop-shadow(0 0 3px rgba(13, 148, 136, 0.8));
}
.compass-segment.is-disabled, .compass-outer.is-disabled { opacity: 0.4; cursor: default; }
.compass-label { font-size: 18px; font-weight: 700; fill: var(--c-shadow-light); pointer-events: none; }


/* Workspace & Cards */
.workspace {
  padding-bottom: 3rem;
}

.grid-3 {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(25rem, 1fr));
  gap: 2.5rem;
}

.card--glass {
  border-radius: 1.5rem;
  box-shadow: var(--shadow);
  padding: 1.5rem;
  transition: .3s ease;
  display: flex;
  flex-direction: column;
}

.card-header {
  display: flex;
  align-items: flex-start;
  justify-content: space-between;
  gap: .75rem;
  margin-bottom: 1.5rem;
}

.card-title {
  font-size: 1.6rem;
  font-weight: 700;
}

.card--trygghet .card-title { color: var(--ps); }
.card--m .card-title { color: var(--mod-m); }
.card--o .card-title { color: var(--mod-o); }
.card--d .card-title { color: var(--mod-d); }

.card-subtitle {
  font-size: 1.2rem;
  color: var(--c-text-primary);
}

.card-close {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  color: var(--c-text-primary);
  transition: all .5s ease;
  border: none;
  background: transparent;
}
.card-close:active {
  box-shadow: var(--inner-shadow);
  color: var(--primary);
}

.card-close-icon {
  font-size: 2.5rem;
  line-height: 1;
}

.card-body {
  display: flex;
  flex-direction: column;
  flex-grow: 1;
  gap: 1.5rem;
  font-size: 1.4rem;
}

.card-body > p:first-child {
  flex-grow: 1;
}

.question-box {
  border-radius: 1rem;
  font-size: 1.4rem;
  padding: 1.4rem;
  box-shadow: var(--inner-shadow);
  background: none;
  font-family: inherit;
  color: var(--c-text-primary);
  position: relative; /* Add position relative */
  padding-bottom: 4rem; /* Add padding to make space for the button */
}

.icon-button.question-box__deep-btn {
  position: absolute;
  bottom: 1rem;
  right: 1rem;
  width: 3rem; /* Match card-close button size */
  height: 3rem; /* Match card-close button size */
}

.icon-button.question-box__deep-btn svg {
  width: 2rem; /* Match card-close icon size */
  height: 2rem; /* Match card-close icon size */
}

.question-text, .deep-question {
  margin: 0;
  color: var(--c-text-primary);
}

.deep-question {
  display: none;
  margin-top: 1rem;
  font-style: italic;
}
.deep-question.is-visible { display: block; }

.card-actions {
  display: flex;
  justify-content: flex-start; /* Changed from flex-end */
}

.icon-buttons {
  display: flex;
  gap: 1.5rem;
}

.icon-button {
  width: 4rem;
  height: 4rem;
  border-radius: 50%;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  color: var(--c-text-primary);
  transition: all .5s ease;
  border: none;
  background: transparent;
}
.icon-button:active {
  box-shadow: var(--inner-shadow);
  color: var(--primary);
}
.icon-button:hover {
  color: var(--primary);
}
.icon-button svg {
  width: 2rem;
  height: 2rem;
}
.icon-button svg path {
  stroke: currentColor;
}

/* Admin Panel */
.admin-backdrop {
  position: fixed;
  inset: 0;
  display: flex;
  align-items: flex-start;
  justify-content: center;
  background: rgba(228, 235, 245, 0.8);
  backdrop-filter: blur(6px);
  z-index: 20;
  padding: 5vh 2rem;
  overflow-y: auto;
}

/* Footer */
.app-footer {
  text-align: center;
  padding: 2rem 0;
  font-size: 1.2rem;
  color: var(--c-text-secondary);
}

.app-footer p {
  margin: 0;
}

.admin-panel {
  width: min(75rem, 92vw);
  border-radius: 3rem;
  box-shadow: var(--shadow);
  padding: 4rem;
  display: grid;
  grid-template-rows: auto 1fr;
  gap: 2.5rem;
  margin-bottom: auto;
}

.admin-panel__header {
  display: flex;
  align-items: center;
  justify-content: space-between;
}

#admin-title {
  font-size: 1.6rem;
  color: var(--mod-o); /* Changed to green */
}

.admin-close {
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  box-shadow: var(--shadow);
  display: flex;
  justify-content: center;
  align-items: center;
  font-size: 2rem;
  cursor: pointer;
  color: var(--c-text-primary);
  transition: all .5s ease;
  border: none;
  background: transparent;
}
.admin-close:active {
  box-shadow: var(--inner-shadow);
  color: var(--primary);
}

.admin-panel__body {
  overflow: auto;
  display: grid;
  gap: 1.5rem;
  font-size: 1.4rem;
}

.admin-panel__controls {
  display: flex;
  gap: 3rem;
}

.admin-control label {
  font-size: 1.4rem;
  margin-bottom: 1rem;
  display: block;
  color: var(--mod-o); /* Changed to green */
}

.admin-select {
  width: 20.4rem;
  height: 4rem;
  border: none;
  border-radius: 1rem;
  font-size: 1.4rem;
  padding-left: 1.4rem;
  box-shadow: var(--inner-shadow);
  background: none;
  font-family: inherit;
  color: var(--c-text-primary);
  -webkit-appearance: none;
  appearance: none;
}

.admin-questions {
  margin-top: .25rem;
  border-radius: 1rem;
  padding: 1.4rem;
  box-shadow: var(--inner-shadow);
}

.admin-questions table {
  width: 100%;
  border-collapse: collapse;
  font-size: 1.2rem;
}
.admin-questions th, .admin-questions td {
  padding: .5rem;
  text-align: left;
}
.admin-questions thead {
  color: var(--mod-o); /* Changed to green */
}
.admin-questions tbody tr + tr {
  border-top: 1px solid var(--c-shadow-dark);
}

.admin-question-form {
  margin-top: 1.5rem;
  display: grid;
  gap: 1rem;
}

.admin-question-form__title {
  font-size: 1.4rem;
  margin: 0 0 0.5rem;
  color: var(--mod-o);
}

.admin-question-form__field label {
  display: block;
  font-size: 1.2rem;
  color: var(--c-text-muted);
}

.admin-question-form__field textarea {
  width: 100%;
  margin-top: 0.4rem;
  border-radius: 1rem;
  border: none;
  padding: 0.8rem 1rem;
  font-family: inherit;
  font-size: 1.3rem;
  box-shadow: var(--inner-shadow);
  background: transparent;
  color: var(--c-text-primary);
  resize: vertical;
}

.admin-question-form__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.admin-questions__actions {
  display: flex;
  justify-content: flex-end;
  gap: 0.5rem;
}

.admin-question-add,
.admin-question-edit,
.admin-question-delete,
.admin-question-save,
.admin-question-cancel {
  padding: 0.4rem 1.1rem;
  border-radius: 999px;
  border: none;
  font-size: 1.2rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  background: var(--c-surface);
  color: var(--mod-o);
  transition: all 0.2s ease;
  white-space: nowrap;
}

.admin-question-add,
.admin-question-save {
  color: var(--mod-o);
}

.admin-question-edit {
  color: var(--mod-m);
}

.admin-question-delete {
  color: var(--mod-d);
}

.admin-question-cancel {
  color: var(--c-text-muted);
}

.admin-question-add:hover,
.admin-question-edit:hover,
.admin-question-delete:hover,
.admin-question-save:hover,
.admin-question-cancel:hover {
  box-shadow: var(--shadow-strong);
}

.admin-question-add:active,
.admin-question-edit:active,
.admin-question-delete:active,
.admin-question-save:active,
.admin-question-cancel:active {
  box-shadow: var(--inner-shadow);
}

.admin-export {
  display: grid;
  gap: 0.75rem;
  margin-top: 1.5rem;
  padding: 1.4rem;
  border-radius: 1rem;
  box-shadow: var(--inner-shadow);
  background: var(--c-surface);
}

.admin-export__header {
  display: flex;
  align-items: center;
  gap: 1rem;
}

.admin-export__header h3 {
  font-size: 1.4rem;
  margin: 0;
}

.admin-export__button {
  padding: 0.6rem 1.4rem;
  border-radius: 999px;
  border: none;
  margin-left: auto;
  font-size: 1.2rem;
  font-weight: 500;
  cursor: pointer;
  box-shadow: var(--shadow);
  background: var(--c-surface);
  color: var(--mod-o);
  transition: all 0.2s ease;
}

.admin-export__button:hover {
  box-shadow: var(--shadow-strong);
}

.admin-export__button:active {
  box-shadow: var(--inner-shadow);
}

.admin-export__hint {
  font-size: 1.2rem;
  color: var(--c-text-muted);
}

.admin-export__output {
  width: 100%;
  min-height: 10rem;
  border-radius: 1rem;
  border: none;
  padding: 1rem 1.2rem;
  font-family: ui-monospace, SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
  font-size: 1.2rem;
  box-shadow: var(--inner-shadow);
  background: transparent;
  color: var(--c-text-primary);
  resize: vertical;
}

.admin-export__path {
  font-size: 1.1rem;
  color: var(--mod-o);
}

.admin-export__help-button {
  width: 2.4rem;
  height: 2.4rem;
  border-radius: 999px;
  border: none;
  margin-left: 0.5rem;
  margin-right: 0.5rem;
  display: inline-flex;
  align-items: center;
  justify-content: center;
  font-size: 1.4rem;
  font-weight: 600;
  cursor: pointer;
  box-shadow: var(--shadow);
  background: var(--c-surface);
  color: var(--c-text-secondary);
  transition: all 0.2s ease;
}

.admin-export__help-button:hover {
  box-shadow: var(--shadow-strong);
  color: var(--mod-o);
}

.admin-export__help-button:active {
  box-shadow: var(--inner-shadow);
}

.admin-export__help {
  font-size: 1.2rem;
  color: var(--c-text-secondary);
  padding-left: 1.4rem;
}

.admin-export__help ol {
  padding-left: 1.6rem;
}

.admin-export__help li + li {
  margin-top: 0.25rem;
}

/* Mobile Responsiveness */
@media (max-width: 600px) {
  /* Reduce container padding */
  .container {
    padding: 1.5rem;
    margin: 1rem auto;
    border-radius: 2rem;
  }

  /* Make tabs fluid and smaller */
  .scope-tabs {
    width: 100%;
    height: auto;
    min-height: 4rem;
    margin: 1rem auto;
  }

  .scope-tab {
    width: 33.33%; /* Distribute space evenly */
    font-size: 1.3rem;
  }

  .scope-tabs-highlight {
    width: 32%; /* Adjust highlight width to match tab */
    margin-left: 0.5%; /* Adjust centering */
  }

  /* Adjust highlight translation for percentage widths */
  #tab-individ:checked ~ .scope-tabs-highlight {
    transform: translateX(0);
  }
  #tab-team:checked ~ .scope-tabs-highlight {
    transform: translateX(100%);
  }
  #tab-ledning:checked ~ .scope-tabs-highlight {
    transform: translateX(200%);
  }

  /* Scale down compass */
  .compass {
    width: 16rem;
    height: 16rem;
  }

  .compass-label {
    font-size: 16px;
  }

  .compass-ring-label {
    font-size: 7px;
  }

  /* Improve touch targets */
  .card-close, 
  .icon-button {
    width: 4rem;
    height: 4rem;
  }
  
  .card-close-icon {
    font-size: 2.8rem;
  }

  /* Stack grid columns sooner if needed */
  .grid-3 {
    grid-template-columns: 1fr;
  }

  /* Adjust header */
  h1.app-title {
    font-size: 2rem;
  }

  .app-header {
    padding-top: 4rem; /* Reserve space for top-right buttons */
    margin-bottom: 1rem;
  }

  .intro-text {
    font-size: 1.4rem;
  }

  /* Dark mode toggle position */
  .dark-mode-toggle {
    top: 0;
    right: 0;
  }
  
  .admin-toggle {
    top: 0;
    right: 4.5rem; /* Move it left of the dark mode toggle */
  }
}