/* Основные стили */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: #333;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
}

/* Заголовок */
.header {
    text-align: center;
    margin-bottom: 30px;
    color: white;
}

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

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

/* Основной контент */
.main-content {
    display: grid;
    gap: 25px;
    grid-template-columns: repeat(auto-fit, minmax(350px, 1fr));
}

/* Секции */
.settings-section, .campaign-section, .progress-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}

.settings-section:hover, .campaign-section:hover, .progress-section:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(0,0,0,0.15);
}

.settings-section h2, .progress-section h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

/* Формы */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 600;
    color: #2d3748;
}

.form-group input, .form-group textarea, .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.form-group input:focus, .form-group textarea:focus, .form-group select:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.form-group textarea {
    resize: vertical;
    min-height: 80px;
}

/* Контейнер селекта товаров */
#productSelectContainer {
    display: flex;
    gap: 10px;
    align-items: center;
}

#productSelectContainer select {
    flex: 1;
}

#productSelectContainer .btn-small {
    padding: 12px 16px;
    min-width: auto;
}

.product-select {
    cursor: pointer;
}

.product-select:disabled {
    cursor: not-allowed;
    background-color: #f7fafc;
    opacity: 0.6;
}

.form-hint {
    display: block;
    margin-top: 8px;
    font-size: 0.85rem;
    color: #718096;
    font-style: italic;
}

/* Диапазон дат */
.date-range {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 15px;
}

/* Информационные блоки */
.info-box {
    background: #f7fafc;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
    padding: 15px;
    margin-top: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
    color: #4a5568;
}

.info-box.hidden {
    display: none;
}

