@charset 'UTF-8';
:root {
  --primary: #4F46E5;
  --primary-hover: #4338CA;
  --bg: #F3F4F6;
  --panel-bg: #FFFFFF;
  --text: #1F2937;
  --border: #E5E7EB;
}

* {
  box-sizing: border-box;
  font-family: 'Inter', sans-serif;
}

body, html {
  margin: 0;
  padding: 0;
  height: 100%;
  background-color: var(--bg);
  color: var(--text);
}

.app-container {
  display: flex;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.admin-panel {
  width: 400px;
  min-width: 400px;
  background: var(--panel-bg);
  padding: 16px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0,0,0,0.05);
  z-index: 10;
}

.admin-panel::-webkit-scrollbar {
  width: 6px;
}
.admin-panel::-webkit-scrollbar-thumb {
  background: #cbd5e1;
  border-radius: 4px;
}

.admin-panel h1 {
  font-size: 20px;
  margin-top: 0;
  margin-bottom: 16px;
}

.control-group {
  background: #FAFAFA;
  border: 1px solid var(--border);
  border-radius: 10px;
  padding: 12px;
  margin-bottom: 10px;
}

.control-group h3 {
  margin: 0 0 8px 0;
  font-size: 13px;
  color: var(--primary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.control-group label {
  display: block;
  font-size: 13px;
  margin-bottom: 8px;
  font-weight: 600;
  color: #4B5563;
}

.control-group input[type="text"],
.control-group input[type="file"] {
  width: 100%;
  padding: 8px;
  border: 1px solid var(--border);
  border-radius: 6px;
  margin-bottom: 8px;
  font-size: 13px;
  transition: border-color 0.2s;
}

.control-group input[type="text"]:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.1);
}

/* --- Модальное окно кадрирования --- */
.crop-modal {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.crop-modal-content {
  background: white;
  padding: 30px;
  border-radius: 12px;
  width: 90%;
  max-width: 720px;
  display: flex;
  flex-direction: column;
}

.crop-img-container {
  width: 100%;
  height: 400px;
  background: #0f172a;
  border-radius: 8px;
  overflow: hidden;
  margin-bottom: 20px;
}

.crop-img-container img {
  display: block;
  max-width: 100%;
}

.crop-actions {
  display: flex;
  justify-content: flex-end;
  gap: 15px;
}

.image-preview {
  margin-top: 10px;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 10px;
}

.image-preview img {
  max-width: 100%;
  max-height: 100px;
  border-radius: 8px;
  border: 1px solid var(--border);
}

.small-btn {
  background: #FEE2E2;
  color: #DC2626;
  border: none;
  padding: 6px 12px;
  border-radius: 6px;
  cursor: pointer;
  font-size: 12px;
  font-weight: 600;
}

.settings-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  margin-bottom: 6px;
  font-size: 13px;
}

.settings-row input[type="range"] {
  width: 60%;
}

.settings-row input[type="color"] {
  width: 32px;
  height: 32px;
  border: 1px solid var(--border);
  border-radius: 4px;
  cursor: pointer;
  padding: 0;
}

.settings-row label {
  margin-bottom: 0;
  display: flex;
  align-items: center;
  gap: 6px;
  font-weight: 400;
  white-space: nowrap;
}

.primary-btn, .secondary-btn {
  width: 100%;
  padding: 10px;
  border: none;
  border-radius: 8px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.2s;
  margin-bottom: 8px;
}

.primary-btn {
  background: var(--primary);
  color: white;
}

.primary-btn:hover {
  background: var(--primary-hover);
}

/* Floating Add Button */
.floating-add-btn {
  position: absolute;
  left: 400px; /* Right on the border of admin-panel */
  top: 50%;
  transform: translate(-50%, -50%);
  width: 52px;
  height: 52px;
  background-color: var(--primary);
  color: white;
  border: none;
  border-radius: 50%;
  box-shadow: 0 4px 15px rgba(79, 70, 229, 0.4);
  cursor: pointer;
  z-index: 100;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s cubic-bezier(0.175, 0.885, 0.32, 1.275);
}

