/* ==================== ОСНОВНЫЕ СТИЛИ ==================== */

/* Сброс стилей и базовые настройки */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* Стили для тела страницы */
body {
    font-family: system-ui, -apple-system, 'Segoe UI', Roboto, sans-serif;
    background: linear-gradient(135deg, #0a0f1e 0%, #0c1222 100%);
    min-height: 100vh;
    padding: 20px;
    color: #e2e8f0;
}

/* Контейнер для центрирования содержимого */
.container {
    max-width: 1400px;
    margin: 0 auto;
    width: 100%;
}

/* ==================== СТЕКЛЯННЫЕ КАРТОЧКИ ==================== */

/* Основной стиль для карточек с эффектом стекла */
.glass-card {
    background: rgba(18, 25, 45, 0.85);
    backdrop-filter: blur(14px);
    border-radius: 2rem;
    border: 1px solid rgba(59, 130, 246, 0.3);
    padding: 2rem;
    transition: all 0.3s ease;
}

/* Карточка входа (ограниченная ширина) */
.login-box {
    max-width: 450px;
    margin: 0 auto;
}

/* Карточка дашборда (полная ширина) */
.dashboard-box {
    max-width: 1400px;
    margin: 0 auto;
}

/* ==================== ЗАГОЛОВКИ ==================== */

h2 {
    color: #eef5ff;
    font-weight: 600;
    font-size: 1.5rem;
    margin-bottom: 1.5rem;
    border-left: 4px solid #3b82f6;
    padding-left: 1rem;
}

/* ==================== ФОРМЫ И ЭЛЕМЕНТЫ ВВОДА ==================== */

.form-group {
    margin-bottom: 1.25rem;
}

label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 500;
    color: #cbd5e6;
    font-size: 0.9rem;
}

input, select {
    width: 100%;
    padding: 0.75rem 1rem;
    background: #0f1a2b;
    border: 1px solid #2c3e5c;
    border-radius: 1rem;
    color: #e2e8f0;
    font-size: 1rem;
    outline: none;
    transition: all 0.2s;
}

input:focus, select:focus {
    border-color: #3b82f6;
    box-shadow: 0 0 0 3px rgba(59, 130, 246, 0.2);
}

/* ==================== КНОПКИ ==================== */

button {
    border: none;
    border-radius: 2rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
    font-size: 0.95rem;
}

