:root {
    --primary: #8b5cf6;
    --primary-dark: #7c3aed;
    --secondary: #10b981;
    --success: #10b981;
    --warning: #f59e0b;
    --danger: #ef4444;
    --dark: #1f2937;
    --light: #f9fafb;
    --gray: #6b7280;
    --border: #e5e7eb;
    --shadow: 0 1px 3px rgba(0,0,0,0.1);
    --shadow-lg: 0 10px 25px -5px rgba(0,0,0,0.1);
    --shadow-xl: 0 20px 25px -5px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

body {
    font-family: 'Inter', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    color: var(--dark);
}

.app {
    max-width: 1200px;
    margin: 20px auto;
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    overflow: hidden;
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
}

/* Header */
.header {
    padding: 16px 24px;
    background: white;
    border-bottom: 1px solid var(--border);
    display: flex;
    align-items: center;
    justify-content: space-between;
}

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

.logo i {
    font-size: 32px;
    color: var(--primary);
    animation: pulse 2s infinite;
}

.logo-text h1 {
    font-size: 20px;
    font-weight: 700;
    color: var(--dark);
    line-height: 1.2;
}

.version {
    font-size: 12px;
    color: var(--gray);
    font-weight: 400;
}

.stats {
    display: flex;
    gap: 24px;
}

.stat-item {
    display: flex;
    align-items: center;
    gap: 8px;
    font-size: 14px;
    color: var(--gray);
    cursor: help;
}

.stat-item i {
    color: var(--primary);
}

.stat-item span {
    font-weight: 600;
    color: var(--dark);
}

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

.icon-btn {
    width: 40px;
    height: 40px;
    border: none;
    background: var(--light);
    border-radius: 10px;
    color: var(--gray);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.icon-btn:hover {
    background: var(--primary);
    color: white;
    transform: translateY(-2px);
}

.icon-btn i {
    font-size: 18px;
}

/* Main Content */
.main {
    flex: 1;
    display: flex;
    flex-direction: column;
    overflow: hidden;
    background: #f9fafb;
}

/* Chat Container */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* Welcome Screen */
.welcome-screen {
    height: 100%;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-align: center;
    color: var(--gray);
    animation: fadeIn 0.5s;
}

.welcome-icon {
    width: 120px;
    height: 120px;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 24px;
    animation: float 3s ease infinite;
}

.welcome-icon i {
    font-size: 48px;
    color: white;
}

.welcome-screen h2 {
    color: var(--dark);
    margin-bottom: 8px;
    font-size: 24px;
}

.welcome-screen p {
    font-size: 16px;
    margin-bottom: 24px;
}

.features {
    display: flex;
    gap: 24px;
    margin: 24px 0;
    font-size: 14px;
    flex-wrap: wrap;
    justify-content: center;
}

.features span {
    display: flex;
    align-items: center;
    gap: 6px;
    background: white;
    padding: 8px 16px;
    border-radius: 30px;
    box-shadow: var(--shadow);
}

.features i {
    color: var(--secondary);
}

.quick-actions {
    display: flex;
    gap: 12px;
    flex-wrap: wrap;
    justify-content: center;
    max-width: 600px;
}

.quick-chip {
    padding: 8px 16px;
    background: white;
    border: 1px solid var(--border);
    border-radius: 30px;
    color: var(--dark);
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    box-shadow: var(--shadow);
}

.quick-chip:hover {
    background: var(--primary);
    color: white;
    border-color: var(--primary);
    transform: translateY(-2px);
    box-shadow: var(--shadow-lg);
}

.quick-chip i {
    font-size: 14px;
}

/* Messages */
.message {
    display: flex;
    gap: 16px;
    margin-bottom: 24px;
    animation: slideIn 0.3s;
}

.message.user {
    flex-direction: row-reverse;
}

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--light);
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--gray);
    flex-shrink: 0;
    box-shadow: var(--shadow);
}

.user .message-avatar {
    background: var(--primary);
    color: white;
}

.message-content {
    max-width: 70%;
}

.user .message-content {
    text-align: right;
}

.message-header {
    margin-bottom: 6px;
    display: flex;
    align-items: center;
    gap: 8px;
    flex-wrap: wrap;
}

