/* Стили для печати SVG сетки на листе A4 */

/* Для олимпийской системы - альбомная ориентация */
@media print {
    @page {
        size: A4 landscape;
        margin: 10mm;
    }

    /* Скрываем все элементы страницы, кроме сетки */
    html,
    body {
        margin: 0 !important;
        padding: 0 !important;
        background: white !important;
        width: 100% !important;
        height: 100% !important;
    }

    /* Скрываем кнопку печати */
    .print-button-wrapper {
        display: none !important;
    }

    /* Скрываем навигацию, фильтры и все остальное */
    .navbar,
    #filters,
    h1,
    h2,
    footer,
    .messages,
    .alert,
    [data-competition-id] > h1,
    [data-competition-id] > #filters {
        display: none !important;
    }

    /* Показываем контейнер, но скрываем его лишнее содержимое */
    .container {
        margin: 0 !important;
        padding: 0 !important;
        background-color: white !important;
        width: 100% !important;
        max-width: 100% !important;
    }

    .container > *:not([data-competition-id]) {
        display: none !important;
    }

    /* Показываем родительские контейнеры сетки */
    [data-competition-id],
    #bracket-container {
        display: block !important;
        margin: 0 !important;
        padding: 0 !important;
        background-color: white !important;
        width: 100% !important;
        height: auto !important;
        visibility: visible !important;
    }

    /* Скрываем все элементы внутри контейнера, кроме сетки */
    [data-competition-id] > *:not(#bracket-container) {
        display: none !important;
    }

    #bracket-container > *:not(.main-toss):not(.circle-toss-container) {
        display: none !important;
    }

    /* Стили для контейнера сетки */
    .main-toss {
        margin: 0 !important;
        padding: 0 !important;
        background-color: white !important;
        min-width: auto !important;
        min-height: auto !important;
        width: 100% !important;
        height: auto !important;
        display: block !important;
        page-break-inside: avoid;
        overflow: visible !important;
        visibility: visible !important;
    }

    /* Стили для SVG */
    #toss-svg {
        width: 100% !important;
        height: auto !important;
        max-width: 100% !important;
        max-height: 100% !important;
        page-break-inside: avoid;
        display: block !important;
        margin: 0 auto !important;
        background-color: white !important;
        visibility: visible !important;
        opacity: 1 !important;
    }

    /* Предотвращаем разрыв ячеек участников */
    .participant-slot {
        page-break-inside: avoid;
    }

    /* Убираем серый фон у foreignObject */
    foreignObject {
        background-color: white !important;
    }

    /* Убираем тени и эффекты */
    .main-toss,
    #bracket-container {
        box-shadow: none !important;
    }

    /* Стили для круговой системы при печати */
    .circle-toss-container {
        margin: 0 !important;
        padding: 5mm !important;
        background-color: white !important;
        width: 100% !important;
        page-break-inside: avoid;
        font-size: 9pt !important;
    }

    .participants-list-section {
        margin-bottom: 3mm !important;
        padding: 3mm !important;
        page-break-inside: avoid;
    }

    .participants-list-section h2 {
        font-size: 11pt !important;
        margin-bottom: 2mm !important;
        margin-top: 0 !important;
    }

    .participants-list {
        display: grid !important;
        grid-template-columns: repeat(auto-fill, minmax(40mm, 1fr)) !important;
        gap: 1.5mm !important;
    }

    .participant-item {
        padding: 1.5mm 2mm !important;
        min-width: auto !important;
        font-size: 7pt !important;
        border: 1px solid #000 !important;
    }

    .participant-name {
        font-size: 7pt !important;
        margin-bottom: 0.5mm !important;
    }

    .participant-org,
    .participant-number {
        font-size: 6pt !important;
    }

    .rounds-section {
        margin-bottom: 0 !important;
        padding: 3mm !important;
        page-break-inside: avoid;
    }

    .rounds-section h2 {
        font-size: 11pt !important;
        margin-bottom: 2mm !important;
        margin-top: 0 !important;
    }

    .round-container {
        margin-bottom: 2mm !important;
        padding: 1.5mm !important;
        page-break-inside: avoid;
    }

    .round-title {
        font-size: 9pt !important;
        margin-bottom: 1.5mm !important;
        padding-bottom: 0.5mm !important;
    }

    .matches-list {
        gap: 1.5mm !important;
    }

    .match-item {
        padding: 1.5mm !important;
        gap: 1.5mm !important;
        page-break-inside: avoid;
        margin-bottom: 0.5mm !important;
    }

    .match-participant {
        padding: 1.5mm 2mm !important;
        min-width: auto !important;
        font-size: 7pt !important;
        border: 1px solid #000 !important;
        flex: 1 1 auto !important;
    }

    .match-participant-name {
        font-size: 7pt !important;
        margin-bottom: 0.5mm !important;
    }

    .match-participant-org {
        font-size: 6pt !important;
    }

    .match-vs {
        font-size: 8pt !important;
        padding: 0 1.5mm !important;
        flex-shrink: 0 !important;
    }

    .match-score-input {
        width: 40px !important;
        padding: 1.5mm !important;
        border: 1px solid #000 !important;
        background: transparent !important;
        font-size: 7pt !important;
        text-align: center !important;
        flex-shrink: 0 !important;
    }
}