.btn-primary {
    background: linear-gradient(135deg, #3b82f6, #2563eb);
    color: white;
    padding: 0.75rem 1.5rem;
    width: 100%;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(59, 130, 246, 0.4);
}

.btn-secondary {
    background: #334155;
    color: #e2e8f0;
    padding: 0.5rem 1.2rem;
}

.btn-secondary:hover {
    background: #475569;
}

.btn-success {
    background: #10b981;
    color: white;
    padding: 0.5rem 1.2rem;
}

.btn-success:hover {
    background: #059669;
}

/* Сортировочные кнопки */
.sort-btn {
    background: #2d3748;
    color: #cbd5e6;
    padding: 0.5rem 1.2rem;
    font-size: 0.85rem;
    display: inline-flex;
    align-items: center;
    gap: 6px;
}

.sort-btn.active {
    background: #3b82f6;
    box-shadow: 0 0 8px rgba(59, 130, 246, 0.5);
}

.sort-btn:hover {
    background: #3b82f6;
    transform: translateY(-1px);
}

/* ==================== ПАНЕЛИ И ИНФОРМАЦИЯ ==================== */

.info-panel {
    background: rgba(15, 26, 42, 0.9);
    border-radius: 1rem;
    padding: 1rem 1.25rem;
    margin-bottom: 1.5rem;
    border: 1px solid #2d3a5e;
    font-size: 0.9rem;
}

.info-panel div {
    margin-bottom: 0.5rem;
}

.indexer-badge {
    background: #1e2a47;
    display: inline-block;
    padding: 0.25rem 0.75rem;
    border-radius: 20px;
    font-size: 0.75rem;
    margin-left: 0.5rem;
}

/* ==================== ПОИСКОВАЯ СТРОКА ==================== */

.search-row {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    margin-bottom: 1rem;
}

.search-row input {
    flex: 3;
    min-width: 200px;
}

.search-row select {
    flex: 1;
    min-width: 150px;
}

.search-row button {
    flex: 1;
    min-width: 120px;
}

.toolbar-row {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 12px;
    margin-bottom: 1rem;
    flex-wrap: wrap;
}

.results-count {
    background: rgba(15, 26, 42, 0.8);
    padding: 0.4rem 1rem;
    border-radius: 2rem;
    font-size: 0.85rem;
    color: #90b4f0;
}

/* ==================== ТАБЛИЦА РЕЗУЛЬТАТОВ ==================== */

.results-table {
    overflow-x: auto;
    margin-top: 1rem;
}

table {
    width: 100%;
    border-collapse: collapse;
    font-size: 0.85rem;
}

th, td {
    padding: 0.75rem 0.5rem;
    text-align: left;
    border-bottom: 1px solid #2d3a5e;
}

th {
    color: #90b4f0;
    font-weight: 600;
    background: rgba(15, 26, 42, 0.5);
}

.sortable-header {
    cursor: pointer;
    user-select: none;
    transition: color 0.2s;
}

.sortable-header:hover {
    color: #3b82f6;
}

.sort-icon {
    display: inline-block;
    margin-left: 5px;
    font-size: 0.7rem;
    opacity: 0.7;
}

.badge {
    background: #1e2a47;
    padding: 0.2rem 0.6rem;
    border-radius: 30px;
    font-size: 0.7rem;
    display: inline-block;
}

/* Действия с торрентами */
.action-buttons {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

.action-btn {
    background: #2d3748;
    padding: 0.3rem 0.7rem;
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: #cbd5e6;
    border: none;
    white-space: nowrap;
}

.action-btn:hover {
    background: #3b82f6;
    color: white;
    transform: translateY(-1px);
}

.download-btn:hover {
    background: #059669;
}

.magnet-btn:hover {
    background: #7c3aed;
}

/* ==================== СООБЩЕНИЯ ==================== */

.error-msg {
    background: rgba(239, 68, 68, 0.2);
    border-left: 4px solid #ef4444;
    padding: 0.75rem;
    border-radius: 0.75rem;
    margin-top: 1rem;
    color: #fca5a5;
}

.placeholder {
    text-align: center;
    padding: 3rem;
    color: #6c86a3;
}

/* ==================== ПАНЕЛЬ ОТЛАДКИ ==================== */

.debug-panel {
    background: #0a0f1e;
    border-radius: 1rem;
    padding: 0.75rem;
    margin-top: 1rem;
    font-family: monospace;
    font-size: 0.7rem;
    color: #ffd966;
    border: 1px solid #3b82f6;
    max-height: 250px;
    overflow-y: auto;
}

.debug-panel pre {
    margin: 0;
    white-space: pre-wrap;
    word-break: break-all;
}

/* ==================== МОДАЛЬНОЕ ОКНО ==================== */

.magnet-modal {
    position: fixed;
    z-index: 1000;
    left: 0;
    top: 0;
    width: 100%;
    height: 100%;
    background-color: rgba(0, 0, 0, 0.85);
    display: flex;
    justify-content: center;
    align-items: center;
}

.magnet-modal-content {
    background: #0f172a;
    border-radius: 1.5rem;
    padding: 1.5rem;
    max-width: 700px;
    width: 90%;
    border: 1px solid #3b82f6;
    box-shadow: 0 20px 40px rgba(0, 0, 0, 0.4);
}

.magnet-modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1rem;
    border-bottom: 1px solid #2d3a5e;
    padding-bottom: 0.75rem;
}

.magnet-modal-header h3 {
    color: #3b82f6;
    margin: 0;
}

.close-magnet-modal {
    background: none;
    border: none;
    color: #94a3b8;
    font-size: 2rem;
    cursor: pointer;
    padding: 0 0.5rem;
    line-height: 1;
}

.close-magnet-modal:hover {
    color: #ef4444;
}

.magnet-title {
    color: #cbd5e6;
    font-size: 0.9rem;
    word-break: break-word;
    margin-bottom: 1rem;
}

.magnet-url {
    background: #0a0f1e;
    padding: 1rem;
    border-radius: 1rem;
    font-family: monospace;
    font-size: 0.75rem;
    word-break: break-all;
    color: #a5f3c3;
    margin: 1rem 0;
    max-height: 200px;
    overflow-y: auto;
}

.magnet-actions {
    display: flex;
    gap: 1rem;
    justify-content: flex-end;
}

/* ==================== ТОСТ-УВЕДОМЛЕНИЯ ==================== */

.toast {
    position: fixed;
    bottom: 20px;
    right: 20px;
    padding: 12px 20px;
    border-radius: 12px;
    font-size: 0.85rem;
    z-index: 1100;
    animation: fadeInOut 2.5s ease;
}

.toast-success {
    background: #10b981;
    color: white;
}

.toast-error {
    background: #ef4444;
    color: white;
}

@keyframes fadeInOut {
    0% { opacity: 0; transform: translateY(20px); }
    15% { opacity: 1; transform: translateY(0); }
    85% { opacity: 1; transform: translateY(0); }
    100% { opacity: 0; transform: translateY(-20px); }
}

/* ==================== FOOTER ==================== */

footer {
    font-size: 0.7rem;
    text-align: center;
    margin-top: 2rem;
    padding-top: 1rem;
    border-top: 1px solid #2d3a5e;
    color: #5f7ea0;
}

/* ==================== УТИЛИТЫ ==================== */

.flex-between {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
    margin-bottom: 1.5rem;
}

/* Адаптивность для мобильных устройств */
@media (max-width: 768px) {
    .glass-card {
        padding: 1.25rem;
    }
    
    h2 {
        font-size: 1.25rem;
    }
    
    .search-row {
        flex-direction: column;
    }
    
    .search-row input,
    .search-row select,
    .search-row button {
        width: 100%;
    }
    
    .toolbar-row {
        flex-direction: column;
        align-items: stretch;
    }
    
    .action-buttons {
        flex-direction: column;
    }
    
    th, td {
        font-size: 0.75rem;
        padding: 0.5rem 0.25rem;
    }
}
/* Группа кнопок */
.button-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.button-group .btn-secondary {
    margin: 0;
    white-space: nowrap;
}

/* Разделитель */
.button-divider {
    color: #2d3a5e;
    font-size: 1.2rem;
    user-select: none;
}
/* Стили для кнопок Home Assistant */
.ha-btn {
    background: #7c3aed;
}

.film-btn {
    background: #3b82f6;
}

.film-btn:hover {
    background: #2563eb;
}

.serial-btn {
    background: #10b981;
}

.serial-btn:hover {
    background: #059669;
}

.random-btn {
    background: #f59e0b;
}

.random-btn:hover {
    background: #d97706;
}

.ha-btn:hover {
    transform: translateY(-1px);
    filter: brightness(1.1);
}

/* Адаптация для мобильных */
@media (max-width: 768px) {
    .action-buttons {
        display: grid;
        grid-template-columns: repeat(2, 1fr);
        gap: 5px;
    }
    
    .action-btn {
        text-align: center;
        font-size: 0.65rem;
        padding: 0.25rem 0.5rem;
    }
}
/* Действия с торрентами - две колонки */
.action-buttons {
    display: flex;
    gap: 8px;
    min-width: 170px;
}

/* Левая колонка */
.action-left {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

/* Правая колонка */
.action-right {
    display: flex;
    flex-direction: column;
    gap: 5px;
    flex: 1;
}

.action-btn {
    background: #2d3748;
    padding: 0.3rem 0.5rem;
    border-radius: 20px;
    font-size: 0.7rem;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
    color: #cbd5e6;
    border: none;
    white-space: nowrap;
    text-align: center;
    width: 100%;
}

.action-btn:hover {
    background: #3b82f6;
    color: white;
    transform: translateY(-1px);
}

/* Левая колонка - скачивание */
.download-btn {
    background: #059669;
}

.download-btn:hover {
    background: #047857;
}

.magnet-btn {
    background: #7c3aed;
}

.magnet-btn:hover {
    background: #6d28d9;
}

/* Правая колонка - медиатека */
.film-btn {
    background: #3b82f6;
}

.film-btn:hover {
    background: #2563eb;
}

.serial-btn {
    background: #10b981;
}

.serial-btn:hover {
    background: #059669;
}

.random-btn {
    background: #f5510b;
}

.random-btn:hover {
    background: #87492a;
}

/* Адаптация для мобильных устройств */
@media (max-width: 768px) {
    .action-buttons {
        flex-direction: column;
        gap: 5px;
    }
    
    .action-left, .action-right {
        flex-direction: row;
    }
    
    .action-btn {
        font-size: 0.65rem;
        padding: 0.25rem 0.3rem;
    }
}