/* =========================
   Стили для add-product.php
   ========================= */
.add-product-page {
    background: #f8f9fa;
    min-height: calc(100vh - 120px); /* Учитываем высоту header и footer */
    padding: 40px 0 20px 0; /* Уменьшили bottom padding */
}

/* Скрываем плавающую кнопку добавления на странице добавления товара */
.add-product-page .mobile-add-btn {
    display: none !important;
}

.add-product-page .container {
    max-width: 700px;
    margin: 0 auto;
    background: #fff;
    border-radius: 18px;
    box-shadow: 0 8px 32px rgba(0,0,0,0.08);
    padding: 36px 28px 32px 28px;
}
.page-header {
    text-align: center;
    margin-bottom: 32px;
}
.page-header h1 {
    font-size: 2.2rem;
    font-weight: 700;
    color: #dc2626;
    margin-bottom: 8px;
}
.page-header .subtitle {
    color: #888;
    font-size: 1.1rem;
}
.form-container {
    margin-top: 10px;
}
.product-form {
    display: flex;
    flex-direction: column;
    gap: 32px;
}
.form-section {
    background: #f3f4f6;
    border-radius: 12px;
    padding: 22px 18px 18px 18px;
    margin-bottom: 0;
    box-shadow: 0 2px 8px rgba(220,38,38,0.03);
}
.form-section h3 {
    font-size: 1.1rem;
    color: #b91c1c;
    margin-bottom: 18px;
    font-weight: 600;
    letter-spacing: 0.5px;
}
.form-group {
    margin-bottom: 18px;
    display: flex;
    flex-direction: column;
}
.form-group label {
    font-weight: 500;
    margin-bottom: 6px;
    color: #23272f;
}
.form-group input,
.form-group select,
.form-group textarea {
    padding: 12px 14px;
    border: 1.5px solid #e5e7eb;
    border-radius: 8px;
    font-size: 1rem;
    background: #fff;
    transition: border-color 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: #dc2626;
    outline: none;
}
.form-hint {
    color: #bdbdbd;
    font-size: 0.95rem;
    margin-top: 4px;
}
.form-row {
    display: flex;
    gap: 18px;
}
.form-row .form-group {
    flex: 1 1 0;
}
.image-upload-area {
    display: flex;
    flex-wrap: wrap;
    gap: 16px;
    min-height: 120px;
    align-items: center;
    justify-content: flex-start;
    background: #fff;
    border: 2px dashed #e5e7eb;
    border-radius: 10px;
    padding: 18px 12px;
    cursor: pointer;
    transition: border-color 0.2s;
}
.image-upload-area.dragover {
    border-color: #8b5cf6;
    background: #f5f3ff;
    border-width: 3px;
    transform: scale(1.01);
}

.image-upload-area.dragover .upload-placeholder {
    color: #8b5cf6;
}

.image-upload-area.dragover .upload-placeholder i {
    transform: scale(1.2);
    color: #8b5cf6;
}
.upload-placeholder {
    text-align: center;
    color: #bdbdbd;
    width: 100%;
}
.upload-placeholder i {
    font-size: 2.2rem;
    color: #b91c1c;
    margin-bottom: 8px;
}
.upload-hint {
    font-size: 0.95rem;
    color: #bdbdbd;
}
.form-actions {
    display: flex;
    gap: 16px;
    justify-content: flex-end;
    margin-top: 10px;
}
.btn.btn-lg {
    font-size: 1.1rem;
    padding: 12px 28px;
    border-radius: 8px;
}

/* Стили для кнопки отмены */
.btn.btn-secondary.btn-lg {
    background: #fff;
    color: #b91c1c;
    border: 1.5px solid #b91c1c;
    transition: background 0.2s, color 0.2s, border 0.2s;
}
.btn.btn-secondary.btn-lg:hover {
    background: #fef2f2;
    color: #dc2626;
    border-color: #dc2626;
}

/* =========================
   Стили для неавторизованного состояния на add-product.php
   ========================= */
