/**
 * Tengo Fundraising - Frontend Styles
 * Wersja: Basic - Enhanced v5
 */

/* Kontener formularza */
.tf-donation-form {
    max-width: 600px;
    margin: 0 auto;
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
}

/* Sekcje formularza */
.tf-form-section {
    background: #f9fafb;
    padding: 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    border: 1px solid #e5e7eb;
}

.tf-form-section h3,
.tf-form-section .tf-section-title {
    margin: 0 0 15px 0;
    color: #111827;
    font-size: 18px;
    font-weight: 600;
    padding: 0;
    border: none;
    background: none;
    text-transform: none;
    letter-spacing: normal;
}

/* =====================================================
   PRZYCISKI KWOT - SPÃ“JNY STYL DLA WSZYSTKICH
   ===================================================== */

.tf-preset-amounts {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 10px;
    margin-bottom: 15px;
}

.tf-amount-btn {
    background: #fff;
    border: 1px solid #d1d5db;
    color: #374151;
    padding: 0 12px;
    border-radius: 8px;
    font-size: 16px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    height: 44px;
    display: flex;
    align-items: center;
    justify-content: center;
    outline: none;
    box-shadow: none;
}

.tf-amount-btn:hover {
    border-color: #2563eb;
    background: #eff6ff;
    transform: translateY(-1px);
}

.tf-amount-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Stan zaznaczony - IDENTYCZNY dla wszystkich przyciskÃ³w */
.tf-amount-btn.selected {
    background: #2563eb;
    color: white;
    border-color: #1d4ed8; /* Osobny kolor obramowania! */
}

/* =====================================================
   POLE WÅASNEJ KWOTY - WYGLÄ„DA JAK INPUT, NIE PRZYCISK
   ===================================================== */

.tf-custom-amount {
    margin-top: 15px;
}

.tf-custom-amount-field {
    position: relative;
    width: 100%;
}

/* Input wÅ‚asnej kwoty - te same style co inne pola formularza */
.tf-custom-amount-input {
    width: 100%;
    height: 42px;
    padding: 0 40px 0 12px;
    font-size: 16px;
    font-weight: 400;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    box-shadow: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    text-align: center;
}

.tf-custom-amount-input::placeholder {
    color: #9ca3af;
    text-align: center;
    opacity: 1;
}

.tf-custom-amount-input:hover {
    border-color: #374151;
}

.tf-custom-amount-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

/* Ukrycie strzaÅ‚ek dla number input */
.tf-custom-amount-input::-webkit-outer-spin-button,
.tf-custom-amount-input::-webkit-inner-spin-button {
    -webkit-appearance: none;
    margin: 0;
}

.tf-custom-amount-input {
    -moz-appearance: textfield;
}

/* Znak "zÅ‚" - ukryty domyÅ›lnie */
.tf-currency-suffix {
    position: absolute;
    right: 50%;
    top: 50%;
    transform: translate(50%, -50%);
    font-size: 16px;
    font-weight: 500;
    color: #1f2937;
    pointer-events: none;
    opacity: 0;
    transition: opacity 0.2s ease;
}

/* Gdy pole jest w trybie wpisywania (ma klasÄ™ .tf-typing) */
.tf-custom-amount-field.tf-typing .tf-currency-suffix {
    opacity: 1;
    right: calc(50% - 30px);
    transform: translate(0, -50%);
}

/* Gdy wpisana kwota - tekst i zÅ‚ wyÅ›rodkowane */
.tf-custom-amount-field.tf-has-value .tf-custom-amount-input {
    padding-right: 40px;
    text-align: center;
}

/* Stan bÅ‚Ä™du */
.tf-custom-amount-input.tf-error {
    border-color: #ef4444;
}

/* =====================================================
   TEKST INFORMACYJNY POD KWOTAMI
   ===================================================== */

.tf-amount-info {
    display: none;
    width: 100%;
    margin-top: 12px;
    padding: 8px 0;
    background: transparent;
    border: none;
    box-sizing: border-box;
    text-align: center;
}

