/* 
  Ulepszone style dla aplikacji do kolorowania
  Zoptymalizowane dla urządzeń mobilnych i tabletów
*/

/* ========== ZMIENNE CSS ========== */
:root {
  /* Kolory */
  --primary-color: #FFA38A; /* Przytłumiony pomarańczowy – header, footer, akcenty */
  --secondary-color: #FFD1DC; /* Jasny różowy – tło sekcji, ramki */
  --danger-color: #FF6B6B; /* Czerwień dla przycisków zapisz/usuń (bez zmian) */
  --text-color: #4A4A4A; /* Ciemnoszary – czytelny tekst */
  --bg-color: #FFF0E0; /* Kremowe tło – główne tło strony */
  --light-color: #FFFFFF; /* Czysta biel – dla kontrastu */
  --border-color: #FFD1DC; /* Jasny różowy – granice, ramki */
  --shadow-color: rgba(255, 209, 220, 0.3); /* Lekki różowy cień – subtelne efekty */
  --focus-color: #FFDB7A; /* Przytłumiony żółty – akcent dla stanu aktywnego */
    
    /* Wymiary */
  --header-height: 60px;
  --footer-height: 80px;
  --section-spacing: 1rem;
  --mobile-nav-height: 60px;
    
    /* Wymiary dotykowe */
  --touch-target-size: 44px; /* Minimalny obszar dotyku zgodnie z WCAG */
    
    /* Układ 3-kolumnowy dla desktopów */
  --canvas-width: calc(55% - var(--section-spacing));
  --tools-width: calc(22.5% - var(--section-spacing));
  --gallery-width: var(--tools-width);
}

/* ========== PODSTAWOWE STYLE - MOBILE FIRST ========== */
*,
*::before,
*::after {
  margin: 0;
  padding: 0;
  box-sizing: border-box;
}
body {
  font-family: 'Arial', sans-serif;
  line-height: 1.6;
  color: var(--text-color);
  background-color: var(--bg-color);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  transition: all 0.3s ease;
  overflow-x: hidden;
}
h1,
h2,
h3 {
  margin-bottom: 0.5rem;
}

/* ========== NAGŁÓWEK I NAWIGACJA - DOMYŚLNIE DLA MOBILNYCH ========== */
header {
  background-color: var(--primary-color);
  color: var(--light-color);
  padding: 1rem;
  text-align: center;
  box-shadow: 0 2px 5px var(--shadow-color);
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  z-index: 20;
  height: var(--header-height);
  display: flex;
  justify-content: space-between;
  align-items: center;
}
header h1 {
  font-size: 20px;
  margin: 0;
}
nav#main-nav {
  display: flex;
  justify-content: space-around;
  position: fixed;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: white;
  box-shadow: 0 -2px 5px rgba(0, 0, 0, 0.1);
  padding: 8px 0;
  z-index: 100;
  height: var(--mobile-nav-height);
}
nav#main-nav button {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 24px;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
  min-width: var(--touch-target-size);
  min-height: var(--touch-target-size);
  padding: 0;
}
nav#main-nav button:active {
  transform: scale(0.9);
  color: var(--secondary-color);
}

/* ========== GŁÓWNY UKŁAD - DOMYŚLNIE KOLUMNOWY DLA MOBILNYCH ========== */
main {
  display: flex;
  flex-direction: column;
  flex: 1;
  padding: 0;
  overflow: hidden;
}

/* ========== PRZYCISKI I ELEMENTY INTERAKTYWNE ========== */
main button {
  background-color: var(--light-color);
  border: none;
  padding: 0.5rem 1rem;
  margin: 0.25rem;
  border-radius: 4px;
  cursor: pointer;
  font-size: 1rem;
  color: var(--primary-color);
  box-shadow: 0 2px 5px var(--shadow-color);
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}
main button:hover {
  background-color: #f0f0f0;
  transform: translateY(-2px);
}
main button:active {
  transform: translateY(1px);
}
main button:disabled,
main button.disabled {
  opacity: 0.5;
  cursor: not-allowed;
}
main button:focus {
  outline: 2px solid var(--focus-color);
  outline-offset: 2px;
}
main button i {
  font-size: 0.9rem;
}
.mobile main {
  margin-bottom: var(--mobile-nav-height);
}
.section {
  width: 100%;
  background-color: var(--light-color);
  border-radius: 0;
  box-shadow: none;
  padding: 0.5rem;
}
.column {
  height: auto;
  overflow-y: auto;
}
#gallery.mobile-menu-visible,
#tools-panel.mobile-menu-visible {
  display: block;
  position: fixed;
  top: 0;
  bottom: var(--mobile-nav-height);
  left: 0;
  right: 0;
  background-color: white;
  z-index: 101;
  overflow-y: auto;
  padding: 10px !important;
}

/* ========== STANY WIDOCZNOŚCI I DOSTĘPNOŚĆ ========== */
.hidden {
  display: none !important;
}