.auth-required-container {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 32px 0;
    min-height: 400px; /* Минимальная высота для правильного позиционирования */
}
.auth-required-card {
    width: 100%;
    max-width: 760px;
    background: linear-gradient(180deg, #ffffff 0%, #fffaf9 100%);
    border-radius: 14px;
    box-shadow: 0 10px 30px rgba(15, 23, 42, 0.06);
    padding: 28px 26px;
    border: 1px solid rgba(15,23,42,0.04);
    text-align: center;
}
.auth-required-card .auth-icon {
    width: 72px;
    height: 72px;
    margin: 0 auto 12px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    background: #fff;
    border: 2px solid rgba(220,38,38,0.08);
    color: #dc2626;
    font-size: 1.6rem;
}
.auth-required-card h1 {
    font-size: 1.6rem;
    margin: 6px 0 8px 0;
    color: #111827;
}
.auth-message {
    color: #6b7280;
    margin-bottom: 12px;
    font-size: 1rem;
}
.auth-benefits {
    text-align: left;
    margin: 16px auto;
    max-width: 640px;
}
.auth-benefits h3 {
    margin: 0 0 8px 0;
    font-size: 1rem;
    color: #111827;
}
.auth-benefits ul {
    list-style: none;
    padding: 0;
    margin: 0;
    display: grid;
    gap: 8px;
}
.auth-benefits li {
    display: flex;
    gap: 10px;
    align-items: center;
    color: #374151;
}
.auth-benefits li i { color: #10b981; }
.auth-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
    margin-top: 18px;
    flex-wrap: wrap;
}

.auth-btn.login-btn {
        display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.12s ease, opacity 0.12s ease;
    background: #fff;
    color: #dc2626;
    border: 1px solid rgba(220,38,38,0.12);
}
.auth-btn.register-btn {
        display: inline-flex;
    gap: 8px;
    align-items: center;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.12s ease, opacity 0.12s ease;
    background: #dc2626;
    color: #fff;
    border: 1px solid rgba(220,38,38,0.12);
}
.auth-btn:hover { transform: translateY(-2px); opacity: 0.98; }

/* Разделитель "или" */
.auth-divider {
    display: flex;
    align-items: center;
    width: 100%;
    margin: 8px 0;
    color: #9ca3af;
    font-size: 0.9rem;
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: #e5e7eb;
}

.auth-divider span {
    padding: 0 12px;
    background: white;
}

/* Кнопка Telegram */
.auth-btn.telegram-btn {
    display: inline-flex;
    gap: 8px;
    align-items: center;
    justify-content: center;
    padding: 10px 16px;
    border-radius: 8px;
    font-weight: 600;
    text-decoration: none;
    transition: transform 0.12s ease, opacity 0.12s ease, box-shadow 0.12s ease;
    background: #0088cc;
    color: #fff;
    border: 1px solid #0088cc;
    cursor: pointer;
    font-size: 0.95rem;
    width: 100%;
    max-width: 280px;
}

.auth-btn.telegram-btn:hover {
    background: #0077b5;
    border-color: #0077b5;
    box-shadow: 0 4px 12px rgba(0, 136, 204, 0.3);
}

.auth-btn.telegram-btn svg {
    width: 20px;
    height: 20px;
    flex-shrink: 0;
}

/* Адаптация для мобильных */
@media (max-width: 600px) {
    .auth-actions {
        flex-direction: column;
        align-items: center;
    }
    
    .auth-btn {
        width: 100%;
        max-width: 280px;
        justify-content: center;
    }
    
    .auth-divider {
        width: 100%;
        margin: 12px 0;
    }
}

@media (max-width: 800px) {
    .add-product-page .container {
        padding: 18px 4vw 18px 4vw;
    }
    .form-row {
        flex-direction: column;
        gap: 0;
    }
}
@media (max-width: 500px) {
    .add-product-page {
        padding: 20px 10px 10px 10px;
    }
    .add-product-page .container {
        padding: 8px 0 8px 0;
        border-radius: 12px;
    }
    .form-section {
        padding: 12px 6px 10px 6px;
    }
    .btn.btn-lg {
        width: 100%;
        padding: 12px 0;
    }
    .form-actions {
        flex-direction: column;
        gap: 10px;
    }
}

/* =========================
   AI улучшение описания
   ========================= */
.description-with-ai {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.improve-description-btn {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    padding: 10px 18px;
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    border: none;
    border-radius: 10px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
    align-self: flex-start;
}

.improve-description-btn:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    transform: translateY(-2px);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
}

.improve-description-btn:active {
    transform: translateY(0);
}

.improve-description-btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none;
}

.improve-description-btn svg {
    width: 20px;
    height: 20px;
}

.improve-description-btn .spinning {
    animation: spin 1s linear infinite;
}

.ai-features-hint {
    display: flex;
    align-items: center;
    gap: 8px;
    padding: 10px 14px;
    background: #f3f4f6;
    border-radius: 8px;
    font-size: 13px;
    color: #6b7280;
    line-height: 1.4;
}

.ai-features-hint svg {
    flex-shrink: 0;
    color: #8b5cf6;
}

@keyframes spin {
    from {
        transform: rotate(0deg);
    }
    to {
        transform: rotate(360deg);
    }
}

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

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

.ai-notification {
    animation: slideInRight 0.3s ease-out;
}

@media (max-width: 768px) {
    .improve-description-btn {
        width: 100%;
        justify-content: center;
    }
    
    .undo-ai-btn {
        width: 100%;
        justify-content: center;
    }
    
    .ai-buttons-row {
        flex-direction: column;
    }
}

/* AI Buttons Row */
.ai-buttons-row {
    display: flex;
    gap: 10px;
    align-items: center;
    flex-wrap: wrap;
}

/* Undo Button */
.undo-ai-btn {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    padding: 8px 14px;
    background: #f3f4f6;
    color: #6b7280;
    border: 1px solid #d1d5db;
    border-radius: 8px;
    font-size: 13px;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.3s ease;
}