.user .message-header {
    flex-direction: row-reverse;
}

.author {
    font-weight: 600;
    font-size: 14px;
}

.time {
    font-size: 12px;
    color: var(--gray);
}

.badge {
    font-size: 11px;
    padding: 2px 8px;
    border-radius: 20px;
    display: inline-flex;
    align-items: center;
    gap: 4px;
    font-weight: 500;
}

.badge.success {
    background: #d1fae5;
    color: #065f46;
}

.badge.warning {
    background: #fed7aa;
    color: #92400e;
}

.message-text {
    background: white;
    padding: 12px 16px;
    border-radius: 18px;
    box-shadow: var(--shadow);
    line-height: 1.6;
    font-size: 14px;
    word-wrap: break-word;
}

.user .message-text {
    background: var(--primary);
    color: white;
}

/* Code blocks */
.message-text pre {
    background: #f3f4f6;
    padding: 12px;
    border-radius: 8px;
    overflow-x: auto;
    margin: 8px 0;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 13px;
}

.user .message-text pre {
    background: rgba(255,255,255,0.1);
    color: white;
}

.message-text code {
    background: #f3f4f6;
    padding: 2px 4px;
    border-radius: 4px;
    font-family: 'Monaco', 'Menlo', monospace;
    font-size: 12px;
}

.user .message-text code {
    background: rgba(255,255,255,0.1);
    color: white;
}

/* Loading Indicator */
.loading-indicator {
    padding: 16px 24px;
    background: white;
    border-top: 1px solid var(--border);
}

.loading-content {
    display: flex;
    align-items: center;
    gap: 12px;
    color: var(--gray);
    font-size: 14px;
}

.loading-spinner {
    width: 24px;
    height: 24px;
    border: 2px solid var(--border);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.6s linear infinite;
}

.loading-text {
    display: flex;
    align-items: center;
    gap: 8px;
}

.loading-time {
    font-weight: 600;
    color: var(--primary);
}

/* Input Area */
.input-area {
    padding: 20px 24px;
    background: white;
    border-top: 1px solid var(--border);
}

.input-wrapper {
    display: flex;
    align-items: flex-end;
    gap: 12px;
    background: var(--light);
    border-radius: 20px;
    padding: 8px 16px;
    transition: all 0.2s;
}

.input-wrapper:focus-within {
    background: white;
    box-shadow: 0 0 0 2px var(--primary);
}

.input-wrapper textarea {
    flex: 1;
    border: none;
    background: transparent;
    padding: 10px 0;
    font-size: 14px;
    font-family: inherit;
    resize: none;
    max-height: 120px;
    outline: none;
}

.input-options {
    display: flex;
    align-items: center;
    gap: 16px;
}

.option-checkbox {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 13px;
    color: var(--gray);
    cursor: pointer;
    user-select: none;
}

.option-checkbox input {
    display: none;
}

.option-checkbox i {
    font-size: 16px;
    transition: color 0.2s;
}

.option-checkbox input:checked + i {
    color: var(--secondary);
}

.option-checkbox:hover i {
    transform: scale(1.1);
}

.option-text {
    font-size: 13px;
}

.send-btn {
    width: 44px;
    height: 44px;
    border: none;
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 50%;
    color: white;
    cursor: pointer;
    transition: all 0.2s;
    display: flex;
    align-items: center;
    justify-content: center;
}

.send-btn:hover:not(:disabled) {
    transform: scale(1.05);
    box-shadow: var(--shadow-lg);
}

.send-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
    transform: none;
}

.btn-loader {
    font-size: 18px;
    animation: spin 1s linear infinite;
}

.input-footer {
    margin-top: 8px;
    display: flex;
    justify-content: space-between;
    font-size: 12px;
    color: var(--gray);
    padding: 0 8px;
}

.input-hint {
    display: flex;
    align-items: center;
    gap: 4px;
}

.input-hint i {
    font-size: 12px;
}

.char-counter {
    font-weight: 500;
    transition: color 0.2s;
}

/* Typing Cursor */
.typing-cursor {
    display: inline-block;
    width: 2px;
    height: 16px;
    background: var(--primary);
    animation: blink 1s infinite;
    margin-left: 2px;
    vertical-align: middle;
}