.tf-amount-info.tf-visible {
    display: block;
}

.tf-amount-info-content {
    display: inline-flex;
    align-items: center;
    gap: 12px;
    text-align: left;
    max-width: 90%;
    box-sizing: border-box;
}

.tf-amount-info-content.tf-with-icon {
    display: inline-flex;
}

.tf-amount-info-text {
    line-height: 1.5;
    text-wrap: balance;
    text-align: center;
}

.tf-amount-info-content.tf-with-icon .tf-amount-info-text {
    text-align: left;
    text-wrap: wrap;
    max-width: 350px;
}

.tf-amount-info-text strong {
    font-weight: 700;
}

.tf-amount-info-icon {
    display: none;
    width: 40px;
    height: 40px;
    object-fit: contain;
    flex-shrink: 0;
}

/* =====================================================
   POLA FORMULARZA - DANE OSOBOWE
   ===================================================== */

.tf-form-row {
    display: flex;
    gap: 15px;
    margin-bottom: 15px;
}

.tf-form-group {
    margin-bottom: 15px;
}

.tf-form-group.tf-half {
    flex: 1;
}

.tf-form-group.tf-full {
    flex: 1;
}

.tf-form-group label {
    display: block;
    margin-bottom: 6px;
    font-size: 14px;
    font-weight: 500;
    color: #374151;
}

/* Wszystkie pola tekstowe - spÃ³jny styl */
.tf-input {
    width: 100%;
    height: 42px;
    padding: 0 12px;
    font-size: 16px;
    font-weight: 400;
    background: #ffffff;
    color: #1f2937;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    outline: none;
    box-shadow: none;
    box-sizing: border-box;
    transition: border-color 0.2s ease, box-shadow 0.2s ease;
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
}

.tf-input::placeholder {
    color: #9ca3af;
    opacity: 1;
}

.tf-input:hover {
    border-color: #374151;
}

.tf-input:focus {
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.15);
    outline: none;
}

/* Nadpisanie autofill Chrome */
.tf-input:-webkit-autofill,
.tf-input:-webkit-autofill:hover,
.tf-input:-webkit-autofill:focus {
    -webkit-box-shadow: 0 0 0 30px #ffffff inset;
    -webkit-text-fill-color: #1f2937;
    transition: background-color 5000s ease-in-out 0s;
}

/* Stan bÅ‚Ä™du */
.tf-input.tf-error {
    border-color: #ef4444;
    background: rgba(239, 68, 68, 0.03);
}

.tf-input.tf-error:focus {
    box-shadow: 0 0 0 3px rgba(239, 68, 68, 0.15);
}

/* =====================================================
   CHECKBOXY - CUSTOM STYLING
   ===================================================== */

.tf-consent-item {
    margin-bottom: 16px;
}

.tf-consent-item:last-child {
    margin-bottom: 0;
}

.tf-checkbox-label {
    display: flex;
    align-items: flex-start;
    cursor: pointer;
}

/* Custom checkbox */
.tf-checkbox {
    -webkit-appearance: none;
    -moz-appearance: none;
    appearance: none;
    width: 18px;
    height: 18px;
    min-width: 18px;
    margin: 2px 10px 0 0;
    padding: 0;
    background: #ffffff;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    cursor: pointer;
    position: relative;
    flex-shrink: 0;
    transition: all 0.2s ease;
}

.tf-checkbox:hover {
    border-color: #2563eb;
}

.tf-checkbox:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.2);
}

/* Checkbox zaznaczony - kolor jak zaznaczony przycisk kwoty */
.tf-checkbox:checked {
    background: #2563eb;
    border-color: #2563eb;
}

.tf-checkbox:checked::after {
    content: "";
    position: absolute;
    left: 5px;
    top: 1px;
    width: 5px;
    height: 10px;
    border: solid #ffffff;
    border-width: 0 2px 2px 0;
    transform: rotate(45deg);
}

.tf-checkbox.tf-error {
    border-color: #ef4444;
}

.tf-consent-text {
    font-size: 14px;
    line-height: 1.5;
    color: #374151;
    flex: 1;
}

