/* Современные стили для управления роботами Bitrix24 */

/* Сброс и базовые стили */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: #333;
    line-height: 1.6;
    min-height: 100vh;
    padding: 20px;
}

/* Заголовок страницы */
.page-header {
    text-align: center;
    margin-bottom: 40px;
    color: white;
}

.page-header h1 {
    font-size: 2.5rem;
    font-weight: 300;
    text-shadow: 0 2px 4px rgba(0,0,0,0.3);
    margin-bottom: 10px;
}

.page-header p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Контейнер для таблиц */
.table-container {
    display: flex;
    gap: 30px;
    max-width: 1400px;
    margin: 0 auto;
    flex-wrap: wrap;
    justify-content: center;
    align-items: flex-start;  /* Выравнивание по верху */
}

/* Стили для таблиц */
table {
    background: white;
    border-radius: 12px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.2);
    border-collapse: separate;
    border-spacing: 0;
    overflow: hidden;
    width: 100%;
    max-width: 600px;
    margin-bottom: 20px;
    animation: slideInUp 0.6s ease-out;
    align-self: flex-start;  /* Принудительное выравнивание по верху */
}

/* Заголовок таблицы */
table caption {
    background: linear-gradient(45deg, #4a90e2, #357abd);
    color: white;
    padding: 20px;
    font-size: 1.3rem;
    font-weight: 600;
    text-align: center;
    margin: 0;
    border-radius: 12px 12px 0 0;
    text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

/* Заголовки столбцов */
th {
    background: linear-gradient(to bottom, #f8f9fa, #e9ecef);
    border-bottom: 2px solid #dee2e6;
    padding: 15px 12px;
    font-weight: 600;
    color: #495057;
    text-align: left;
    font-size: 0.95rem;
}

th:first-child {
    width: 60px;
    text-align: center;
}

th:nth-child(3), th:nth-child(4) {
    width: 100px;
    text-align: center;
}

/* Ячейки таблицы */
td {
    padding: 15px 12px;
    border-bottom: 1px solid #e9ecef;
    vertical-align: middle;
    transition: background-color 0.2s ease;
}

td:first-child {
    text-align: center;
}

td:nth-child(3), td:nth-child(4) {
    text-align: center;
}

/* Чередование строк */
tbody tr:nth-child(even) {
    background-color: #f8f9fa;
}

tbody tr:hover {
    background-color: #e3f2fd;
    transform: translateY(-1px);
    transition: all 0.2s ease;
}

/* Индикатор установки */
.installed, .installed-task {
    display: inline-block;
    width: 24px;
    height: 24px;
    border-radius: 50%;
    background: #dc3545;
    color: white;
    text-align: center;
    line-height: 24px;
    font-size: 12px;
    font-weight: bold;
    transition: all 0.3s ease;
}

.installed:empty, .installed-task:empty {
    background: #dc3545;
}

.installed:not(:empty), .installed-task:not(:empty) {
    background: linear-gradient(45deg, #28a745, #20c997);
    animation: pulse 2s infinite;
}

/* Кнопки действий */
.install-crm, .uninstall-crm, .install-task, .uninstall-task {
    display: inline-block;
    padding: 8px 16px;
    text-decoration: none;
    border-radius: 6px;
    font-size: 0.85rem;
    font-weight: 500;
    transition: all 0.2s ease;
    cursor: pointer;
    border: none;
    margin: 2px;
}

.install-crm, .install-task {
    background: linear-gradient(45deg, #28a745, #20c997);
    color: white;
}

.install-crm:hover, .install-task:hover {
    background: linear-gradient(45deg, #218838, #1e7e34);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(40, 167, 69, 0.3);
}

.uninstall-crm, .uninstall-task {
    background: linear-gradient(45deg, #dc3545, #c82333);
    color: white;
}

.uninstall-crm:hover, .uninstall-task:hover {
    background: linear-gradient(45deg, #c82333, #a71e2a);
    transform: translateY(-1px);
    box-shadow: 0 4px 8px rgba(220, 53, 69, 0.3);
}

/* Скрытые кнопки */
.install-crm:hidden, .install-task:hidden,
.uninstall-crm:hidden, .uninstall-task:hidden {
    display: none;
}

/* Название робота */
tbody td:nth-child(2) {
    font-weight: 500;
    color: #495057;
    max-width: 300px;
    word-wrap: break-word;
}

/* Анимации */
@keyframes slideInUp {
    from {
        opacity: 0;
        transform: translateY(30px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

@keyframes pulse {
    0% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0.7);
    }
    70% {
        box-shadow: 0 0 0 10px rgba(40, 167, 69, 0);
    }
    100% {
        box-shadow: 0 0 0 0 rgba(40, 167, 69, 0);
    }
}

/* Загрузчик */
.loading {
    display: none;
    text-align: center;
    padding: 20px;
    color: white;
}

.loading.active {
    display: block;
}

.spinner {
    border: 3px solid rgba(255,255,255,0.3);
    border-top: 3px solid white;
    border-radius: 50%;
    width: 30px;
    height: 30px;
    animation: spin 1s linear infinite;
    margin: 0 auto 10px;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

/* Уведомления */
.notification {
    position: fixed;
    top: 20px;
    right: 20px;
    padding: 15px 20px;
    border-radius: 8px;
    color: white;
    font-weight: 500;
    z-index: 1000;
    opacity: 0;
    transform: translateX(100%);
    transition: all 0.3s ease;
}

.notification.show {
    opacity: 1;
    transform: translateX(0);
}

.notification.success {
    background: linear-gradient(45deg, #28a745, #20c997);
}

.notification.error {
    background: linear-gradient(45deg, #dc3545, #c82333);
}

/* Адаптивность */
@media (max-width: 768px) {
    .table-container {
        flex-direction: column;
        gap: 20px;
        align-items: stretch;  /* На мобильных растягиваем таблицы по ширине */
    }
    
    table {
        max-width: 100%;
        align-self: stretch;   /* Растягиваем таблицы по ширине контейнера */
    }
    
    .page-header h1 {
        font-size: 2rem;
    }
    
    th, td {
        padding: 10px 8px;
        font-size: 0.9rem;
    }
    
    .install-crm, .uninstall-crm, 
    .install-task, .uninstall-task {
        padding: 6px 12px;
        font-size: 0.8rem;
    }
}

@media (max-width: 480px) {
    body {
        padding: 10px;
    }
    
    .page-header h1 {
        font-size: 1.5rem;
    }
    
    th:nth-child(1) {
        width: 40px;
    }
    
    th:nth-child(3), th:nth-child(4) {
        width: 80px;
    }
    
    .install-crm, .uninstall-crm, 
    .install-task, .uninstall-task {
        padding: 4px 8px;
        font-size: 0.75rem;
    }
}

/* Темы */
.dark-theme {
    background: linear-gradient(135deg, #2c3e50 0%, #3498db 100%);
}

.dark-theme table {
    background: #34495e;
    color: #ecf0f1;
}

.dark-theme th {
    background: linear-gradient(to bottom, #2c3e50, #34495e);
    color: #ecf0f1;
    border-bottom-color: #4a6741;
}

.dark-theme tbody tr:nth-child(even) {
    background-color: #3c5a78;
}

.dark-theme tbody tr:hover {
    background-color: #4a90e2;
}