/* ========================================
   ReplyMan AI Assistant - Main Styles
   ======================================== */

/* CSS Variables */
:root {
    --primary-color: #7c3aed;
    --primary-light: #a78bfa;
    --primary-dark: #5b21b6;
    --secondary-color: #ec4899;
    --accent-color: #06b6d4;
    
    --gradient-primary: linear-gradient(135deg, #7c3aed 0%, #ec4899 100%);
    --gradient-secondary: linear-gradient(135deg, #a78bfa 0%, #f472b6 100%);
    --gradient-dark: linear-gradient(135deg, #1e1b4b 0%, #312e81 100%);
    --gradient-light: linear-gradient(135deg, #f5f3ff 0%, #fdf2f8 100%);
    
    --bg-primary: #faf5ff;
    --bg-secondary: #ffffff;
    --bg-dark: #1e1b4b;
    
    --text-primary: #1e1b4b;
    --text-secondary: #6b7280;
    --text-light: #f5f3ff;
    
    --border-radius: 30px;
    --border-radius-sm: 15px;
    --border-radius-xs: 10px;
    
    --shadow-sm: 0 2px 10px rgba(124, 58, 237, 0.1);
    --shadow-md: 0 4px 20px rgba(124, 58, 237, 0.15);
    --shadow-lg: 0 10px 40px rgba(124, 58, 237, 0.2);
    
    --transition: all 0.3s ease;
}

/* Reset & Base */
* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    font-size: 16px;
    scroll-behavior: smooth;
}

body {
    font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, Oxygen, Ubuntu, sans-serif;
    background: var(--gradient-light);
    color: var(--text-primary);
    min-height: 100vh;
    line-height: 1.6;
}

/* Typography */
h1, h2, h3, h4, h5, h6 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 1rem;
}

h1 { font-size: 2.5rem; }
h2 { font-size: 2rem; }
h3 { font-size: 1.5rem; }
h4 { font-size: 1.25rem; }

p {
    margin-bottom: 1rem;
    color: var(--text-secondary);
}

a {
    color: var(--primary-color);
    text-decoration: none;
    transition: var(--transition);
}

a:hover {
    color: var(--primary-dark);
}

/* Layout */
.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 20px;
}

.app-layout {
    display: flex;
    min-height: 100vh;
}

/* Sidebar */
.sidebar {
    width: 280px;
    background: var(--gradient-dark);
    color: var(--text-light);
    padding: 30px 20px;
    display: flex;
    flex-direction: column;
    position: fixed;
    height: 100vh;
    left: 0;
    top: 0;
    z-index: 100;
    transition: var(--transition);
}

.sidebar-logo {
    display: flex;
    align-items: center;
    gap: 12px;
    margin-bottom: 40px;
    padding: 0 10px;
}

.sidebar-logo .logo-icon {
    width: 45px;
    height: 45px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    overflow: hidden;
}

.sidebar-logo .logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.sidebar-logo h1 {
    font-size: 1.4rem;
    font-weight: 700;
    margin: 0;
    background: var(--gradient-secondary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.sidebar-nav {
    flex: 1;
}

.nav-item {
    display: flex;
    align-items: center;
    gap: 14px;
    padding: 16px 20px;
    border-radius: var(--border-radius-sm);
    color: rgba(255, 255, 255, 0.7);
    cursor: pointer;
    transition: var(--transition);
    margin-bottom: 8px;
    text-decoration: none;
}

.nav-item:hover {
    background: rgba(255, 255, 255, 0.1);
    color: #fff;
}

.nav-item.active {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-md);
}

.nav-item i {
    font-size: 1.3rem;
    width: 24px;
    text-align: center;
}

.nav-item span {
    font-size: 1rem;
    font-weight: 500;
}

.sidebar-footer {
    margin-top: auto;
    padding-top: 20px;
    border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.user-info {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 10px;
}

.user-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    font-weight: 600;
}

.user-name {
    font-size: 0.95rem;
    font-weight: 500;
}

.user-email {
    font-size: 0.8rem;
    opacity: 0.7;
}

/* Main Content */
.main-content {
    flex: 1;
    margin-left: 280px;
    padding: 30px;
    min-height: 100vh;
}

.page-header {
    margin-bottom: 30px;
}

.page-header h2 {
    margin-bottom: 8px;
}

.page-header p {
    margin: 0;
}

/* Cards */
.card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 30px;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.card:hover {
    box-shadow: var(--shadow-md);
}

.card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 20px;
    padding-bottom: 15px;
    border-bottom: 1px solid rgba(124, 58, 237, 0.1);
}

.card-title {
    font-size: 1.2rem;
    font-weight: 600;
    margin: 0;
}

/* Buttons */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    padding: 14px 28px;
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    font-weight: 500;
    cursor: pointer;
    border: none;
    transition: var(--transition);
    text-decoration: none;
}