/* Кнопки */
.btn {
    padding: 12px 20px;
    border: none;
    border-radius: 8px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
    text-decoration: none;
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.btn-primary {
    background: #667eea;
    color: white;
}

.btn-primary:hover:not(:disabled) {
    background: #5a67d8;
    transform: translateY(-2px);
}

.btn-secondary {
    background: #718096;
    color: white;
}

.btn-secondary:hover:not(:disabled) {
    background: #4a5568;
    transform: translateY(-2px);
}

.btn-success {
    background: #48bb78;
    color: white;
}

.btn-success:hover:not(:disabled) {
    background: #38a169;
    transform: translateY(-2px);
}

.btn-danger {
    background: #f56565;
    color: white;
}

.btn-danger:hover:not(:disabled) {
    background: #e53e3e;
    transform: translateY(-2px);
}

.btn-large {
    padding: 15px 30px;
    font-size: 1.2rem;
    width: 100%;
    justify-content: center;
}

/* Секция кампании */
.campaign-section {
    grid-column: 1 / -1;
    text-align: center;
}

/* Прогресс */
.progress-info {
    margin-bottom: 25px;
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
    margin-bottom: 20px;
}

.stat-item {
    background: #f7fafc;
    padding: 15px;
    border-radius: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
    font-size: 1rem;
}

.progress-bar {
    background: #e2e8f0;
    border-radius: 10px;
    height: 20px;
    overflow: hidden;
    margin-bottom: 10px;
}

.progress-fill {
    background: linear-gradient(90deg, #48bb78, #38a169);
    height: 100%;
    width: 0%;
    transition: width 0.3s ease;
    border-radius: 10px;
}

.progress-text {
    text-align: center;
    font-weight: 600;
    color: #4a5568;
}

/* Логи */
.logs-container h3 {
    color: #4a5568;
    margin-bottom: 15px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.logs-list {
    max-height: 400px;
    overflow-y: auto;
    border: 1px solid #e2e8f0;
    border-radius: 8px;
}

.log-item {
    padding: 12px 15px;
    border-bottom: 1px solid #e2e8f0;
    display: flex;
    align-items: center;
    gap: 10px;
    transition: background-color 0.2s ease;
}

.log-item:last-child {
    border-bottom: none;
}

.log-item:hover {
    background: #f7fafc;
}

.log-status {
    padding: 4px 8px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 600;
    text-transform: uppercase;
}

.log-status.pending {
    background: #fef5e7;
    color: #d69e2e;
}

.log-status.success {
    background: #f0fff4;
    color: #38a169;
}

.log-status.error {
    background: #fed7d7;
    color: #e53e3e;
}

.log-message {
    flex: 1;
    color: #4a5568;
}

.log-time {
    color: #a0aec0;
    font-size: 0.9rem;
}

/* Управление кампанией */
.campaign-controls {
    display: flex;
    gap: 15px;
    justify-content: center;
    margin-top: 20px;
}

/* Уведомления */
.notifications {
    position: fixed;
    top: 20px;
    right: 20px;
    z-index: 1000;
}

.notification {
    background: white;
    border-radius: 8px;
    padding: 15px 20px;
    margin-bottom: 10px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border-left: 4px solid;
    animation: slideIn 0.3s ease;
    max-width: 400px;
}

.notification.success {
    border-left-color: #48bb78;
}

.notification.error {
    border-left-color: #f56565;
}

.notification.info {
    border-left-color: #667eea;
}

@keyframes slideIn {
    from {
        transform: translateX(100%);
        opacity: 0;
    }
    to {
        transform: translateX(0);
        opacity: 1;
    }
}

/* Адаптивность */
@media (max-width: 768px) {
    .container {
        padding: 15px;
    }
    
    .main-content {
        grid-template-columns: 1fr;
    }
    
    .date-range {
        grid-template-columns: 1fr;
    }
    
    .progress-stats {
        grid-template-columns: 1fr;
    }
    
    .campaign-controls {
        flex-direction: column;
    }
    
    .header h1 {
        font-size: 2rem;
    }
}

/* Скрытые элементы */
.hidden {
    display: none !important;
}

/* Экран загрузки */
.loading-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.loading-content {
    text-align: center;
    color: white;
}

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

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

.loading-content h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.loading-content p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Экран ошибки */
.error-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e53e3e 0%, #c53030 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.error-content {
    text-align: center;
    color: white;
    max-width: 500px;
    padding: 40px;
}

.error-content i {
    font-size: 4rem;
    margin-bottom: 20px;
    opacity: 0.8;
}

.error-content h2 {
    font-size: 2rem;
    margin-bottom: 15px;
}

.error-content p {
    font-size: 1.2rem;
    margin-bottom: 30px;
    opacity: 0.9;
}

/* Экран капчи */
.captcha-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.captcha-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    text-align: center;
    max-width: 500px;
    width: 90%;
}

.captcha-content h2 {
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.captcha-container {
    margin-bottom: 25px;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.captcha-img {
    max-width: 600px;
    max-height: 300px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    background: #f7fafc;
}

.captcha-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 2px;
    font-weight: bold;
}

.captcha-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Экран входа */
.login-screen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.login-content {
    background: white;
    border-radius: 15px;
    padding: 40px;
    box-shadow: 0 20px 60px rgba(0,0,0,0.3);
    max-width: 500px;
    width: 90%;
}

.login-content h2 {
    color: #4a5568;
    margin-bottom: 30px;
    font-size: 1.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 10px;
}

.login-content .form-group {
    margin-bottom: 20px;
}

.login-content input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.login-content input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

.login-content .captcha-container {
    margin: 20px 0;
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 15px;
}

.login-content .captcha-img {
    max-width: 600px;
    max-height: 300px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    padding: 10px;
    background: #f7fafc;
}

.login-content .captcha-input {
    width: 100%;
    padding: 15px;
    border: 2px solid #e2e8f0;
    border-radius: 8px;
    font-size: 1.2rem;
    text-align: center;
    letter-spacing: 2px;
    font-weight: bold;
}

.login-content .captcha-input:focus {
    outline: none;
    border-color: #667eea;
    box-shadow: 0 0 0 3px rgba(102, 126, 234, 0.1);
}

/* Адаптивность для новых экранов */
@media (max-width: 768px) {
    .captcha-content, .login-content {
        padding: 30px 20px;
        margin: 20px;
    }
    
    .captcha-content h2, .login-content h2 {
        font-size: 1.5rem;
    }
    
    .captcha-img, .login-content .captcha-img {
        max-width: 450px;
        max-height: 240px;
    }
}

/* Анимации загрузки */
.loading {
    position: relative;
    overflow: hidden;
}

.loading::after {
    content: '';
    position: absolute;
    top: 0;
    left: -100%;
    width: 100%;
    height: 100%;
    background: linear-gradient(90deg, transparent, rgba(255,255,255,0.4), transparent);
    animation: loading 1.5s infinite;
}

@keyframes loading {
    0% { left: -100%; }
    100% { left: 100%; }
}

/* Приветственное сообщение */
.welcome-message {
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    color: white;
    padding: 30px;
    border-radius: 15px;
    text-align: center;
    margin-bottom: 25px;
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
    grid-column: 1 / -1;
}

.welcome-message h2 {
    font-size: 1.8rem;
    margin-bottom: 10px;
}

.welcome-message p {
    font-size: 1.1rem;
    opacity: 0.9;
}

/* Растягиваем секции настроек на всю ширину */
.main-content .settings-section {
    grid-column: 1 / -1;
}

/* Информация о рассылке */
.campaign-info {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    grid-column: 1 / -1;
}

.campaign-info h2 {
    color: #667eea;
    margin-bottom: 20px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 15px;
}

.info-item {
    background: white;
    padding: 15px;
    border-radius: 8px;
    border: 1px solid #e2e8f0;
}

.info-item strong {
    color: #667eea;
    display: block;
    margin-bottom: 5px;
}

.uuid-text {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #555;
    word-break: break-all;
}

.status-badge {
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    font-size: 0.9rem;
    font-weight: 600;
}

.status-in-progress {
    background: #fff3cd;
    color: #856404;
}

.status-recipients-collected {
    background: #d1ecf1;
    color: #0c5460;
}

.status-completed {
    background: #d4edda;
    color: #155724;
}

.status-error {
    background: #f8d7da;
    color: #721c24;
}

/* Описание секции */
.section-description {
    color: #666;
    font-size: 0.95rem;
    margin-bottom: 15px;
}

/* Улучшенная кнопка запуска */
.btn-large {
    font-size: 1.2rem;
    padding: 18px 35px;
    min-width: 280px;
}

/* Адаптивность для информации о рассылке */
@media (max-width: 768px) {
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .welcome-message h2 {
        font-size: 1.4rem;
    }
    
    .welcome-message p {
        font-size: 1rem;
    }
}

/* Лоадер для блокировки форм */
.form-loader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    backdrop-filter: blur(5px);
    animation: fadeIn 0.2s ease-in;
}

.form-loader.hidden {
    display: none;
}

.form-loader-content {
    background: white;
    padding: 40px 60px;
    border-radius: 20px;
    text-align: center;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideIn 0.3s ease-out;
}

.form-loader-content .spinner {
    width: 60px;
    height: 60px;
    border: 6px solid #f3f3f3;
    border-top: 6px solid #667eea;
    border-radius: 50%;
    margin: 0 auto 20px;
    animation: spin 1s linear infinite;
}

.form-loader-content p {
    font-size: 1.1rem;
    color: #4a5568;
    font-weight: 600;
    margin: 0;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

@keyframes slideIn {
    from {
        transform: translateY(-30px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

/* История рассылок */
.campaigns-history-section {
    background: white;
    border-radius: 15px;
    padding: 25px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    grid-column: 1 / -1;
    margin-top: 25px;
}

.campaigns-history-section h2 {
    color: #4a5568;
    margin-bottom: 20px;
    font-size: 1.4rem;
    display: flex;
    align-items: center;
    gap: 10px;
}

.campaigns-history-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

.loading-history {
    text-align: center;
    padding: 20px;
    color: #667eea;
    font-size: 1.1rem;
}

.campaign-card {
    background: #f8f9fa;
    border: 2px solid #e2e8f0;
    border-radius: 12px;
    padding: 20px;
    transition: all 0.3s ease;
}

.campaign-card:hover {
    border-color: #667eea;
    box-shadow: 0 5px 15px rgba(102, 126, 234, 0.1);
    transform: translateX(5px);
}

.campaign-card-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 15px;
    padding-bottom: 15px;
    border-bottom: 1px solid #e2e8f0;
}

.campaign-uuid {
    font-family: 'Courier New', monospace;
    font-size: 0.9rem;
    color: #667eea;
    font-weight: 600;
}

.campaign-status {
    display: inline-block;
    padding: 6px 15px;
    border-radius: 20px;
    font-size: 0.85rem;
    font-weight: 700;
    text-transform: uppercase;
}

.campaign-status.status-in-progress {
    background: #fff3cd;
    color: #856404;
}

.campaign-status.status-recipients-collected {
    background: #d1ecf1;
    color: #0c5460;
}

.campaign-status.status-completed {
    background: #d4edda;
    color: #155724;
}

.campaign-status.status-error {
    background: #f8d7da;
    color: #721c24;
}

.campaign-card-body {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 15px;
}

.campaign-detail {
    display: flex;
    flex-direction: column;
    gap: 5px;
}

.campaign-detail-label {
    font-size: 0.85rem;
    color: #718096;
    font-weight: 600;
    text-transform: uppercase;
}

.campaign-detail-value {
    font-size: 1rem;
    color: #2d3748;
    font-weight: 500;
}

.campaign-detail-value.amount {
    color: #667eea;
    font-weight: 700;
    font-size: 1.2rem;
}

.no-campaigns {
    text-align: center;
    padding: 40px 20px;
    color: #718096;
}

.no-campaigns i {
    font-size: 3rem;
    margin-bottom: 15px;
    opacity: 0.5;
}

.no-campaigns p {
    font-size: 1.1rem;
    margin: 10px 0;
}

@media (max-width: 768px) {
    .campaign-card-header {
        flex-direction: column;
        align-items: flex-start;
        gap: 10px;
    }
    
    .campaign-card-body {
        grid-template-columns: 1fr;
    }
}

/* Анимация для обновления счетчика получателей */
@keyframes pulse {
    0% {
        transform: scale(1);
    }
    50% {
        transform: scale(1.2);
        color: #667eea;
    }
    100% {
        transform: scale(1);
    }
}

/* Стили для прогресса рассылки */
.distribution-progress {
    background: #f8f9fa;
    border-left: 4px solid #667eea;
    padding: 20px;
    margin-top: 20px;
    border-radius: 8px;
}

.distribution-progress h3 {
    color: #667eea;
    margin-bottom: 15px;
}

.progress-bar {
    width: 100%;
    height: 30px;
    background: #e2e8f0;
    border-radius: 15px;
    overflow: hidden;
    margin-bottom: 15px;
}

.progress-fill {
    height: 100%;
    background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
    transition: width 0.5s ease-in-out;
}

.progress-stats {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 10px;
}

.progress-stats p {
    margin: 5px 0;
    padding: 10px;
    background: white;
    border-radius: 6px;
}

.campaign-actions {
    text-align: center;
}

.campaign-actions .btn-large {
    padding: 15px 30px;
    font-size: 1.1rem;
}