/* Tryby dostępności */
.large-text {
  font-size: 1.2rem !important;
}
.large-text h1 {
  font-size: 2.2rem;
}
.large-text h2 {
  font-size: 1.8rem;
}
.large-text h3 {
  font-size: 1.5rem;
}
.large-text button,
.large-text input,
.large-text select {
  font-size: 1.2rem;
}
.high-contrast {
  --primary-color: #0055aa;
  --text-color: #000;
  --bg-color: #fff;
  --light-color: #fff;
  --border-color: #000;
  filter: contrast(150%);
}
.high-contrast header,
.high-contrast footer {
  background-color: #000;
  color: #fff;
}
.high-contrast .section {
  border: 2px solid #000;
}
.high-contrast button {
  background-color: #000;
  color: #fff;
  border: 2px solid #fff;
}
.high-contrast .color {
  border: 3px solid #000;
}
.high-contrast .color.active {
  border: 3px solid #fff;
  outline: 2px solid #000;
}
canvas {
  image-rendering: -webkit-optimize-contrast; /* Dla Safari */
  image-rendering: crisp-edges; /* Zachowuje ostrość pikseli */
  width: 100%;
  height: auto;
  overflow:hidden;
  object-fit: contain;
  object-position: center;
  display: block;
  touch-action: none;
}
/* ========== CANVAS CONTAINER - DOMYŚLNIE DLA MOBILNYCH ========== */
#canvas-container {
  position: relative; /* Aby absolutnie pozycjonowane warstwy miały punkt odniesienia */
  flex: 0 0 100%;
  order: 1;
  height: calc(100vh - 120px);
  border-radius: 8px;
  box-shadow: 0 2px 10px var(--shadow-color);
  box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
  touch-action: manipulation;
}
.canvas-layer {
  position: absolute;
  transform-origin: center!important;
  box-shadow: 0 2px 15px var(--shadow-color);
  cursor: crosshair;
  user-select: none;
  will-change: transform;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}


/* Warstwy canvasu */
#layers-container {
  position: relative;
  overflow:hidden;
  width: 100%;
  height: 100%;
}
#drawing-canvas {
  position: absolute;
  z-index: 1;
}
#outline-canvas {
  position: absolute;
  z-index: 2;
  pointer-events: none;
}
#crosshair-canvas {
  z-index: 3;
  pointer-events: none;
}

/* ========== PRZYCISKI NARZĘDZI - ZOPTYMALIZOWANE DLA DOTYKU ========== */
.mobile .tools-buttons-container .icon-btn {
  width: var(--touch-target-size);
  height: var(--touch-target-size);
  min-width: var(--touch-target-size);
  min-height: var(--touch-target-size);
}
.icon-btn {
  width: 35px;
  height: 35px;
  padding: 0;
  border-radius: 4px;
  background-color: rgba(255, 255, 255, 0.9);
  color: var(--text-color);
  border: 1px solid var(--border-color);
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  transition: all 0.2s ease;
  font-size: 18px;
  margin: 2px;
  gap: 5px;
}
.icon-btn:active {
  transform: scale(0.9);
  background-color: var(--primary-light);
}
.icon-btn.tool.active {
  background-color: var(--primary-color);
  color: white;
  box-shadow: 0 0 5px rgba(66, 133, 244, 0.5);
  border-color: var(--primary-color);
}
.icon-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 2px 5px rgba(0, 0, 0, 0.15);
  background-color: white;
}
.mobile .save-btn-inline,
.tools-divider {
  display: none;
}
/* Style dla przycisków ustawień */
.settings-buttons {
  display: flex;
  gap: 8px;
  margin-top: 8px;
}
.settings-btn {
  background-color: var(--light-color);
  color: var(--primary-color);
  border: 1px solid var(--border-color);
  border-radius: 4px;
  padding: 6px 12px;
  font-size: 0.9rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  width: auto;
  height: auto;
}
.settings-btn:hover {
  background-color: var(--primary-color);
  color: white;
  transform: translateY(-2px);
}
.settings-btn i {
  font-size: 1rem;
}

/* Styl dla label, by wyglądał jak przycisk */
label.settings-btn {
  margin: 0;
  cursor: pointer;
}
/* Style dla poszczególnych grup narzędzi */
.drawing-tools .icon-btn {
  color: #333;
}
.history-tools .icon-btn {
  color: #555;
}
.canvas-tools .icon-btn {
  color: #444;
}
.outline-tools .icon-btn {
  color: #333;
}
.save-tools .icon-btn {
  color: #444;
}

/* Wyróżniony przycisk zapisu */
.save-btn-inline {
  background-color: var(--danger-color) !important;
  color: white !important;
  border-color: var(--danger-color);
}

/* Hover dla przycisku zapisu */
.save-btn-inline:hover {
  background-color: #dc3545 !important;
}

/* Style dla grup przycisków */
.tools-group {
  display: flex;
  gap: 3px;
  border-right: 1px solid rgba(255, 255, 255, 0.15);
  padding-right: 4px;
  margin-right: 4px;
}
.tools-group:last-child {
  border-right: none;
  padding-right: 0;
  margin-right: 0;
}

/* ========== PALETA KOLORÓW - ZOPTYMALIZOWANA DLA DOTYKU ========== */
.color-palette {
  margin-bottom: 1rem;
}
.colors-grid {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  margin-top: 0.5rem;
}
.color {
  width: var(--touch-target-size);
  height: var(--touch-target-size);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s ease;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.5);
  margin: 0 auto;
}
.color:active {
  transform: scale(0.9);
  box-shadow: 0 0 5px var(--shadow-color);
}
.color.active {
  border: 3px solid #333;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.3);
  transform: scale(1.1);
}

