/* ========================================
   🎨 СОВРЕМЕННЫЙ ДИЗАЙН - CSS VARIABLES
   ======================================== */
:root {
  --primary: #6366f1;
  --primary-hover: #4f46e5;
  --primary-light: #eef2ff;
  --secondary: #64748b;
  --success: #10b981;
  --warning: #f59e0b;
  --danger: #ef4444;
  --info: #3b82f6;
  
  --bg-page: #f8fafc;
  --bg-card: #ffffff;
  --bg-input: #f1f5f9;
  
  --text-main: #0f172a;
  --text-muted: #64748b;
  --text-light: #94a3b8;
  
  --border-color: #e2e8f0;
  --radius: 16px;
  --radius-sm: 12px;
  --shadow: 0 1px 3px 0 rgba(0, 0, 0, 0.1), 0 1px 2px -1px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -2px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 15px -3px rgba(0, 0, 0, 0.1), 0 4px 6px -4px rgba(0, 0, 0, 0.1);
  --shadow-primary: 0 4px 12px rgba(99, 102, 241, 0.15);
}

/* ========================================
   🌐 БАЗОВЫЕ СТИЛИ
   ======================================== */
body {
  background: var(--bg-page);
  font-family: 'Inter', system-ui, -apple-system, sans-serif;
  color: var(--text-main);
  line-height: 1.6;
  min-height: 100vh;
  -webkit-font-smoothing: antialiased;
}

/* ========================================
   🧭 НАВИГАЦИЯ
   ======================================== */
.navbar {
  background: rgba(255, 255, 255, 0.95) !important;
  backdrop-filter: blur(10px);
  box-shadow: var(--shadow);
  padding: 0.75rem 0;
}
.navbar-brand {
  font-size: 1.25rem;
  letter-spacing: -0.025em;
  font-weight: 700;
}

/* ========================================
   📦 КАРТОЧКИ И МАКЕТ
   ======================================== */
.card {
  background: var(--bg-card);
  border: 1px solid var(--border-color);
  border-radius: var(--radius);
  box-shadow: var(--shadow);
  transition: transform 0.25s cubic-bezier(0.4, 0, 0.2, 1), box-shadow 0.25s ease;
}
.card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-lg);
}
.card-header {
  background: transparent;
  border-bottom: 1px solid var(--border-color);
  padding: 1.25rem 1.5rem;
  font-weight: 600;
}
.card-body { padding: 1.5rem; }

.event-detail-header {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%) !important;
  color: white !important;
  border-bottom: none;
}

/* ========================================
   🔘 КНОПКИ
   ======================================== */
