/* Общие стили и сброс */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

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

/* Кнопка "Вернуться" */
.back-button {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 8px 16px;
    background: transparent;
    border: none;
    color: #666;
    font-size: 15px;
    cursor: pointer;
    margin-bottom: 30px;
    transition: color 0.2s;
}

.back-button:hover {
    color: #333;
}

.back-icon {
    width: 20px;
    height: 20px;
    border: 2px solid currentColor;
    border-radius: 50%;
    position: relative;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-icon::before {
    content: '';
    width: 8px;
    height: 8px;
    border-left: 2px solid currentColor;
    border-bottom: 2px solid currentColor;
    transform: rotate(45deg);
    margin-left: 2px;
}

/* Контейнер */
.container {
    max-width: 900px;
    margin: 0 auto;
}

/* Карточка */
.card {
    background: white;
    border-radius: 16px;
    padding: 40px;
    box-shadow: 0 4px 20px rgba(0, 0, 0, 0.08);
    margin-bottom: 30px;
}

/* Заголовок карточки */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 24px;
    flex-wrap: wrap;
    gap: 16px;
}

.card-title {
    font-size: 20px;
    font-weight: 600;
    color: #222;
    margin: inherit;
}

/* Описание */
.card-description {
    color: #666;
    font-size: 15px;
    line-height: 1.6;
    margin-bottom: 24px;
}

/* Кнопка "Инструкция" */
.instruction-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 20px;
    background: white;
    border: 1px solid #4BA3E3;
    border-radius: 8px;
    color: #4BA3E3;
    font-size: 14px;
    cursor: pointer;
    transition: all 0.2s;
    text-decoration: none;
}

.instruction-btn:hover {
    background: #f0f8ff;
}

.instruction-btn::before {
    content: '📖';
    font-size: 16px;
}

/* Инпуты */
.input-group {
    display: flex;
    gap: 12px;
    margin-bottom: 24px;
}

.input-field {
    flex: 1;
    padding: 14px 18px;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.input-field:focus {
    outline: none;
    border-color: #4BA3E3;
}

.input-field::placeholder {
    color: #999;
}

/* Кнопки */
.btn {
    padding: 12px 24px;
    border: none;
    border-radius: 10px;
    font-size: 15px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
    justify-content: center;
}

.btn-primary {
    background: #4BA3E3;
    color: white;
}

.btn-primary:hover {
    background: #3d8fc7;
    transform: translateY(-1px);
    box-shadow: 0 4px 12px rgba(75, 163, 227, 0.3);
}

.btn-secondary {
    background: white;
    color: #4BA3E3;
    border: 1px solid #4BA3E3;
}

.btn-secondary:hover {
    background: #f0f8ff;
}

.btn-danger {
    background: white;
    color: #dc3545;
    border: 1px solid #dc3545;
}

.btn-danger:hover {
    background: #fff5f5;
}

.btn-icon {
    width: 18px;
    height: 18px;
}

/* Код бота */
.bot-username {
    display: inline-flex;
    align-items: center;
    gap: 16px;
    padding: 14px 18px;
    background: #f8f9fa;
    border: 1px solid #e0e0e0;
    border-radius: 10px;
    font-family: 'Courier New', monospace;
    font-size: 15px;
    color: #333;
}

/* Список источников */
.source-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
    margin-bottom: 24px;
}

.source-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #f0f4f7;
    border-radius: 10px;
    transition: background 0.2s;
}

.source-item:hover {
    background: #e8eef3;
}

.source-info {
    display: flex;
    align-items: center;
    gap: 12px;
}

.source-icon {
    font-size: 20px;
}

.source-name {
    font-size: 15px;
    color: #333;
}

.delete-btn {
    width: 36px;
    height: 36px;
    border: 1px solid #dc3545;
    background: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
    color: #dc3545;
}

.delete-btn:hover {
    background: #fff5f5;
}

/* Популярные источники */
.popular-sources {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 16px;
    margin-top: 24px;
}

.popular-item {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 14px 18px;
    background: #f8f9fa;
    border-radius: 10px;
}

.popular-info {
    display: flex;
    align-items: center;
    gap: 12px;
    flex: 1;
}

.popular-actions {
    display: flex;
    gap: 8px;
}

.icon-btn {
    width: 36px;
    height: 36px;
    border: none;
    background: #4BA3E3;
    color: white;
    border-radius: 8px;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.2s;
}

.icon-btn:hover {
    background: #3d8fc7;
    transform: translateY(-1px);
}

.load-more-btn {
    display: block;
    margin: 24px auto 0;
    padding: 10px 24px;
    background: white;
    border: 1px solid #4BA3E3;
    color: #4BA3E3;
    border-radius: 20px;
    cursor: pointer;
    transition: all 0.2s;
}

.load-more-btn:hover {
    background: #f0f8ff;
}

