/**
 * Klub Strzelecki - Responsive CSS
 * Breakpointy: 1024px (tablet landscape), 768px (tablet), 480px (mobile)
 */

/* ============================================
   TABLET LANDSCAPE (max-width: 1024px)
   ============================================ */
@media (max-width: 1024px) {

    /* --- Kontenery --- */
    .ks-container,
    .ks-tab-content,
    .ks-klub-container {
        padding: 20px !important;
    }

    /* --- Gridy: 4 kolumny -> 2 kolumny --- */
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* --- Two-column layout: zmniejsz gap --- */
    .ks-two-column-layout {
        gap: 25px !important;
    }
}

/* ============================================
   TABLET (max-width: 768px)
   ============================================ */
@media (max-width: 768px) {

    /* --- Zakładki: Account (Moje konto) --- */
    .ks-tabs {
        flex-wrap: wrap !important;
    }

    .ks-tabs .ks-tab {
        padding: 10px 16px !important;
        font-size: 14px !important;
        flex: 1 1 auto !important;
        text-align: center !important;
        margin-right: 2px !important;
    }

    /* --- Zakładki: Panel klubu (v2) --- */
    .ks-tabs-container {
        flex-direction: column !important;
        padding: 10px !important;
        gap: 4px !important;
    }

    .ks-tabs-container .ks-tab {
        padding: 10px 15px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
        border: 1px solid #dee2e6 !important;
        margin-bottom: 0 !important;
    }

    .ks-tabs-container .ks-tab.active {
        border-bottom: 1px solid #dee2e6 !important;
        margin-bottom: 0 !important;
    }

    /* --- Zakładki: Zarządzanie zawodami --- */
    .ks-klub-tabs {
        flex-direction: column !important;
        gap: 4px !important;
    }

    .ks-klub-tab {
        padding: 10px 15px !important;
        font-size: 14px !important;
        border-radius: 6px !important;
        text-align: center !important;
    }

    /* --- Kontenery --- */
    .ks-container {
        padding: 15px !important;
        margin: 10px auto !important;
        border-width: 1px !important;
    }

    .ks-tab-content {
        padding: 15px !important;
        min-height: auto !important;
    }

    .ks-klub-tab-content.active {
        padding: 0 !important;
    }

    /* --- Two-column layout -> jedna kolumna --- */
    .ks-two-column-layout {
        grid-template-columns: 1fr !important;
        gap: 20px !important;
    }

    /* --- Gridy -> jedna kolumna --- */
    .ks-account-grid,
    .ks-registration-grid,
    .ks-grid {
        grid-template-columns: 1fr !important;
    }

    /* --- Tabele: horizontal scroll --- */
    .ks-table-responsive,
    [style*="overflow-x: auto"],
    [style*="overflow-x:auto"] {
        -webkit-overflow-scrolling: touch;
    }

    table.ks-table,
    table.widefat,
    .ks-payments-table,
    .ks-wplaty-table,
    .ks-kasa-table,
    .ks-kalendarz-table,
    .ks-zgloszenia-table,
    .ks-tab-content table,
    .ks-klub-tab-content table {
        font-size: 13px !important;
    }

    table.ks-table th,
    table.ks-table td,
    table.widefat th,
    table.widefat td,
    .ks-payments-table th,
    .ks-payments-table td,
    .ks-wplaty-table th,
    .ks-wplaty-table td,
    .ks-kasa-table th,
    .ks-kasa-table td,
    .ks-kalendarz-table th,
    .ks-kalendarz-table td,
    .ks-zgloszenia-table th,
    .ks-zgloszenia-table td,
    .ks-tab-content table th,
    .ks-tab-content table td,
    .ks-klub-tab-content table th,
    .ks-klub-tab-content table td {
        padding: 8px 6px !important;
    }

    /* Wrap tabeli w scroll jeśli nie ma wrappera */
    .ks-tab-content > table,
    .ks-klub-tab-content > table {
        display: block;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
    }

    /* --- Formularze --- */
    .ks-field input,
    .ks-field select,
    .ks-field textarea,
    .ks-form-row input,
    .ks-form-row select,
    .ks-form-row textarea {
        font-size: 16px !important; /* Zapobiega zoom na iOS */
    }

    /* --- Filtry i formularze inline --- */
    [style*="display: flex"][style*="gap"] {
        flex-wrap: wrap !important;
    }

    form[style*="display: flex"] {
        flex-wrap: wrap !important;
    }

    form[style*="display: flex"] select,
    form[style*="display: flex"] input[type="text"],
    form[style*="display: flex"] input[type="search"] {
        min-width: 100% !important;
        width: 100% !important;
    }

    /* --- Nagłówki --- */
    .ks-container > h2,
    .ks-tab-content > h2,
    .ks-section-title {
        font-size: 20px !important;
    }

    .ks-tab-content h3,
    .ks-klub-tab-content h3 {
        font-size: 17px !important;
    }

    /* --- Przyciski akcji: touch-friendly --- */
    a[style*="padding: 6px 12px"],
    a[style*="padding:6px 12px"],
    button[style*="padding: 6px 12px"],
    button[style*="padding:6px 12px"] {
        padding: 10px 14px !important;
        font-size: 13px !important;
    }

    /* Grupy przycisków - stack vertical */
    td [style*="display: flex"][style*="gap"] {
        flex-direction: column !important;
        gap: 4px !important;
    }

    /* --- Karty --- */
    .ks-card {
        padding: 15px !important;
    }

    /* --- Membership fee banner --- */
    .ks-membership-fee-banner {
        padding: 15px !important;
    }

    .ks-membership-fee-banner > div[style*="display: flex"] {
        flex-direction: column !important;
        gap: 10px !important;
    }

    /* --- SOZ PZSS box --- */
    .ks-membership-fee-banner + div[style*="display: flex"],
    div[style*="background: linear-gradient"][style*="border-radius: 12px"] > div[style*="display: flex"] {
        flex-direction: column !important;
        align-items: stretch !important;
        gap: 10px !important;
    }

    /* --- Stats grid: 4 -> 2 kolumny --- */
    [style*="grid-template-columns: repeat(4"] {
        grid-template-columns: repeat(2, 1fr) !important;
    }

    /* --- Składka status --- */
    .ks-skladka-container {
        padding: 15px !important;
    }

    /* --- WC zamówienia: filtry --- */
    .ks-tab-content form[style*="display: flex"] {
        flex-direction: column !important;
    }

    /* --- Selektory zawodów/rund --- */
    .ks-wyniki-section select,
    select[style*="min-width: 300px"] {
        min-width: 100% !important;
        width: 100% !important;
    }

    .ks-wyniki-section form[style*="display: flex"] {
        flex-direction: column !important;
    }

    /* --- Wydruk zawodników: zdjęcie mniejsze --- */
    .ks-container img[style*="max-width: 200px"],
    img[style*="max-width:200px"] {
        max-width: 120px !important;
    }

    /* --- Password section --- */
    .ks-password-change-section {
        padding: 15px !important;
    }

    .ks-password-fields {
        max-width: 100% !important;
    }

    /* --- Admin notice --- */
    .ks-admin-notice {
        padding: 10px !important;
        font-size: 14px !important;
    }

    /* --- System header --- */
    .ks-system-header {
        padding: 20px !important;
    }

    .ks-system-header h2 {
        font-size: 20px !important;
    }

    .ks-system-header p {
        font-size: 14px !important;
    }

    /* --- Rejestracja gości --- */
    .ks-rejestracja-gosc-container {
        padding: 15px !important;
    }

    /* --- Payment options --- */
    .ks-payment-option {
        padding: 10px !important;
    }

    /* --- Zawody karty --- */
    .ks-zawody-card {
        padding: 15px !important;
    }
}

