.files-grid,
.files-table-container {
    margin: 1.5rem 0;
}

.files-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1rem;
}

.file-card {
    background-color: #fff;
    border: 1px solid #e5e7eb;
    border-radius: 12px;
    padding: 1.25rem;
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: all 0.3s ease;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
}

.file-card:hover {
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
    border-color: #d1d5db;
    transform: translateY(-2px);
}

.file-card-header {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    flex: 1;
    min-width: 0;
}

.file-icon {
    font-size: 1.5rem;
    flex-shrink: 0;
    margin-top: 0.125rem;
    color: #6b7280;
}

.file-info {
    flex: 1;
    min-width: 0;
}

.file-name {
    color: #374151;
    text-decoration: none;
    font-weight: 500;
    font-size: 0.875rem;
    line-height: 1.4;
    display: block;
    margin-bottom: 0.5rem;
    transition: color 0.2s ease;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
}

.file-name:hover {
    color: #2563eb;
    text-decoration: none;
}

.file-meta {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
}

.file-size {
    color: #6b7280;
    font-size: 0.75rem;
    font-weight: 400;
    padding: 0.25rem 0.5rem;
    background-color: #f9fafb;
    border-radius: 6px;
    border: 1px solid #e5e7eb;
}

.file-downloads {
    color: #059669;
    font-size: 0.75rem;
    font-weight: 400;
    padding: 0.25rem 0.5rem;
    background-color: #f0fdf4;
    border-radius: 6px;
    border: 1px solid #dcfce7;
    display: flex;
    align-items: center;
    gap: 0.25rem;
}

.file-downloads-icon {
    font-size: 0.6875rem;
}

.file-download-btn {
    background: #f8f9fa;
    color: #374151 !important;
    text-decoration: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    font-weight: 500;
    font-size: 0.8125rem;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    transition: all 0.3s ease;
    border: 1px solid #e5e7eb;
    box-shadow: 0 1px 2px rgba(0, 0, 0, 0.05);
    white-space: nowrap;
}

.file-download-btn:hover {
    background: #2563eb;
    color: #fff !important;
    border-color: #2563eb;
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(37, 99, 235, 0.2);
}

.file-download-btn .icms-svg-icon {
    width: 16px;
    height: 16px;
    transition: transform 0.2s ease;
}

.file-download-btn:hover .icms-svg-icon {
    transform: translateY(1px);
}

.download-text {
    font-weight: 500;
}

@keyframes fileAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-card {
    animation: fileAppear 0.3s ease forwards;
}