.floating-add-btn:hover {
  transform: translate(-50%, -50%) scale(1.1);
  background-color: var(--primary-hover);
}

.floating-add-btn:active {
  transform: translate(-50%, -50%) scale(0.95);
}

.floating-add-btn svg {
  width: 28px;
  height: 28px;
}

.secondary-btn {
  background: white;
  border: 2px solid var(--primary);
  color: var(--primary);
}

.secondary-btn:hover {
  background: #EEF2FF;
}

.preview-panel {
  flex: 1;
  overflow-y: auto;
  padding: 40px;
  display: flex;
  flex-direction: column;
  gap: 40px;
}

#pagesContainer {
  display: flex;
  flex-direction: column;
  gap: 40px;
  margin: 0 auto;
  width: 100%;
}

.page {
  width: 100%;
  max-width: 1000px;
  background: #E2E8F0;
  box-shadow: 0 10px 25px rgba(0,0,0,0.1);
  padding: 24px 20px;
  display: grid;
  grid-template-columns: repeat(2, minmax(0, 1fr));
  grid-template-rows: repeat(5, minmax(0, 1fr));
  gap: 20px;
  position: relative;
  overflow: hidden;
  box-sizing: border-box;
  margin: 0 auto;
}

.card {
  aspect-ratio: 16 / 9;
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0;
  text-align: center;
  position: relative;
  overflow: hidden;
  background: white;
  border-radius: 0;
  box-shadow: 0 4px 10px rgba(0,0,0,0.15);
  border: 2px solid transparent;
  box-sizing: border-box;
}

/* Фоновое фото 16:9 на весь экран */
.card-img-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  padding: 0;
  z-index: 1;
  overflow: hidden;
}

.card-img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

/* Прозрачный оверлей для идеальной поддержки PNG с прозрачностью */
.card-img-container::after {
  content: "";
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: transparent;
  pointer-events: none;
}

/* Кино-плашка (полоса 1/4 экрана) */
.card-stripe {
  position: absolute;
  left: 0;
  width: 100%;
  height: 25%;
  z-index: 2;
  pointer-events: none;
  box-sizing: border-box;
  box-shadow: 0 4px 16px rgba(0, 0, 0, 0.35);
}

/* Текстовые титры поверх кадра */
.card-text-container {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  z-index: 3;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 10px;
  padding: 20px;
  box-sizing: border-box;
  text-align: center;
  pointer-events: none;
}

.card-text-container > div {
  text-shadow: 0 2px 4px rgba(0, 0, 0, 0.95), 0 0 12px rgba(0, 0, 0, 0.7);
  word-break: break-word;
  max-width: 92%;
}