/* =====================================================
   BÅÄ˜DY WALIDACJI
   ===================================================== */

.tf-field-error {
    display: none;
    color: #ef4444;
    font-size: 13px;
    font-weight: 400;
    margin-top: 4px;
    line-height: 1.4;
}

.tf-consent-item .tf-field-error {
    margin-left: 28px;
    font-size: 12px;
}

.tf-required {
    color: #ef4444;
    font-weight: normal;
}

/* =====================================================
   PRZYCISK SUBMIT
   ===================================================== */

.tf-submit-section {
    text-align: center;
}

.tf-submit-btn {
    width: 100%;
    height: 48px;
    background: #2563eb;
    color: white;
    border: none;
    border-radius: 8px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    outline: none;
}

.tf-submit-btn:hover {
    background: #1d4ed8;
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.tf-submit-btn:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.3);
}

.tf-submit-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

/* Loader w przycisku */
.tf-spinner {
    display: inline-block;
    width: 16px;
    height: 16px;
    border: 2px solid rgba(255,255,255,0.3);
    border-top-color: white;
    border-radius: 50%;
    animation: tf-spin 0.8s linear infinite;
}

@keyframes tf-spin {
    to { transform: rotate(360deg); }
}

/* Informacja o bezpieczeÅ„stwie */
.tf-secure-info {
    margin-top: 15px;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    color: #6b7280;
    font-size: 14px;
}

/* =====================================================
   KOMUNIKATY
   ===================================================== */

.tf-messages {
    margin-top: 15px;
    padding: 12px;
    border-radius: 6px;
    font-size: 14px;
}

.tf-messages.error {
    background: #fee2e2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.tf-messages.success {
    background: #d1fae5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

/* =====================================================
   TRYB ROZWIJANY
   ===================================================== */

.tf-mode-collapsed .tf-expandable-sections {
    max-height: 0;
    opacity: 0;
    overflow: hidden;
    transition: max-height 0.6s cubic-bezier(0.4, 0, 0.2, 1), opacity 0.4s ease-out;
}

.tf-mode-collapsed.tf-expanded .tf-expandable-sections {
    max-height: 3000px;
    opacity: 1;
}

/* =====================================================
   TRYB KOMPAKTOWY
   ===================================================== */

.tf-donation-form.tf-compact .tf-form-section {
    margin-bottom: 0;
}

.tf-donation-form.tf-compact.tf-expanded .tf-amounts-section,
.tf-donation-form.tf-compact.tf-mode-expanded .tf-amounts-section {
    border-bottom-left-radius: 0;
    border-bottom-right-radius: 0;
    border-bottom: none;
}

.tf-donation-form.tf-compact.tf-expanded .tf-donor-section,
.tf-donation-form.tf-compact.tf-mode-expanded .tf-donor-section {
    border-radius: 0;
    border-top: none;
    border-bottom: none;
}

.tf-donation-form.tf-compact.tf-expanded .tf-consents-section,
.tf-donation-form.tf-compact.tf-mode-expanded .tf-consents-section {
    border-radius: 0;
    border-top: none;
    border-bottom: none;
}

.tf-donation-form.tf-compact.tf-expanded .tf-submit-section,
.tf-donation-form.tf-compact.tf-mode-expanded .tf-submit-section {
    border-top-left-radius: 0;
    border-top-right-radius: 0;
    border-top: none;
}

/* =====================================================
   RESPONSYWNOÅšÄ† - MOBILE
   ===================================================== */

@media (max-width: 1920px) and (min-width: 1367px) {
    .tf-donation-form {
        max-width: 100%;
        padding: 0 20px;
    }
}

@media (max-width: 1366px) {
    .tf-donation-form {
        max-width: 100%;
        width: 100%;
        margin: 0;
        padding: 0;
        border-radius: 0;
        border: none;
        box-shadow: none;
        filter: none;
    }
    
    .tf-donation-form .tf-form-section {
        border-radius: 0;
        padding: 16px;
        margin-bottom: 0;
        border-left: none;
        border-right: none;
        border-top: none;
        border-bottom: 1px solid #e5e7eb;
        box-shadow: none;
    }
    
    .tf-expandable-sections {
        margin: 0;
        padding: 0;
    }
    
    .tf-amounts-section {
        border-top: none;
    }
    
    .tf-submit-section {
        border-bottom: none;
    }
    
    .tf-form-section h3,
    .tf-section-title {
        font-size: 16px;
        margin-bottom: 16px;
    }
    
    .tf-preset-amounts {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .tf-amount-btn {
        height: 44px;
        font-size: 15px;
    }
    
    .tf-form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .tf-form-group.tf-half {
        flex: none;
        width: 100%;
    }
    
    .tf-input {
        font-size: 16px; /* Zapobiega zoom na iOS */
        height: 44px;
    }
    
    .tf-custom-amount-input {
        font-size: 16px;
        height: 44px;
    }
    
    .tf-checkbox {
        min-width: 20px;
        width: 20px;
        height: 20px;
    }
    
    .tf-consent-text {
        font-size: 13px;
    }
    
    .tf-submit-btn {
        height: 50px;
        font-size: 16px;
    }
}

@media (max-width: 375px) {
    .tf-form-section {
        padding: 14px 12px;
    }
    
    .tf-preset-amounts {
        gap: 6px;
    }
    
    .tf-amount-btn {
        font-size: 14px;
    }
}

/* =====================================================
   MODAL PRZEKIEROWANIA
   ===================================================== */

.tf-redirect-modal {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 999999;
    display: none;
}

.tf-redirect-modal.tf-modal-visible {
    display: flex;
    align-items: center;
    justify-content: center;
}

.tf-redirect-modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 1);
}