@media (min-width: 768px) {
    .files-table-container {
        width: 100%;
    }

    .files-table {
        width: 100%;
        display: table;
        border-collapse: collapse;
        background-color: #fff;
        border-radius: 12px;
        overflow: hidden;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        border: 1px solid #e5e7eb;
    }

    .files-table-header {
        display: table-header-group;
        background-color: #f9fafb;
    }

    .files-table-body {
        display: table-row-group;
    }

    .file-table-row {
        display: table-row;
        transition: all 0.3s ease;
    }

    .file-table-row:hover {
        background-color: #f9fafb;
    }

    .file-cell {
        display: table-cell;
        padding: 1rem;
        vertical-align: middle;
        border-bottom: 1px solid #f3f4f6;
    }

    .files-table-header .file-cell {
        font-weight: 600;
        font-size: 0.875rem;
        color: #374151;
        border-bottom: 2px solid #e5e7eb;
        text-align: left;
        padding: 0.875rem 1rem;
    }

    .file-table-row:last-child .file-cell {
        border-bottom: none;
    }

    .file-icon-col {
        width: 40px;
        text-align: center;
    }

    .file-name-col {
        min-width: 200px;
        max-width: 400px;
    }

    .file-size-col,
    .file-downloads-col {
        width: 100px;
        text-align: center;
    }

    .file-size-col {
        font-size: 0.8125rem;
        color: #6b7280;
    }

    .file-action-col {
        width: 120px;
        text-align: center;
    }

    .files-table .file-download-btn {
        padding: 0.5rem 0.875rem;
    }

    .download-text {
        display: none;
    }

    .files-table .file-icon {
        font-size: 1.25rem;
        color: #6b7280;
    }

    .files-table .file-name {
        color: #374151;
        text-decoration: none;
        font-weight: 500;
        font-size: 0.875rem;
        transition: color 0.2s ease;
        overflow: hidden;
        text-overflow: ellipsis;
        white-space: nowrap;
        line-height: 1.4;
    }

    .files-table .file-name:hover {
        color: #2563eb;
        text-decoration: underline;
    }

    .files-table .file-downloads {
        color: #059669;
        font-size: 0.75rem;
        font-weight: 500;
        padding: 0.25rem 0.5rem;
        background-color: #f0fdf4;
        border-radius: 6px;
        border: 1px solid #dcfce7;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }
}

@media (min-width: 1024px) {
    .file-size-col,
    .file-downloads-col {
        width: 120px;
    }

    .file-action-col {
        width: 140px;
    }

    .download-text {
        display: inline;
    }
}

@media (max-width: 767px) {
    .files-table-container {
        display: grid;
        grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
        gap: 1rem;
    }

    .files-table {
        display: contents;
    }

    .files-table-header {
        display: none;
    }

    .files-table-body {
        display: contents;
    }

    .file-table-row {
        display: flex;
        flex-direction: column;
        background-color: #fff;
        border: 1px solid #e5e7eb;
        border-radius: 12px;
        padding: 1.25rem;
        transition: all 0.3s ease;
        box-shadow: 0 1px 3px rgba(0, 0, 0, 0.05);
        gap: 0.75rem;
    }

    .file-table-row:hover {
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.08);
        border-color: #d1d5db;
        transform: translateY(-2px);
        background-color: #fff;
    }

    .file-cell {
        display: flex;
        width: 100%;
        padding: 0;
        border: none;
    }

    .file-icon-col {
        order: 1;
        justify-content: flex-start;
    }

    .file-name-col {
        order: 2;
    }

    .file-action-col {
        order: 3;
        margin-top: 0.5rem;
    }

    .file-size-col,
    .file-downloads-col {
        order: 4;
        display: flex !important;
        margin-top: 0.5rem;
    }

    .file-table-row .file-icon {
        font-size: 1.5rem;
        color: #6b7280;
        margin-bottom: 0.5rem;
    }

    .file-table-row .file-name {
        color: #374151;
        font-weight: 500;
        font-size: 0.875rem;
        line-height: 1.4;
        white-space: nowrap;
        overflow: hidden;
        text-overflow: ellipsis;
    }

    .file-table-row .file-name:hover {
        color: #2563eb;
        text-decoration: none;
    }

    .file-table-row .file-meta {
        display: flex;
        align-items: center;
        gap: 0.75rem;
        flex-wrap: wrap;
        margin-top: 0.5rem;
    }

    .file-table-row .file-size,
    .file-table-row .file-downloads {
        color: #6b7280;
        font-size: 0.75rem;
        font-weight: 400;
        padding: 0.25rem 0.5rem;
        background-color: #f9fafb;
        border-radius: 6px;
        border: 1px solid #e5e7eb;
        display: inline-flex;
        align-items: center;
        gap: 0.25rem;
    }

    .file-table-row .file-downloads {
        color: #059669;
        background-color: #f0fdf4;
        border-color: #dcfce7;
    }

    .file-table-row .file-download-btn {
        width: 100%;
        justify-content: center;
        padding: 0.75rem 1rem;
        font-size: 0.875rem;
    }

    .file-table-row .download-text {
        display: inline;
    }

    .file-size-col,
    .file-downloads-col {
        display: none !important;
    }
}

@media (max-width: 480px) {
    .files-grid,
    .files-table-container {
        grid-template-columns: 1fr;
        gap: 0.75rem;
    }

    .file-card,
    .file-table-row {
        padding: 1rem;
    }

    .file-icon {
        font-size: 1.25rem;
    }

    .file-name {
        font-size: 0.8125rem;
    }

    .file-card .file-download-btn,
    .file-table-row .file-download-btn {
        padding: 0.625rem 1rem;
    }
}