/* ========== MOBILNY SELEKTOR KOLORÓW ========== */
#mobile-color-panel {
  position: fixed;
  z-index: 9999;
  background-color: white;
  border-radius: 8px;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.5);
  padding: 15px;
  width: 280px;
  max-width: 90vw;
  transition: opacity 0.3s, transform 0.3s;
}
#mobile-color-panel.hidden {
  opacity: 0;
  transform: scale(0.9);
  pointer-events: none;
}
.mobile-panel-header {
  margin-bottom: 10px;
  text-align: center;
  border-bottom: 1px solid #eee;
  padding-bottom: 5px;
}
.mobile-panel-header h3 {
  margin: 0;
  font-size: 16px;
  color: #333;
}
.mobile-colors-container {
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
}
.mobile-color-btn {
  width: 40px;
  height: 40px;
  border-radius: 4px;
  border: 2px solid #ddd;
  cursor: pointer;
  transition: transform 0.2s, border-color 0.2s;
  margin: 2px;
}
.mobile-color-btn:hover,
.mobile-color-btn:focus {
  transform: scale(1.1);
  box-shadow: 0 0 8px rgba(0, 0, 0, 0.3);
}
.mobile-color-btn.selected {
  border: 3px solid #333;
  box-shadow: 0 0 10px rgba(0, 0, 0, 0.5);
}
.close-panel-btn {
  position: absolute;
  top: -10px;
  right: -10px;
  width: 30px;
  height: 30px;
  border-radius: 50%;
  background-color: #f44336;
  color: white;
  border: none;
  display: flex;
  align-items: center;
  justify-content: center;
  cursor: pointer;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.3);
  font-size: 18px;
}

/* Adnotacja dla trybu pełnoekranowego */
.fullscreen #mobile-color-panel {
  z-index: 10000;
}

/* ========== PRZYCISK PEŁNOEKRANOWY ========== */
#tools-buttons-container {
  transition: transform 0.3s ease, opacity 0.3s ease;
  border-radius: 8px;
  bottom: 0;
  left: 0;
  right: 0;
  background-color: rgba(255, 255, 255, 0.9);
  border-top: 1px solid #ddd;
  padding: 10px;
  box-shadow: 0 -2px 10px rgba(0, 0, 0, 0.1);
  z-index: 100;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  margin: 0 auto;
  position: absolute;
}
#tools-buttons-container.hidden {
  opacity: 0;
  pointer-events: none;
}
#tools-buttons-container.visible {
  opacity: 1;
  pointer-events: auto;
}
.mobile #tools-buttons-container {
  position: fixed;
  bottom: 76px;
}

/* Przycisk fullscreen zawsze widoczny */
#tools-buttons-container.hidden #fullscreen-btn {
  display: flex !important;
  position: fixed;
  bottom: 20px;
  right: 20px;
  opacity: 1;
  pointer-events: auto;
  transform: none;
  z-index: 1000;
  box-shadow: 0 3px 10px rgba(0, 0, 0, 0.3);
}
#tools-buttons-container button::before,
#tools-buttons-container button::after {
  position: absolute;
  left: 50%;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease, transform 0.25s ease;
}

/* Strzałka pod tooltipem */
#tools-buttons-container button::before {
  content: "";
  bottom: calc(100% + 4px);
  transform: translateX(-50%) translateY(5px);
  border-width: 6px;
  border-style: solid;
  border-color: rgba(0, 0, 0, 0.8) transparent transparent transparent;
}
#tools-buttons-container button::after {
  content: attr(title);
  bottom: calc(100% + 10px);
  transform: translateX(-50%) translateY(5px);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 4px 8px;
  border-radius: 4px;
  white-space: nowrap;
  font-size: 12px;
  line-height: 1;
  box-shadow: 0 2px 6px rgba(0,0,0,0.3);
  z-index: 10;
}

/* Stan „hover” – pokazujemy tooltip i strzałkę */
#tools-buttons-container button:hover::before,
#tools-buttons-container button:hover::after {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}
#tools-buttons-container button.active {
  background-color: var(--primary-color);
  color: var(--light-color);
}
.current-color-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
  position: relative;
  cursor: pointer;
}
.current-color-btn span {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  color: rgba(255,255,255,0.8);
  text-shadow: 0 0 2px rgba(0,0,0,0.7);
}
.fullscreen-colors-panel {
  position: absolute;
  top: 60px;
  right: 0;
  background: rgba(255,255,255,0.95);
  border-radius: 8px;
  box-shadow: 0 0 10px rgba(0,0,0,0.3);
  padding: 10px;
  display: grid;
  grid-template-columns: repeat(5, 1fr);
  gap: 8px;
  z-index: 1001;
  max-width: 250px;
  max-height: 400px;
  overflow-y: auto;
}
.fullscreen-colors-header {
  grid-column: 1 / -1;
  font-size: 12px;
  font-weight: bold;
  color: #555;
  margin-top: 10px;
  margin-bottom: 5px;
  padding-top: 5px;
  border-top: 1px solid #ddd;
}
.fullscreen-colors-panel.hidden {
  display: none;
}
.quick-color-btn {
  width: 30px;
  height: 30px;
  border-radius: 50%;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: transform 0.2s, box-shadow 0.2s;
}
.quick-color-btn:hover {
  transform: scale(1.15);
  box-shadow: 0 0 5px rgba(0,0,0,0.3);
}
.quick-color-btn.active {
  border: 2px solid #333;
  box-shadow: 0 0 5px rgba(0,0,0,0.5);
}
.quick-color-btn.history-color {
  width: 25px;
  height: 25px;
  opacity: 0.9;
}        
/* Style dla iframe */
.in-iframe {
  overflow: hidden;
  margin: 0;
  padding: 0;
}
.in-iframe header {
  height: auto;
  padding: 5px;
}
.in-iframe #canvas-container {
  height: 100vh;
  margin: 0;
}

/* ========== WSPÓLNE KONTROLKI SUWAKÓW ========== */
/* Wspólna klasa dla wszystkich kontrolek suwaków */
.slider-control {
  display: flex;
  flex-direction: column;
  margin-bottom: 1rem;
}
.slider-control label {
  margin-bottom: 0.5rem;
  font-weight: 500;
  color: var(--text-color);
  font-size: 0.9rem;
}
.slider-control .slider-row {
  display: flex;
  align-items: center;
  gap: 0.5rem;
}
.slider-control input[type="range"] {
  flex: 1;
  min-width: 0;
  cursor: grab;
  width: 100%;
}
.slider-control .value-display {
  min-width: 1.5rem;
  text-align: right;
  font-family: monospace;
  font-size: 0.9rem;
}