.tf-redirect-modal-content {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    text-align: center;
    padding: 40px;
    max-width: 90%;
    width: 500px;
    z-index: 1;
}

.tf-redirect-logo {
    max-width: 200px;
    max-height: 80px;
    margin-bottom: 30px;
}

.tf-redirect-title {
    color: #ffffff;
    font-size: 24px;
    font-weight: 600;
    margin: 0 0 15px 0;
}

.tf-redirect-text {
    color: #ffffff;
    font-size: 16px;
    opacity: 0.9;
    margin: 0 0 30px 0;
}

.tf-redirect-spinner {
    display: flex;
    justify-content: center;
}

.tf-spinner-svg {
    width: 50px;
    height: 50px;
    animation: tf-spinner-rotate 2s linear infinite;
}

.tf-spinner-circle {
    stroke: #ffffff;
    stroke-linecap: round;
    animation: tf-spinner-dash 1.5s ease-in-out infinite;
}

@keyframes tf-spinner-rotate {
    100% { transform: rotate(360deg); }
}

@keyframes tf-spinner-dash {
    0% {
        stroke-dasharray: 1, 150;
        stroke-dashoffset: 0;
    }
    50% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -35;
    }
    100% {
        stroke-dasharray: 90, 150;
        stroke-dashoffset: -124;
    }
}

/* Responsive modal */
@media (max-width: 1366px) {
    .tf-redirect-modal-content {
        padding: 30px 20px;
    }
    
    .tf-redirect-title {
        font-size: 20px;
    }
    
    .tf-redirect-text {
        font-size: 14px;
    }
    
    .tf-redirect-logo {
        max-width: 150px;
        max-height: 60px;
    }
}

/* ========================================
   TRYB KAFELKOWY - FALLBACK STYLES
   ======================================== */

.tf-tiles-grid {
    display: grid;
    grid-template-columns: repeat(4, 1fr);
    gap: 8px;
    margin-bottom: 15px;
}

.tf-amount-tile {
    aspect-ratio: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 4px 5px 8px 5px;
    background: #ffffff;
    border: 2px solid #e5e7eb;
    border-radius: 8px;
    cursor: pointer;
    transition: all 0.2s ease;
    text-align: center;
    box-sizing: border-box;
}

