.wyswietlana-tresc h3::selection,
.wysiwyg-editor h3::selection,
.wyswietlana-tresc h2::selection,
.wysiwyg-editor h2::selection,
.wyswietlana-tresc h1::selection,
.wysiwyg-editor h1::selection,
.gradient-zloty::selection,
.gradient-czerwony::selection {
    -webkit-text-fill-color: #ffffff;
    color: #ffffff;
    background: #6b0f1a;
}

.wyswietlana-tresc h3::-moz-selection,
.wysiwyg-editor h3::-moz-selection,
.wyswietlana-tresc h2::-moz-selection,
.wysiwyg-editor h2::-moz-selection,
.wyswietlana-tresc h1::-moz-selection,
.wysiwyg-editor h1::-moz-selection,
.gradient-zloty::-moz-selection,
.gradient-czerwony::-moz-selection {
    color: #ffffff;
}


.edytor-toolbar {
    display: flex;
    flex-wrap: wrap;
    gap: 5px;
    margin-bottom: 10px;
    padding: 10px;
    background: rgba(50, 0, 0, 0.7);
    border: 1px solid #bd4534;
    border-radius: 6px;
}

.edytor-btn {
    background: linear-gradient(180deg, #bd4534, #9a2c2c);
    color: #f3e1be;
    border: 1px solid #d5bd8a;
    padding: 8px 12px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    text-shadow: 1px 1px 0 #000;
    font-size: 14px;
    min-width: 40px;
}

.edytor-btn:hover {
    background: linear-gradient(180deg, #f03a3a, #9a1a1a);
    transform: translateY(-2px);
}

.edytor-btn.active {
    background: linear-gradient(180deg, #d5bd8a, #bda45c);
    color: #6b0f1a;
    border-color: #f3e1be;
}


.wysiwyg-editor {
    width: 100%;
    padding: 12px;
    background: rgba(50, 0, 0, 0.7);
    border: 1px solid #bd4534;
    border-radius: 6px;
    color: #f3e1be;
    font-size: 16px;
    min-height: 200px;
    resize: vertical;
    overflow-y: auto;
    text-align: center;
}

.wysiwyg-editor:focus {
    outline: none;
    border-color: #d5bd8a;
}


.wyswietlana-tresc {
    text-align: center;
    width: 100%;
}


.wyswietlana-tresc h1,
.wysiwyg-editor h1 {
    font-size: 24px;
    background: #CEA565;
    background: linear-gradient(360deg, rgba(206, 165, 101, 1) 0%, rgba(252, 238, 204, 1) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 20px 0;
    padding: 5px;
    text-align: center;
    display: block;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}


.wyswietlana-tresc h2,
.wysiwyg-editor h2 {
    font-size: 24px;
    background: #B34B40;
    background: linear-gradient(360deg, rgba(179, 75, 64, 1) 0%, rgba(230, 154, 142, 1) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    margin: 15px 0;
    padding: 5px;
    text-align: center;
    display: block;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.5);
}


.wyswietlana-tresc h3,
.wysiwyg-editor h3 {
    font-size: 16px;
    text-transform: uppercase;
    color: #f3e1be;
    margin: 10px 0;
    padding: 5px;
    text-align: center;
    display: block;
    font-weight: bold;
    text-shadow: 1px 1px 0 #000;
}


.wyswietlana-tresc .gradient-zloty,
.wysiwyg-editor .gradient-zloty {
    background: #CEA565;
    background: linear-gradient(360deg, rgba(206, 165, 101, 1) 0%, rgba(252, 238, 204, 1) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline;
}

.wyswietlana-tresc .gradient-czerwony,
.wysiwyg-editor .gradient-czerwony {
    background: #B34B40;
    background: linear-gradient(360deg, rgba(179, 75, 64, 1) 0%, rgba(230, 154, 142, 1) 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    display: inline;
}


.wyswietlana-tresc strong,
.wysiwyg-editor strong {
    font-weight: bold;
    color: #d5bd8a;
}

.wyswietlana-tresc em,
.wysiwyg-editor em {
    font-style: italic;
    color: #f3e1be;
}

.wyswietlana-tresc u,
.wysiwyg-editor u {
    text-decoration: underline;
    text-decoration-color: #bd4534;
}


.wyswietlana-tresc p,
.wysiwyg-editor p {
    text-align: center;
    margin: 10px 0;
    line-height: 1.6;
}


.wyswietlana-tresc ul,
.wyswietlana-tresc ol,
.wysiwyg-editor ul,
.wysiwyg-editor ol {
    text-align: center;
    list-style-position: inside;
    padding: 0;
    margin: 10px 0;
}

.wyswietlana-tresc li,
.wysiwyg-editor li {
    text-align: center;
    margin: 5px 0;
}


.wyswietlana-tresc div,
.wysiwyg-editor div {
    text-align: center;
}

.edytor-btn.active {
    background: linear-gradient(180deg, #d5bd8a, #bda45c);
    color: #fff;
    border-color: #fff;
    box-shadow: 0 0 10px rgba(213, 189, 138, 0.8);
}

.card-title i {
    font-style: italic;
    color: #d5bd8a;
    opacity: 0.8;
}


.modal-large {
    max-width: 900px;
}

.image-library-tabs {
    display: flex;
    border-bottom: 1px solid #ddd;
    margin-bottom: 20px;
}

.tab-btn {
    padding: 10px 20px;
    background: none;
    border: none;
    border-bottom: 2px solid transparent;
    cursor: pointer;
    font-weight: 500;
    color: #666;
    transition: all 0.3s;
}

.tab-btn:hover {
    color: #4a6cf7;
}

.tab-btn.active {
    color: #4a6cf7;
    border-bottom-color: #4a6cf7;
}

.tab-content {
    display: none;
    min-height: 400px;
}

.tab-content.active {
    display: block;
}


.upload-area {
    border: 2px dashed #4a6cf7;
    border-radius: 10px;
    padding: 40px 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    margin-bottom: 20px;
}

.upload-area:hover {
    background-color: rgba(74, 108, 247, 0.05);
}

.upload-area.highlight {
    background-color: rgba(74, 108, 247, 0.1);
    border-color: #2e4bd1;
}

.upload-area i {
    font-size: 48px;
    color: #4a6cf7;
    margin-bottom: 15px;
}

.upload-area p {
    margin: 5px 0;
    color: #666;
}

.upload-hint {
    font-size: 14px;
    color: #888;
}

.upload-info {
    margin-top: 20px;
    font-size: 12px;
    color: #777;
}

.upload-info i {
    margin-right: 5px;
}

#fileInput {
    display: none;
}


.preview-container {
    margin-bottom: 20px;
}

.preview-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 15px;
    margin: 15px 0;
}

.preview-item {
    position: relative;
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
}

.preview-item img {
    width: 100%;
    height: 120px;
    object-fit: cover;
}

.preview-info {
    padding: 8px;
    font-size: 12px;
    background: #f5f5f5;
}

.preview-info span {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.preview-remove {
    position: absolute;
    top: 5px;
    right: 5px;
    width: 24px;
    height: 24px;
    background: rgba(255, 0, 0, 0.8);
    border: none;
    border-radius: 50%;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}


.frame-selection {
    margin: 20px 0;
    padding: 15px;
    background: #f9f9f9;
    border-radius: 8px;
}

.frame-selection label {
    display: block;
    margin-bottom: 10px;
    font-weight: 500;
}

.frame-options {
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
}

.frame-option {
    flex: 1;
    min-width: 150px;
}

.frame-option input {
    display: none;
}

.frame-option input:checked + .frame-preview {
    border-color: #4a6cf7;
    background: rgba(74, 108, 247, 0.1);
}

.frame-preview {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
}

.frame-preview:hover {
    border-color: #4a6cf7;
}

.frame-preview img {
    max-width: 100%;
    height: 80px;
    object-fit: contain;
    margin-bottom: 5px;
}

.frame-preview span {
    display: block;
    font-size: 12px;
    color: #666;
}


.upload-progress {
    margin: 20px 0;
}

.progress-bar {
    height: 20px;
    background: #f0f0f0;
    border-radius: 10px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a6cf7, #2e4bd1);
    width: 0%;
    transition: width 0.3s;
}

.progress-text {
    text-align: center;
    margin-top: 5px;
    font-size: 14px;
    color: #666;
}


.library-controls {
    display: flex;
    gap: 15px;
    margin-bottom: 20px;
}

.search-box {
    flex: 1;
    position: relative;
}

.search-box input {
    width: 100%;
    padding: 10px 15px 10px 40px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.search-box i {
    position: absolute;
    left: 15px;
    top: 50%;
    transform: translateY(-50%);
    color: #888;
}

.library-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    max-height: 500px;
    overflow-y: auto;
    padding: 10px;
}

.library-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    transition: all 0.3s;
}

.library-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

.library-item-image {
    position: relative;
    height: 150px;
    overflow: hidden;
}

.library-item-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    cursor: pointer;
}

.gif-badge::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0,0,0,0.3);
    z-index: 1;
}

.gif-label, .svg-label {
    position: absolute;
    top: 10px;
    right: 10px;
    background: #ff4757;
    color: white;
    padding: 2px 8px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    z-index: 2;
}

.svg-label {
    background: #4a6cf7;
}

.library-item-info {
    padding: 10px;
}

.library-item-name {
    font-weight: 500;
    margin-bottom: 5px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.library-item-meta {
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: #777;
    margin-bottom: 10px;
}

.library-item-actions {
    display: flex;
    gap: 5px;
}

.library-item-actions .btn {
    flex: 1;
    padding: 5px;
    font-size: 12px;
}

.loading-library, .empty-library {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #666;
}

.loading-library i, .empty-library i {
    font-size: 48px;
    margin-bottom: 15px;
}

.frames-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.frame-item {
    display: flex;
    gap: 20px;
    align-items: center;
    padding: 20px;
    background: #f9f9f9;
    border-radius: 8px;
}

.frame-preview-large {
    flex: 0 0 200px;
}

.frame-preview-large img {
    width: 100%;
    max-height: 150px;
    object-fit: contain;
}

.frame-info {
    flex: 1;
}

.frame-info h4 {
    margin: 0 0 10px 0;
    color: #333;
}

.frame-info p {
    margin: 5px 0;
    color: #666;
    font-size: 14px;
}

.image-frame {
    text-align: center;
    margin: 20px auto;
    position: relative;
}

.image-frame.no-frame img {
    max-width: 500px;
    width: 100%;
    height: auto;
    border-radius: 5px;
}

.frame-container {
    position: relative;
    display: inline-block;
}

.frame-container img {
    max-width: 100%;
    height: auto;
    border-radius: 5px;
}

.frame-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    pointer-events: none;
}

.frame-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.small-frame .frame-container {
    max-width: 430px;
}

.small-frame .frame-container img:first-child {
    max-width: 390px;
    width: 100%;
    position: relative;
    z-index: 1;
    margin: 20px auto;
    display: block;
}

.large-frame .frame-container {
    max-width: 710px;
}

.large-frame .frame-container img:first-child {
    max-width: 670px;
    width: 100%;
    position: relative;
    z-index: 1;
    margin: 20px auto;
    display: block;
}

.wyswietlana-tresc .image-frame img[src$=".gif"],
.wyswietlana-tresc .image-frame img[src*=".gif"] {
    image-rendering: optimizeSpeed;
    image-rendering: -moz-crisp-edges;
    image-rendering: -o-crisp-edges;
    image-rendering: -webkit-optimize-contrast;
    image-rendering: pixelated;
    image-rendering: optimize-contrast;
}

@media (max-width: 768px) {
    .modal-large {
        max-width: 95%;
        margin: 10px;
    }
    
    .frame-options {
        flex-direction: column;
    }
    
    .frame-item {
        flex-direction: column;
        text-align: center;
    }
    
    .frame-preview-large {
        flex: 0 0 auto;
    }
    
    .library-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    }
}

@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

.library-item-image img:hover {
    animation: pulse 0.5s ease-in-out;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 10px;
    max-height: 400px;
    overflow-y: auto;
}

.gallery-item {
    border: 1px solid #ddd;
    border-radius: 8px;
    overflow: hidden;
    background: white;
    transition: all 0.3s;
    cursor: pointer;
    display: flex;
    flex-direction: column;
    height: 220px;
}

.gallery-item:hover {
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
    border-color: #4a6cf7;
}

.gallery-item.selected {
    border-color: #4a6cf7;
    box-shadow: 0 0 0 3px rgba(74, 108, 247, 0.3);
}

.image-preview {
    position: relative;
    height: 140px;
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #f5f5f5;
}

.image-preview img {
    max-width: 100%;
    max-height: 100%;
    width: auto;
    height: auto;
    object-fit: contain;
    transition: transform 0.3s;
}

.gallery-item:hover .image-preview img {
    transform: scale(1.05);
}

.gif-badge, .svg-badge {
    position: absolute;
    top: 5px;
    right: 5px;
    background: rgba(0,0,0,0.7);
    color: white;
    padding: 2px 6px;
    border-radius: 3px;
    font-size: 10px;
    font-weight: bold;
    z-index: 2;
}

.svg-badge {
    background: #4a6cf7;
}

.image-overlay {
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(74, 108, 247, 0);
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.gallery-item.selected .image-overlay {
    background: rgba(74, 108, 247, 0.3);
}

.image-overlay i {
    color: white;
    font-size: 24px;
    opacity: 0;
    transition: opacity 0.3s;
}

.gallery-item.selected .image-overlay i {
    opacity: 1;
}

.image-info {
    padding: 10px;
    flex: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.image-name {
    font-weight: 500;
    font-size: 12px;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    margin-bottom: 5px;
    color: #333;
}

.image-meta {
    display: flex;
    justify-content: space-between;
    font-size: 11px;
    color: #777;
    margin-bottom: 8px;
}

.image-info .btn {
    align-self: flex-end;
    padding: 4px 8px;
    font-size: 11px;
}

.gallery-loading, .empty-gallery, .gallery-error {
    grid-column: 1 / -1;
    text-align: center;
    padding: 40px;
    color: #666;
}

.gallery-loading i, .empty-gallery i, .gallery-error i {
    font-size: 36px;
    margin-bottom: 15px;
    color: #4a6cf7;
}

.gallery-error i {
    color: #ff4757;
}

.modal-large .modal-content {
    max-width: 900px;
    width: 90%;
    max-height: 85vh;
    display: flex;
    flex-direction: column;
}

.modal-large .modal-body {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.image-library-container {
    display: flex;
    flex-direction: column;
    gap: 20px;
    height: 100%;
    overflow: hidden;
}

.image-upload-panel {
    flex: 0 0 auto;
}

.upload-area {
    border: 3px dashed #4a6cf7;
    border-radius: 10px;
    padding: 30px;
    text-align: center;
    cursor: pointer;
    background: #f8f9ff;
    transition: all 0.3s;
    margin-bottom: 15px;
}

.upload-area:hover {
    background: #edf0ff;
    border-color: #2e4bd1;
}

.upload-area.highlight {
    background: #e3e8ff;
    border-color: #1e3db1;
}

.upload-area i {
    font-size: 48px;
    color: #4a6cf7;
    margin-bottom: 10px;
}

.upload-area p {
    margin: 5px 0;
    color: #555;
}

.upload-hint {
    font-size: 14px;
    color: #777;
}

.file-info {
    font-size: 12px;
    color: #888;
    margin-top: 10px;
}

.upload-progress {
    margin-top: 15px;
}

.progress-bar {
    height: 10px;
    background: #eee;
    border-radius: 5px;
    overflow: hidden;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #4a6cf7, #2e4bd1);
    width: 0%;
    transition: width 0.3s;
}

.progress-info {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
    text-align: center;
}

.image-gallery {
    flex: 1;
    overflow-y: auto;
    border: 1px solid #eee;
    border-radius: 8px;
    padding: 15px;
    background: #fafafa;
    min-height: 200px;
    max-height: 400px;
}

.frame-selection {
    flex: 0 0 auto;
    border-top: 1px solid #eee;
    padding-top: 15px;
}

.frame-selection h4 {
    margin: 0 0 10px 0;
    color: #333;
    font-size: 16px;
}

.frame-options {
    display: flex;
    gap: 10px;
    flex-wrap: wrap;
}

.frame-option {
    flex: 1;
    min-width: 150px;
}

.frame-option input {
    display: none;
}

.frame-option input:checked + .frame-preview {
    border-color: #4a6cf7;
    background: rgba(74, 108, 247, 0.1);
}

.frame-preview {
    border: 2px solid #ddd;
    border-radius: 8px;
    padding: 10px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s;
    height: 100px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.frame-preview:hover {
    border-color: #4a6cf7;
}

.frame-preview img {
    max-width: 100%;
    max-height: 60px;
    object-fit: contain;
    margin-bottom: 5px;
}

.frame-label {
    font-size: 12px;
    color: #666;
    margin-top: 5px;
}

.modal-actions {
    display: flex;
    justify-content: flex-end;
    gap: 10px;
    padding: 15px;
    border-top: 1px solid #eee;
    background: #f9f9f9;
    flex: 0 0 auto;
}

.image-frame {
    margin: 20px auto;
    text-align: center;
}

.image-frame.no-frame img {
    max-width: 500px;
    width: 100%;
    height: auto;
    border-radius: 5px;
}

.image-frame .frame-container {
    position: relative;
    display: inline-block;
}

.image-frame .frame-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    pointer-events: none;
}

.image-frame .frame-overlay img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.image-frame.small-frame .frame-container {
    max-width: 430px;
}

.image-frame.small-frame .frame-container img:first-child {
    max-width: 390px;
    width: 100%;
    position: relative;
    z-index: 1;
    margin: 20px auto;
    display: block;
}

.image-frame.large-frame .frame-container {
    max-width: 710px;
}

.image-frame.large-frame .frame-container img:first-child {
    max-width: 670px;
    width: 100%;
    position: relative;
    z-index: 1;
    margin: 20px auto;
    display: block;
}

.special-element {
    text-align: center;
    margin: 20px auto;
}

.special-element img {
    max-width: 100%;
    height: auto;
}

.special-element.element1 img {
    max-width: 430px;
}

.special-element.element2 img {
    max-width: 710px;
}

@media (max-width: 768px) {
    .modal-large {
        max-width: 95%;
        margin: 10px;
    }
    
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }
    
    .gallery-item {
        height: 200px;
    }
    
    .image-preview {
        height: 120px;
    }
    
    .frame-options {
        flex-direction: column;
    }
    
    .frame-option {
        min-width: 100%;
    }
    
    .upload-area {
        padding: 20px;
    }
    
    .upload-area i {
        font-size: 36px;
    }
}

@media (max-width: 480px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
        gap: 10px;
    }
    
    .gallery-item {
        height: 180px;
    }
    
    .image-preview {
        height: 100px;
    }
    
    .image-name {
        font-size: 11px;
    }
    
    .image-meta {
        font-size: 10px;
    }
}

.image-gallery::-webkit-scrollbar {
    width: 8px;
}

.image-gallery::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 4px;
}

.image-gallery::-webkit-scrollbar-thumb {
    background: #c1c1c1;
    border-radius: 4px;
}

.image-gallery::-webkit-scrollbar-thumb:hover {
    background: #a1a1a1;
}

.wyswietlana-tresc iframe,
.card-body iframe,
.wysiwyg-editor iframe {
    border: 3px solid #bd4534 !important;
    border-radius: 8px !important;
    box-shadow: 0 5px 20px rgba(189, 69, 52, 0.5) !important;
    background: #000 !important;
    margin: 20px 0 !important;
}

.video-container {
    position: relative;
    padding-bottom: 56.25%;
    height: 0;
    overflow: hidden;
    max-width: 100%;
    margin: 20px 0;
    border-radius: 8px;
    border: 3px solid #bd4534;
    box-shadow: 0 5px 20px rgba(189, 69, 52, 0.5);
}

.video-container iframe {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    border: 0;
}

.video-center {
    text-align: center;
}

.video-left {
    float: left;
    margin: 0 20px 20px 0;
    max-width: 50%;
}

.video-right {
    float: right;
    margin: 0 0 20px 20px;
    max-width: 50%;
}