/* Odstępy między sekcjami */
.control-group,
.brush-size,
.tolerance-control,
.filter-settings {
  margin-top: 1.2rem;
  padding-top: 0.8rem;
  border-top: 1px solid var(--border-color);
  flex: 1;
}

/* Style dla nagłówków sekcji */
.section-header {
  margin-bottom: 0.7rem;
  color: var(--primary-color);
  font-size: 1rem;
}
.color-picker-container {
	/* margin-bottom: 1rem; */
  padding: 12px 12px 0;
  background-color: #f8f8f8;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}
#color-preview {
  width: 100%;
  height: 25px;
  border-radius: 4px;
  border: 1px solid #ddd;
  cursor: pointer;
  transition: transform 0.2s;
}
#color-preview:hover {
  transform: scale(1.1);
}
#current-color-value {
  font-family: monospace;
  font-size: 1rem;
  font-weight: bold;
}
#color-picker {
  margin-top: 5px;
}
/* CSS dla kolorów z przezroczystością */

/* Tło szachownicy dla przezroczystych kolorów */
.transparent-color {
  position: relative;
  z-index: 1;
}
.transparent-color::before {
    /*! content: ''; */
    /*! position: absolute; */
    /*! top: 0; */
    /*! left: 0; */
    /*! right: 0; */
    /*! bottom: 0; */
    /*! background-image: linear-gradient(45deg, #ddd 25%, transparent 25%),
                      linear-gradient(-45deg, #ddd 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #ddd 75%),
                      linear-gradient(-45deg, transparent 75%, #ddd 75%); */
    /*! background-size: 10px 10px; */
    /*! background-position: 0 0, 0 5px, 5px -5px, -5px 0px; */
    /*! z-index: -1; */
    /*! border-radius: inherit; */
}

/* Wskaźnik przezroczystości - mała ikonka w rogu */
.transparent-color::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 2;
}

/* Style dla podglądu koloru z przezroczystością */
.color-preview-container {
  position: relative;
  width: 100%;
  height: 100%;
}

/* Szachownica w tle dla aktualnego koloru */
#color-preview.transparent-preview::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: 16px 16px;
  background-position: 0 0, 0 8px, 8px -8px, -8px 0px;
  z-index: -1;
  border-radius: inherit;
}

/* Dodatkowy styl dla tooltipa z informacją o przezroczystości */
.color-tooltip {
  position: absolute;
  bottom: 100%;
  left: 50%;
  transform: translateX(-50%);
  background-color: rgba(0, 0, 0, 0.8);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 12px;
  white-space: nowrap;
  pointer-events: none;
  opacity: 0;
  transition: opacity 0.2s ease;
  z-index: 100;
}
.transparent-color:hover .color-tooltip {
  opacity: 1;
}

/* Style dla mobilnego panelu kolorów */
.mobile-color-btn.transparent-color::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(45deg, #ddd 25%, transparent 25%),
                      linear-gradient(-45deg, #ddd 25%, transparent 25%),
                      linear-gradient(45deg, transparent 75%, #ddd 75%),
                      linear-gradient(-45deg, transparent 75%, #ddd 75%);
  background-size: 8px 8px;
  background-position: 0 0, 0 4px, 4px -4px, -4px 0px;
  z-index: -1;
  border-radius: inherit;
}
/* Dostosowanie wyglądu Pickr */
.pcr-app {
  border-radius: 6px;
  box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}
.pcr-app .pcr-swatches {
  margin-top: 10px;
}

/* Style dla szybkiego wyboru kolorów i historii */
.quick-colors-container,
.color-history-container {
  margin-top: 1rem;
  padding: 12px;
  background-color: #f8f8f8;
  border-radius: 8px;
  border: 1px solid #e0e0e0;
}
.quick-colors-container h4,
.color-history-container h4 {
  margin-top: 0;
  margin-bottom: 8px;
  font-size: 0.9rem;
  color: #555;
}

/* Brush size preview */
.brush-preview {
  display: flex;
  justify-content: center;
  margin-top: 0.5rem;
  padding: 1rem;
  background-color: #f5f5f5;
  border-radius: 4px;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
#brush-preview-circle {
  width: 5px;
  height: 5px;
  background-color: var(--text-color);
  border-radius: 50%;
  transition: all 0.2s ease;
  filter: drop-shadow(0 0 0.5px black);
}

/* Tolerance description */
.tolerance-description {
  font-size: 0.8rem;
  color: #666;
  margin-top: 0.25rem;
}

/* Select control */
.select-control {
  margin-bottom: 1rem;
}
.select-control label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 500;
  font-size: 0.9rem;
}
.select-control select {
  width: 100%;
  padding: 8px;
  border-radius: 4px;
  border: 1px solid var(--border-color);
  background-color: var(--light-color);
  font-size: 0.9rem;
}

/* Checkbox control */
.checkbox-control {
  display: flex;
  align-items: center;
  margin-bottom: 0.5rem;
}
.checkbox-control input[type="checkbox"] {
  margin-right: 0.5rem;
}

/* Wybór koloru konturów */
#outline-color option {
  padding: 4px;
}
#outline-color option[value="purple"] {
  color: #8000ff;
}
#outline-color option[value="blue"] {
  color: #0000ff;
}
#outline-color option[value="red"] {
  color: #ff0000;
}
#outline-color option[value="green"] {
  color: #008000;
}
#outline-color option[value="orange"] {
  color: #ffa500;
}
#outline-color option[value="gray"] {
  color: #808080;
}
#outline-color option[value="black"] {
  color: #000000;
}
#outline-color option[value="white"] {
  color: #ffffff;
  background-color: #eeeeee;
}

