/* Blokada scrollowania gdy modal jest otwarty */
body.zrzutki-modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
    top: var(--scroll-y, 0) !important;
    left: 0 !important;
}

html.zrzutki-modal-open {
    overflow: hidden !important;
    position: fixed !important;
    width: 100% !important;
    height: 100% !important;
}

/* Dodatkowe zabezpieczenie dla iOS Safari */
.zrzutki-modal-open,
.zrzutki-modal-open body {
    touch-action: none !important;
    -webkit-overflow-scrolling: auto !important;
}

/* Overlay modala - usuń padding, fullscreen */
.zrzutki-modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    z-index: 99999;
    display: none;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    overflow: hidden;
    -webkit-backdrop-filter: blur(5px);
    backdrop-filter: blur(5px);
    padding: 0;
    box-sizing: border-box;
    overscroll-behavior: contain;
}

.zrzutki-modal-overlay.active {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
}

/* Loader */
.zrzutki-modal-loader {
    width: 50px;
    height: 50px;
    border: 5px solid rgba(255, 255, 255, 0.3);
    border-radius: 50%;
    border-top-color: #fff;
    -webkit-animation: spin 1s ease-in-out infinite;
    animation: spin 1s ease-in-out infinite;
}

@-webkit-keyframes spin {
    to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

@keyframes spin {
    to { -webkit-transform: rotate(360deg); transform: rotate(360deg); }
}

/* Modal - ZAWSZE fullscreen */
.zrzutka-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100vw; 
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    background: #fff;
    border-radius: 0;
    overflow: hidden;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    box-shadow: none;
    -webkit-animation: modalFadeIn 0.3s ease-out;
    animation: modalFadeIn 0.3s ease-out;
    margin: 0;
    padding-top: 24px;
    z-index: 100000;
}

@-webkit-keyframes modalFadeIn {
    from { opacity: 0; -webkit-transform: translateY(20px); transform: translateY(20px); }
    to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}

@keyframes modalFadeIn {
    from { opacity: 0; -webkit-transform: translateY(20px); transform: translateY(20px); }
    to { opacity: 1; -webkit-transform: translateY(0); transform: translateY(0); }
}

/* Modal błędu - również fullscreen */
.zrzutka-modal-error {
    background: #fff;
    width: 100vw;
    max-width: 100vw;
    height: 100vh;
    max-height: 100vh;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    overflow-y: auto;
    display: flex;
    align-items: center;
    justify-content: center;
}

.zrzutka-modal-error-content {
    padding: 60px 40px;
    text-align: center;
    max-width: 600px;
    width: 90%;
}

.error-icon {
    font-size: 80px;
    margin-bottom: 30px;
    display: block;
}

.error-title {
    font-size: 40px; /* was 2.5rem */
    font-weight: 700;
    color: #333;
    margin: 0 0 25px;
    line-height: 1.3;
}

.error-message {
    font-size: 22px; /* was 1.4rem */
    color: #666;
    margin: 0 0 35px;
    line-height: 1.6;
}

.error-details {
    text-align: left;
    background: #f8f9fa;
    padding: 25px;
    border-radius: 8px;
    margin: 25px 0;
}

.error-details p {
    margin: 0 0 18px;
    color: #555;
    font-size: 19px; /* was 1.2rem */
    line-height: 1.7;
}

.error-details ul {
    margin: 18px 0;
    padding-left: 28px;
}

.error-details li {
    margin: 10px 0;
    color: #666;
    font-size: 18px; /* was 1.1rem */
    line-height: 1.6;
}

.error-actions {
    margin-top: 25px;
    display: flex;
    gap: 15px;
    flex-wrap: wrap;
    justify-content: center;
}

.error-button {
    display: inline-block;
    padding: 18px 30px;
    border-radius: 8px;
    text-decoration: none;
    font-weight: 600;
    font-size: 18px; /* was 1.1rem */
    border: none;
    cursor: pointer;
    transition: all 0.3s ease;
    min-width: 160px; /* ZWIĘKSZONE z 140px */
    text-align: center;
}

.error-button-primary {
    background-color: #4a90e2;
    color: white;
}