/* Форма настроек AI - горизонтальное расположение */
.form-row {
    display: flex;
    align-items: center;
    gap: 20px;
    margin-bottom: 16px;
}

.form-row-label {
    min-width: 240px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
    flex-shrink: 0;
}

.form-row-input {
    flex: 1;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-row-input:focus {
    outline: none;
    border-color: #4BA3E3;
}

.form-textarea {
    min-height: 80px;
    resize: vertical;
    font-family: inherit;
}

/* Старые стили .form-group оставляем для других страниц */
.form-group {
    margin-bottom: 24px;
}

.form-label {
    display: block;
    margin-bottom: 8px;
    font-size: 14px;
    color: #666;
    font-weight: 500;
}

.form-input {
    width: 100%;
    padding: 12px 16px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    font-size: 15px;
    transition: border-color 0.2s;
}

.form-input:focus {
    outline: none;
    border-color: #4BA3E3;
}

/* Адаптивность для AI настроек */
@media (max-width: 768px) {
    .form-row {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .form-row-label {
        min-width: auto;
    }
}

@media (max-width: 480px) {
    .form-row-label {
        font-size: 13px;
    }

    .form-row-input {
        font-size: 14px;
        padding: 10px 14px;
    }
}

/* Чекбоксы */
.checkbox-group {
    background: #f0f4f7;
    padding: 18px;
    border-radius: 10px;
    margin-bottom: 16px;
}

.checkbox-label {
    display: flex;
    align-items: center;
    gap: 12px;
    cursor: pointer;
    font-size: 15px;
    color: #333;
}

.checkbox-input {
    width: 20px;
    height: 20px;
    cursor: pointer;
}

/* Время публикации */
.time-group {
    display: flex;
    align-items: center;
    gap: 16px;
    background: #f0f4f7;
    padding: 20px;
    border-radius: 10px;
    margin-bottom: 20px;
}

.time-label {
    flex: 1;
    font-size: 15px;
    color: #333;
}

.time-input {
    width: 100px;
    padding: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 8px;
    text-align: center;
    font-size: 15px;
}

.time-separator {
    color: #999;
    font-size: 18px;
}

.time-unit {
    color: #666;
    font-size: 14px;
}

/* Дополнительные опции */
.options-list {
    display: flex;
    flex-direction: column;
    gap: 16px;
}

.option-item {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 20px;
    background: #f0f4f7;
    border-radius: 10px;
}

.option-text {
    font-size: 15px;
    color: #333;
}

/* Кнопки действий */
.action-buttons {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    margin-top: 24px;
}

/* Адаптивность */
@media (max-width: 768px) {
    body {
        padding: 12px;
    }

    .card {
        padding: 24px 20px;
        border-radius: 12px;
    }

    .card-title {
        font-size: 18px;
    }

    .card-header {
        flex-direction: column;
        align-items: flex-start;
    }

    .input-group {
        flex-direction: column;
    }

    .popular-sources {
        grid-template-columns: 1fr;
    }

    .time-group {
        flex-wrap: wrap;
    }

    .action-buttons {
        flex-direction: column-reverse;
    }

    .btn {
        width: 100%;
    }

    .option-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .option-item .btn {
        width: 100%;
    }
}

/* Мобильная адаптивность для временных промежутков */
@media (max-width: 700px) {
    .time-group {
        flex-direction: column;
        align-items: stretch;
        gap: 8px;
    }

    .time-label {
        flex: none;
        width: 100%;
        margin-bottom: 0;
        font-weight: 500;
        order: -1;
    }

    .time-group > div {
        display: flex;
        align-items: center;
        gap: 12px;
    }

    .time-input {
        flex: 1;
        width: auto;
    }

    .time-separator {
        margin: 0;
    }

    .time-unit {
        flex-shrink: 0;
    }
}

@media (max-width: 480px) {
    .card {
        padding: 20px 16px;
    }

    .card-title {
        font-size: 16px;
    }

    .btn, .input-field, .form-input {
        font-size: 14px;
    }

    .popular-item {
        flex-direction: column;
        align-items: flex-start;
        gap: 12px;
    }

    .popular-actions {
        width: 100%;
        justify-content: flex-end;
    }
}

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

.card {
    animation: fadeIn 0.3s ease-out;
}

.source-toggle {
    display: flex;
    border: 1px solid #d0d7de;
    border-radius: 12px;
    overflow: hidden;
    background: #f9fafb;
    margin-right: 8px;
}

.toggle-btn {
    flex: 1;
    padding: 8px 14px;
    font-size: 14px;
    font-weight: 500;
    background: none;
    border: none;
    cursor: pointer;
    color: #555;
    transition: all 0.2s ease;
}

.toggle-btn.active {
    background: #007bff;
    color: #fff;
}

.toggle-btn:not(.active):hover {
    background: #e9ecef;
}