/* ========== MINIATURY W GALERII - ZOPTYMALIZOWANE DLA MOBILNYCH ========== */
#gallery-container {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 12px;
  padding: 0.5rem;
}
.thumbnail-wrapper {
  position: relative;
  overflow: hidden;
  border-radius: 4px;
  transition: transform 0.3s ease;
  aspect-ratio: 1;
  box-shadow: rgba(0, 0, 0, 0.24) 0px 3px 8px;
}
.thumbnail {
  width: 100%;
  aspect-ratio: 1/1;
  object-fit: cover;
  border-radius: 4px;
  cursor: pointer;
  transition: transform 0.3s ease;
  border: 2px solid transparent;
}
.thumbnail:active {
  border-color: var(--primary-color);
}
.thumbnail.selected {
  border-color: var(--primary-color);
  box-shadow: 0 0 0 3px rgba(66, 133, 244, 0.3);
}
.desktop .flex-two {
  display:flex;
  gap: 10px;
}
.text-color {color:var(--text-color);}
/* ========== MODALNE OKNA - ZOPTYMALIZOWANE DLA MOBILNYCH ========== */
.modal {
  display: none;
  position: fixed;
  z-index: 1030;
  left: 0;
  top: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  overflow-y: auto;
}
.modal-content {
  background-color: var(--light-color);
  margin: 10% auto;
  padding: 20px;
  border-radius: 8px;
  width: 90%;
  max-width: 600px;
  box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
  position: relative;
}
.mobile .modal-content {
  margin: 5% auto;
  padding: 15px;
  width: 95%;
}

/* Modal potwierdzenia */
.modal-footer {
  margin-top: 1.5rem;
  padding-top: 1rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: center;
  gap: 10px;
}
.confirm-content {
  margin: 1.5rem 0;
  text-align: center;
}
.confirm-buttons {
  display: flex;
  justify-content: space-between;
  gap: 1rem;
}
.confirm-btn,
.cancel-btn {
  padding: 0.5rem 1rem;
  border-radius: 4px;
  cursor: pointer;
  flex: 1;
}
.confirm-btn {
  background-color: var(--primary-color);
  color: white;
  border: none;
}
.cancel-btn {
  background-color: #f1f1f1;
  color: #333;
  border: 1px solid #ddd;
}
.confirm-btn:hover {
  background-color: #3367d6;
}
.cancel-btn:hover {
  background-color: #e0e0e0;
}
.confirm-buttons .close-btn {
  background-color: #f8f8f8;
  color: #333;
  border: 1px solid #ddd;
}
.confirm-buttons .close-btn:hover {
  background-color: #f0f0f0;
}
.confirm-info {
  text-align: center;
}
.confirm-info h3 {
  color: var(--primary-color);
  margin-bottom: 0.5rem;
}

/* Treść pomocy */
.help-content {
  margin: 1.5rem 0;
}
.help-section {
  margin-bottom: 1.5rem;
}
.help-section h3 {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  margin-bottom: 0.5rem;
  color: var(--primary-color);
}
.help-section ul {
  margin-left: 1.5rem;
}
.help-footer {
  margin-top: 1.5rem;
  border-top: 1px solid var(--border-color);
  padding-top: 1rem;
  text-align: center;
}

/* Modal z zapisanymi stanami */
.saved-states-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  max-height: 60vh;
  overflow-y: auto;
  padding: 1rem 0;
}
.saved-state-item {
  display: flex;
  align-items: center;
  padding: 0.5rem;
  border: 1px solid #ddd;
  border-radius: 8px;
  background-color: #f8f8f8;
}
.saved-state-preview {
  width: 120px;
  height: 90px;
  margin-right: 1rem;
  overflow: hidden;
  border-radius: 4px;
  border: 1px solid #ddd;
}
.state-preview-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.saved-state-info {
  flex: 1;
}
.saved-state-info h3 {
  margin: 0;
  font-size: 1rem;
}
.saved-state-info p {
  margin: 0.25rem 0 0;
  font-size: 0.8rem;
  color: #666;
}
.saved-state-actions {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}
.load-state-btn,
.delete-state-btn {
  padding: 0.25rem 0.5rem;
  font-size: 0.85rem;
}
.load-state-btn {
  background-color: var(--primary-color);
  color: white;
}
.delete-state-btn {
  background-color: #f44336;
  color: white;
}

/* Modal z podglądem */
.saved-preview-container {
  text-align: center;
  margin-bottom: 1rem;
  background-color: #f5f5f5;
  padding: 10px;
  border-radius: 4px;
  border: 1px solid #ddd;
}
.saved-state-preview-img {
  max-width: 100%;
  max-height: 200px;
  object-fit: contain;
  border-radius: 4px;
}

/* Większe cele dotykowe dla zamykania modalu */
.close {
  position: absolute;
  top: 10px;
  right: 15px;
  color: #aaa;
  font-size: 28px;
  font-weight: bold;
  cursor: pointer;
  width: var(--touch-target-size);
  height: var(--touch-target-size);
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 50%;
  transition: all 0.2s ease-in-out;
}

/* Przyciski w modalu */
.close-btn {
  background-color: #f1f1f1;
  color: #555;
  padding: 8px 16px;
  border: 1px solid #ddd;
  border-radius: 4px;
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
  min-width: 100px;
  text-align: center;
  margin: 1rem auto 0;
  display: block;
}
.close-btn:hover {
  background-color: #e0e0e0;
  border-color: #ccc;
}
.close-btn:active {
  transform: translateY(1px);
  background-color: #d5d5d5;
}

