.painter-button {
    background-color: #444;
    border: 1px solid #555;
    border-radius: 5px;
    color: #fff;
    padding: 6px 14px;
    font-size: 12px;
    font-weight: 550;
    cursor: pointer;
    transition: background 0.3s ease-in-out, border-color 0.3s ease-in-out, opacity 0.3s ease-in-out;
    min-width: 80px;
    text-align: center;
    margin: 2px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
    text-shadow: 0 1px 2px rgb(0,0,0);
}

.painter-button:hover {
    background-color: #555;
    border-color: #666;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

.painter-button:active {
    background-color: #3a3a3a;
    transform: translateY(0);
    box-shadow: inset 0 1px 2px rgba(0,0,0,0.1);
}

.painter-button:disabled,
.painter-button:disabled:hover {
    background-color: #3a3a3a;
    color: #777;
    cursor: not-allowed;
    transform: none;
    box-shadow: none;
    border-color: #4a4a4a;
    opacity: 0.6;
}

.painter-button.primary {
    background-color: #3a76d6;
    border-color: #2a6ac4;
    color: #fff;
    text-shadow: 0 1px 2px rgb(0,0,0);
}

.painter-button.primary:hover {
    background-color: #4a86e4;
    border-color: #3a76d6;
}

/* Crop mode button styling */
.painter-button#crop-mode-btn {
    background-color: #444;
    border-color: #555;
    color: #fff;
    transition: all 0.2s ease-in-out;
}

.painter-button#crop-mode-btn.primary {
    background-color: #0080ff;
    border-color: #0070e0;
    color: #fff;
    box-shadow: 0 0 8px rgba(0, 128, 255, 0.3);
}

.painter-button#crop-mode-btn.primary:hover {
    background-color: #1090ff;
    border-color: #0080ff;
    box-shadow: 0 0 12px rgba(0, 128, 255, 0.4);
}

.painter-button#crop-mode-btn:hover {
    background-color: #555;
    border-color: #666;
}

.painter-button.success {
    border-color: #4ae27a;
    background-color: #444;
    color: #fff;
    box-shadow: 0 0 0 1.5px #4ae27a88;
}
.painter-button.success:hover {
    border-color: #6aff9a;
    box-shadow: 0 0 0 2.5px #6aff9a88;
    background-color: #555;
}

.painter-button.danger {
    border-color: #e24a4a;
    background-color: #444;
    color: #fff;
    box-shadow: 0 0 0 1.5px #e24a4a88;
}
.painter-button.danger:hover {
    border-color: #ff6a6a;
    box-shadow: 0 0 0 2.5px #ff6a6a88;
    background-color: #555;
}

.painter-button.icon-button {
    width: 30px;
    height: 30px;
    min-width: 30px;
    padding: 0;
    font-size: 16px;
    line-height: 30px; /* Match height */
    display: flex;
    align-items: center;
    justify-content: center;
}

.painter-controls {
    background-color: #2f2f2f;
    border-bottom: 1px solid #202020;
    box-shadow: 0 1px 3px rgba(0,0,0,0.2);
    padding: 10px;
    display: flex;
    gap: 8px;
    flex-wrap: wrap;
    align-items: center;
    justify-content: flex-start;
}

.painter-slider-container {
   display: flex;
   flex-direction: column;
   align-items: center;
   gap: 4px;
   color: #fff;
   font-size: 12px;
   min-width: 100px;
}

.painter-slider-container input[type="range"] {
   -webkit-appearance: none;
   width: 80px;
   height: 4px;
   background: #555;
   border-radius: 2px;
   outline: none;
   padding: 0;
   margin: 0;
}

.painter-slider-container input[type="range"]::-webkit-slider-thumb {
  -webkit-appearance: none;
  appearance: none;
  width: 14px;
  height: 14px;
  background: #e0e0e0;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #555;
  transition: background 0.2s;
}

.painter-slider-container input[type="range"]::-webkit-slider-thumb:hover {
  background: #fff;
}

