/**
 * responsive.css - Responsiv design for Bildegenerator
 *
 * Breakpoints:
 * - xs: 480px (mobil portrait)
 * - sm: 640px (mobil landscape / liten tablet)
 * - md: 768px (tablet)
 * - lg: 1024px (stor tablet / liten desktop)
 * - xl: 1280px (desktop)
 * - 2xl: 1536px (stor desktop)
 *
 * @author SANZERO DESIGN AS
 * @version 2.0.0 - Mobil-first oppdatering
 */

/* =============================================================================
   BOTTOM NAVIGATION - Hvit pill med sort oval indikator
   ============================================================================= */

.bottom-nav {
  display: none;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  z-index: var(--z-sticky);
  padding: 20px 16px calc(20px + env(safe-area-inset-bottom, 0));
  background: transparent;
}

/* Ytre wrapper for pill + more-btn - responsiv til skjermbredde */
.bottom-nav-wrapper {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 12px;
  width: calc(100% - 32px);
  max-width: 420px;
  margin: 0 auto;
}

/* Pill-formet container for de 4 hovedknappene - HVIT bakgrunn */
.bottom-nav-container {
  position: relative;
  display: flex;
  align-items: center;
  background-color: #FFFFFF;
  border-radius: 50px;
  padding: 8px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.12);
  border: 1px solid rgba(0, 0, 0, 0.06);
}

/* Animert pill-indikator - SORT oval som glir */
.bottom-nav-indicator {
  position: absolute;
  height: calc(100% - 16px);
  background-color: #1F2937;
  border-radius: 50px;
  transition: transform 0.3s cubic-bezier(0.4, 0, 0.2, 1), width 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 0;
  top: 8px;
  left: 8px;
  pointer-events: none;
}

/* Nav item - kun ikon som standard (mørk farge på hvit bakgrunn) */
.bottom-nav-item {
  position: relative;
  z-index: 1;
  display: flex;
  flex-direction: row;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 18px;
  background: none;
  border: none;
  cursor: pointer;
  color: rgba(31, 41, 55, 0.5);
  transition: color 0.3s ease;
  -webkit-tap-highlight-color: transparent;
  border-radius: 50px;
  outline: none;
  min-height: 48px; /* Touch target minimum */
}

.bottom-nav-item:focus,
.bottom-nav-item:focus-visible {
  outline: none;
}

.bottom-nav-item:active {
  transform: scale(0.95);
}

/* Aktiv item - HVIT tekst og ikon på SORT bakgrunn */
.bottom-nav-item.active {
  color: #FFFFFF;
}

.bottom-nav-item.active .bottom-nav-icon {
  stroke: #FFFFFF;
}

/* Vis tekst kun når aktiv */
.bottom-nav-label {
  font-size: 14px;
  font-weight: var(--font-weight-semibold);
  line-height: 1;
  white-space: nowrap;
  max-width: 0;
  overflow: hidden;
  opacity: 0;
  transition: max-width 0.3s ease, opacity 0.3s ease;
}

.bottom-nav-item.active .bottom-nav-label {
  max-width: 80px;
  opacity: 1;
}

.bottom-nav-icon {
  width: 24px;
  height: 24px;
  stroke: currentColor;
  transition: stroke 0.3s ease;
  flex-shrink: 0;
}

/* "Mer"-knapp - separat SORT sirkel til høyre */
.bottom-nav-item.more-btn {
  width: 56px;
  height: 56px;
  padding: 0;
  border-radius: 50%;
  background-color: #1F2937;
  color: rgba(255, 255, 255, 0.7);
  flex-shrink: 0;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.15);
}

.bottom-nav-item.more-btn:active {
  background-color: #374151;
  transform: scale(0.95);
}

.bottom-nav-item.more-btn .bottom-nav-icon {
  width: 24px;
  height: 24px;
  stroke: rgba(255, 255, 255, 0.7);
}

/* Skjul label på more-btn */
.bottom-nav-item.more-btn .bottom-nav-label {
  display: none;
}