.btn-primary {
    background: var(--gradient-primary);
    color: #fff;
    box-shadow: var(--shadow-sm);
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}

.btn-secondary {
    background: var(--bg-primary);
    color: var(--primary-color);
    border: 2px solid var(--primary-light);
}

.btn-secondary:hover {
    background: var(--primary-light);
    color: #fff;
}

.btn-outline {
    background: transparent;
    color: var(--primary-color);
    border: 2px solid var(--primary-color);
}

.btn-outline:hover {
    background: var(--primary-color);
    color: #fff;
}

.btn-danger {
    background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%);
    color: #fff;
}

.btn-sm {
    padding: 10px 20px;
    font-size: 0.9rem;
}

.btn-lg {
    padding: 18px 36px;
    font-size: 1.1rem;
}

.btn-icon {
    width: 45px;
    height: 45px;
    padding: 0;
    border-radius: var(--border-radius-sm);
}

.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    transform: none !important;
}

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

.form-label {
    display: block;
    margin-bottom: 8px;
    font-weight: 500;
    color: var(--text-primary);
}

.form-input {
    width: 100%;
    padding: 16px 20px;
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    transition: var(--transition);
    background: var(--bg-secondary);
}

.form-input:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(124, 58, 237, 0.1);
}

.form-input::placeholder {
    color: var(--text-secondary);
}

textarea.form-input {
    min-height: 150px;
    resize: vertical;
}

/* File Upload */
.file-upload-area {
    border: 2px dashed var(--primary-light);
    border-radius: var(--border-radius);
    padding: 50px 30px;
    text-align: center;
    cursor: pointer;
    transition: var(--transition);
    background: rgba(124, 58, 237, 0.02);
}

.file-upload-area:hover {
    border-color: var(--primary-color);
    background: rgba(124, 58, 237, 0.05);
}

.file-upload-area.dragover {
    border-color: var(--primary-color);
    background: rgba(124, 58, 237, 0.1);
}

.file-upload-icon {
    font-size: 3rem;
    color: var(--primary-color);
    margin-bottom: 15px;
}

.file-upload-text {
    color: var(--text-secondary);
    margin-bottom: 10px;
}

.file-upload-hint {
    font-size: 0.85rem;
    color: var(--text-secondary);
    opacity: 0.8;
}

/* File List */
.file-list {
    display: flex;
    flex-direction: column;
    gap: 12px;
}

.file-item {
    display: flex;
    align-items: center;
    gap: 15px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    transition: var(--transition);
}

.file-item:hover {
    background: rgba(124, 58, 237, 0.1);
}