/* ========== SYSTEM POWIADOMIEŃ - ZOPTYMALIZOWANY DLA MOBILNYCH ========== */
.notifications-container {
  position: fixed;
  top: 20px;
  left: 10px;
  right: 10px;
  z-index: 1000;
  display: flex;
  flex-direction: column;
  gap: 10px;
}
.notification {
  padding: 12px 16px;
  border-radius: 8px;
  color: white;
  animation: fadeIn 0.3s ease-out;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
  display: flex;
  align-items: center;
  justify-content: space-between;
  word-break: break-word;
}
.notification.success {
  background-color: #4caf50;
}
.notification.error {
  background-color: #f44336;
}
.notification.warning {
  background-color: #ff9800;
}
.notification.info {
  background-color: #2196f3;
}
.notification .close-btn {
  background: none;
  border: none;
  color: white;
  cursor: pointer;
  margin-left: 10px;
  font-size: 18px;
  padding: 0;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
@keyframes fadeIn {
  from {
    opacity: 0;
    transform: translateY(10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}
/* Style dla aktywnych kontrolek narzędzi */
.active-tool-control {
  animation: highlight-pulse 2s ease-in-out 1;
  border: 1px solid var(--primary-color);
  box-shadow: 0 0 10px rgba(66, 133, 244, 0.3);
  background-color: rgba(66, 133, 244, 0.05);
  border-radius: 8px;
  padding: 10px;
  transition: all 0.3s ease;
}
.active-tool-control .section-header {
  color: var(--primary-color);
  font-weight: bold;
}
.active-tool-control input[type="range"] {
  accent-color: var(--primary-color);
}
@keyframes highlight-pulse {
  0% {
    transform: translateY(0);
    box-shadow: 0 0 5px rgba(66, 133, 244, 0.2);
  }
  50% {
    transform: translateY(-2px);
    box-shadow: 0 0 15px rgba(66, 133, 244, 0.5);
  }
  100% {
    transform: translateY(0);
    box-shadow: 0 0 5px rgba(66, 133, 244, 0.2);
  }
}

/* Style dla wskaźnika wypełniania */
.fill-indicator-container {
  pointer-events: none;
  z-index: 9999;
}
.fill-indicator {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
}
.percent-label {
  z-index: 10001;
  pointer-events: none;
}
.tolerance-label {
  z-index: 10000;
  pointer-events: none;
}
/* Animacja wyróżnienia przy zmianie wartości */
@keyframes slider-highlight {
  0% {
    background-color: rgba(66, 133, 244, 0.1);
  }
  50% {
    background-color: rgba(66, 133, 244, 0.3);
  }
  100% {
    background-color: rgba(66, 133, 244, 0.1);
  }
}
.highlight-animation {
  animation: slider-highlight 0.8s ease-out;
}

/* Style dla suwaków aktywnego narzędzia */
.active-tool-control input[type="range"] {
  height: 8px;
  cursor: pointer;
  transition: all 0.3s ease;
}
.active-tool-control input[type="range"]::-webkit-slider-thumb {
  width: 18px;
  height: 18px;
  border-radius: 50%;
  background: var(--primary-color);
  box-shadow: 0 0 5px rgba(66, 133, 244, 0.5);
  cursor: pointer;
  transition: all 0.3s ease;
}
.active-tool-control input[type="range"]::-webkit-slider-thumb:hover {
  transform: scale(1.2);
  box-shadow: 0 0 10px rgba(66, 133, 244, 0.8);
}
/* ========== PRZYCISKI STANU CANVASU I POMOCY ========== */
/* Przyciski stanów canvasu */
#toggle-outlines-btn.active,
#enhance-edges-btn.active {
  background-color: var(--primary-color);
  color: white;
}
#enhance-edges-btn.active:hover {
  background-color: #3367d6;
}
@keyframes pulse {
  0% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.1);
  }
  100% {
    transform: scale(1);
  }
}
#toggle-outlines-btn.flashing {
  animation: pulse 1s infinite;
}

/* Przyciski pomocy */
.help-icon-btn {
  background: none;
  border: none;
  color: var(--primary-color);
  font-size: 1.1rem;
  padding: 0;
  cursor: pointer;
  box-shadow: none;
  width: 24px;
  height: 24px;
  display: flex;
  align-items: center;
  justify-content: center;
}
.help-icon-btn:hover {
  color: #3367d6;
  background: none;
  transform: scale(1.1);
}

/* Nagłówki sekcji z przyciskami */
.settings-header,
.tools-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}
.settings-header h3 {
  margin: 0;
}

/* ========== STOPKA ========== */
footer {
  background-color: var(--primary-color);
  color: var(--light-color);
  text-align: center;
  padding: 1rem;
  margin-top: auto;
}
footer a {
  color: var(--light-color);
  text-decoration: underline;
  transition: opacity 0.3s ease;
}
footer a:hover {
  opacity: 0.8;
}

/* Panel dostępności */
.accessibility-panel {
  margin: 0 auto 1rem;
  display: flex;
  justify-content: center;
  flex-wrap: wrap;
  gap: 1rem;
  max-width: 600px;
}
.help-btn,
.accessibility-btn {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem 1rem;
  background-color: rgba(255, 255, 255, 0.2);
  border: 1px solid rgba(255, 255, 255, 0.3);
  border-radius: 4px;
  cursor: pointer;
  color: var(--light-color);
  transition: all 0.3s ease;
}
.help-btn:hover,
.accessibility-btn:hover {
  background-color: rgba(255, 255, 255, 0.3);
}