/* =============================================================================
   TABLET (max-width: 1024px)
   ============================================================================= */

@media (max-width: 1024px) {
  /* Sidebar skjules som standard */
  .sidebar {
    transform: translateX(-100%);
    height: 100vh;
    height: 100dvh; /* Dynamisk viewport for mobil */
    max-height: -webkit-fill-available;
    overflow-y: auto;
    padding-bottom: env(safe-area-inset-bottom, 0);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Sidebar nav - scroll med plass til footer */
  .sidebar-nav {
    flex: 1;
    min-height: 0; /* Viktig for flex scroll */
    overflow-y: auto;
  }

  /* Sidebar footer - alltid synlig i bunn, over bottom nav */
  .sidebar-footer {
    flex-shrink: 0;
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
  }

  /* Bakgrunnoverlay når sidebar er åpen */
  .sidebar-backdrop {
    position: fixed;
    inset: 0;
    background-color: rgba(0, 0, 0, 0.5);
    z-index: calc(var(--z-sticky) - 1);
    opacity: 0;
    visibility: hidden;
    transition: all var(--transition-normal);
  }

  .sidebar-backdrop.visible {
    opacity: 1;
    visibility: visible;
  }

  /* Vis toggle-knapper */
  .sidebar-toggle {
    display: flex;
  }

  .menu-toggle {
    display: flex;
  }

  /* Hovedinnhold tar full bredde */
  .main-content {
    margin-left: 0;
  }

  /* Upload-grid blir en kolonne på mindre skjermer */
  .upload-grid {
    grid-template-columns: 1fr;
  }

  /* Resultat-grid blir responsiv */
  .result-grid {
    grid-template-columns: repeat(2, 1fr);
  }
}

/* =============================================================================
   MOBIL - Vis bottom navigation (max-width: 640px)
   ============================================================================= */

@media (max-width: 640px) {
  /* Vis bottom navigation - kun når ikke skjult (utlogget) */
  .bottom-nav:not([hidden]) {
    display: block;
  }

  /* Vis Google innloggingsknapp på mobil */
  .btn.btn-google-login {
    display: inline-flex !important;
  }

  /* =========================================
     SIDEBAR MOBIL-OPTIMALISERING
     ========================================= */

  /* Sidebar - sikre at footer alltid er synlig */
  .sidebar {
    display: flex;
    flex-direction: column;
  }

  .sidebar-header {
    flex-shrink: 0;
  }

  .user-section {
    flex-shrink: 0;
  }

  .sidebar-nav {
    flex: 1;
    min-height: 0;
    overflow-y: auto;
  }

  .sidebar-footer {
    flex-shrink: 0;
    background-color: var(--color-bg-primary);
    border-top: 1px solid var(--color-border-light);
    padding-bottom: calc(80px + env(safe-area-inset-bottom, 0));
  }

  /* Model selector - mer synlig på mobil */
  .model-selector {
    padding: var(--spacing-sm) 0;
  }

  .toggle-label {
    font-size: var(--font-size-sm);
  }

  .toggle-option {
    padding: var(--spacing-xs) var(--spacing-sm);
    font-size: var(--font-size-xs);
  }

  /* Current model tekst - mer plass */
  .current-model {
    padding-bottom: var(--spacing-md);
  }

  /* =========================================
     INNSTILLINGER MODAL MOBIL
     ========================================= */

  .settings-sidebar {
    padding: var(--spacing-xs) var(--spacing-sm);
    position: relative;
  }

  /* Gradient-fade på høyre side for å vise at det er mer å scrolle */
  .settings-sidebar::after {
    content: '';
    position: absolute;
    top: 0;
    right: 0;
    bottom: 0;
    width: 40px;
    background: linear-gradient(to right, transparent, var(--color-bg-primary));
    pointer-events: none;
    z-index: 1;
  }

  .settings-nav {
    display: flex;
    flex-direction: row;
    flex-wrap: nowrap;
    gap: 6px;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    padding: 4px 40px 4px 0; /* Ekstra padding til høyre for gradient */
    scrollbar-width: none;
    -ms-overflow-style: none;

    /* Scroll snap - knapper snapper til venstre kant */
    scroll-snap-type: x mandatory;
    scroll-behavior: smooth;
  }

  .settings-nav::-webkit-scrollbar {
    display: none;
  }

  .settings-nav-item {
    flex-shrink: 0;
    padding: 10px 14px;
    font-size: 13px;
    border-radius: var(--radius-full);
    background-color: var(--color-bg-secondary);

    /* Snap til venstre kant */
    scroll-snap-align: start;
    border: 1px solid var(--color-border);
  }

  .settings-nav-item.active {
    background-color: var(--color-accent);
    color: white;
    border-color: var(--color-accent);
  }

  .settings-nav-item.active svg {
    stroke: white;
  }

  .settings-nav-item svg {
    width: 16px;
    height: 16px;
  }

  /* Logged out overlay - 100% viewport på mobil */
  .logged-out-overlay {
    position: fixed;
    height: 100vh;
    height: 100dvh;
    overflow: hidden;
  }

  .logged-out-content {
    padding: var(--spacing-md);
    max-height: 100%;
    justify-content: center;
  }

  .logged-out-image {
    max-width: 280px;
    margin-bottom: var(--spacing-md);
  }

  .logged-out-image img {
    max-height: 30vh;
  }

  .logged-out-text h2 {
    font-size: var(--font-size-xl);
    margin-bottom: var(--spacing-xs);
  }

  .logged-out-text p {
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-sm);
  }

  /* Skjul hamburger-meny (bruker bottom nav istedet) */
  .menu-toggle {
    display: none !important;
  }

  /* Juster hovedinnhold for bottom nav */
  .main-content {
    padding-bottom: calc(64px + env(safe-area-inset-bottom, 0));
  }

  /* Header - forenklet på mobil */
  .header {
    padding: 0 var(--spacing-md);
    height: 56px;
  }

  .page-title {
    font-size: var(--font-size-lg);
    font-weight: var(--font-weight-semibold);
  }

  /* Toast over bottom nav */
  .toast-container {
    bottom: calc(72px + env(safe-area-inset-bottom, 0));
    left: var(--spacing-md);
    right: var(--spacing-md);
  }

  .toast {
    max-width: none;
    width: 100%;
  }

  /* Loading overlay - juster for bottom nav */
  .loading-overlay .loading-content {
    margin-bottom: 80px;
  }

  /* Content wrapper - full bredde på mobil */
  .content-wrapper {
    padding: var(--spacing-sm);
    max-width: 100%;
    overflow-x: hidden;
  }

  /* Main content - hindre horisontal overflow */
  .main-content {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* Body og HTML - hindre horisontal scroll */
  html, body {
    overflow-x: hidden;
    max-width: 100vw;
  }

  /* ===========================================
     MILJØBILDER - MOBIL FIX
     Forhindre horisontal overflow
     =========================================== */

  /* Hovedcontainer - hindre overflow */
  #area-miljo {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
  }

  /* Alle seksjoner i Miljøbilder */
  #area-miljo .upload-single,
  #area-miljo .mode-section,
  #area-miljo .prompt-section,
  #area-miljo .angle-section,
  #area-miljo .format-section,
  #area-miljo .action-section,
  #area-miljo .result-section {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Textarea - hindre at placeholder skaper overflow */
  #area-miljo .prompt-input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Prompt-input-wrapper */
  #area-miljo .prompt-input-wrapper {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  /* Mode-section - full bredde på mobil */
  .mode-section {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  /* Mode-buttons - 2x2 grid på mobil */
  .mode-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-sm);
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
    box-sizing: border-box;
  }

  .mode-btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    justify-content: center;
    padding: var(--spacing-sm);
    text-align: center;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mode-btn span {
    font-size: var(--font-size-sm);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Angle-section - hindre overflow */
  #area-miljo .angle-selector {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-sm);
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
    box-sizing: border-box;
  }

  #area-miljo .angle-checkbox {
    width: 100%;
    min-width: 0;
  }

  #area-miljo .angle-box {
    width: 100%;
    box-sizing: border-box;
    overflow: hidden;
  }

  #area-miljo .angle-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Angle-actions */
  #area-miljo .angle-actions {
    display: flex;
    gap: var(--spacing-sm);
    flex-wrap: wrap;
  }

  /* Format-buttons i Miljøbilder */
  #area-miljo .format-buttons {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: auto;
    box-sizing: border-box;
  }
}