/* Animations */
@keyframes pulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.1); }
}

@keyframes float {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

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

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

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

@keyframes blink {
    0%, 100% { opacity: 1; }
    50% { opacity: 0; }
}

/* Scrollbar */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: #f1f1f1;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 3px;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Notifications */
.notification {
    animation: slideIn 0.3s;
    font-size: 14px;
    line-height: 1.5;
}

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

/* Responsive Design */
@media (max-width: 768px) {
    .app {
        margin: 0;
        height: 100vh;
        border-radius: 0;
    }
    
    .stats {
        display: none;
    }
    
    .features {
        flex-direction: column;
        gap: 12px;
    }
    
    .quick-actions {
        flex-direction: column;
        padding: 0 20px;
    }
    
    .message-content {
        max-width: 85%;
    }
    
    .option-text {
        display: none;
    }
    
    .option-checkbox i {
        font-size: 20px;
    }
    
    .input-options {
        gap: 12px;
    }
    
    .header-actions {
        gap: 4px;
    }
    
    .icon-btn {
        width: 36px;
        height: 36px;
    }
}

@media (max-width: 480px) {
    .logo-text h1 {
        font-size: 16px;
    }
    
    .version {
        display: none;
    }
    
    .message-header {
        flex-wrap: wrap;
    }
    
    .badge {
        font-size: 10px;
    }
}

/* Survey Styles */
.survey-container,
.payment-container,
.processing-container,
.result-container {
    max-width: 600px;
    margin: 40px auto;
    padding: 20px;
}

@media(max-width: 700px) {
    .survey-container,
    .payment-container,
    .processing-container,
    .result-container {
        max-width: 100%
    }
}

.progress-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 40px;
    padding: 0 20px;
}

.progress-step {
    text-align: center;
    flex: 1;
}

.step-number {
    width: 40px;
    height: 40px;
    background: #e5e7eb;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    margin: 0 auto 8px;
    font-weight: 600;
    color: #6b7280;
    position: relative;
}

