/* ==========================================
   МАХ MESSENGER STYLE - Сине-фиолетовая гамма
   ========================================== */

   @import url('https://fonts.googleapis.com/css2?family=Inter:wght@400;500;600;700;800&display=swap');

   :root {
     /* Основные цвета МАХ */
     --primary: #6C5CE7;
     --primary-dark: #5849C7;
     --primary-light: #A29BFE;
     --secondary: #0984E3;
     --accent: #74B9FF;
     
     /* Градиенты */
     --gradient-primary: linear-gradient(135deg, #667EEA 0%, #764BA2 100%);
     --gradient-secondary: linear-gradient(135deg, #6C5CE7 0%, #0984E3 100%);
     --gradient-hover: linear-gradient(135deg, #5849C7 0%, #0770C7 100%);
     
     /* Нейтральные цвета */
     --bg-primary: #F7F8FC;
     --bg-secondary: #FFFFFF;
     --bg-dark: #2D3436;
     --text-primary: #2D3436;
     --text-secondary: #636E72;
     --text-light: #B2BEC3;
     
     /* Акценты */
     --success: #00B894;
     --error: #FF6B6B;
     --warning: #FDCB6E;
     --info: #74B9FF;
     
     /* Тени */
     --shadow-sm: 0 2px 8px rgba(108, 92, 231, 0.1);
     --shadow-md: 0 4px 16px rgba(108, 92, 231, 0.15);
     --shadow-lg: 0 8px 32px rgba(108, 92, 231, 0.2);
     --shadow-xl: 0 12px 48px rgba(108, 92, 231, 0.25);
     
     /* Радиусы */
     --radius-sm: 8px;
     --radius-md: 16px;
     --radius-lg: 24px;
     --radius-xl: 32px;
   }
   
   * {
     margin: 0;
     padding: 0;
     box-sizing: border-box;
   }
   
   body {
     font-family: 'Inter', -apple-system, BlinkMacSystemFont, 'Segoe UI', sans-serif;
     background: var(--bg-primary);
     color: var(--text-primary);
     line-height: 1.6;
     overflow-x: hidden;
   }
   
   /* Анимация фона */
   body::before {
     content: '';
     position: fixed;
     top: -50%;
     left: -50%;
     width: 200%;
     height: 200%;
     background: radial-gradient(circle, rgba(108, 92, 231, 0.03) 1px, transparent 1px);
     background-size: 50px 50px;
     animation: backgroundMove 20s linear infinite;
     z-index: -1;
   }
   
   @keyframes backgroundMove {
     0% { transform: translate(0, 0); }
     100% { transform: translate(50px, 50px); }
   }
   
   .container {
     max-width: 1200px;
     margin: 0 auto;
     padding: 20px;
   }
   
   /* ==========================================
      HEADER - Стиль МАХ
      ========================================== */
   
   .header {
     background: var(--gradient-primary);
     color: white;
     padding: 40px 20px;
     text-align: center;
     position: relative;
     overflow: hidden;
     box-shadow: var(--shadow-lg);
     margin-bottom: 40px;
   }
   
   .header::before {
     content: '';
     position: absolute;
     top: 0;
     left: 0;
     right: 0;
     bottom: 0;
     background: url('data:image/svg+xml,<svg width="100" height="100" xmlns="http://www.w3.org/2000/svg"><circle cx="50" cy="50" r="40" fill="rgba(255,255,255,0.05)"/></svg>');
     opacity: 0.3;
     animation: float 15s ease-in-out infinite;
   }
   
   @keyframes float {
     0%, 100% { transform: translateY(0) rotate(0deg); }
     50% { transform: translateY(-20px) rotate(180deg); }
   }
   
   .header h1 {
     font-size: 2.8rem;
     font-weight: 800;
     margin-bottom: 12px;
     position: relative;
     z-index: 1;
     text-shadow: 0 4px 12px rgba(0, 0, 0, 0.2);
     letter-spacing: -0.5px;
   }
   
   .header p {
     font-size: 1.2rem;
     opacity: 0.95;
     position: relative;
     z-index: 1;
     font-weight: 500;
   }
   
   .logo {
     font-size: 0.95rem;
     opacity: 0.85;
     margin-top: 16px;
     font-weight: 600;
     letter-spacing: 0.5px;
     position: relative;
     z-index: 1;
   }
   
   /* Навигация УБРАНА для страницы облака */
   .nav-links {
     display: flex;
     justify-content: center;
     gap: 15px;
     margin-top: 24px;
     flex-wrap: wrap;
     position: relative;
     z-index: 1;
   }
   
   .nav-links a {
     color: white;
     text-decoration: none;
     padding: 10px 24px;
     border-radius: var(--radius-lg);
     background: rgba(255, 255, 255, 0.15);
     backdrop-filter: blur(10px);
     transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
     font-weight: 600;
     font-size: 0.95rem;
     border: 1px solid rgba(255, 255, 255, 0.2);
   }
   
   .nav-links a:hover {
     background: rgba(255, 255, 255, 0.25);
     transform: translateY(-2px);
     box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
   }
   
   /* ==========================================
      CARDS - МАХ Style
      ========================================== */
   
   .card {
     background: var(--bg-secondary);
     border-radius: var(--radius-lg);
     padding: 32px;
     box-shadow: var(--shadow-md);
     margin-bottom: 24px;
     transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
     border: 1px solid rgba(108, 92, 231, 0.08);
     position: relative;
     overflow: hidden;
   }
   
   .card::before {
     content: '';
     position: absolute;
     top: 0;
     left: 0;
     right: 0;
     height: 4px;
     background: var(--gradient-primary);
     transform: scaleX(0);
     transition: transform 0.3s ease;
   }
   
   .card:hover {
     transform: translateY(-4px);
     box-shadow: var(--shadow-xl);
     border-color: rgba(108, 92, 231, 0.2);
   }
   
   .card:hover::before {
     transform: scaleX(1);
   }
   
   .card h2 {
     color: var(--primary);
     margin-bottom: 24px;
     font-size: 1.5rem;
     font-weight: 700;
     letter-spacing: -0.3px;
   }
   
   /* ==========================================
      FORMS - МАХ Style
      ========================================== */
   
   .form-group {
     margin-bottom: 24px;
   }
   
   label {
     display: block;
     font-weight: 600;
     margin-bottom: 10px;
     color: var(--text-primary);
     font-size: 0.95rem;
     letter-spacing: 0.2px;
   }
   
   input[type="text"],
   textarea {
     width: 100%;
     padding: 14px 18px;
     border: 2px solid #E8E4FF;
     border-radius: var(--radius-md);
     font-size: 1rem;
     transition: all 0.3s ease;
     font-family: inherit;
     background: var(--bg-primary);
     color: var(--text-primary);
   }
   
   input[type="text"]:focus,
   textarea:focus {
     outline: none;
     border-color: var(--primary);
     background: white;
     box-shadow: 0 0 0 4px rgba(108, 92, 231, 0.1);
   }
   
   textarea {
     resize: vertical;
     min-height: 120px;
   }
   
   /* ==========================================
      BUTTONS - МАХ Style
      ========================================== */
   
   .btn {
     padding: 14px 32px;
     border: none;
     border-radius: var(--radius-lg);
     font-size: 1rem;
     font-weight: 600;
     cursor: pointer;
     transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
     display: inline-flex;
     align-items: center;
     justify-content: center;
     gap: 8px;
     text-decoration: none;
     position: relative;
     overflow: hidden;
     font-family: inherit;
   }
   
   .btn::before {
     content: '';
     position: absolute;
     top: 50%;
     left: 50%;
     width: 0;
     height: 0;
     border-radius: 50%;
     background: rgba(255, 255, 255, 0.3);
     transform: translate(-50%, -50%);
     transition: width 0.6s, height 0.6s;
   }
   
   .btn:hover::before {
     width: 300px;
     height: 300px;
   }
   
   .btn > * {
     position: relative;
     z-index: 1;
   }
   
   .btn-primary {
     background: var(--gradient-primary);
     color: white;
     box-shadow: var(--shadow-md);
   }
   
   .btn-primary:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-lg);
   }
   
   .btn-primary:active {
     transform: translateY(0);
   }
   
   .btn-success {
     background: linear-gradient(135deg, #00B894, #00CEC9);
     color: white;
     box-shadow: var(--shadow-md);
   }
   
   .btn-success:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-lg);
   }
   
   .btn-danger {
     background: linear-gradient(135deg, #FF6B6B, #FF8787);
     color: white;
     box-shadow: var(--shadow-md);
   }
   
   .btn-danger:hover {
     transform: translateY(-2px);
     box-shadow: var(--shadow-lg);
   }
   
   .btn-block {
     width: 100%;
     display: flex;
   }
   
   .btn:disabled {
     opacity: 0.6;
     cursor: not-allowed;
     transform: none !important;
   }
   
   /* ==========================================
      STATISTICS CARDS
      ========================================== */
   
   .stats {
     display: grid;
     grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
     gap: 20px;
     margin-bottom: 32px;
   }
   
   .stat-card {
     background: var(--gradient-secondary);
     color: white;
     padding: 28px;
     border-radius: var(--radius-lg);
     text-align: center;
     box-shadow: var(--shadow-md);
     transition: all 0.3s ease;
     position: relative;
     overflow: hidden;
   }
   
   .stat-card::before {
     content: '';
     position: absolute;
     top: -50%;
     right: -50%;
     width: 200%;
     height: 200%;
     background: radial-gradient(circle, rgba(255,255,255,0.1) 0%, transparent 70%);
     animation: shimmer 3s ease-in-out infinite;
   }
   
   @keyframes shimmer {
     0%, 100% { transform: translate(0, 0); }
     50% { transform: translate(-30%, -30%); }
   }
   
   .stat-card:hover {
     transform: translateY(-4px) scale(1.02);
     box-shadow: var(--shadow-xl);
   }
   
   .stat-value {
     font-size: 3rem;
     font-weight: 800;
     margin-bottom: 8px;
     position: relative;
     z-index: 1;
     text-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
   }
   
   .stat-label {
     font-size: 0.95rem;
     opacity: 0.95;
     font-weight: 600;
     position: relative;
     z-index: 1;
     letter-spacing: 0.3px;
   }
   
   /* ==========================================
      QUESTION DISPLAY
      ========================================== */
   
   .question {
     font-size: 1.6rem;
     font-weight: 700;
     color: var(--primary);
     margin-bottom: 24px;
     text-align: center;
     padding: 28px;
     background: linear-gradient(135deg, #E8E4FF 0%, #F0EEFF 100%);
     border-radius: var(--radius-lg);
     border-left: 5px solid var(--primary);
     box-shadow: var(--shadow-sm);
     line-height: 1.4;
   }
   
   /* ==========================================
      TAG CLOUD
      ========================================== */
   
   #tagCloud {
     position: relative;
     width: 100%;
     height: 600px;
     background: linear-gradient(135deg, #FFFFFF 0%, #F7F8FC 100%);
     border-radius: var(--radius-lg);
     overflow: hidden;
     box-shadow: var(--shadow-lg);
     border: 2px solid rgba(108, 92, 231, 0.1);
   }
   
   .tag {
     position: absolute;
     padding: 12px 24px;
     border-radius: var(--radius-xl);
     font-weight: 700;
     white-space: nowrap;
     cursor: pointer;
     transition: all 0.6s cubic-bezier(0.4, 0, 0.2, 1);
     opacity: 0;
     transform: scale(0.8);
     user-select: none;
     text-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
     letter-spacing: 0.3px;
   }
   
   .tag:hover {
     transform: scale(1.15) !important;
     box-shadow: var(--shadow-lg);
     z-index: 100;
     filter: brightness(1.1);
   }
   
   /* ==========================================
      NOTIFICATIONS
      ========================================== */
   
   .notification {
     position: fixed;
     top: 24px;
     right: 24px;
     padding: 18px 28px;
     border-radius: var(--radius-lg);
     color: white;
     box-shadow: var(--shadow-xl);
     animation: slideInRight 0.4s cubic-bezier(0.4, 0, 0.2, 1);
     z-index: 10000;
     font-weight: 600;
     display: flex;
     align-items: center;
     gap: 12px;
     backdrop-filter: blur(10px);
   }
   
   @keyframes slideInRight {
     from {
       transform: translateX(400px);
       opacity: 0;
     }
     to {
       transform: translateX(0);
       opacity: 1;
     }
   }
   
   .notification.success {
     background: linear-gradient(135deg, #00B894, #00CEC9);
   }
   
   .notification.error {
     background: linear-gradient(135deg, #FF6B6B, #FF8787);
   }
   
   /* ==========================================
      EMPTY STATE
      ========================================== */
   
   .empty-state {
     text-align: center;
     padding: 80px 20px;
     color: var(--text-secondary);
   }
   
   .empty-state-icon {
     font-size: 5rem;
     margin-bottom: 24px;
     opacity: 0.5;
     animation: bounce 2s ease-in-out infinite;
   }
   
   @keyframes bounce {
     0%, 100% { transform: translateY(0); }
     50% { transform: translateY(-20px); }
   }
   
   .empty-state-text {
     font-size: 1.3rem;
     font-weight: 600;
     color: var(--text-light);
   }
   
   /* ==========================================
      LOADING
      ========================================== */
   
   .loading {
     display: inline-block;
     width: 20px;
     height: 20px;
     border: 3px solid rgba(255, 255, 255, 0.3);
     border-radius: 50%;
     border-top-color: white;
     animation: spin 0.8s linear infinite;
   }
   
   @keyframes spin {
     to { transform: rotate(360deg); }
   }
   
   /* ==========================================
      TABLES
      ========================================== */
   
   table {
     width: 100%;
     border-collapse: collapse;
     font-size: 0.95rem;
   }
   
   table thead th {
     font-weight: 700;
     color: var(--primary);
     padding: 14px;
     text-align: left;
     border-bottom: 2px solid #E8E4FF;
     font-size: 0.9rem;
     text-transform: uppercase;
     letter-spacing: 0.5px;
   }
   
   table tbody tr {
     transition: all 0.2s ease;
     border-bottom: 1px solid #F0F0F0;
   }
   
   table tbody tr:hover {
     background: linear-gradient(90deg, #F7F8FC 0%, #FFFFFF 100%);
   }
   
   table tbody td {
     padding: 14px;
   }
   
   /* ==========================================
      HISTORY
      ========================================== */
   
   .history-list {
     display: flex;
     flex-direction: column;
     gap: 16px;
   }
   
   .history-item {
     padding: 24px;
     background: linear-gradient(135deg, #F7F8FC, #FFFFFF);
     border-radius: var(--radius-lg);
     border-left: 4px solid var(--primary);
     transition: all 0.3s ease;
     box-shadow: var(--shadow-sm);
   }
   
   .history-item:hover {
     transform: translateX(8px);
     box-shadow: var(--shadow-md);
     border-left-width: 6px;
   }
   
   .history-header {
     display: flex;
     align-items: center;
     gap: 16px;
     margin-bottom: 12px;
   }
   
   .history-number {
     background: var(--gradient-primary);
     color: white;
     padding: 6px 16px;
     border-radius: var(--radius-lg);
     font-weight: 700;
     font-size: 0.9rem;
     box-shadow: var(--shadow-sm);
   }
   
   .history-question {
     font-weight: 700;
     font-size: 1.15rem;
     color: var(--text-primary);
     flex: 1;
     letter-spacing: -0.2px;
   }
   
   .history-meta {
     display: flex;
     gap: 20px;
     font-size: 0.9rem;
     color: var(--text-secondary);
     flex-wrap: wrap;
   }
   
   .history-meta span {
     display: flex;
     align-items: center;
     gap: 6px;
     font-weight: 500;
   }
   
   .status-completed {
     background: linear-gradient(135deg, #E8F5E9, #C8E6C9);
     color: #2E7D32;
     padding: 5px 14px;
     border-radius: var(--radius-lg);
     font-weight: 700;
     font-size: 0.85rem;
   }
   
   .status-active {
     background: linear-gradient(135deg, #FFF3E0, #FFE0B2);
     color: #E65100;
     padding: 5px 14px;
     border-radius: var(--radius-lg);
     font-weight: 700;
     font-size: 0.85rem;
     animation: pulse 2s infinite;
   }
   
   @keyframes pulse {
     0%, 100% { opacity: 1; }
     50% { opacity: 0.7; }
   }
   
   /* ==========================================
      RESPONSIVE
      ========================================== */
   
   @media (max-width: 768px) {
     .header h1 {
       font-size: 2rem;
     }
   
     .card {
       padding: 20px;
     }
   
     #tagCloud {
       height: 400px;
     }
   
     .stats {
       grid-template-columns: 1fr;
     }
   
     .history-header {
       flex-direction: column;
       align-items: flex-start;
     }
   
     .history-meta {
       flex-direction: column;
       gap: 8px;
     }
   
     .notification {
       left: 20px;
       right: 20px;
       top: 20px;
     }
   }
   
   /* ==========================================
      SCROLLBAR
      ========================================== */
   
   ::-webkit-scrollbar {
     width: 10px;
     height: 10px;
   }
   
   ::-webkit-scrollbar-track {
     background: #F7F8FC;
   }
   
   ::-webkit-scrollbar-thumb {
     background: var(--gradient-primary);
     border-radius: 10px;
   }
   
   ::-webkit-scrollbar-thumb:hover {
     background: var(--gradient-hover);
   }

  /* ==========================================
   LIBRARY STYLES - Справочник вопросов
   ========================================== */

.library-add-form {
  margin-bottom: 32px;
  padding: 24px;
  background: linear-gradient(135deg, #F7F8FC, #FFFFFF);
  border-radius: var(--radius-lg);
  border: 2px dashed rgba(108, 92, 231, 0.2);
}

.form-row {
  display: flex;
  gap: 16px;
  align-items: flex-end;
}

.library-list {
  margin-top: 24px;
}

.library-category {
  margin-bottom: 28px;
}

.library-category-title {
  font-size: 1.1rem;
  font-weight: 700;
  color: var(--primary);
  margin-bottom: 16px;
  padding-bottom: 8px;
  border-bottom: 2px solid #E8E4FF;
  display: flex;
  align-items: center;
  gap: 8px;
}

.library-category-title::before {
  content: '📂';
  font-size: 1.2rem;
}

.library-questions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.library-question-item {
  display: flex;
  justify-content: space-between;
  align-items: center;
  padding: 16px 20px;
  background: white;
  border-radius: var(--radius-md);
  border: 2px solid #E8E4FF;
  transition: all 0.3s ease;
  cursor: pointer;
}

.library-question-item:hover {
  border-color: var(--primary);
  transform: translateX(4px);
  box-shadow: var(--shadow-md);
}

.library-question-content {
  flex: 1;
  display: flex;
  align-items: center;
  gap: 12px;
}

.library-question-text {
  font-weight: 600;
  color: var(--text-primary);
  font-size: 1rem;
}

.usage-badge {
  background: linear-gradient(135deg, #E8E4FF, #D0C9FF);
  color: var(--primary);
  padding: 4px 12px;
  border-radius: var(--radius-lg);
  font-size: 0.8rem;
  font-weight: 700;
  white-space: nowrap;
}

.library-question-actions {
  display: flex;
  gap: 8px;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.library-question-item:hover .library-question-actions {
  opacity: 1;
}

.btn-icon {
  width: 36px;
  height: 36px;
  border: none;
  border-radius: 50%;
  background: var(--bg-primary);
  cursor: pointer;
  transition: all 0.3s ease;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
}

.btn-icon:hover {
  transform: scale(1.1);
  box-shadow: var(--shadow-sm);
}

.btn-use {
  background: linear-gradient(135deg, #00B894, #00CEC9);
}

.btn-use:hover {
  box-shadow: 0 4px 12px rgba(0, 184, 148, 0.3);
}

.btn-edit {
  background: linear-gradient(135deg, #74B9FF, #0984E3);
}

.btn-edit:hover {
  box-shadow: 0 4px 12px rgba(9, 132, 227, 0.3);
}

.btn-delete {
  background: linear-gradient(135deg, #FF6B6B, #FF8787);
}

.btn-delete:hover {
  box-shadow: 0 4px 12px rgba(255, 107, 107, 0.3);
}

/* Адаптивность для формы */
@media (max-width: 768px) {
  .form-row {
    flex-direction: column;
  }

  .library-question-item {
    flex-direction: column;
    align-items: flex-start;
    gap: 12px;
  }

  .library-question-actions {
    opacity: 1;
    width: 100%;
    justify-content: flex-end;
  }
}