/* =============================================================================
   MOBIL LANDSCAPE (max-width: 768px)
   ============================================================================= */

@media (max-width: 768px) {
  :root {
    --spacing-lg: 1rem;
    --spacing-xl: 1.5rem;
  }

  /* Header justeringer */
  .header {
    padding: 0 var(--spacing-md);
  }

  .page-title {
    font-size: var(--font-size-lg);
  }

  /* Innholdswrapper */
  .content-wrapper {
    padding: var(--spacing-md);
  }

  /* Area header */
  .area-header h2 {
    font-size: var(--font-size-xl);
  }

  /* Format-knapper - horisontal scroll på mobil */
  .format-buttons {
    gap: var(--spacing-xs);
    flex-wrap: nowrap;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
    scrollbar-width: none;
    -ms-overflow-style: none;
    padding-bottom: var(--spacing-xs);
  }

  .format-buttons::-webkit-scrollbar {
    display: none;
  }

  .format-btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
    flex-shrink: 0;
  }

  /* Miljøbilder - full bredde */
  #area-miljo {
    width: 100%;
    max-width: 100%;
  }

  #area-miljo .upload-single,
  #area-miljo .prompt-section.large {
    max-width: 100%;
  }

  /* Modus-knapper - 2x2 grid */
  .mode-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-sm);
    width: 100%;
  }

  .mode-btn {
    width: 100% !important;
    justify-content: center;
    padding: var(--spacing-sm);
    box-sizing: border-box;
  }

  .mode-btn span {
    font-size: var(--font-size-sm);
  }

  /* Vinkelvelger - 2x2 grid */
  .angle-selector {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: var(--spacing-sm);
    width: 100%;
  }

  .angle-checkbox {
    width: 100%;
  }

  .angle-checkbox .angle-box {
    padding: var(--spacing-sm);
    width: 100%;
    box-sizing: border-box;
  }

  .angle-name {
    font-size: var(--font-size-sm);
  }

  .angle-desc {
    font-size: var(--font-size-xs);
  }

  /* Resultat-grid blir en kolonne */
  .result-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-md);
  }

  /* Historikk-grid */
  .history-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
  }

  /* Knapper - full bredde */
  .btn-large {
    width: 100%;
  }

  /* Resultat-aksjoner - vertikal stacking */
  .result-actions {
    flex-direction: column;
    gap: var(--spacing-sm);
  }

  .result-actions .btn {
    width: 100%;
  }

  /* Fargevelger - kompakt */
  .color-buttons {
    gap: var(--spacing-sm);
  }

  .color-btn {
    padding: var(--spacing-sm);
  }

  .color-preview {
    width: 40px;
    height: 40px;
  }

  .color-label {
    font-size: var(--font-size-xs);
  }

  /* Prompt textarea */
  .prompt-input {
    font-size: 16px; /* Hindrer zoom på iOS */
  }

  /* Sammenligning - vertikal på mobil */
  .comparison-container {
    flex-direction: column;
    gap: var(--spacing-md);
  }

  .comparison-divider {
    transform: rotate(90deg);
  }

  .comparison-image {
    width: 100%;
  }
}