.undo-ai-btn:hover {
    background: #e5e7eb;
    color: #374151;
    border-color: #9ca3af;
}

.undo-ai-btn svg {
    width: 18px;
    height: 18px;
}

/* Progress Steps */
.ai-progress-steps {
    display: flex;
    flex-direction: column;
    gap: 8px;
    padding: 12px;
    background: #fef3c7;
    border-radius: 8px;
    border-left: 3px solid #f59e0b;
}

.progress-step {
    display: flex;
    align-items: center;
    gap: 10px;
    opacity: 0.4;
    transition: opacity 0.3s ease;
}

.progress-step.active {
    opacity: 1;
}

.progress-step.completed {
    opacity: 0.6;
}

.step-spinner {
    width: 16px;
    height: 16px;
    border: 2px solid #f59e0b;
    border-top-color: transparent;
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

.progress-step:not(.active) .step-spinner {
    border-color: #d1d5db;
    animation: none;
}

.progress-step span {
    font-size: 13px;
    color: #78350f;
    font-weight: 500;
}

/* AI Preview Modal */
.ai-preview-modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.6);
    z-index: 10000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    animation: fadeIn 0.2s ease-out;
}

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

.ai-preview-content {
    background: white;
    border-radius: 16px;
    max-width: 700px;
    width: 100%;
    max-height: 90vh;
    display: flex;
    flex-direction: column;
    box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
    animation: slideUp 0.3s ease-out;
}

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

.ai-preview-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 20px 24px;
    border-bottom: 1px solid #e5e7eb;
}

.ai-preview-header h3 {
    margin: 0;
    font-size: 20px;
    font-weight: 600;
    color: #111827;
}

.ai-preview-close {
    background: none;
    border: none;
    padding: 4px;
    cursor: pointer;
    color: #6b7280;
    transition: color 0.2s;
    border-radius: 6px;
}

.ai-preview-close:hover {
    color: #111827;
    background: #f3f4f6;
}

.ai-preview-body {
    padding: 24px;
    overflow-y: auto;
    flex: 1;
}

.ai-preview-section {
    margin-bottom: 24px;
}

.ai-preview-section:last-of-type {
    margin-bottom: 0;
}

.ai-preview-section > label {
    display: block;
    font-weight: 600;
    font-size: 14px;
    color: #374151;
    margin-bottom: 12px;
}

.ai-preview-field {
    background: #f9fafb;
    padding: 16px;
    border-radius: 10px;
    border: 1px solid #e5e7eb;
}

.preview-label {
    font-size: 12px;
    font-weight: 600;
    color: #6b7280;
    text-transform: uppercase;
    letter-spacing: 0.5px;
    margin-bottom: 6px;
    margin-top: 12px;
}

.preview-label:first-child {
    margin-top: 0;
}

.preview-old {
    padding: 10px;
    background: #fef2f2;
    border: 1px solid #fecaca;
    border-radius: 6px;
    color: #991b1b;
    font-size: 14px;
    line-height: 1.5;
    min-height: 40px;
    white-space: pre-wrap;
}

.preview-old:empty::before {
    content: '(пусто)';
    color: #9ca3af;
    font-style: italic;
}

.preview-new {
    padding: 10px;
    background: #f0fdf4;
    border: 1px solid #bbf7d0;
    border-radius: 6px;
    color: #166534;
    font-size: 14px;
    line-height: 1.5;
    min-height: 40px;
    white-space: pre-wrap;
    font-weight: 500;
}

.ai-preview-changes {
    margin-top: 16px;
    padding: 14px;
    background: #eff6ff;
    border-radius: 8px;
    display: flex;
    flex-direction: column;
    gap: 8px;
}

.change-item {
    display: flex;
    align-items: center;
    gap: 8px;
    color: #1e40af;
    font-size: 13px;
    font-weight: 500;
}

.change-item svg {
    color: #3b82f6;
    flex-shrink: 0;
}

.ai-preview-footer {
    display: flex;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e5e7eb;
    justify-content: flex-end;
}

.ai-preview-btn {
    padding: 10px 24px;
    border-radius: 8px;
    font-size: 14px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    border: none;
}

.ai-preview-btn.cancel {
    background: #f3f4f6;
    color: #374151;
}

.ai-preview-btn.cancel:hover {
    background: #e5e7eb;
}

.ai-preview-btn.apply {
    background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%);
    color: white;
    box-shadow: 0 4px 12px rgba(139, 92, 246, 0.25);
}

.ai-preview-btn.apply:hover {
    background: linear-gradient(135deg, #7c3aed 0%, #6d28d9 100%);
    box-shadow: 0 6px 20px rgba(139, 92, 246, 0.35);
    transform: translateY(-1px);
}

@media (max-width: 768px) {
    .ai-preview-content {
        max-height: 95vh;
    }
    
    .ai-preview-footer {
        flex-direction: column-reverse;
    }
    
    .ai-preview-btn {
        width: 100%;
    }
}