.painter-slider-container input[type="range"]::-moz-range-thumb {
  width: 14px;
  height: 14px;
  background: #e0e0e0;
  border-radius: 50%;
  cursor: pointer;
  border: 2px solid #555;
}

.slider-value {
    font-size: 11px;
    color: #bbb;
    margin-top: 2px;
    min-height: 14px;
    text-align: center;
}

.painter-button-group {
    display: flex;
    align-items: center;
    gap: 4px;
    background-color: transparent;
    padding: 0;
    border-radius: 6px;
}

.painter-clipboard-group {
    display: flex;
    align-items: center;
    gap: 4px;
}

.painter-clipboard-group .painter-button {
    margin: 1px;
    height: 30px; /* Match switch height */
    box-sizing: border-box;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* --- Clipboard Switch Modern --- */
.clipboard-switch {
    position: relative;
    width: 90px;
    height: 30px;
    box-sizing: border-box;
    background: linear-gradient(to right, #5a5a5a 30%, #3a76d6);
    border-radius: 5px;
    border: 1px solid #555;
    cursor: pointer;
    transition: background 0.3s ease-in-out, border-color 0.3s ease-in-out, opacity 0.3s ease-in-out;
    user-select: none;
    padding: 0;
    font-family: inherit;
    font-size: 12px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.1);
}
.clipboard-switch:hover {
    background: linear-gradient(to right, #6a6a6a 30%, #4a86e4);
    border-color: #666;
    box-shadow: 0 2px 4px rgba(0,0,0,0.15);
    transform: translateY(-1px);
}

/* Mask switch: szaro-czarny gradient tylko dla maski */
.clipboard-switch.mask-switch {
    background: linear-gradient(to right, #5a5a5a 30%, #e53935);
}
.clipboard-switch.mask-switch:hover {
    background: linear-gradient(to right, #6a6a6a 30%, #ff5252);
}
.clipboard-switch:active {
    background: linear-gradient(135deg, #3a76d6, #3a3a3a);
}

.clipboard-switch input[type="checkbox"] {
    display: none;
}

.clipboard-switch .switch-track {
    display: none;
}

.clipboard-switch .switch-knob {
    position: absolute;
    top: 2px;
    left: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 24px;
    height: 24px;
    background-color: #5a5a5a;
    border-radius: 4px;
    box-shadow: 0 1px 2px rgba(0,0,0,0.2);
    transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
    z-index: 2;
}

.clipboard-switch:hover .switch-knob {
    background-color: #6a6a6a;
}

.clipboard-switch:hover .switch-knob {
    background-color: #6a6a6a;
}

.clipboard-switch .switch-labels {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 550;
    color: #ffffff;
    pointer-events: none;
    z-index: 1;
    transition: opacity 0.3s ease-in-out;
    text-shadow: 0 1px 2px rgb(0, 0, 0);
}
.clipboard-switch .switch-labels .text-clipspace,
.clipboard-switch .switch-labels .text-system {
    position: absolute;
    transition: opacity 0.2s ease-in-out;
}
.clipboard-switch .switch-labels .text-clipspace { opacity: 0; }
.clipboard-switch .switch-labels .text-system { opacity: 1; padding-left: 20px; }

.clipboard-switch .switch-knob .switch-icon {
    width: 20px;
    height: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.clipboard-switch .switch-knob .switch-icon img {
    width: 100%;
    height: 100%;
}

/* Checked state */
.clipboard-switch:has(input:checked) {
    background: linear-gradient(to right, #3a76d6, #5a5a5a 70%);
    border-color: #2a6ac4;
}
.clipboard-switch:has(input:checked):hover {
    background: linear-gradient(to right, #4a86e4, #6a6a6a 70%);
    border-color: #3a76d6;
}

.clipboard-switch input:checked ~ .switch-knob {
    left: calc(100% - 26px);
}
.clipboard-switch input:checked ~ .switch-knob .switch-icon img {
    filter: none;
}
.clipboard-switch input:checked ~ .switch-labels .text-clipspace {
    opacity: 1;
    color: #fff;
    padding-right: 20px;
}
.clipboard-switch input:checked ~ .switch-labels .text-system {
    opacity: 0;
}

/* Disabled state for switch */
.clipboard-switch.disabled {
    cursor: not-allowed;
    opacity: 0.6;
    background: #3a3a3a !important; /* Override gradient */
    border-color: #4a4a4a !important;
    transform: none !important;
    box-shadow: none !important;
}

.clipboard-switch.disabled .switch-knob {
    background-color: #4a4a4a !important;
}

.clipboard-switch.disabled .switch-labels {
    color: #777 !important;
}



.painter-separator {
    width: 1px;
    height: 24px;
    background-color: #444;
    margin: 0 8px;
}

.painter-container {
    background: #607080;  /* 带蓝色的灰色背景 */
    border: 1px solid #4a5a6a;
    border-radius: 6px;
    box-shadow: inset 0 0 10px rgba(0,0,0,0.1);
    transition: border-color 0.3s ease; /* Dodano dla płynnej zmiany ramki */
}

.painter-container.drag-over {
    border-color: #00ff00; /* Zielona ramka podczas przeciągania */
    border-style: dashed;
}

.painter-dialog {
    background: #404040;
    border-radius: 8px;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    padding: 20px;
    color: #ffffff;
}

.painter-dialog input {
    background: #303030;
    border: 1px solid #505050;
    border-radius: 4px;
    color: #ffffff;
    padding: 4px 8px;
    margin: 4px;
    width: 80px;
}

.painter-dialog button {
    background: #505050;
    border: 1px solid #606060;
    border-radius: 4px;
    color: #ffffff;
    padding: 4px 12px;
    margin: 4px;
    cursor: pointer;
}

.painter-dialog button:hover {
    background: #606060;
}

.blend-opacity-slider {
    width: 100%;
    margin: 5px 0;
    display: none;
}

.blend-mode-active .blend-opacity-slider {
    display: block;
}

.blend-mode-item {
    padding: 5px;
    cursor: pointer;
    position: relative;
}

.blend-mode-item.active {
    background-color: rgba(0,0,0,0.1);
}

.blend-mode-item.active {
    background-color: rgba(0,0,0,0.1);
}

.painter-tooltip {
    position: fixed;
    display: none;
    background: #2B2B2B;
    color: #f0f0f0;
    border: 1px solid #444;
    border-top: 2px solid #4a90e2;
    border-radius: 6px;
    padding: 12px 18px;
    z-index: 9999;
    font-size: 12px;
    line-height: 1.5;
    width: auto;
    max-width: min(450px, calc(100vw - 30px));
    box-shadow: 0 4px 15px rgba(0,0,0,0.3);
    pointer-events: none;
    transform-origin: top left;
    transition: transform 0.2s ease;
    will-change: transform;
}

.painter-tooltip.scale-down {
    transform: scale(0.9);
    transform-origin: top;
}

.painter-tooltip.scale-down-more {
    transform: scale(0.8);
    transform-origin: top;
}

.painter-tooltip table {
    width: 100%;
    border-collapse: collapse;
    margin: 8px 0;
}

.painter-tooltip table td {
    padding: 4px 8px;
    vertical-align: middle;
    transition: background-color 0.2s;
}

.painter-tooltip table td:first-child {
    width: auto;
    white-space: nowrap;
    min-width: fit-content;
}

.painter-tooltip table td:last-child {
    width: auto;
}

.painter-tooltip table tr:nth-child(odd) td {
    background-color: rgba(255, 255, 255, 0.02);
}
.painter-tooltip table tr:hover td {
    background-color: rgba(74, 144, 226, 0.15);
}

@media (max-width: 600px) {
    .painter-tooltip {
        font-size: 11px;
        padding: 8px 12px;
    }
    .painter-tooltip table td {
        padding: 2px 4px;
    }
    .painter-tooltip kbd {
        padding: 1px 4px;
        font-size: 10px;
    }
    .painter-tooltip table td:first-child {
        width: 40%;
    }
    .painter-tooltip table td:last-child {
        width: 60%;
    }
    .painter-tooltip h4 {
        font-size: 12px;
        margin-top: 8px;
        margin-bottom: 4px;
    }
}

@media (max-width: 400px) {
    .painter-tooltip {
        font-size: 10px;
        padding: 6px 8px;
    }
    .painter-tooltip table td {
        padding: 1px 3px;
    }
    .painter-tooltip kbd {
        padding: 0px 3px;
        font-size: 9px;
    }
    .painter-tooltip table td:first-child {
        width: 35%;
    }
    .painter-tooltip table td:last-child {
        width: 65%;
    }
    .painter-tooltip h4 {
        font-size: 11px;
        margin-top: 6px;
        margin-bottom: 3px;
    }
}

.painter-tooltip::-webkit-scrollbar {
    width: 8px;
}

.painter-tooltip::-webkit-scrollbar-track {
    background: #2a2a2a;
    border-radius: 4px;
}

.painter-tooltip::-webkit-scrollbar-thumb {
    background: #555;
    border-radius: 4px;
}

.painter-tooltip::-webkit-scrollbar-thumb:hover {
    background: #666;
}

.painter-tooltip h4 {
    margin-top: 10px;
    margin-bottom: 6px;
    color: #4a90e2;
    border-bottom: 1px solid #4a90e2;
    padding-bottom: 4px;
    font-size: 14px;
    font-weight: 600;
}
.painter-tooltip h4:first-child {
    margin-top: 0;
}

.painter-tooltip ul {
    list-style: none;
    padding-left: 10px;
    margin: 0;
}

.painter-tooltip kbd {
    background-color: #444;
    border: 1px solid #555;
    border-bottom-width: 2px;
    border-radius: 4px;
    padding: 2px 6px;
    font-family: monospace;
    font-size: 11px;
    color: #e0e0e0;
    box-shadow: 0 1px 1px rgba(0,0,0,0.15);
    margin: 0 1px;
    display: inline-block;
    vertical-align: middle;
}

.painter-container.has-focus {
    /* Używamy box-shadow, aby stworzyć efekt zewnętrznej ramki,
       która nie wpłynie na rozmiar ani pozycję elementu. */
    box-shadow: 0 0 0 2px white;
    /* Możesz też zmienić kolor istniejącej ramki, ale box-shadow jest bardziej wyrazisty */
    /* border-color: white; */
}

.painter-button.matting-button {
    position: relative;
    transition: all 0.3s ease;
}

.painter-button.matting-button.loading {
    padding-right: 36px; /* Make space for spinner */
    cursor: wait;
}

.painter-button.matting-button .matting-spinner {
    display: none;
    position: absolute;
    right: 10px;
    top: 50%;
    transform: translateY(-50%);
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    animation: matting-spin 1s linear infinite;
}

.painter-button.matting-button.loading .matting-spinner {
    display: block;
}

@keyframes matting-spin {
    to {
        transform: translateY(-50%) rotate(360deg);
    }
}
.painter-modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw;
    height: 100vh;
    background-color: rgba(0, 0, 0, 0.8);
    z-index: 111;
    display: flex;
    align-items: center;
    justify-content: center;
}

.painter-modal-content {
    width: 90vw;
    height: 90vh;
    background-color: #353535;
    border: 1px solid #222;
    border-radius: 8px;
    box-shadow: 0 5px 25px rgba(0,0,0,0.5);
    display: flex;
    flex-direction: column;
    position: relative;
}

.painterMainContainer {
    display: flex;
    flex-direction: column;
    height: 100%;
    flex-grow: 1;
}

.painterCanvasContainer {
    flex-grow: 1;
    position: relative;
}