/* =============================================================================
   MOBIL PORTRAIT (max-width: 480px)
   ============================================================================= */

@media (max-width: 480px) {
  :root {
    --font-size-base: 0.9375rem;
    --spacing-md: 0.75rem;
  }

  /* Sidebar fullskjerm på mobil */
  .sidebar {
    width: 100%;
  }

  /* Logo */
  .logo-text {
    font-size: var(--font-size-sm);
  }

  /* Header - kompakt */
  .header {
    height: 52px;
  }

  .page-title {
    font-size: var(--font-size-base);
  }

  .header-actions {
    gap: var(--spacing-xs);
  }

  /* Innholdswrapper - mindre padding */
  .content-wrapper {
    padding: var(--spacing-sm);
  }

  /* Area header */
  .area-header {
    margin-bottom: var(--spacing-md);
  }

  .area-header h2 {
    font-size: var(--font-size-lg);
  }

  .area-description {
    font-size: var(--font-size-sm);
  }

  /* Dropzones - mer kompakt */
  .dropzone {
    min-height: 140px;
    padding: var(--spacing-md);
  }

  .dropzone-icon svg {
    width: 32px;
    height: 32px;
  }

  .dropzone-text {
    font-size: var(--font-size-sm);
  }

  .dropzone-subtext {
    font-size: var(--font-size-xs);
    display: none; /* Skjul undertekst på små skjermer */
  }

  /* Upload-kort titler */
  .upload-title {
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-sm);
  }

  /* Section titles */
  .section-title {
    font-size: var(--font-size-sm);
    margin-bottom: var(--spacing-sm);
  }

  .section-description {
    font-size: var(--font-size-xs);
    margin-bottom: var(--spacing-sm);
  }

  /* Prompt input */
  .prompt-input {
    min-height: 100px;
    font-size: 16px; /* Hindrer zoom på iOS */
    padding: var(--spacing-sm);
  }

  .prompt-input.large {
    min-height: 120px;
  }

  /* Format-knapper - kompakt horisontal scroll */
  .format-buttons {
    gap: 6px;
    padding: 2px 0;
  }

  .format-btn {
    padding: 8px 12px;
    font-size: var(--font-size-xs);
    min-width: auto;
  }

  /* ===========================================
     MILJØBILDER - 480px FIX
     =========================================== */

  #area-miljo {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
    box-sizing: border-box;
  }

  #area-miljo .upload-single,
  #area-miljo .mode-section,
  #area-miljo .prompt-section,
  #area-miljo .angle-section,
  #area-miljo .format-section {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  #area-miljo .prompt-input {
    width: 100% !important;
    max-width: 100% !important;
    box-sizing: border-box;
  }

  /* Mode-section - full bredde */
  .mode-section {
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }

  /* Modus-knapper - 2x2 grid, enda mer kompakt */
  .mode-buttons {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
    width: 100% !important;
    max-width: 100% !important;
    overflow: hidden;
    box-sizing: border-box;
  }

  .mode-btn {
    width: 100% !important;
    min-width: 0 !important;
    max-width: 100% !important;
    padding: 8px;
    justify-content: center;
    box-sizing: border-box;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .mode-btn svg {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
  }

  .mode-btn span {
    font-size: var(--font-size-xs);
    overflow: hidden;
    text-overflow: ellipsis;
  }

  /* Angle-selector - 2x2 grid */
  #area-miljo .angle-selector {
    display: grid !important;
    grid-template-columns: repeat(2, 1fr) !important;
    gap: 6px;
    width: 100% !important;
    overflow: hidden;
  }

  #area-miljo .angle-checkbox {
    width: 100%;
    min-width: 0;
  }

  #area-miljo .angle-box {
    width: 100%;
    box-sizing: border-box;
  }

  /* Vinkelvelger - kompakt */
  .angle-checkbox .angle-box {
    padding: var(--spacing-sm);
    gap: 4px;
  }

  .angle-checkbox .angle-box svg {
    width: 20px;
    height: 20px;
  }

  .angle-name {
    font-size: var(--font-size-xs);
  }

  .angle-desc {
    display: none; /* Skjul beskrivelse på små skjermer */
  }

  /* Fargevelger - enda mer kompakt */
  .color-buttons {
    gap: 6px;
    justify-content: space-between;
  }

  .color-btn {
    padding: 6px;
    flex: 1;
    max-width: 70px;
  }

  .color-preview {
    width: 32px;
    height: 32px;
    border-radius: var(--radius-sm);
  }

  .color-label {
    font-size: 10px;
  }

  /* Generer-knapp */
  .action-section {
    margin: var(--spacing-md) 0;
  }

  .btn-large {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
  }

  /* Resultat-visning */
  .result-section {
    margin-top: var(--spacing-md);
  }

  .result-image img {
    border-radius: var(--radius-md);
  }

  .result-actions {
    gap: var(--spacing-xs);
    margin-top: var(--spacing-sm);
  }

  .result-actions .btn {
    padding: var(--spacing-sm) var(--spacing-md);
    font-size: var(--font-size-sm);
  }

  /* Historikk-grid */
  .history-section {
    margin-top: var(--spacing-lg);
  }

  .history-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: var(--spacing-sm);
  }

  .history-item {
    border-radius: var(--radius-md);
  }

  /* Loading overlay */
  .loading-content {
    margin: var(--spacing-md);
    padding: var(--spacing-md);
  }

  .spinner {
    width: 32px;
    height: 32px;
  }

  .loading-text {
    font-size: var(--font-size-sm);
  }

  .loading-subtext {
    font-size: var(--font-size-xs);
  }

  /* Lightbox */
  .lightbox {
    padding: var(--spacing-sm);
  }

  .lightbox-close {
    top: var(--spacing-sm);
    right: var(--spacing-sm);
  }

  /* Modal tilpasninger */
  .modal {
    margin: var(--spacing-sm);
    max-height: calc(100vh - 80px - env(safe-area-inset-bottom, 0));
  }

  .modal-header h3 {
    font-size: var(--font-size-base);
  }

  .modal-body {
    padding: var(--spacing-sm);
  }

  .favorite-preview img {
    max-height: 120px;
  }

  /* Favoritt-kort */
  .favorite-prompts-grid {
    grid-template-columns: 1fr;
    gap: var(--spacing-sm);
  }

  .favorite-prompt-card {
    padding: var(--spacing-sm);
  }

  .card-image img {
    height: 80px;
  }

  .card-name {
    font-size: var(--font-size-sm);
  }

  .card-prompt {
    font-size: var(--font-size-xs);
    -webkit-line-clamp: 2;
  }

  /* Prompt-historikk */
  .prompt-history {
    gap: var(--spacing-xs);
  }

  .prompt-history-item {
    padding: var(--spacing-sm);
    font-size: var(--font-size-xs);
  }

  /* Juster prompt seksjon */
  .adjust-prompt-section {
    padding: var(--spacing-sm);
  }

  .adjust-prompt-section textarea {
    min-height: 80px;
    font-size: 16px;
  }

  /* Bottom nav - tilpasninger for små skjermer */
  .bottom-nav {
    padding: 16px 12px calc(16px + env(safe-area-inset-bottom, 0));
  }

  .bottom-nav-wrapper {
    gap: 8px;
    width: calc(100% - 24px);
  }

  .bottom-nav-container {
    padding: 4px;
  }

  .bottom-nav-item {
    padding: 8px 10px;
    gap: 4px;
  }

  .bottom-nav-icon {
    width: 18px;
    height: 18px;
  }

  .bottom-nav-label {
    font-size: 10px;
  }

  .bottom-nav-indicator {
    height: calc(100% - 8px);
    top: 4px;
    left: 4px;
  }

  .bottom-nav-item.more-btn {
    width: 40px;
    height: 40px;
  }

  .bottom-nav-item.more-btn .bottom-nav-icon {
    width: 16px;
    height: 16px;
  }
}

