/* ========== ОСНОВНОЙ АККОРДЕОН (СЕКЦИИ) ========== */

.models-accordion {
    margin: 0;
    width: 100%;
}

.accordion-item {
    border: 1px solid #dee2e6;
    border-radius: 4px;
    margin-bottom: 10px;
    background: #fff;
    overflow: hidden;
}

.accordion-item:last-child {
    margin-bottom: 0;
}

/* Заголовок внешнего аккордеона */
.accordion-header {
    display: flex;
    align-items: center;
    padding: 15px 20px;
    cursor: pointer;
    background: #f8f9fa;
    font-weight: 600;
    font-size: 16px;
    color: #333;
    transition: background 0.2s ease;
    user-select: none;
    gap: 10px;
}

.accordion-header:hover {
    background: #e9ecef;
}

.accordion-header:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

.accordion-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 20px;
    height: 20px;
    transition: transform 0.3s ease;
    color: #6c757d;
}

.accordion-icon svg {
    width: 14px;
    height: 14px;
    display: block;
}

.accordion-item.active .accordion-icon {
    transform: rotate(90deg);
}

.accordion-item.active .accordion-header {
    background: #e9ecef;
}

.accordion-content {
    display: none;
    padding: 20px;
    background: #fff;
}

.accordion-item.active .accordion-content {
    display: block;
}

/* ========== ВНУТРЕННИЙ АККОРДЕОН (ТАБЛИЦЫ) ========== */

.tables-accordion {
    display: flex;
    flex-direction: column;
    gap: 8px;
}

/* Каждая таблица - отдельный элемент */
.table-item {
    border: 1px solid #e9ecef;
    border-radius: 4px;
    background: #fff;
    overflow: hidden;
}

.table-item:last-child {
    margin-bottom: 0;
}

/* Заголовок таблицы (внутренний аккордеон) */
.table-header {
    display: flex;
    align-items: center;
    padding: 10px 15px;
    cursor: pointer;
    background: #f8f9fa;
    font-weight: 500;
    font-size: 14px;
    color: #495057;
    transition: background 0.2s ease;
    user-select: none;
    gap: 8px;
    border-bottom: 1px solid transparent;
}

.table-header:hover {
    background: #e9ecef;
}

.table-header:focus-visible {
    outline: 2px solid #007bff;
    outline-offset: -2px;
}

.table-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    flex-shrink: 0;
    width: 16px;
    height: 16px;
    transition: transform 0.3s ease;
    color: #6c757d;
}

.table-icon svg {
    width: 10px;
    height: 10px;
    display: block;
}

.table-item.active .table-icon {
    transform: rotate(90deg);
}

.table-item.active .table-header {
    background: #e9ecef;
    border-bottom-color: #dee2e6;
}

/* Контент таблицы */
.table-content {
    display: none;
    padding: 15px;
    background: #fff;
}

.table-item.active .table-content {
    display: block;
}

/* ========== САМА ТАБЛИЦА ========== */

.table-wrapper {
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
}

.models-table {
    width: 100%;
    border-collapse: collapse;
    font-size: 14px;
    background: #fff;
    min-width: 600px;
}

.models-table thead th {
    padding: 10px 12px;
    border: 1px solid #dee2e6;
    text-align: center;
    font-weight: 600;
    color: #333;
    background: #f8f9fa;
    white-space: nowrap;
}

.models-table tbody td {
    padding: 8px 12px;
    border: 1px solid #dee2e6;
    text-align: center;
    vertical-align: middle;
}

.models-table .dn-header {
    background: #e9ecef;
    min-width: 80px;
}

.models-table .dn-cell {
    background: #f8f9fa;
    font-weight: 600;
    white-space: nowrap;
    text-align: center;
}

/* ========== ССЫЛКИ НА ФАЙЛЫ ========== */

.file-link {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 6px;
    padding: 5px 12px;
    color: #fff;
    text-decoration: none;
    border-radius: 4px;
    font-size: 12px;
    font-weight: 600;
    transition: all 0.2s ease;
    min-height: 30px;
    min-width: 48px;
    white-space: nowrap;
    border: 1px solid transparent;
}

.file-link:hover {
    color: #fff;
    text-decoration: none;
    transform: translateY(-2px);
    box-shadow: 0 4px 8px rgba(0,0,0,0.2);
}

.file-link:focus-visible {
    outline: 2px solid #333;
    outline-offset: 2px;
}

.file-link:active {
    transform: translateY(0);
    box-shadow: none;
}

.download-icon {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    opacity: 0.8;
    transition: opacity 0.2s ease;
}