.file-icon {
    width: 45px;
    height: 45px;
    background: var(--gradient-secondary);
    border-radius: var(--border-radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 1.2rem;
}

.file-info {
    flex: 1;
}

.file-name {
    font-weight: 500;
    margin-bottom: 4px;
}

.file-meta {
    font-size: 0.85rem;
    color: var(--text-secondary);
}

.file-actions {
    display: flex;
    gap: 10px;
}

/* Chat Interface */
.chat-container {
    display: flex;
    flex-direction: column;
    height: calc(100vh - 340px);
    min-height: 350px;
}

.chat-messages {
    flex: 1;
    overflow-y: auto;
    padding: 20px;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

.message {
    display: flex;
    gap: 12px;
    max-width: 85%;
    animation: fadeIn 0.3s ease;
}

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

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

.message-avatar {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 0.9rem;
    flex-shrink: 0;
    overflow: hidden;
}

.message-avatar img {
    width: 32px;
    height: 32px;
    object-fit: contain;
}

.message.user .message-avatar {
    background: var(--bg-primary);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

.message-content {
    padding: 16px 30px;
    border-radius: var(--border-radius-sm);
    background: var(--bg-primary);
}

.message.user .message-content {
    background: var(--gradient-primary);
    color: #fff;
}

.message-text {
    line-height: 1.5;
    word-wrap: break-word;
}

.message-text p {
    margin: 0 0 4px 0;
    color: inherit;
}

.message-text p:last-child {
    margin-bottom: 0;
}

.message-text pre {
    background: #5d4b60;
    color: #f3f3f3;
    padding: 12px 16px;
    border-radius: 8px;
    overflow-x: auto;
    font-family: 'Courier New', monospace;
    font-size: 1em;
    margin: 12px 0;
    white-space: pre-wrap;
    word-break: break-word;
}

.message-text code {
    background: #f0f0f0;
    padding: 2px 6px;
    border-radius: 4px;
    font-family: monospace;
    font-size: 0.9em;
}

.message-text pre code {
    background: transparent;
    padding: 0;
}

/* Кнопка копирования */
.copy-btn {
    position: absolute;
    top: 8px;
    right: 8px;
    background: #ffffff;
    border: 1px solid #d0d7de;
    border-radius: 6px;
    padding: 4px 8px;
    font-size: 12px;
    cursor: pointer;
    font-family: inherit;
    color: #24292e;
    transition: 0.2s;
}

.copy-btn:hover {
    background: #e9ecef;
    border-color: #afb8c1;
}

.copy-btn.copied {
    background: #2cbe4e;
    color: white;
    border-color: #2cbe4e;
}

.chat-input-area {
    padding: 20px;
    border-top: 1px solid rgba(124, 58, 237, 0.1);
    background: var(--bg-secondary);
    border-radius: 0 0 var(--border-radius) var(--border-radius);
}

.chat-input-wrapper {
    display: flex;
    gap: 12px;
    align-items: flex-end;
}

.chat-input {
    flex: 1;
    padding: 16px 20px;
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    resize: none;
    max-height: 150px;
    min-height: 56px;
    transition: var(--transition);
}

.chat-input:focus {
    outline: none;
    border-color: var(--primary-color);
}

.chat-send-btn {
    width: 56px;
    height: 56px;
    border-radius: var(--border-radius-sm);
    background: var(--gradient-primary);
    color: #fff;
    border: none;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
}

.chat-send-btn:hover {
    transform: scale(1.05);
    box-shadow: var(--shadow-md);
}

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

/* Training Mode */
.training-status {
    display: flex;
    align-items: center;
    gap: 10px;
    padding: 12px 20px;
    background: linear-gradient(135deg, #10b981 0%, #059669 100%);
    color: #fff;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
}

.training-status.inactive {
    background: var(--bg-primary);
    color: var(--text-secondary);
}

.status-dot {
    width: 10px;
    height: 10px;
    background: #fff;
    border-radius: 50%;
    animation: pulse 2s infinite;
}

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

.training-feedback {
    background: var(--bg-primary);
    border-radius: var(--border-radius);
    padding: 30px;
    margin-top: 20px;
}

.feedback-score {
    display: flex;
    align-items: center;
    gap: 15px;
    margin-bottom: 20px;
}

.score-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    background: var(--gradient-primary);
    display: flex;
    align-items: center;
    justify-content: center;
    color: #fff;
    font-size: 2rem;
    font-weight: 700;
}

.feedback-section {
    margin-bottom: 20px;
}

.feedback-section h4 {
    display: flex;
    align-items: center;
    gap: 8px;
    margin-bottom: 12px;
}

.feedback-list {
    list-style: none;
    padding-left: 0;
}

.feedback-list li {
    padding: 10px 0;
    padding-left: 25px;
    position: relative;
    border-bottom: 1px solid rgba(124, 58, 237, 0.1);
}

.feedback-list li::before {
    content: '•';
    position: absolute;
    left: 8px;
    color: var(--primary-color);
}

/* Auth Pages */
.auth-container {
    min-height: 100vh;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: var(--gradient-light);
}

.auth-card {
    width: 100%;
    max-width: 450px;
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 40px;
    box-shadow: var(--shadow-lg);
}

.auth-logo {
    text-align: center;
    margin-bottom: 30px;
}

.auth-logo .logo-icon {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    margin: 0 auto 15px;
    overflow: hidden;
}

.auth-logo .logo-icon img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

.auth-logo h1 {
    font-size: 1.8rem;
    margin: 0;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.auth-logo p {
    color: var(--text-secondary);
    margin: 0;
}

.auth-form {
    margin-bottom: 25px;
}

.auth-divider {
    display: flex;
    align-items: center;
    gap: 15px;
    margin: 25px 0;
    color: var(--text-secondary);
}

.auth-divider::before,
.auth-divider::after {
    content: '';
    flex: 1;
    height: 1px;
    background: rgba(124, 58, 237, 0.2);
}

.auth-footer {
    text-align: center;
    color: var(--text-secondary);
}

/* Instructions Editor */
.instructions-editor {
    margin-top: 20px;
}

.instructions-textarea {
    width: 100%;
    min-height: 200px;
    padding: 20px;
    border: 2px solid rgba(124, 58, 237, 0.2);
    border-radius: var(--border-radius-sm);
    font-size: 1rem;
    resize: vertical;
    font-family: inherit;
    line-height: 1.6;
}

.instructions-textarea:focus {
    outline: none;
    border-color: var(--primary-color);
}

/* Stats Grid */
.stats-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.stat-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 25px;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: var(--transition);
}

.stat-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-md);
}

.stat-value {
    font-size: 2.5rem;
    font-weight: 700;
    background: var(--gradient-primary);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
}

.stat-label {
    color: var(--text-secondary);
    font-size: 0.95rem;
    margin-top: 5px;
}

/* Scenarios Grid */
.scenarios-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    margin-bottom: 30px;
}