/* =============================================================================
   TOUCH DEVICE OPTIMALISERING
   ============================================================================= */

@media (hover: none) and (pointer: coarse) {
  /* Større klikkmål for touch */
  .btn {
    min-height: 44px;
    min-width: 44px;
  }

  .nav-link {
    min-height: 44px;
  }

  .format-btn {
    min-height: 44px;
    padding: var(--spacing-sm) var(--spacing-md);
  }

  .mode-btn {
    min-height: 44px;
  }

  .color-btn {
    min-height: 44px;
    min-width: 44px;
  }

  .angle-checkbox .angle-box {
    min-height: 60px;
  }

  /* Bottom nav items - touch-vennlig */
  .bottom-nav-item {
    min-height: 44px;
  }

  .bottom-nav-item.more-btn {
    min-width: 44px;
    min-height: 44px;
  }

  /* Vis alltid aksjonsknapper */
  .preview .remove-btn {
    opacity: 1;
  }

  .result-item .download-btn {
    opacity: 1;
  }

  .history-item-overlay {
    opacity: 1;
  }

  /* Dropzone - større touch-target */
  .dropzone {
    min-height: 160px;
  }

  /* Fjern hover-effekter som ikke fungerer på touch */
  .dropzone:hover {
    border-color: var(--color-border);
    background-color: transparent;
  }

  .dropzone.drag-over {
    border-color: var(--color-accent);
    background-color: var(--color-accent-light);
  }

  .result-image img:hover {
    transform: none;
  }

  .history-item:hover {
    transform: none;
    box-shadow: none;
  }

  /* Aktiv-tilstand for touch feedback */
  .btn:active:not(:disabled) {
    transform: scale(0.97);
    opacity: 0.9;
  }

  .format-btn:active,
  .mode-btn:active,
  .color-btn:active {
    transform: scale(0.97);
  }

  .dropzone:active {
    border-color: var(--color-accent);
    background-color: var(--color-accent-light);
  }

  /* Forbedre scrolling */
  .format-buttons,
  .history-grid,
  .result-grid {
    -webkit-overflow-scrolling: touch;
  }
}