/* ============================================
   MOBILE (max-width: 480px)
   ============================================ */
@media (max-width: 480px) {

    /* --- Zakładki: jeszcze mniejsze --- */
    .ks-tabs .ks-tab,
    .ks-tabs-container .ks-tab,
    .ks-klub-tab {
        padding: 8px 12px !important;
        font-size: 13px !important;
    }

    .ks-tab-icon {
        font-size: 14px !important;
    }

    /* --- Kontenery --- */
    .ks-container {
        padding: 10px !important;
        margin: 5px !important;
        border-radius: 8px !important;
    }

    .ks-tab-content {
        padding: 10px !important;
        border-radius: 0 0 8px 8px !important;
    }

    /* --- Tabele: mniejszy font --- */
    table.ks-table,
    table.widefat,
    .ks-payments-table,
    .ks-wplaty-table,
    .ks-kasa-table,
    .ks-kalendarz-table,
    .ks-zgloszenia-table,
    .ks-tab-content table,
    .ks-klub-tab-content table {
        font-size: 11px !important;
    }

    table.ks-table th,
    table.ks-table td,
    table.widefat th,
    table.widefat td,
    .ks-payments-table th,
    .ks-payments-table td,
    .ks-wplaty-table th,
    .ks-wplaty-table td,
    .ks-kasa-table th,
    .ks-kasa-table td,
    .ks-kalendarz-table th,
    .ks-kalendarz-table td,
    .ks-zgloszenia-table th,
    .ks-zgloszenia-table td,
    .ks-tab-content table th,
    .ks-tab-content table td,
    .ks-klub-tab-content table th,
    .ks-klub-tab-content table td {
        padding: 5px 3px !important;
    }

    /* --- Stats grid: 1 kolumna --- */
    [style*="grid-template-columns: repeat(4"],
    [style*="grid-template-columns: repeat(2"] {
        grid-template-columns: 1fr !important;
    }

    /* --- Nagłówki --- */
    .ks-container > h2,
    .ks-tab-content > h2 {
        font-size: 18px !important;
    }

    h3 {
        font-size: 15px !important;
    }

    /* --- Tytuł strony --- */
    h2[style*="text-align:center"] {
        font-size: 20px !important;
    }

    /* --- Badge / Status --- */
    .ks-badge,
    .ks-payment-status,
    .ks-membership-fee-value,
    span[style*="border-radius: 12px"][style*="font-size: 12px"] {
        font-size: 10px !important;
        padding: 3px 8px !important;
    }

    /* --- Submit button --- */
    .ks-submit input,
    .ks-pay-fee-btn {
        width: 100% !important;
        padding: 14px 20px !important;
        font-size: 16px !important;
    }

    /* --- Membership fee banner --- */
    .ks-membership-fee-banner {
        padding: 12px !important;
        border-radius: 8px !important;
    }

    /* --- Zdjęcie zawodnika --- */
    .ks-container img[style*="max-width: 200px"],
    img[style*="max-width:200px"] {
        max-width: 80px !important;
    }

    /* --- Karty --- */
    .ks-card {
        padding: 12px !important;
    }

    .ks-card-title {
        font-size: 15px !important;
    }

    /* --- Grupy checkboxów --- */
    .ks-checkbox-group {
        gap: 8px !important;
        padding: 8px !important;
    }

    /* --- Club group sections --- */
    .ks-club-group {
        padding: 12px !important;
    }

    /* --- Generator dokumentów grid --- */
    [style*="grid-template-columns: repeat(auto-fit, minmax(150px"] {
        grid-template-columns: 1fr !important;
    }

    /* --- Zawody card --- */
    .ks-zawody-card {
        padding: 12px !important;
    }

    /* --- Alert messages --- */
    .ks-alert,
    .ks-message {
        padding: 10px !important;
        font-size: 13px !important;
    }
}