.scenario-card {
    background: var(--bg-secondary);
    border-radius: var(--border-radius);
    padding: 25px;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid transparent;
}

.scenario-card:hover {
    border-color: var(--primary-light);
    transform: translateY(-3px);
}

.scenario-card.selected {
    border-color: var(--primary-color);
    background: var(--bg-primary);
}

.scenario-icon {
    width: 50px;
    height: 50px;
    background: var(--gradient-secondary);
    border-radius: var(--border-radius-xs);
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.5rem;
    margin-bottom: 15px;
}

.scenario-title {
    font-weight: 600;
    margin-bottom: 8px;
}

.scenario-desc {
    font-size: 0.9rem;
    color: var(--text-secondary);
    margin: 0;
}

/* Loading States */
.loading {
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 40px;
}

.spinner {
    width: 40px;
    height: 40px;
    border: 3px solid rgba(124, 58, 237, 0.2);
    border-top-color: var(--primary-color);
    border-radius: 50%;
    animation: spin 1s linear infinite;
}

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

.typing-indicator {
    display: flex;
    gap: 5px;
    padding: 16px 20px;
    background: var(--bg-primary);
    border-radius: var(--border-radius-sm);
    width: fit-content;
}

.typing-dot {
    width: 8px;
    height: 8px;
    background: var(--primary-color);
    border-radius: 50%;
    animation: typingBounce 1.4s infinite ease-in-out;
}