/* --- РЕЖИМ ЦВЕТНЫХ РАМОК --- */
.page.colored-borders .card {
  border: 4px solid var(--card-border-color, #E2E8F0) !important;
}

  /* 9 гармоничных цветов для рамок */
  .border-color-1 { --card-border-color: #FB7185; } /* Розовый */
  .border-color-2 { --card-border-color: #38BDF8; } /* Голубой */
  .border-color-3 { --card-border-color: #4ADE80; } /* Салатовый */
  .border-color-4 { --card-border-color: #FBBF24; } /* Солнечный */
  .border-color-5 { --card-border-color: #A78BFA; } /* Лавандовый */
  .border-color-6 { --card-border-color: #FB923C; } /* Оранжевый */
  .border-color-7 { --card-border-color: #2DD4BF; } /* Бирюзовый */
  .border-color-8 { --card-border-color: #F43F5E; } /* Малиновый */
  .border-color-9 { --card-border-color: #818CF8; } /* Индиго */

  .card.editing {
    border: 2.5px solid #4F46E5 !important;
    box-shadow: 0 0 0 3px rgba(79, 70, 229, 0.35), 0 6px 16px rgba(79, 70, 229, 0.2) !important;
    transition: all 0.2s ease;
  }
  
  .card.editing .card-number-badge {
    background: #4F46E5 !important;
    color: #ffffff !important;
    box-shadow: 0 0 8px rgba(79, 70, 229, 0.7);
  }

.delete-card-btn, .edit-card-btn {
  position: absolute;
  top: 6px;
  color: white;
  border: none;
  border-radius: 50%;
  width: 24px;
  height: 24px;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 14px;
  opacity: 0;
  transition: opacity 0.2s, transform 0.1s;
  z-index: 5;
}

.delete-card-btn {
  right: 6px;
  background: #EF4444;
}

.edit-card-btn {
  right: 36px;
  background: #3B82F6;
  font-size: 12px;
}

.card:hover .delete-card-btn,
.card:hover .edit-card-btn {
  opacity: 1;
}

.delete-card-btn:active,
.edit-card-btn:active {
  transform: scale(0.9);
}

/* Для пустых слотов */
.card.empty {
  background: #F9FAFB;
}

/* Для печати */
@media print {
  @page {
    size: A4 portrait;
    margin: 0;
  }
  
  body {
    -webkit-print-color-adjust: exact;
    print-color-adjust: exact;
    background: white;
  }
  
  .app-container {
    height: auto;
    overflow: visible;
    display: block;
  }
  
  .admin-panel,
  .site-header,
  #notepadDrawer,
  .floating-add-btn {
    display: none !important;
  }
  
  .preview-panel {
    padding: 0;
    overflow: visible;
    display: block;
  }
  
  .page {
    box-shadow: none;
    margin: 0;
    page-break-after: always; /* Каждый лист на новой странице */
    border: none;
  }
  
  .delete-card-btn {
    display: none !important;
  }
  
  #livePreviewCard {
    visibility: hidden;
  }
  
  .notepad-drawer {
    display: none !important;
  }
}

/* Notepad Drawer */
.notepad-drawer {
  position: fixed;
  top: 0;
  left: -400px;
  width: 400px;
  height: 100vh;
  background: #1E1E2D;
  color: #fff;
  box-shadow: 5px 0 25px rgba(0,0,0,0.2);
  transition: left 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  z-index: 100;
  display: flex;
  flex-direction: column;
}

.notepad-drawer.open {
  left: 0;
}

.notepad-toggle {
  position: absolute;
  left: 400px;
  top: 90px;
  width: 38px;
  height: 110px;
  background-color: #ef4444;
  border: none;
  border-radius: 0 10px 10px 0;
  cursor: pointer;
  box-shadow: 4px 0 15px rgba(239, 68, 68, 0.35);
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  display: flex;
  justify-content: center;
  align-items: center;
  z-index: 95;
}

.notepad-toggle:hover {
  background-color: #dc2626;
  transform: translateX(2px);
}

.notepad-toggle.active {
  background-color: #b91c1c;
  box-shadow: 4px 0 18px rgba(185, 28, 28, 0.45);
}

.notepad-toggle span {
  writing-mode: vertical-rl;
  transform: rotate(180deg);
  font-weight: 800;
  color: #ffffff;
  letter-spacing: 2px;
  font-size: 13px;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.notes-close-btn {
  background: transparent;
  border: none;
  font-size: 20px;
  color: #94a3b8;
  cursor: pointer;
  line-height: 1;
  padding: 4px 8px;
  border-radius: 4px;
  transition: 0.15s;
}

.notes-close-btn:hover {
  background: rgba(255, 255, 255, 0.1);
  color: #ffffff;
}

.notepad-header {
  padding: 20px;
  background: #171722;
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid #2B2B40;
}

.notepad-header h3 {
  margin: 0;
  font-size: 16px;
  font-weight: 600;
}

.save-indicator {
  font-size: 12px;
  color: #A1A5B7;
  display: flex;
  align-items: center;
  gap: 6px;
}

.save-indicator span {
  display: inline-block;
  width: 8px;
  height: 8px;
  background: #10B981;
  border-radius: 50%;
}

.notepad-tools {
  padding: 20px;
  border-bottom: 1px solid #2B2B40;
}

.tools-label {
  font-size: 13px;
  color: #A1A5B7;
  margin-bottom: 12px;
}

.tools-buttons {
  display: flex;
  gap: 8px;
}

.tool-btn {
  flex: 1;
  background: #2B2B40;
  border: 1px solid #3F4254;
  color: white;
  padding: 10px;
  border-radius: 6px;
  cursor: pointer;
  font-weight: 600;
  font-size: 13px;
  transition: all 0.2s;
}

.tool-btn:hover {
  background: #3F4254;
  border-color: #565674;
}

.tool-btn:active {
  transform: translateY(1px);
}

#notepadTextarea {
  flex: 1;
  background: #1E1E2D;
  border: none;
  color: #E4E6EF;
  padding: 20px;
  font-size: 14px;
  line-height: 1.6;
  resize: none;
}

#notepadTextarea:focus {
  outline: none;
}

#notepadTextarea::placeholder {
  color: #565674;
  font-style: italic;
}

.top-nav-bar {
  display: flex;
  align-items: center;
  justify-content: space-between;
  background: white;
  padding: 10px 20px;
  border-bottom: 1px solid #E5E7EB;
  z-index: 10;
  position: relative;
}

.mode-switcher {
  display: flex;
  gap: 10px;
  flex: 1;
}

.project-actions {
  display: flex;
  gap: 8px;
  flex: 1;
  justify-content: flex-end;
  align-items: center;
}

.project-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  padding: 8px 14px;
  font-size: 13px;
  font-weight: 600;
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
  outline: none;
}

.project-btn.save {
  background: #F0FDF4;
  color: #15803D;
  border-color: #BBF7D0;
}

.project-btn.save:hover {
  background: #DCFCE7;
  border-color: #86EFAC;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(22, 163, 74, 0.15);
}

.project-btn.load {
  background: #F8FAFC;
  color: #334155;
  border-color: #CBD5E1;
}

.project-btn.load:hover {
  background: #F1F5F9;
  border-color: #94A3B8;
  transform: translateY(-1px);
  box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05);
}

.project-btn:active {
  transform: translateY(0);
}

.mode-btn {
  background: none;
  border: none;
  padding: 10px 20px;
  font-weight: 600;
  color: #6B7280;
  cursor: pointer;
  border-radius: 6px;
  transition: all 0.2s;
}

.mode-btn:hover {
  background: #F3F4F6;
}

.mode-btn.active {
  background: var(--primary);
  color: white;
}

/* Video Container */
.video-container {
  display: flex;
  height: calc(100vh - 58px);
  overflow: hidden;
}

.video-admin-panel {
  width: 400px;
  background: var(--panel-bg);
  padding: 20px;
  border-right: 1px solid var(--border);
  overflow-y: auto;
  box-shadow: 2px 0 10px rgba(0,0,0,0.05);
  display: flex;
  flex-direction: column;
}

.video-subtitle {
  font-size: 13px;
  color: #6B7280;
  margin-top: 0;
  margin-bottom: 20px;
}

.video-cards-list {
  display: flex;
  flex-direction: column;
  gap: 15px;
}

.video-card-item {
  border: 1px solid #E5E7EB;
  padding: 15px;
  border-radius: 8px;
  background: #F9FAFB;
  display: flex;
  flex-direction: column;
  gap: 10px;
}

.video-card-item h4 {
  margin: 0;
  font-size: 14px;
}

.video-preview-panel {
  flex: 1;
  background: #111827;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  padding: 20px;
  gap: 20px;
}

.canvas-wrapper {
  height: 70vh;
  aspect-ratio: 16/9;
  background: #0f172a;
  border-radius: 0;
  overflow: hidden;
  box-shadow: 0 10px 30px rgba(0,0,0,0.5);
}

#videoCanvas {
  width: 100%;
  height: 100%;
  object-fit: contain;
}

.video-controls {
  display: flex;
  gap: 15px;
  width: 100%;
  max-width: 400px;
}

/* --- Плеер управления видео --- */
.video-player-controls {
  display: flex;
  align-items: center;
  gap: 12px;
  width: 100%;
  max-width: 320px;
  background: #1F2937;
  padding: 8px 14px;
  border-radius: 12px;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.action-icon-btn {
  background: var(--primary);
  border: none;
  color: white;
  font-size: 16px;
  width: 36px;
  height: 36px;
  border-radius: 50%;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: all 0.2s;
}

.action-icon-btn:hover {
  transform: scale(1.05);
}

#videoSeekbar {
  flex: 1;
  cursor: pointer;
  accent-color: var(--primary);
}

#videoTimeDisplay {
  font-size: 13px;
  font-weight: 600;
  color: #F3F4F6;
  min-width: 85px;
  text-align: right;
}

/* --- Оверлей Экспорта --- */
.export-overlay {
  position: fixed;
  top: 0; left: 0; width: 100%; height: 100%;
  background: rgba(0,0,0,0.85);
  z-index: 9999;
  display: flex;
  align-items: center;
  justify-content: center;
}

.export-box {
  background: white;
  padding: 40px;
  border-radius: 12px;
  text-align: center;
  max-width: 400px;
}

.export-box h2 {
  margin: 20px 0 10px 0;
  color: var(--text);
}

.export-box p {
  color: #6B7280;
  font-size: 14px;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 5px solid #E5E7EB;
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* --- Шапка сайта (логотип теперь внутри top-nav-bar) --- */
.site-header {
  display: none; /* Удалено */
}

.site-logo {
  display: flex;
  align-items: center;
  gap: 12px;
}

.site-logo img {
  width: 36px;
  height: 36px;
  border-radius: 8px; /* Небольшое скругление для квадрата */
}

.site-title {
  font-size: 28px;
  font-weight: 800;
  color: #1F2937;
  letter-spacing: -0.5px;
}

.badge-cinema {
  color: #B45309;
  font-weight: 800;
  font-size: 20px;
  margin-left: 8px;
  background: linear-gradient(135deg, #FEF3C7 0%, #FDE68A 100%);
  padding: 2px 12px;
  border-radius: 8px;
  letter-spacing: 0.5px;
  border: 2px solid #F59E0B;
  box-shadow: 0 2px 6px rgba(245, 158, 11, 0.25);
}

/* --- Заглушка для мобильных устройств --- */
.mobile-stub {
  display: none;
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: #111827;
  color: #ffffff;
  z-index: 999999;
  align-items: center;
  justify-content: center;
  text-align: center;
  padding: 20px;
  box-sizing: border-box;
}

.mobile-stub-content {
  max-width: 400px;
}

.mobile-stub h2 {
  font-size: 24px;
  margin-bottom: 15px;
  color: #F9FAFB;
}

.mobile-stub p {
  font-size: 15px;
  color: #9CA3AF;
  line-height: 1.6;
}

@media (max-width: 1024px) {
  .top-nav-bar,
  .app-container,
  #exportOverlay,
  .floating-add-btn {
    display: none !important;
  }
  
  .mobile-stub {
    display: flex;
  }
}

/* --- Update Banner --- */
.update-banner {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%);
  background-color: #10B981;
  color: white;
  padding: 12px 24px;
  border-radius: 50px;
  box-shadow: 0 10px 25px rgba(16, 185, 129, 0.4);
  display: flex;
  align-items: center;
  gap: 15px;
  z-index: 1000000;
  font-weight: 600;
  font-size: 14px;
  animation: slideUp 0.5s ease-out forwards;
}

.update-banner button {
  background: white;
  color: #10B981;
  border: none;
  padding: 6px 16px;
  border-radius: 20px;
  font-weight: bold;
  cursor: pointer;
  transition: transform 0.1s;
}

.update-banner button:active {
  transform: scale(0.95);
}

@keyframes slideUp {
  from { bottom: -100px; opacity: 0; }
  to { bottom: 20px; opacity: 1; }
}

/* --- ��������� ������ --- */
.card-overlay {
  position: absolute;
  left: 0;
  width: 100%;
  z-index: 1; /* ��� �������, �� ��� ����� */
  transition: all 0.3s ease;
}

.card-number-badge {
  position: absolute;
  top: 6px;
  left: 6px;
  background: rgba(15, 23, 42, 0.7);
  color: #ffffff;
  font-size: 11px;
  font-weight: 800;
  padding: 2px 7px;
  border-radius: 4px;
  z-index: 5;
  pointer-events: none;
  letter-spacing: 0.5px;
}