.tf-amount-tile:hover {
    background: #f0f9ff;
    border-color: #3b82f6;
    transform: translateY(-2px);
}

.tf-amount-tile.selected {
    background: #3b82f6;
    border-color: #3b82f6;
    color: #ffffff;
}

.tf-amount-tile.selected .tf-tile-amount,
.tf-amount-tile.selected .tf-tile-desc,
.tf-amount-tile.selected .tf-tile-line1,
.tf-amount-tile.selected .tf-tile-line2 {
    color: #ffffff;
}

.tf-tile-icon {
    width: 60px;
    height: 60px;
    margin-bottom: 2px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.tf-tile-icon img {
    max-width: 100%;
    max-height: 100%;
    object-fit: contain;
    filter: invert(1);
}

.tf-amount-tile.selected .tf-tile-icon img {
    filter: invert(0);
}

/* Odwrocenie kolorow ikon na biale */
.tf-tiles-invert-icons .tf-tile-icon img {
    filter: invert(1);
}

.tf-tiles-invert-icons .tf-amount-tile.selected .tf-tile-icon img {
    filter: invert(0);
}

.tf-tile-icon-placeholder {
    background: #f3f4f6;
    border-radius: 8px;
    width: 100%;
    height: 100%;
}

.tf-amount-tile.selected .tf-tile-icon-placeholder {
    background: rgba(255,255,255,0.2);
}

.tf-tile-amount {
    font-size: 30px;
    font-weight: 700;
    color: #1f2937;
    margin-bottom: 2px;
    line-height: 1.1;
}

.tf-tile-desc {
    display: flex;
    flex-direction: column;
    align-items: center;
    font-size: 16px;
    color: #1f2937;
    line-height: 1.2;
    max-width: 100%;
}

.tf-tile-line1,
.tf-tile-line2 {
    display: block;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    max-width: 100%;
    font-weight: 600;
    color: #1f2937;
}

/* Kafelek Wlasna kwota */
.tf-tile-custom {
    position: relative;
}

.tf-tile-custom .tf-tile-amount {
    font-size: 22px;
    margin-bottom: 4px;
}

.tf-tile-input-wrapper {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 4px;
    margin-top: 2px;
}

.tf-tile-custom-input {
    width: 70px;
    padding: 5px 8px;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    font-size: 18px;
    font-weight: 600;
    text-align: center;
    background: #fff;
    transition: all 0.2s ease;
    line-height: 1;
}

.tf-tile-custom-input:focus {
    outline: none;
    border-color: #3b82f6;
}

.tf-tile-custom-input::placeholder {
    font-weight: 500;
    color: #6b7280;
    font-size: 14px;
    text-align: center;
    line-height: 1;
}

.tf-tile-custom.selected .tf-tile-custom-input {
    border-color: rgba(255,255,255,0.5);
    background: rgba(255,255,255,0.95);
    color: #1f2937;
}

.tf-tile-custom.selected .tf-tile-custom-input::placeholder {
    color: #9ca3af;
}

.tf-tile-currency {
    font-size: 18px;
    font-weight: 600;
    color: #374151;
}

.tf-tile-custom.selected .tf-tile-currency {
    color: #ffffff;
}

/* Komunikat o minimalnej kwocie */
.tf-tile-min-error {
    margin-top: 6px;
    padding: 0;
    background: transparent;
    border: none;
    color: #dc2626;
    font-size: 14px;
    font-weight: 500;
    text-align: right;
}

/* Responsywnosc mobile - kafelki 2x2 */
@media (max-width: 1366px) {
    .tf-tiles-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 8px;
    }
    
    .tf-tile-icon {
        width: 48px;
        height: 48px;
    }
    
    .tf-tile-amount {
        font-size: 24px;
    }
    
    .tf-tile-desc {
        font-size: 13px;
    }
    
    .tf-tile-custom .tf-tile-amount {
        font-size: 16px;
    }
    
    .tf-tile-custom-input {
        width: 60px;
        font-size: 14px;
        padding: 4px 6px;
    }
    
    .tf-tile-currency {
        font-size: 14px;
    }
}