.error-button-primary:hover {
    background-color: #357ABD;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

.error-button-secondary {
    background-color: #6c757d;
    color: white;
}

.error-button-secondary:hover {
    background-color: #545b62;
    color: white;
    text-decoration: none;
    transform: translateY(-1px);
}

/* Przycisk zamknięcia */
.zrzutka-modal-close {
    position: absolute;
    top: 32px;
    right: 16px;
    width: 40px;
    height: 40px;
    background: rgba(0, 0, 0, 0.5);
    color: #fff;
    font-size: 24px;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-align: center;
    -ms-flex-align: center;
    align-items: center;
    -webkit-box-pack: center;
    -ms-flex-pack: center;
    justify-content: center;
    border-radius: 50%;
    cursor: pointer;
    z-index: 100000;
    -webkit-transition: background 0.2s, -webkit-transform 0.2s;
    transition: background 0.2s, -webkit-transform 0.2s;
    transition: background 0.2s, transform 0.2s;
    transition: background 0.2s, transform 0.2s, -webkit-transform 0.2s;
}

.zrzutka-modal-close:hover {
    background: rgba(0, 0, 0, 0.7);
    -webkit-transform: scale(1.1);
    transform: scale(1.1);
}

/* Treść zrzutki */
.zrzutka-modal-content {
    padding: 20px 20px 130px 20px; /* Dodany padding-bottom dla przycisku */
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    overflow-y: auto;
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-orient: vertical;
    -webkit-box-direction: normal;
    -ms-flex-direction: column;
    flex-direction: column;
    height: calc(100vh - 24px); /* Wysokość minus padding-top modala */
    box-sizing: border-box;
    text-align: left;
}

.zrzutka-modal-title {
    font-size: 24px;
    font-weight: 700;
    margin: 0 0 15px;
    color: #000;
    line-height: 1.2;
}

.zrzutka-modal-meta {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    -webkit-box-pack: justify;
    -ms-flex-pack: justify;
    justify-content: space-between;
    margin-bottom: 20px;
}

.zrzutka-modal-author {
    font-size: 16px;
    color: #666;
}

.zrzutka-modal-date {
    font-size: 16px;
    color: #666;
}

/* Informacja o kwocie docelowej w modalu */
.zrzutka-modal-kwoty {
    margin-bottom: 20px;
    background-color: #f8f9fa;
    padding: 15px;
    border-radius: 8px;
    -webkit-box-shadow: 0 1px 3px rgba(0,0,0,0.05);
    box-shadow: 0 1px 3px rgba(0,0,0,0.05);
}

.zrzutka-modal .zrzutka-kwota-docelowa {
    display: -webkit-box;
    display: -ms-flexbox;
    display: flex;
    gap: 10px;
    -webkit-box-align: baseline;
    -ms-flex-align: baseline;
    align-items: baseline;
    font-size: 16px;
    font-weight: 600;
    color: #444;
}

.zrzutka-modal .zrzutka-kwota-docelowa-etykieta {
    text-transform: uppercase;
    font-weight: 700;
    font-size: 16px;
    letter-spacing: 0.05em;
    color: #6c757d;
}

.zrzutka-modal .zrzutka-kwota-zbiorki {
    font-weight: 700;
    color: #212529;
}

.zrzutka-modal-text {
    font-size: 18px;
    line-height: 1.65;
    color: #333;
    margin-bottom: 20px;
    overflow: visible;
    -webkit-box-flex: 1;
    -ms-flex-positive: 1;
    flex-grow: 1;
    text-align: left;
}

.zrzutka-modal-text p {
    margin-bottom: 15px;
}

.zrzutka-modal-link {
    position: fixed;
    bottom: 15px;
    left: 0;
    right: 0;
    width: 100%;
    background: #222;
    color: white;
    text-align: center;
    padding: 16px;
    font-size: 16px;
    font-weight: 600;
    text-decoration: none;
    -webkit-transition: all 0.3s ease;
    transition: all 0.3s ease;
    letter-spacing: 0.5px;
    text-transform: uppercase;
    border-radius: 0;
    z-index: 100001;
    margin: 0;
    box-sizing: border-box;
}

.zrzutka-modal-link:hover {
    background: #333;
    color: white;
    text-decoration: none;
}

/* ******************************************************************* */

/* Responsywność */
@media (min-width: 992px) {
    .zrzutka-modal {
        position: relative;
        -webkit-box-orient: horizontal;
        -webkit-box-direction: normal;
        -ms-flex-direction: row;
        flex-direction: row;
        height: 90vh;
        max-width: 90%;
        max-height: 90vh;
        border-radius: 8px;
        margin: auto;
        -webkit-box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        box-shadow: 0 5px 15px rgba(0,0,0,0.3);
        top: auto;
        left: auto;
    }
    
    .zrzutka-modal-image {
        width: 50%;
        height: 100%; /* na dużych ekranach zdjęcie zajmuje pełną wysokość */
    }
    
    .zrzutka-modal-content {
        width: 50%;
        padding: 30px 30px 100px 30px; /* Dodany padding-bottom dla przycisku */
        height: 100%;
    }
    
    .zrzutka-modal-title {
        font-size: 28px;
    }
    
    .zrzutka-modal-close {
        position: absolute;
        top: 20px;
        right: 20px;
        width: 50px;
        height: 50px;
        background: rgba(0, 0, 0, 0.7);
        font-size: 28px;
        z-index: 100000;
    }
    
    .zrzutka-modal-link {
        position: absolute;
        bottom: 15px;
        left: 50%; /* Zacznie się od połowy modala (tam gdzie zaczyna się content) */
        right: 15px;
        width: auto; /* Auto width */
        margin-left: 0;
        margin-right: 0;
    }
}

@media (max-width: 991px) {
    .zrzutka-modal-image {
      height: 25vh !important;
      width: 100% !important;
      max-height: 25vh !important;
      flex: 0 0 auto !important;
    }
  
    .zrzutka-modal-image img {
      object-fit: cover;
      object-position: center;
      height: 100% !important;
      width: 100% !important;
    }
    
    /* Z-index dla przycisku zamknięcia powinien być wyższy niż wszystko inne */
    .zrzutka-modal-close {
        z-index: 100001;
    }
}

/* Dodatkowe styles dla Safari i iOS */
@supports (-webkit-overflow-scrolling: touch) {
    .zrzutka-modal-content {
        -webkit-overflow-scrolling: touch;
    }
    
    .zrzutka-modal-overlay.active {
        -webkit-overflow-scrolling: touch;
    }
}

/* Dodatkowe styles dla Firefoxa */
@-moz-document url-prefix() {
    .zrzutka-modal-overlay {
        scrollbar-width: none;
    }
    
    .zrzutka-modal-content {
        scrollbar-width: thin;
        scrollbar-color: #ccc transparent;
    }
}

/* Dodatkowe styles dla Chrome, Edge i Safari */
.zrzutka-modal-overlay::-webkit-scrollbar {
    display: none;
}

.zrzutka-modal-content::-webkit-scrollbar {
    width: 6px;
}

.zrzutka-modal-content::-webkit-scrollbar-track {
    background: transparent;
}

.zrzutka-modal-content::-webkit-scrollbar-thumb {
    background-color: #ccc;
    border-radius: 3px;
}

@media (max-width: 991px) {
    .zrzutka-modal-image {
      height: 25vh !important;
      width: 100% !important;
      max-height: 25vh !important;
      flex: 0 0 auto !important;
    }
  
    .zrzutka-modal-image img {
      object-fit: cover;
      object-position: center;
      height: 100% !important;
      width: 100% !important;
    }
}

/* Responsywność dla modala błędu */
@media (max-width: 576px) {
    .zrzutka-modal-error {
        width: 95%;
        margin: 20px auto;
        max-height: 90vh;
    }
    
    .zrzutka-modal-error-content {
        padding: 30px 20px;
    }
    
    .error-title {
        font-size: 24px;
    }

    .error-message {
        font-size: 16px;
    }
    
    .error-actions {
        flex-direction: column;
    }
    
    .error-button {
        width: 100%;
    }
}