.btn-primary {
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  border: none;
  border-radius: var(--radius-sm);
  font-weight: 500;
  padding: 0.625rem 1.5rem;
  box-shadow: var(--shadow-primary);
  transition: all 0.2s ease;
}
.btn-primary:hover {
  background: linear-gradient(135deg, var(--primary-hover) 0%, #7c3aed 100%);
  transform: translateY(-2px);
  box-shadow: 0 8px 20px rgba(99, 102, 241, 0.25);
}
.btn-outline-primary {
  border: 2px solid var(--primary);
  color: var(--primary);
  border-radius: var(--radius-sm);
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-outline-primary:hover {
  background: var(--primary);
  border-color: var(--primary);
  color: white;
  transform: translateY(-1px);
}
.btn-outline-secondary {
  border-radius: var(--radius-sm);
  padding: 0.5rem 1rem;
  font-weight: 500;
  transition: all 0.2s ease;
}
.btn-outline-secondary:hover {
  transform: translateX(-4px);
  background-color: var(--secondary);
  border-color: var(--secondary);
  color: white;
}
.btn-sm { padding: 0.375rem 1rem; font-size: 0.875rem; }

/* ========================================
   📝 ФОРМЫ
   ======================================== */
.form-control, .form-select {
  border-radius: var(--radius-sm);
  padding: 0.75rem 1rem;
  border: 2px solid var(--border-color);
  background: var(--bg-input);
  font-size: 0.9375rem;
  transition: all 0.2s ease;
}
.form-control:focus, .form-select:focus {
  background: white;
  border-color: var(--primary);
  box-shadow: 0 0 0 4px var(--primary-light);
  outline: none;
}
.form-label {
  font-weight: 500;
  color: var(--text-main);
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
}

/* ========================================
   🏷️ БЕЙДЖИ И СТАТУСЫ
   ======================================== */
.badge {
  padding: 0.5em 1em;
  border-radius: 20px;
  font-weight: 600;
  font-size: 0.8125rem;
  letter-spacing: 0.025em;
  box-shadow: 0 2px 6px rgba(0,0,0,0.08);
}
.bg-success { background: #d1fae5 !important; color: #065f46 !important; }
.bg-warning { background: #fef3c7 !important; color: #92400e !important; }
.bg-info    { background: #dbeafe !important; color: #1e40af !important; }
.bg-secondary { background: #f1f5f9 !important; color: #475569 !important; }
.bg-danger  { background: #fee2e2 !important; color: #991b1b !important; }

/* ========================================
   📊 ТАБЛИЦЫ
   ======================================== */
.table {
  border-radius: var(--radius);
  overflow: hidden;
  box-shadow: var(--shadow);
}
.table thead {
  background: var(--bg-input);
  border-bottom: 2px solid var(--border-color);
}
.table thead th {
  font-weight: 600;
  color: var(--text-muted);
  text-transform: uppercase;
  font-size: 0.75rem;
  letter-spacing: 0.05em;
  padding: 1rem;
  border: none;
}
.table tbody tr { transition: background 0.2s ease; }
.table tbody tr:hover { background: var(--primary-light); }
.table tbody td { padding: 1rem; vertical-align: middle; border-color: var(--border-color); }

/* ========================================
   ✨ АНИМАЦИИ
   ======================================== */
@keyframes fadeIn {
  from { opacity: 0; transform: translateY(10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes fadeInUp {
  from { opacity: 0; transform: translateY(15px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes slideIn {
  from { opacity: 0; transform: translateY(-10px); }
  to { opacity: 1; transform: translateY(0); }
}
@keyframes loading {
  0% { background-position: 200% 0; }
  100% { background-position: -200% 0; }
}

.alert { animation: fadeIn 0.3s ease-out; }
.card { animation: fadeInUp 0.4s ease backwards; }

/* ========================================
   🛠 УТИЛИТЫ
   ======================================== */
.text-primary { color: var(--primary) !important; }
.bg-primary { background: var(--primary) !important; }
.bg-primary-light { background: var(--primary-light) !important; }
.rounded-4 { border-radius: var(--radius) !important; }
.shadow-soft { box-shadow: var(--shadow) !important; }

/* ========================================
   📋 КАНБАН-ДОСКА
   ======================================== */
.kanban-board { overflow-x: auto; padding-bottom: 20px; }
.kanban-row { display: flex; gap: 20px; min-width: max-content; }
.kanban-column {
  width: 350px; background: #f0f2f5; border-radius: 12px;
  display: flex; flex-direction: column; max-height: calc(100vh - 250px);
}
.kanban-column-header { padding: 16px; border-radius: 12px 12px 0 0; font-size: 14px; }
.kanban-column-header.bg-new { background: linear-gradient(135deg, #00b4db 0%, #0083b0 100%); color: white; }
.kanban-column-header.bg-progress { background: linear-gradient(135deg, #f093fb 0%, #f5576c 100%); color: white; }
.kanban-column-header.bg-signing { background: linear-gradient(135deg, #a8edea 0%, #fed6e3 100%); color: #333; }
.kanban-column-header.bg-done { background: linear-gradient(135deg, #11998e 0%, #38ef7d 100%); color: white; }
.kanban-column-header.bg-fail { background: linear-gradient(135deg, #eb3349 0%, #f45c43 100%); color: white; }
.kanban-column-body { padding: 12px; overflow-y: auto; flex: 1; display: flex; flex-direction: column; gap: 12px; }
.kanban-card {
  background: white; border-radius: 8px; padding: 14px;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12); cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1); border: 2px solid transparent;
}
.kanban-card:hover {
  transform: translateY(-4px) scale(1.02);
  box-shadow: 0 8px 25px rgba(0,0,0,0.15); border-color: #6366f1;
}
.kanban-card-header { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 10px; }
.kanban-card-number { font-weight: 600; color: #6366f1; font-size: 13px; }
.kanban-card-date { font-size: 12px; color: #94a3b8; }
.kanban-card-body { margin-bottom: 12px; }
.kanban-card-title { font-size: 14px; line-height: 1.5; color: #0f172a; margin: 0; }
.kanban-card-question { margin-bottom: 8px; padding: 8px; background: #f0f9ff; border-left: 3px solid #0066cc; border-radius: 4px; }
.kanban-card-question small { color: #0f172a; line-height: 1.4; }
.kanban-card-resolution { margin-bottom: 8px; padding: 8px; background: #f0fdf4; border-left: 3px solid #10b981; border-radius: 4px; }
.kanban-card-resolution small { color: #0f172a; line-height: 1.4; }
.kanban-card-comment { margin-bottom: 8px; padding: 8px; background: #f8fafc; border-left: 3px solid #94a3b8; border-radius: 4px; }
.comment-header { display: flex; justify-content: space-between; align-items: center; margin-bottom: 4px; }
.comment-icon { display: flex; align-items: center; }
.comment-icon i { font-size: 14px; }
.kanban-card-comment small { line-height: 1.4; display: block; }
.kanban-comment-meta { margin-top: 4px; font-size: 11px; }
.kanban-empty { text-align: center; padding: 40px 20px; color: #94a3b8; }
.kanban-empty i { font-size: 48px; margin-bottom: 12px; opacity: 0.5; }
.kanban-empty p { margin: 0; font-size: 14px; }
.kanban-column-body::-webkit-scrollbar { width: 6px; }
.kanban-column-body::-webkit-scrollbar-track { background: rgba(0,0,0,0.05); border-radius: 3px; }
.kanban-column-body::-webkit-scrollbar-thumb { background: rgba(0,0,0,0.2); border-radius: 3px; }
.kanban-column-body::-webkit-scrollbar-thumb:hover { background: rgba(0,0,0,0.3); }
.kanban-card-reject { margin-bottom: 8px; padding: 8px; background: #fef2f2; border-left: 3px solid #ef4444; border-radius: 4px; }
.kanban-card-reject small { line-height: 1.4; display: block; }

/* ========================================
   📄 ДЕТАЛИ СОБЫТИЯ
   ======================================== */
.text-muted.small {
  font-size: 0.75rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  font-weight: 600;
  color: var(--text-muted) !important;
}
.text-muted.small i { font-size: 1rem; margin-right: 4px; }
.bg-light {
  background: linear-gradient(135deg, #f8fafc 0%, #f1f5f9 100%) !important;
  border-left: 4px solid var(--primary);
  transition: transform 0.2s ease;
}
.bg-success.bg-opacity-10 {
  background: linear-gradient(135deg, #dcfce7 0%, #bbf7d0 100%) !important;
  border-left: 4px solid var(--success);
}
.hours-badge {
  display: inline-flex; align-items: center; gap: 8px;
  background: linear-gradient(135deg, var(--primary) 0%, #8b5cf6 100%);
  color: white; padding: 10px 20px; border-radius: var(--radius-sm);
  font-weight: 600; box-shadow: 0 4px 15px rgba(102, 126, 234, 0.35);
  transition: transform 0.2s ease;
}
.hours-badge:hover { transform: scale(1.03); }
.border-bottom {
  border-color: var(--border-color) !important;
  transition: background-color 0.2s ease;
}
.border-bottom:hover { background-color: #f8fafc; }
.avatar-initials {
  width: 40px; height: 40px; background: var(--primary-light);
  color: var(--primary); border-radius: 50%;
  display: flex; align-items: center; justify-content: center;
  font-weight: 700; font-size: 14px; flex-shrink: 0;
}
.card-date-badge, .comment-date {
  display: inline-block; background: var(--bg-input);
  color: var(--text-muted); font-size: 0.75rem; font-weight: 600;
  padding: 4px 10px; border-radius: 20px;
}
textarea.form-control { resize: vertical; min-height: 80px; }
.bg-primary.bg-opacity-10 {
  background: linear-gradient(135deg, rgba(99,102,241,0.08) 0%, rgba(139,92,246,0.08) 100%) !important;
  border: 1px solid rgba(99,102,241,0.15);
}
hr { border-color: var(--border-color); opacity: 0.6; }

/* 🔹 Hover-эффект для карточек */
.card-hover { transition: all 0.3s ease; cursor: default; }
.card-hover:hover {
  transform: translateY(-4px);
  box-shadow: 0 12px 40px rgba(0, 0, 0, 0.15) !important;
  border-color: rgba(0, 123, 255, 0.3) !important;
}
.card-hover .card-header { transition: background-color 0.3s ease; }
.card-hover:hover .card-header { background-color: rgba(0, 123, 255, 0.05) !important; }
.card-hover .btn { transition: transform 0.2s ease; }
.card-hover:hover .btn:not(:disabled) { transform: scale(1.02); }
.form-control-hover:focus {
  box-shadow: 0 0 0 0.2rem rgba(0, 123, 255, 0.15);
  border-color: #0066cc; transition: all 0.2s ease;
}
.badge-hover { transition: transform 0.2s ease; }
.card-hover:hover .badge-hover { transform: scale(1.05); }
@media (hover: none) {
  .card-hover:hover { transform: none; box-shadow: var(--shadow) !important; }
}

/* 🔹 Подсказки и Drag&Drop */
.alert-info {
  background: linear-gradient(135deg, rgba(13, 202, 240, 0.1) 0%, rgba(59, 130, 246, 0.1) 100%) !important;
  border: 1px solid rgba(13, 202, 240, 0.3) !important;
  color: #084298 !important;
}
kbd {
  background: #f8f9fa; border: 1px solid #dee2e6; border-radius: 4px;
  padding: 2px 6px; font-size: 0.75rem; font-weight: 600;
  color: #495057; box-shadow: 0 2px 0 rgba(0,0,0,0.05);
}
form.border-primary {
  border: 2px dashed var(--primary) !important;
  transition: all 0.3s ease;
}

/* 🔹 Вложения в комментариях */
.file-attach-btn {
  display: inline-flex; align-items: center; gap: 6px;
  background: #f8f9fa; border: 1px solid #e2e8f0; border-radius: 20px;
  padding: 6px 12px; font-size: 0.85rem; color: #495057;
  text-decoration: none; transition: all 0.2s ease; margin: 4px 2px; font-weight: 500;
}
.file-attach-btn:hover {
  background: #e9ecef; color: #0d6efd; border-color: #0d6efd;
  transform: translateY(-1px); box-shadow: 0 2px 8px rgba(0,0,0,0.05);
}
.comment-link {
  color: #0d6efd; text-decoration: none; border-bottom: 1px dashed #0d6efd;
}
.comment-link:hover { text-decoration: none; border-bottom-style: solid; }

/* ========================================
   📱 АДАПТИВНОСТЬ
   ======================================== */
@media (max-width: 768px) {
  :root { --radius: 12px; }
  .container { padding-left: 1rem; padding-right: 1rem; }
  .card-body { padding: 1.25rem; }
  .kanban-column { width: 300px; }
  .kanban-card { padding: 12px; }
  .table-responsive { border-radius: var(--radius); box-shadow: var(--shadow); }
}

/* ========================================
🔥 ПРИОРИТЕТЫ И ДЕДЛАЙНЫ
======================================== */

/* 🔹 НОВОЕ: Контейнер для выравнивания приоритета и дедлайна в одну строку */
.priority-deadline-container {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 8px;
    margin-bottom: 8px;
    flex-wrap: wrap;
}

/* 🔹 ИСПРАВЛЕНИЕ: Подсветка высокоприоритетных событий ТОЛЬКО в колонках "Новое" и "В работе" */
.kanban-column[data-status="new"] .kanban-card.priority-high,
.kanban-column[data-status="in_progress"] .kanban-card.priority-high {
    border-left: 5px solid #ef4444 !important;
    border-top: 3px solid #ef4444 !important;
    background: linear-gradient(135deg, #fef2f2 0%, #ffffff 100%) !important;
    animation: pulseBorder 2s ease-in-out infinite;
}

.kanban-column[data-status="new"] .kanban-card.priority-highest,
.kanban-column[data-status="in_progress"] .kanban-card.priority-highest {
    border-left: 5px solid #dc2626 !important;
    border-top: 3px solid #dc2626 !important;
    background: linear-gradient(135deg, #fee2e2 0%, #ffffff 100%) !important;
    animation: pulseBorder 1.5s ease-in-out infinite;
}

@keyframes pulseBorder {
    0%, 100% { box-shadow: 0 2px 8px rgba(239, 68, 68, 0.3); }
    50% { box-shadow: 0 4px 16px rgba(239, 68, 68, 0.6); }
}

/* Бейдж приоритета */
.priority-badge {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 11px;
    font-weight: 700;
    text-transform: uppercase;
    letter-spacing: 0.3px;
}

.priority-badge-naivyschiy { background: linear-gradient(135deg, #dc2626 0%, #b91c1c 100%); color: white; box-shadow: 0 2px 6px rgba(220, 38, 38, 0.4); }
.priority-badge-vysokiy { background: linear-gradient(135deg, #ef4444 0%, #dc2626 100%); color: white; box-shadow: 0 2px 6px rgba(239, 68, 68, 0.4); }
.priority-badge-sredniy { background: linear-gradient(135deg, #f59e0b 0%, #d97706 100%); color: white; box-shadow: 0 2px 6px rgba(245, 158, 11, 0.4); }
.priority-badge-nizkiy { background: linear-gradient(135deg, #10b981 0%, #059669 100%); color: white; box-shadow: 0 2px 6px rgba(16, 185, 129, 0.4); }
.priority-badge-obsluzh { background: linear-gradient(135deg, #6366f1 0%, #4f46e5 100%); color: white; box-shadow: 0 2px 6px rgba(99, 102, 241, 0.4); }
.priority-badge-konsult { background: linear-gradient(135deg, #8b5cf6 0%, #7c3aed 100%); color: white; box-shadow: 0 2px 6px rgba(139, 92, 246, 0.4); }

/* Индикатор дедлайна */
.deadline-indicator {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    padding: 3px 8px;
    border-radius: 6px;
    font-size: 11px;
    font-weight: 600;
    white-space: nowrap; /* Запрещаем перенос текста */
}

.deadline-ok { background: #d1fae5; color: #065f46; }
.deadline-warning { background: #fef3c7; color: #92400e; animation: blinkWarning 2s ease-in-out infinite; }
.deadline-expired { background: #fee2e2; color: #991b1b; font-weight: 700; animation: blinkExpired 1s ease-in-out infinite; }
.deadline-negotiable { background: #dbeafe; color: #1e40af; }

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

@keyframes blinkExpired {
    0%, 100% { opacity: 1; transform: scale(1); }
    50% { opacity: 0.8; transform: scale(1.05); }
}

.priority-icon { font-size: 14px; }
.priority-filter-dropdown { min-width: 320px; max-height: 400px; overflow-y: auto; }
.priority-filter-item { display: flex; align-items: center; gap: 8px; padding: 8px 12px; border-radius: 8px; transition: all 0.2s; }
.priority-filter-item:hover { background: #f8fafc; }