@media (prefers-color-scheme: dark) {
    .file-card,
    .file-table-row {
        background-color: #1f2937;
        border-color: #374151;
    }

    .file-card:hover,
    .file-table-row:hover {
        background-color: #374151;
        border-color: #4b5563;
        box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    }

    .file-name {
        color: #e5e7eb;
    }

    .file-name:hover {
        color: #60a5fa;
    }

    .file-icon {
        color: #9ca3af;
    }

    .file-size {
        background-color: #374151;
        border-color: #4b5563;
        color: #d1d5db;
    }

    .file-downloads {
        background-color: #065f46;
        border-color: #047857;
        color: #6ee7b7;
    }

    .file-download-btn {
        background: #374151;
        color: #e5e7eb !important;
        border-color: #4b5563;
    }

    .file-download-btn:hover {
        background: #60a5fa;
        color: #1f2937 !important;
        border-color: #60a5fa;
    }

    @media (min-width: 768px) {
        .files-table {
            background-color: #1f2937;
            border-color: #374151;
        }

        .files-table-header .file-cell {
            background-color: #111827;
            color: #e5e7eb;
            border-bottom-color: #374151;
        }

        .file-cell {
            border-bottom-color: #374151;
            color: #d1d5db;
        }

        .files-table .file-icon {
            color: #9ca3af;
        }

        .files-table .file-name {
            color: #e5e7eb;
        }

        .files-table .file-name:hover {
            color: #60a5fa;
        }

        .files-table .file-downloads {
            background-color: #065f46;
            border-color: #047857;
            color: #6ee7b7;
        }
    }
}

@keyframes tableRowAppear {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.file-table-row {
    animation: tableRowAppear 0.3s ease forwards;
}

.file-card {
    animation: fileAppear 0.3s ease forwards;
}

.file-download-btn:focus {
    outline: 2px solid #3b82f6;
    outline-offset: 2px;
}

.file-name:focus {
    outline: 1px dashed #3b82f6;
}

.files-table-header {
    position: absolute;
    width: 1px;
    height: 1px;
    padding: 0;
    margin: -1px;
    overflow: hidden;
    clip: rect(0, 0, 0, 0);
    white-space: nowrap;
    border: 0;
}

@media (min-width: 768px) {
    .files-table-header {
        position: static;
        width: auto;
        height: auto;
        margin: 0;
        overflow: visible;
        clip: auto;
        white-space: normal;
    }
}

.file-name {
    display: block;
    overflow: hidden;
    text-overflow: ellipsis;
    white-space: nowrap;
    max-width: 100%;
}

@media (prefers-color-scheme: dark) {
    .file-name[title]:hover::after {
        background: #e5e7eb;
        color: #374151;
    }
}

@media (max-width: 767px) {
    .file-name {
        white-space: normal;
        word-break: break-word;
        line-height: 1.5;
    }

    .file-name[title]:hover::after {
        display: none;
    }
}

.file-info {
    min-width: 0;
}

.file-card .file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.file-card,
.file-table-row,
.file-download-btn {
    transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
}

/* Для грида */

.files-grid.grid-cols-1 {
    grid-template-columns: repeat(1, minmax(0, 1fr));
}

.files-grid.grid-cols-2 {
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
}

.files-grid.grid-cols-3 {
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
}

@media (max-width: 1024px) {
    .files-grid.grid-cols-3 {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 768px) {
    .files-grid.grid-cols-2,
    .files-grid.grid-cols-3 {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }
}

@media (max-width: 640px) {
    .files-grid.grid-cols-1,
    .files-grid.grid-cols-2,
    .files-grid.grid-cols-3 {
        grid-template-columns: 1fr;
    }
}

.file-card {
    min-width: 0;
}

.file-info {
    min-width: 0;
}

.file-name {
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.files-grid.grid-cols-1 {
    gap: 1rem;
}

.files-grid.grid-cols-2 {
    gap: 1rem;
}

.files-grid.grid-cols-3 {
    gap: 0.875rem;
}

.file-download-btn {
    flex-shrink: 0;
    white-space: nowrap;
}