/* Tooltips */
.tooltip {
  position: relative;
}
.tooltip .tooltip-text {
  visibility: hidden;
  width: 200px;
  background-color: #333;
  color: #fff;
  text-align: center;
  border-radius: 6px;
  padding: 8px;
  position: absolute;
  z-index: 100;
  bottom: 150%;
  left: 50%;
  transform: translateX(-50%);
  opacity: 0;
  transition: opacity 0.3s;
  pointer-events: none;
}
.tooltip:hover .tooltip-text {
  visibility: visible;
  opacity: 1;
}
/* Style dla płynnego przejścia do trybu pełnoekranowego */





/* Animacja dla kontenera narzędzi w trybie pełnoekranowym */
.fullscreen-tools {
  transition: opacity 0.3s ease-in-out, transform 0.3s ease-in-out !important;
}
.fullscreen-color-picker {
  position: fixed;
  right: 20px;
  top:20px;
  z-index: 9999;
  display: flex;
  flex-direction: column;
  align-items: flex-end;
}
.current-color-btn {
  width: 50px;
  height: 50px;
  border-radius: 50%;
  border: 2px solid white;
  box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
  cursor: pointer;
  transition: transform 0.2s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  background-color: #000;
  position: relative;
}
.current-color-btn span {
  opacity: 0.6;
  color: white;
  transition: opacity 0.2s ease;
}
.current-color-btn:hover span {
  opacity: 1;
}
.current-color-btn:hover {
  transform: scale(1.1);
}
.fullscreen-colors-panel {
  display: none;
  background: rgba(40, 40, 40, 0.9);
  border-radius: 10px;
  box-shadow: 0 4px 15px rgba(0, 0, 0, 0.3);
  padding: 15px;
  margin-bottom: 10px;
  max-width: 90vw;
  max-height: 80vh;
  overflow-y: auto;
  width: 320px;
}
.fullscreen-colors-panel.expanded {
  display: block;
  animation: slideUp 0.3s ease-out;
}
@keyframes slideUp {
  0% {
    transform: translateY(20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}
.fullscreen-colors-header {
  color: white;
  font-size: 14px;
  margin-bottom: 10px;
  font-weight: bold;
  padding-bottom: 5px;
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
}
.fullscreen-quick-colors,
.fullscreen-history-colors {
  display: grid;
  grid-template-columns: repeat(6, 1fr);
  gap: 8px;
  margin-bottom: 15px;
}
.quick-color-btn,
.history-color-btn {
  width: 40px;
  height: 40px;
  border-radius: 8px;
  cursor: pointer;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
  border: 2px solid rgba(255, 255, 255, 0.1);
  position: relative;
}
.quick-color-btn:hover,
.history-color-btn:hover {
  transform: scale(1.1);
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.3);
}
.quick-color-btn.active,
.history-color-btn.active {
  border: 2px solid white;
  box-shadow: 0 0 10px rgba(255, 255, 255, 0.5);
}
.fullscreen-opacity-controls {
  display: flex;
  align-items: center;
  color: white;
  margin-top: 10px;
  gap: 8px;
}
.fullscreen-opacity-controls label {
  font-size: 14px;
  min-width: 100px;
}
.fullscreen-opacity-controls input[type="range"] {
  flex: 1;
  height: 6px;
  background: rgba(255, 255, 255, 0.2);
  border-radius: 3px;
  outline: none;
}
.opacity-value {
  min-width: 30px;
  text-align: center;
  font-weight: bold;
}
        
        /* Style dla przezroczystych kolorów w trybie pełnoekranowym */
.quick-color-btn.transparent-color,
.history-color-btn.transparent-color {
  position: relative;
  z-index: 1;
}
.quick-color-btn.transparent-color::before,
.history-color-btn.transparent-color::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-image: linear-gradient(45deg, #444 25%, transparent 25%),
                            linear-gradient(-45deg, #444 25%, transparent 25%),
                            linear-gradient(45deg, transparent 75%, #444 75%),
                            linear-gradient(-45deg, transparent 75%, #444 75%);
  background-size: 10px 10px;
  background-position: 0 0, 0 5px, 5px -5px, -5px 0px;
  z-index: -1;
  border-radius: 6px;
}
        
        /* Wskaźnik przezroczystości */
.quick-color-btn.transparent-color::after,
.history-color-btn.transparent-color::after {
  content: '';
  position: absolute;
  top: 2px;
  right: 2px;
  width: 8px;
  height: 8px;
  background: rgba(255, 255, 255, 0.7);
  border-radius: 50%;
  border: 1px solid rgba(0, 0, 0, 0.3);
  pointer-events: none;
  z-index: 2;
}
/* Ogólna animacja dla elementów w trybie pełnoekranowym */
.fullscreen-element {
  transition: transform  0.5s cubic-bezier(0.4, 0, 0.2, 1)

}

/* Kontener canvas w trybie pełnoekranowym */
#canvas-container.entering-fullscreen {
}
#canvas-container.exiting-fullscreen {
}
#loading-indicator {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
}

/* Styl dla aktywnych przycisków podczas przejścia */
.button-transition {
  transition: background-color 0.3s ease, transform 0.3s ease, box-shadow 0.3s ease;
}

/* Animacja dla powiadomień w trybie pełnoekranowym */
.fullscreen-notification {
  animation: slide-in 0.3s ease-out forwards;
}
@keyframes slide-in {
  0% {
    transform: translateY(-20px);
    opacity: 0;
  }
  100% {
    transform: translateY(0);
    opacity: 1;
  }
}

/* Styl dla elementu podczas ładowania trybu pełnoekranowego */
.fullscreen-loading {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 1000;
  opacity: 0;
  transition: opacity 0.3s ease;
  pointer-events: none;
}
.fullscreen-loading.visible {
  opacity: 1;
}
/* ========== UKRYJ FOOTER NA MOBILNYCH ========== */
footer {
  display: none;
}
.in-iframe #canvas-container {
  width: 100% !important;
  height: calc(100vh - 76px);
}
.in-iframe main,
.in-iframe section
{
  padding:0;
  margin:0
}  
/* ========== MEDIA QUERIES ========== */
/* Bardzo małe ekrany */
@media (max-width: 380px) {
  #gallery-container {
    grid-template-columns: repeat(2, 1fr);
  }
  .colors-grid {
    grid-template-columns: repeat(4, 1fr);
  }
  .color {
    width: 40px;
    height: 40px;
  }
}