.progress-step.active .step-number {
    background: linear-gradient(135deg, #8b5cf6, #10b981);
    color: white;
    box-shadow: 0 4px 10px rgba(139, 92, 246, 0.3);
}

.step-label {
    font-size: 12px;
    color: #6b7280;
}

.progress-step.active .step-label {
    color: #8b5cf6;
    font-weight: 500;
}

.progress-line {
    width: 100%;
    height: 2px;
    background: #e5e7eb;
    margin: 0 -10px;
}

.form-container {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.form-container h2 {
    font-size: 24px;
    margin-bottom: 8px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.form-description {
    color: #6b7280;
    margin-bottom: 24px;
}

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

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: #374151;
}

.form-group label i {
    margin-right: 8px;
    color: #8b5cf6;
}

.form-group input,
.form-group select {
    width: 100%;
    padding: 12px 16px;
    border: 2px solid #e5e7eb;
    border-radius: 12px;
    font-size: 16px;
    transition: all 0.2s;
}

.form-group input:focus,
.form-group select:focus {
    outline: none;
    border-color: #8b5cf6;
    box-shadow: 0 0 0 3px rgba(139, 92, 246, 0.1);
}

.form-actions {
    margin-top: 30px;
}

/* Стили для кнопки с анимацией загрузки */
.btn-primary {
    width: 100%;
    padding: 14px;
    background: linear-gradient(135deg, #8b5cf6, #10b981);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 16px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.3s ease;
    position: relative;
    overflow: hidden;
}

.btn-primary:hover:not(:disabled) {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(139, 92, 246, 0.3);
}

.btn-primary:active:not(:disabled) {
    transform: translateY(0);
}

.btn-primary:disabled {
    opacity: 0.7;
    cursor: not-allowed;
    background: linear-gradient(135deg, #a78bfa, #6ee7b7);
}

/* Анимация загрузки для кнопки */
.btn-primary.loading {
    position: relative;
    color: transparent;
}

.btn-primary.loading::after {
    content: '';
    position: absolute;
    width: 20px;
    height: 20px;
    top: 50%;
    left: 50%;
    margin-left: -10px;
    margin-top: -10px;
    border: 2px solid white;
    border-top-color: transparent;
    border-radius: 50%;
    animation: button-spin 0.8s linear infinite;
}

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

@keyframes button-spin {
    to {
        transform: rotate(360deg);
    }
}

@keyframes button-shimmer {
    0% {
        left: -100%;
    }
    100% {
        left: 100%;
    }
}

/* Альтернативная анимация с текстом "Загрузка..." */
.btn-primary.loading-text {
    pointer-events: none;
}

.btn-primary.loading-text span {
    visibility: hidden;
}

.btn-primary.loading-text::before {
    content: '⏳';
    position: absolute;
    left: 50%;
    transform: translateX(-50%);
    animation: pulse 1s ease infinite;
}

@keyframes pulse {
    0%, 100% {
        opacity: 1;
    }
    50% {
        opacity: 0.5;
    }
}

/* Стили для кнопки в survey-direct.php */
.btn-primary i {
    margin-right: 8px;
    transition: transform 0.3s ease;
}

.btn-primary:hover:not(:disabled) i {
    transform: translateX(4px);
}

/* Эффект ripple при нажатии */
.btn-primary {
    position: relative;
    overflow: hidden;
}

.btn-primary .ripple {
    position: absolute;
    border-radius: 50%;
    background-color: rgba(255, 255, 255, 0.7);
    transform: scale(0);
    animation: ripple-animation 0.6s linear;
    pointer-events: none;
}

@keyframes ripple-animation {
    to {
        transform: scale(4);
        opacity: 0;
    }
}
/* Стили для disabled кнопки */
.btn-primary:disabled {
    opacity: 0.7;
    cursor: wait;
    transform: none;
    background: linear-gradient(135deg, #a78bfa, #6ee7b7);
}

.btn-primary:disabled i {
    animation: none;
}

/* Анимация для иконки при загрузке */
.fa-spinner {
    animation: spin 1s linear infinite;
}

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

/* Payment Styles */
.payment-card {
    background: white;
    border-radius: 20px;
    padding: 30px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.payment-header {
    text-align: center;
    margin-bottom: 30px;
}

.payment-header i {
    font-size: 48px;
    color: #10b981;
    margin-bottom: 16px;
}

.payment-info {
    background: #f9fafb;
    border-radius: 12px;
    padding: 20px;
    margin-bottom: 30px;
}

.info-row {
    display: flex;
    justify-content: space-between;
    padding: 12px 0;
    border-bottom: 1px solid #e5e7eb;
}

.info-row:last-child {
    border-bottom: none;
}

.info-row .amount {
    font-size: 24px;
    color: #8b5cf6;
}

.btn-pay {
    width: 100%;
    padding: 16px;
    background: linear-gradient(135deg, #10b981, #059669);
    color: white;
    border: none;
    border-radius: 12px;
    font-size: 18px;
    font-weight: 600;
    cursor: pointer;
    transition: all 0.2s;
}

.btn-pay:hover {
    transform: translateY(-2px);
    box-shadow: 0 10px 20px rgba(16, 185, 129, 0.3);
}

.payment-security {
    text-align: center;
    margin-top: 20px;
    font-size: 14px;
    color: #6b7280;
}

/* Processing Styles */
.processing-card {
    background: white;
    border-radius: 20px;
    padding: 40px;
    text-align: center;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.processing-icon i {
    font-size: 64px;
    color: #8b5cf6;
    margin-bottom: 20px;
    animation: pulse 2s infinite;
}

.processing-loader {
    width: 50px;
    height: 50px;
    border: 3px solid #e5e7eb;
    border-top-color: #8b5cf6;
    border-radius: 50%;
    margin: 30px auto;
    animation: spin 1s linear infinite;
}

.processing-note {
    color: #6b7280;
    font-size: 14px;
}

/* Result Styles */
.result-header {
    text-align: center;
    margin-bottom: 30px;
}

.result-header i {
    font-size: 48px;
    color: #10b981;
    margin-bottom: 16px;
}

.user-info-card,
.analysis-card {
    background: white;
    border-radius: 20px;
    padding: 24px;
    margin-bottom: 20px;
    box-shadow: 0 10px 25px -5px rgba(0,0,0,0.1);
}

.user-info-card h3,
.analysis-card h3 {
    margin-bottom: 16px;
    display: flex;
    align-items: center;
    gap: 10px;
}

.info-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 16px;
}

.info-item {
    display: flex;
    justify-content: space-between;
    padding: 8px 0;
    border-bottom: 1px solid #e5e7eb;
    flex-wrap: wrap;
    flex-direction: column;
}

.info-item .label {
    color: #6b7280;
    font-weight: 500;
}

.info-item .value {
    font-weight: 600;
    color: #374151;
}

.analysis-content {
    line-height: 1.8;
    color: #374151;
}

.analysis-content p {
    margin-bottom: 16px;
}

.result-actions {
    display: flex;
    gap: 12px;
    justify-content: center;
}

.btn-secondary {
    padding: 12px 24px;
    background: #f3f4f6;
    border: none;
    border-radius: 12px;
    color: #374151;
    font-weight: 500;
    cursor: pointer;
    transition: all 0.2s;
    display: inline-flex;
    align-items: center;
    text-decoration: none;
    gap: 8px;
}

.btn-secondary:hover {
    background: #e5e7eb;
    transform: translateY(-2px);
}

/* Responsive */
@media (max-width: 640px) {
    .step-label {
        display: none;
    }
    
    .progress-bar {
        padding: 0;
    }
    
    .info-grid {
        grid-template-columns: 1fr;
    }
    
    .result-actions {
        flex-direction: column;
    }
    
    .btn-secondary {
        justify-content: center;
    }
}

.app {
    max-width: 1200px;
    margin: 20px auto;
    background: white;
    border-radius: 24px;
    box-shadow: var(--shadow-xl);
    height: calc(100vh - 40px);
    display: flex;
    flex-direction: column;
    overflow: hidden; /* Важно для сохранения border-radius */
    position: relative;
}

/* Для контента внутри, который требует прокрутки */
.app-content {
    flex: 1;
    overflow-y: auto;
    overflow-x: hidden;
    padding: 20px 24px;
    scroll-behavior: smooth;
}

/* Стилизация скроллбара для .app-content */
.app-content::-webkit-scrollbar {
    width: 8px;
}

.app-content::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    margin: 10px 0;
}

.app-content::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
    transition: background 0.3s;
}

.app-content::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Альтернативный вариант - прокрутка самого .app */
.app-scroll {
    overflow-y: auto;
    overflow-x: hidden;
    scroll-behavior: smooth;
    border-radius: inherit; /* Наследует border-radius от родителя */
}

.app-scroll::-webkit-scrollbar {
    width: 8px;
}

.app-scroll::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
    margin: 20px 0;
}

.app-scroll::-webkit-scrollbar-thumb {
    background: linear-gradient(135deg, var(--primary), var(--secondary));
    border-radius: 10px;
}

.app-scroll::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Для Firefox */
.app-scroll {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f1f1f1;
}

/* Убеждаемся, что border-radius сохраняется при прокрутке */
.app {
    isolation: isolate; /* Создает новый контекст наложения */
}

.app-scroll {
    border-radius: inherit;
    position: relative;
    z-index: 1;
}

/* Для плавной прокрутки внутри чата */
.chat-container {
    flex: 1;
    overflow-y: auto;
    padding: 24px;
    scroll-behavior: smooth;
}

/* Стилизация скроллбара для чата */
.chat-container::-webkit-scrollbar {
    width: 6px;
}

.chat-container::-webkit-scrollbar-track {
    background: #f1f1f1;
    border-radius: 10px;
}

.chat-container::-webkit-scrollbar-thumb {
    background: var(--primary);
    border-radius: 10px;
    transition: background 0.3s;
}

.chat-container::-webkit-scrollbar-thumb:hover {
    background: var(--primary-dark);
}

/* Для Firefox */
.chat-container {
    scrollbar-width: thin;
    scrollbar-color: var(--primary) #f1f1f1;
}

.main-link {
    display: block;
    text-align: center;
    margin: 20px 0;
    color: #374151;
}

.main-link:hover {
    text-decoration: none;
}