.file-link:hover .download-icon {
    opacity: 1;
}

.file-label {
    line-height: 1;
}

/* Цвета для разных форматов */
.file-label-stp { background: #dc3545; border-color: #dc3545; }
.file-label-stp:hover { background: #c82333; border-color: #bd2130; }

.file-label-dwg { background: #007bff; border-color: #007bff; }
.file-label-dwg:hover { background: #0056b3; border-color: #004085; }

.file-label-step { background: #6f42c1; border-color: #6f42c1; }
.file-label-step:hover { background: #5a32a3; border-color: #4a2a8a; }

.file-label-igs { background: #fd7e14; border-color: #fd7e14; }
.file-label-igs:hover { background: #e06b0b; border-color: #c95f0a; }

.file-label-pdf { background: #dc3545; border-color: #dc3545; }
.file-label-pdf:hover { background: #c82333; border-color: #bd2130; }

.file-label-zip { background: #6c757d; border-color: #6c757d; }
.file-label-zip:hover { background: #5a6268; border-color: #4e555b; }

.file-label-rar { background: #6c757d; border-color: #6c757d; }
.file-label-rar:hover { background: #5a6268; border-color: #4e555b; }

/* SAT - оранжевый/золотой */
.file-label-sat {
    background: #e67e22;
    border-color: #e67e22;
}
.file-label-sat:hover {
    background: #d35400;
    border-color: #c0392b;
}

.empty-cell {
    color: #adb5bd;
    font-size: 14px;
}

/* ========== СООБЩЕНИЯ ========== */

.models-error {
    padding: 20px;
    background: #f8d7da;
    border-radius: 4px;
    margin: 20px 0;
    border: 1px solid #f5c6cb;
}

.models-error p {
    color: #721c24;
    margin: 0;
}

.models-error p:not(:last-child) {
    margin-bottom: 5px;
}

.models-empty {
    padding: 60px 20px;
    text-align: center;
    background: #f8f9fa;
    border-radius: 4px;
    border: 1px dashed #dee2e6;
}

.models-empty p {
    margin: 0;
    color: #6c757d;
}

.models-empty p:first-child {
    font-size: 18px;
    font-weight: 500;
}

.models-empty p:last-child {
    margin-top: 8px;
    font-size: 14px;
}

/* ========== АДАПТИВНОСТЬ ========== */

@media (max-width: 768px) {
    .accordion-header {
        padding: 12px 15px;
        font-size: 14px;
    }
    
    .accordion-content {
        padding: 15px;
    }
    
    .accordion-icon {
        width: 16px;
        height: 16px;
    }
    
    .accordion-icon svg {
        width: 12px;
        height: 12px;
    }
    
    .table-header {
        padding: 8px 12px;
        font-size: 13px;
    }
    
    .table-content {
        padding: 10px;
    }
    
    .models-table {
        font-size: 13px;
        min-width: 500px;
    }
    
    .models-table thead th,
    .models-table tbody td {
        padding: 6px 8px;
    }
    
    .file-link {
        padding: 4px 10px;
        font-size: 11px;
        min-height: 26px;
        min-width: 40px;
        gap: 4px;
    }
    
    .download-icon {
        width: 10px;
        height: 10px;
    }
    
    .dn-header {
        min-width: 60px !important;
    }
}

@media (max-width: 480px) {
    .accordion-header {
        padding: 10px 12px;
        font-size: 13px;
    }
    
    .accordion-content {
        padding: 10px;
    }
    
    .accordion-icon {
        width: 14px;
        height: 14px;
    }
    
    .accordion-icon svg {
        width: 10px;
        height: 10px;
    }
    
    .table-header {
        padding: 6px 10px;
        font-size: 12px;
    }
    
    .table-icon {
        width: 14px;
        height: 14px;
    }
    
    .table-icon svg {
        width: 8px;
        height: 8px;
    }
    
    .table-content {
        padding: 8px;
    }
    
    .models-table {
        font-size: 12px;
        min-width: 400px;
    }
    
    .models-table thead th,
    .models-table tbody td {
        padding: 4px 6px;
    }
    
    .file-link {
        padding: 3px 8px;
        font-size: 10px;
        min-height: 22px;
        min-width: 32px;
        gap: 3px;
        border-radius: 3px;
    }
    
    .download-icon {
        width: 8px;
        height: 8px;
    }
}

/* Для пользователей, которые предпочитают меньше движения */
@media (prefers-reduced-motion: reduce) {
    .accordion-icon,
    .table-icon,
    .file-link,
    .download-icon {
        transition: none;
    }
    
    .file-link:hover {
        transform: none;
    }
}