.typing-dot:nth-child(1) { animation-delay: 0s; }
.typing-dot:nth-child(2) { animation-delay: 0.2s; }
.typing-dot:nth-child(3) { animation-delay: 0.4s; }

@keyframes typingBounce {
    0%, 80%, 100% {
        transform: translateY(0);
    }
    40% {
        transform: translateY(-10px);
    }
}

/* Alerts */
.alert {
    padding: 16px 20px;
    border-radius: var(--border-radius-sm);
    margin-bottom: 20px;
    display: flex;
    align-items: center;
    gap: 12px;
}

.alert-success {
    background: rgba(16, 185, 129, 0.1);
    color: #059669;
    border: 1px solid rgba(16, 185, 129, 0.2);
}

.alert-error {
    background: rgba(239, 68, 68, 0.1);
    color: #dc2626;
    border: 1px solid rgba(239, 68, 68, 0.2);
}

.alert-warning {
    background: rgba(245, 158, 11, 0.1);
    color: #d97706;
    border: 1px solid rgba(245, 158, 11, 0.2);
}

.alert-info {
    background: rgba(124, 58, 237, 0.1);
    color: var(--primary-dark);
    border: 1px solid rgba(124, 58, 237, 0.2);
}

/* Empty State */
.empty-state {
    text-align: center;
    padding: 60px 30px;
}

.empty-icon {
    font-size: 4rem;
    color: var(--primary-light);
    margin-bottom: 20px;
}

.empty-title {
    font-size: 1.3rem;
    font-weight: 600;
    margin-bottom: 10px;
}

.empty-desc {
    color: var(--text-secondary);
    max-width: 400px;
    margin: 0 auto 25px;
}

/* Responsive */
@media (max-width: 1024px) {
    .sidebar {
        transform: translateX(-100%);
    }
    
    .sidebar.open {
        transform: translateX(0);
    }
    
    .main-content {
        margin-left: 0;
    }
    
    .mobile-menu-btn {
        display: flex;
    }
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
    
    .main-content {
        padding: 20px 15px;
    }
    
    .card {
        padding: 20px;
    }
    
    .stats-grid {
        grid-template-columns: 1fr 1fr;
    }
    
    .message {
        max-width: 95%;
    }
    
    .auth-card {
        padding: 30px 25px;
    }
}

@media (max-width: 480px) {
    .stats-grid {
        grid-template-columns: 1fr;
    }
    
    .scenarios-grid {
        grid-template-columns: 1fr;
    }
}

/* Mobile Menu Button */
.mobile-menu-btn {
    display: none;
    position: fixed;
    top: 20px;
    left: 20px;
    z-index: 101;
    width: 45px;
    height: 45px;
    background: var(--gradient-primary);
    border: none;
    border-radius: var(--border-radius-xs);
    color: #fff;
    cursor: pointer;
    align-items: center;
    justify-content: center;
    font-size: 1.3rem;
}

@media (max-width: 1024px) {
    .mobile-menu-btn {
        display: flex;
    }
}

/* Scrollbar */
::-webkit-scrollbar {
    width: 8px;
    height: 8px;
}

::-webkit-scrollbar-track {
    background: var(--bg-primary);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb {
    background: var(--primary-light);
    border-radius: 10px;
}

::-webkit-scrollbar-thumb:hover {
    background: var(--primary-color);
}

/* Utility Classes */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-20 { margin-top: 20px; }
.mt-30 { margin-top: 30px; }
.mb-20 { margin-bottom: 20px; }
.mb-30 { margin-bottom: 30px; }
.hidden { display: none !important; }
.flex { display: flex; }
.flex-center { display: flex; align-items: center; justify-content: center; }
.flex-between { display: flex; align-items: center; justify-content: space-between; }
.gap-10 { gap: 10px; }
.gap-15 { gap: 15px; }
.gap-20 { gap: 20px; }