/* =============================================================================
   STORE SKJERMER (min-width: 1536px)
   ============================================================================= */

@media (min-width: 1536px) {
  :root {
    --max-content-width: 1600px;
  }

  .upload-grid {
    gap: var(--spacing-xl);
  }

  .history-grid {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  }

  .result-grid {
    gap: var(--spacing-lg);
  }
}

/* =============================================================================
   REDUSERT BEVEGELSE
   ============================================================================= */

@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }

  .spinner {
    animation: none;
    border-top-color: var(--color-accent);
  }
}

/* =============================================================================
   DARK MODE SUPPORT (valgfritt)
   ============================================================================= */

@media (prefers-color-scheme: dark) {
  /* Kun aktiver hvis brukeren ønsker dark mode */
  /* Kommentert ut - kan aktiveres ved behov */
  /*
  :root {
    --color-bg-primary: #1F2937;
    --color-bg-secondary: #111827;
    --color-bg-hover: #374151;
    --color-border: #374151;
    --color-border-light: #1F2937;

    --color-text-primary: #F9FAFB;
    --color-text-secondary: #9CA3AF;
    --color-text-muted: #6B7280;

    --color-accent-light: rgba(59, 130, 246, 0.2);
  }
  */
}

/* =============================================================================
   PRINT STYLES
   ============================================================================= */

@media print {
  .sidebar,
  .header,
  .loading-overlay,
  .toast-container,
  .lightbox,
  .btn,
  .dropzone-content,
  .action-section {
    display: none !important;
  }

  .main-content {
    margin-left: 0;
  }

  .area-content {
    display: block !important;
    page-break-after: always;
  }

  .result-image img,
  .history-item img {
    max-width: 100%;
    page-break-inside: avoid;
  }
}

/* =============================================================================
   HIGH CONTRAST MODE
   ============================================================================= */

@media (prefers-contrast: high) {
  :root {
    --color-border: #000000;
    --color-text-secondary: #000000;
  }

  .btn-primary {
    border: 2px solid #000000;
  }

  .btn-secondary {
    border-width: 2px;
  }

  .dropzone {
    border-width: 3px;
  }

  .format-btn,
  .mode-btn {
    border-width: 2px;
  }
}