/* Orientacja pozioma na mobilnych */
@media (max-width: 768px) and (orientation: landscape) {
  #tools-buttons-container {
    top: auto;
    bottom: 8px;
    left: 50%;
    transform: translateX(-50%);
  }
  #gallery-container {
    grid-template-columns: repeat(6, 1fr);
  }
  #canvas-container {
    height: calc(100vh - var(--header-height) - var(--mobile-nav-height) - 10px);
  }
  .modal-content {
    max-height: 80vh;
    overflow-y: auto;
  }
}

/* Tablet (średnie ekrany) */
@media (min-width: 768px) {
    /* Przywróć układ 2-kolumnowy */
  main {
    flex-direction: row;
    flex-wrap: wrap;
    padding: var(--section-spacing);
    gap: 1rem;
    place-content: start;
  }
  header {
    position: relative;
    height: auto;
  }
  main {
    margin-top: 0;
  }
  #canvas-container {
    flex: 0 0 100%;
    order: 1;
    height: calc(100vh - 120px);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    box-shadow: rgba(0, 0, 0, 0.35) 0px 5px 15px;
    touch-action: manipulation;
  }
  #gallery-container {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
  .colors-grid {
    grid-template-columns: repeat(auto-fill, minmax(44px, 1fr));
  }
  .color {
    width: 32px;
    height: 32px;
  }
  #tools-buttons-container {
    width: auto;
    padding: 8px 12px;
  }
  .tools-divider {
    display: block;
    width: 1px;
    height: 24px;
    background-color: rgba(0,0,0,0.1);
    margin: 0 5px;
  }
    
    /* Pokazuj stopkę */
  footer {
    display: block;
    padding: 1rem;
    margin-top: auto;
  }
  .confirm-content {
    display: flex;
    align-items: center;
    gap: 1rem;
  }
  .saved-preview-container {
    flex: 0 0 40%;
    margin-bottom: 0;
  }
  .confirm-info {
    flex: 1;
    text-align: left;
  }
    
    /* System powiadomień */
  .notifications-container {
    max-width: 300px;
  }
  .mobile .columns-container,
  .in-iframe .columns-container {
    display: flex;
    flex-wrap: wrap; /* Zapewnia responsywność */
    gap: 20px; /* Odstęp między kolumnami */
  }
  .mobile .column-left,
  .in-iframe .column-left,
  .mobile .column-right,
  .in-iframe .column-right {
    flex: 1; /* Obie kolumny zajmują równą przestrzeń */
    min-width: 300px; /* Minimalna szerokość dla responsywności */
  }
}
@media (max-width: 1199px) {
  #gallery,
  #tools-panel {
    display: none;
  }
  #canvas-container {
    flex: initial;
  }
  header,
  footer {
    display: none;
  }
}

/* Desktop (duże ekrany) */
@media (min-width: 1200px) {
    /* Pełny układ 3-kolumnowy */
  #canvas-container {
    flex: 0 0 var(--canvas-width);
  }
    
    /* Ukryj elementy mobilne */
  #tools-close-btn,
  #main-nav,
  #mobile-color-picker-btn,
  #mobile-color-panel {
    display: none;
  }
    /* Styl dla aktywnego przycisku fullscreen */
  #fullscreen-btn.active {
    background-color: var(--primary-color);
    color: white;
  }
  #tools-panel {
    flex: 0 0 var(--tools-width);
    order: 2;
    display: block;
    position: static;
    height: calc(100vh - 120px);
    border-radius: 8px;
    box-shadow: 0 2px 10px var(--shadow-color);
    padding: 1rem !important;
    overflow-y: auto;
  }
  #gallery {
    flex: 0 0 var(--gallery-width);
    order: 0;
    height: calc(100vh - 120px);
    margin-top: 0;
  }
  #gallery-container {
    grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  }
}
/* Poprawka dla obsługi dotyku przycisków */
@media (pointer: coarse) {
    /* Zwiększ obszar docelowy dla dotyku */
  button,
  .tool,
  .color,
  .icon-btn,
  [role="button"] {
    min-width: 44px;
    min-height: 44px;
    touch-action: manipulation;
    position: relative;
    z-index: 10;
  }
    
    /* Usuń animacje hover na urządzeniach dotykowych, które mogą powodować problemy */
  button:hover,
  .tool:hover,
  .color:hover,
  .icon-btn:hover,
  [role="button"]:hover {
    transform: none !important;
  }
    
    /* Dodaj margines między elementami dotykowymi */
  .tool + .tool,
  .color + .color,
  button + button {
    margin-left: 6px;
  }
}
/* High-DPI devices */
@media (-webkit-min-device-pixel-ratio: 2), (min-resolution: 192dpi) {
    /* Zmniejszone cienie i subtelniejsze efekty dla ostrych wyświetlaczy */
  .icon-btn,
  .modal-content,
  .notification {
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.1);
  }
}
