/**
 * Media Gallery Styles
 * Современный responsive дизайн 2025
 */

/* ===== CSS VARIABLES ===== */
/* Google Fonts: Montserrat + Open Sans */
@import url('https://fonts.googleapis.com/css2?family=Montserrat:wght@400;500;600;700&family=Open+Sans:wght@400;500;600&display=swap');

:root {
  /* Brand Colors */
  --brand-gray: #393947;
  --brand-orange: #E45116;

  /* Primary colors based on brand */
  --primary: #E45116;
  --primary-dark: #c94410;
  --success: #28a745;
  --error: #dc3545;
  --warning: #ffc107;
  --info: #17a2b8;

  /* Light theme (default) */
  --bg-primary: #ffffff;
  --bg-secondary: #f5f5f7;
  --bg-tertiary: #e8e8ed;
  --text-primary: #393947;
  --text-secondary: #5a5a6e;
  --text-muted: #8888a0;
  --border-color: #d8d8e0;
  --card-bg: #ffffff;
  --overlay-bg: rgba(57, 57, 71, 0.95);

  /* Grayscale */
  --gray-50: #f5f5f7;
  --gray-100: #e8e8ed;
  --gray-200: #d8d8e0;
  --gray-300: #c0c0cc;
  --gray-400: #9999aa;
  --gray-500: #6c6c80;
  --gray-600: #5a5a6e;
  --gray-700: #4a4a5a;
  --gray-800: #393947;

  /* Layout */
  --max-width: 1200px;
  --spacing: 1rem;
  --border-radius: 8px;

  /* Typography - Montserrat (main) + Open Sans (secondary) */
  --font-family: 'Montserrat', system-ui, -apple-system, sans-serif;
  --font-family-secondary: 'Open Sans', system-ui, sans-serif;
  --font-size-base: 16px;
  --line-height: 1.5;

  /* Shadows */
  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.1);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.1);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.15);
}

/* Utilities */
.hidden {
  display: none !important;
}

/* Dark theme - based on brand gray #393947 */
[data-theme="dark"] {
  --bg-primary: #1c1c24;
  --bg-secondary: #252530;
  --bg-tertiary: #32323e;
  --text-primary: #f0f0f5;
  --text-secondary: #c0c0cc;
  --text-muted: #9090a0;
  --border-color: #404050;
  --card-bg: #2a2a36;
  --overlay-bg: rgba(28, 28, 36, 0.98);

  --gray-50: #1c1c24;
  --gray-100: #252530;
  --gray-200: #32323e;
  --gray-300: #404050;
  --gray-400: #606070;
  --gray-500: #9090a0;
  --gray-600: #c0c0cc;
  --gray-700: #d8d8e0;
  --gray-800: #f0f0f5;

  --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
  --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
  --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
}

/* Auto dark theme based on system preference */
@media (prefers-color-scheme: dark) {
  :root:not([data-theme="light"]) {
    --bg-primary: #1c1c24;
    --bg-secondary: #252530;
    --bg-tertiary: #32323e;
    --text-primary: #f0f0f5;
    --text-secondary: #c0c0cc;
    --text-muted: #9090a0;
    --border-color: #404050;
    --card-bg: #2a2a36;
    --overlay-bg: rgba(28, 28, 36, 0.98);

    --gray-50: #1c1c24;
    --gray-100: #252530;
    --gray-200: #32323e;
    --gray-300: #404050;
    --gray-400: #606070;
    --gray-500: #9090a0;
    --gray-600: #c0c0cc;
    --gray-700: #d8d8e0;
    --gray-800: #f0f0f5;

    --shadow-sm: 0 1px 3px rgba(0, 0, 0, 0.4);
    --shadow-md: 0 4px 6px rgba(0, 0, 0, 0.4);
    --shadow-lg: 0 10px 20px rgba(0, 0, 0, 0.5);
  }
}

/* ===== RESET & BASE ===== */
*,
*::before,
*::after {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

img,
video {
  max-width: 100%;
  height: auto;
  display: block;
}

html {
  font-size: var(--font-size-base);
  -webkit-text-size-adjust: 100%;
  /* Prevent font scaling in iOS */
  text-size-adjust: 100%;
}

body {
  font-family: var(--font-family);
  line-height: var(--line-height);
  color: var(--text-primary);
  background: var(--bg-secondary);
  min-height: 100vh;
  transition: background-color 0.3s, color 0.3s;
  -webkit-tap-highlight-color: transparent;
  /* Remove tap highlight on iOS */
}

/* ===== TYPOGRAPHY ===== */
h1,
h2,
h3,
h4,
h5,
h6 {
  margin-bottom: var(--spacing);
  font-weight: 600;
  line-height: 1.2;
}

h1 {
  font-size: 2.5rem;
}

h2 {
  font-size: 2rem;
}

h3 {
  font-size: 1.75rem;
}

h4 {
  font-size: 1.5rem;
}

h5 {
  font-size: 1.25rem;
}

h6 {
  font-size: 1rem;
}

p {
  margin-bottom: var(--spacing);
}

a {
  color: var(--primary);
  text-decoration: none;
}

a:hover {
  text-decoration: underline;
}

/* ===== LAYOUT ===== */
.container {
  width: 100%;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: var(--spacing);
}

.app {
  height: 100vh;
  display: flex;
  flex-direction: column;
  overflow: hidden;
}

.app-layout {
  display: flex;
  flex: 1;
  height: calc(100vh - 65px);
  /* Header height approx */
  overflow: hidden;
}

.sidebar {
  width: 300px;
  background: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  flex-shrink: 0;
  overflow-y: auto;
}

.main-content {
  flex: 1;
  overflow-y: auto;
  position: relative;
  background: var(--card-bg);
  display: flex;
  flex-direction: column;
}

/* ===== SIDEBAR TREE ===== */
.sidebar-header {
  padding: 1rem;
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  color: var(--text-muted);
  font-size: 0.85rem;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.sidebar-tree {
  list-style: none;
  padding: 0.5rem;
  margin: 0;
}

.tree-item {
  margin-bottom: 2px;
}

.tree-content {
  display: flex;
  align-items: center;
  padding: 8px 12px;
  cursor: pointer;
  border-radius: var(--border-radius);
  color: var(--text-primary);
  transition: background 0.2s;
  font-size: 0.95rem;
  user-select: none;
}

.tree-content:hover {
  background: var(--bg-tertiary);
}

.tree-content.active {
  background: var(--primary);
  color: white;
}

.tree-toggle {
  margin-right: 6px;
  width: 20px;
  height: 20px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  transition: transform 0.2s;
  border-radius: 4px;
}

.tree-toggle:hover {
  background: rgba(0, 0, 0, 0.05);
}

.tree-content.active .tree-toggle {
  color: rgba(255, 255, 255, 0.8);
}

.tree-toggle.expanded {
  transform: rotate(90deg);
}

.tree-icon {
  margin-right: 8px;
  font-size: 1.1em;
  display: flex;
  align-items: center;
}

.tree-label {
  flex: 1;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.tree-children {
  padding-left: 22px;
  display: none;
}

.tree-children.expanded {
  display: block;
}

/* Virtual items (Favorites) */
.tree-item-virtual .tree-content {
  color: var(--brand-orange);
  font-weight: 500;
}

.tree-item-virtual .tree-content.active {
  background: var(--brand-orange);
  color: white;
}

/* Sidebar Actions */
.sidebar-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.add-root-btn {
  background: transparent;
  border: none;
  color: var(--text-muted);
  font-size: 1.25rem;
  cursor: pointer;
  padding: 0 0.5rem;
  border-radius: 4px;
  line-height: 1;
  transition: all 0.2s;
}

.add-root-btn:hover {
  background: var(--bg-tertiary);
  color: var(--primary);
}

.tree-actions {
  margin-left: auto;
  display: flex;
  gap: 0.25rem;
  opacity: 0;
  transition: opacity 0.2s;
}

.tree-content:hover .tree-actions {
  opacity: 1;
}

/* Mobile: always show actions */
@media (max-width: 768px) {
  .tree-actions {
    opacity: 1;
  }
}

.tree-btn {
  background: transparent;
  border: 1px solid transparent;
  /* invisible border to keep size */
  color: var(--text-secondary);
  width: 24px;
  height: 24px;
  border-radius: 4px;
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1rem;
  line-height: 1;
  padding: 0;
  cursor: pointer;
}

.tree-btn:hover {
  background: var(--bg-primary);
  /* Use primary bg for contrast on hover */
  color: var(--primary);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.tree-delete-btn:hover {
  color: var(--error);
}

/* Company Header */
.company-header {
  background: var(--bg-secondary);
  border-bottom: 1px solid var(--border-color);
  padding: 1.5rem 2rem;
}

.company-title-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
  margin-bottom: 1rem;
}

.company-title-input {
  font-size: 1.75rem;
  font-weight: 600;
  background: transparent;
  border: 1px solid transparent;
  border-radius: 4px;
  color: var(--text-primary);
  width: 100%;
  padding: 0.25rem 0.5rem;
  margin-left: -0.5rem;
}

.company-title-input:focus {
  background: var(--bg-primary);
  border-color: var(--primary);
  outline: none;
}

.company-description {
  width: 100%;
  background: transparent;
  border: 1px solid transparent;
  padding: 0.5rem;
  border-radius: 4px;
  color: var(--text-secondary);
  font-family: inherit;
  resize: none;
}

.company-description:focus {
  background: var(--bg-primary);
  border-color: var(--border-color);
  outline: none;
}

.company-meta-row {
  display: flex;
  gap: 1rem;
  align-items: center;
  margin-top: 0.5rem;
}

.company-website-input {
  flex: 1;
  max-width: 400px;
  padding: 0.4rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: 4px;
  font-size: 0.9rem;
}

/* Gallery adjustments for flex layout */
.gallery {
  padding: 2rem;
  /* More padding */
}

/* ===== HEADER ===== */
.header {
  background: var(--bg-primary);
  border-bottom: 1px solid var(--border-color);
  padding: var(--spacing) 0;
  box-shadow: var(--shadow-sm);
  transition: background-color 0.3s, border-color 0.3s;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  max-width: var(--max-width);
  margin: 0 auto;
  padding: 0 var(--spacing);
}

.logo {
  display: flex;
  align-items: center;
  gap: 0.75rem;
}

.logo-img {
  height: 36px;
  width: auto;
  object-fit: contain;
}

.logo-title {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  letter-spacing: -0.02em;
}

.nav {
  display: flex;
  gap: 0.5rem;
  flex-wrap: nowrap;
}

.nav-btn {
  padding: 0.5rem 1rem;
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s;
  color: var(--text-primary);
  white-space: nowrap;
}

.nav-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--gray-400);
}

.nav-btn.active {
  background: var(--primary);
  color: white;
  border-color: var(--primary);
}

.auth-controls {
  display: flex;
  gap: 0.5rem;
  align-items: center;
}

/* Theme control */
.theme-control {
  display: flex;
  align-items: center;
  gap: 0.35rem;
}

.theme-label {
  font-size: 0.85rem;
  color: var(--text-secondary);
  font-weight: 500;
}

.theme-toggle {
  background: transparent;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  padding: 0.4rem 0.6rem;
  cursor: pointer;
  font-size: 0.9rem;
  line-height: 1;
  transition: all 0.2s;
  color: var(--text-primary);
  min-width: 2.5rem;
}

.theme-toggle:hover {
  background: var(--bg-tertiary);
}

/* ===== BUTTONS ===== */
.btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  font-size: 1rem;
  font-weight: 500;
  border: none;
  border-radius: var(--border-radius);
  cursor: pointer;
  transition: all 0.2s;
  text-decoration: none;
}

.btn-primary {
  background: var(--primary);
  color: white;
}

.btn-primary:hover {
  background: var(--primary-dark);
  text-decoration: none;
}

.btn-secondary {
  background: var(--gray-200);
  color: var(--gray-700);
}

.btn-secondary:hover {
  background: var(--gray-300);
}

.btn-danger {
  background: var(--error);
  color: white;
}

.btn-danger:hover {
  background: #c82333;
}

.btn-sm {
  padding: 0.35rem 0.7rem;
  font-size: 0.875rem;
}

.btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
}

/* ===== GALLERY GRID ===== */
.gallery {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
  gap: 1.5rem;
  padding: var(--spacing);
}

.gallery-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--border-radius);
  overflow: hidden;
  background: var(--card-bg);
  box-shadow: var(--shadow-sm);
  transition: transform 0.2s, box-shadow 0.2s, background-color 0.3s;
  cursor: pointer;
}

.gallery-item:hover {
  transform: translateY(-4px);
  box-shadow: var(--shadow-md);
}

.gallery-item img,
.gallery-item video {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.gallery-item-overlay {
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  background: linear-gradient(to top, rgba(0, 0, 0, 0.7), transparent);
  padding: 1rem;
  color: white;
  opacity: 0;
  transition: opacity 0.2s;
}

.gallery-item:hover .gallery-item-overlay {
  opacity: 1;
}

/* Action buttons container on gallery cards */
.gallery-item-actions {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  display: flex;
  gap: 0.25rem;
  z-index: 10;
}

/* Favorite button */
.favorite-btn {
  background: rgba(0, 0, 0, 0.5);
  border: none;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1.25rem;
  color: white;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-item:hover .favorite-btn {
  opacity: 1;
}

.favorite-btn:hover {
  background: rgba(0, 0, 0, 0.7);
  transform: scale(1.1);
}

.favorite-btn.active {
  color: var(--brand-orange);
  opacity: 1;
}

.favorite-btn.active:hover {
  color: #ff6b3d;
}

/* Delete button (admin only) */
.delete-btn {
  background: rgba(220, 53, 69, 0.8);
  border: none;
  border-radius: 50%;
  width: 2.25rem;
  height: 2.25rem;
  font-size: 1rem;
  color: white;
  cursor: pointer;
  opacity: 0;
  transition: all 0.2s;
  display: flex;
  align-items: center;
  justify-content: center;
}

.gallery-item:hover .delete-btn {
  opacity: 1;
}

.delete-btn:hover {
  background: rgba(200, 35, 51, 0.9);
  transform: scale(1.1);
}

/* Favorites navigation button */
.nav-btn-favorites {
  border-color: var(--brand-orange);
  color: var(--brand-orange);
}

.nav-btn-favorites:hover {
  background: rgba(228, 81, 22, 0.1);
  border-color: var(--brand-orange);
}

.nav-btn-favorites.active {
  background: var(--brand-orange);
  color: white;
  border-color: var(--brand-orange);
}

/* ===== MODAL LIGHTBOX ===== */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.95);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  padding: var(--spacing);
}

.modal-content {
  position: relative;
  display: flex;
  flex-direction: column;
  align-items: center;
  max-width: 95vw;
  max-height: 95vh;
}

.modal-close {
  position: fixed;
  top: 1rem;
  right: 1rem;
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  width: 3rem;
  height: 3rem;
  border-radius: 50%;
  font-size: 2rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
  transition: background 0.2s;
}

.modal-close:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-nav {
  position: fixed;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(255, 255, 255, 0.1);
  color: white;
  border: none;
  width: 3rem;
  height: 5rem;
  font-size: 2.5rem;
  cursor: pointer;
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1010;
  transition: background 0.2s;
}

.modal-nav:hover {
  background: rgba(255, 255, 255, 0.2);
}

.modal-prev {
  left: 0.5rem;
  border-radius: 0 var(--border-radius) var(--border-radius) 0;
}

.modal-next {
  right: 0.5rem;
  border-radius: var(--border-radius) 0 0 var(--border-radius);
}

.modal-media {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  max-width: 90vw;
  max-height: 80vh;
}

.modal-image {
  max-width: 100%;
  max-height: 80vh;
  object-fit: contain;
  border-radius: var(--border-radius);
}

.modal-video {
  max-width: 100%;
  max-height: 80vh;
  border-radius: var(--border-radius);
  background: black;
}

.modal-info {
  margin-top: 1rem;
  text-align: center;
  color: white;
}

.modal-filename {
  font-size: 1rem;
  font-weight: 500;
  margin-bottom: 0.25rem;
  word-break: break-all;
}

.modal-filesize {
  font-size: 0.875rem;
  color: var(--gray-400);
}

/* PDF viewer in modal */
.modal-pdf {
  width: 90vw;
  height: 80vh;
  max-width: 1000px;
  border: none;
  border-radius: var(--border-radius);
  background: white;
}

.modal-download {
  margin-top: 1rem;
}


/* Mobile PDF viewer */
.pdf-viewer-mobile {
  position: relative;
  display: flex;
  align-items: center;
  justify-content: center;
  width: 100vw;
  height: 100vh;
}

.pdf-viewer-mobile canvas {
  max-width: 100%;
  max-height: 100%;
  object-fit: contain;
}

.pdf-controls {
  position: fixed;
  bottom: 15px;
  left: 50%;
  transform: translateX(-50%);
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.35rem 0.7rem;
  background: rgba(0, 0, 0, 0.7);
  border-radius: var(--border-radius);
  z-index: 1020;
}

.pdf-controls button {
  padding: 0.35rem 0.7rem;
  background: rgba(255, 255, 255, 0.9);
  color: #333;
  border: none;
  border-radius: var(--border-radius);
  font-weight: 600;
  min-width: 30px;
  min-height: 30px;
}

.pdf-controls button:active {
  background: rgba(255, 255, 255, 0.7);
}

#pdfPageInfo {
  min-width: 70px;
  text-align: center;
  color: white;
  font-weight: 500;
  font-size: 1rem;
}

/* v1.2.1: PDF loading overlay */
.pdf-loading-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: rgba(0, 0, 0, 0.85);
  z-index: 1010;
  padding: 2rem;
}

.pdf-loading-spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.2);
  border-top-color: var(--primary);
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin-bottom: 1.5rem;
}

.pdf-loading-text {
  color: white;
  text-align: center;
  font-size: 1rem;
  line-height: 1.5;
  max-width: 300px;
}

/* Document icon for gallery */
.document-icon {

  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 4rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
}

.gallery-item-document {
  background: var(--bg-tertiary);
}

.gallery-item-document img {
  min-height: 100%;
  background: var(--bg-tertiary);
}

/* PDF preview placeholder */
.pdf-preview-placeholder {
  width: 100%;
  height: 100%;
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
}

.pdf-preview-placeholder .document-icon {
  height: auto;
  background: transparent;
}

.pdf-loading {
  font-size: 0.75rem;
  color: var(--text-secondary);
  margin-top: 0.5rem;
  animation: pulse 1.5s infinite;
}

@keyframes pulse {

  0%,
  100% {
    opacity: 1;
  }

  50% {
    opacity: 0.5;
  }
}

/* ===== FAVORITES LIST (v1.3.18) ===== */
.favorites-list {
  display: flex !important;
  flex-direction: column;
  gap: 1rem;
  grid-template-columns: none !important;
}

.favorite-row {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 1rem;
  background: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  cursor: pointer;
  transition: all 0.2s;
  gap: 1rem;
}

.favorite-row:hover {
  background: var(--bg-tertiary);
  border-color: var(--brand-orange);
  transform: translateX(4px);
}

.favorite-info {
  flex: 1;
  min-width: 0;
}

.favorite-name {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin-bottom: 0.5rem;
}

.favorite-description {
  font-size: 0.875rem;
  color: var(--text-secondary);
  margin-bottom: 0.5rem;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.favorite-meta {
  font-size: 0.75rem;
  color: var(--text-muted);
}

.favorite-thumbnail {
  flex-shrink: 0;
  width: 120px;
  height: 120px;
  border-radius: 4px;
  overflow: hidden;
  background: var(--bg-tertiary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.favorite-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.favorite-placeholder {
  font-size: 3rem;
  opacity: 0.3;
}

/* Mobile responsive */
@media (max-width: 640px) {
  .favorite-row {
    flex-direction: column;
    align-items: flex-start;
  }

  .favorite-thumbnail {
    width: 100%;
    height: 200px;
  }
}

/* ===== TOAST NOTIFICATIONS ===== */
.toast-container {
  position: fixed;
  top: 1rem;
  right: 1rem;
  z-index: 2000;
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.toast {
  background: var(--card-bg);
  color: var(--text-primary);
  padding: 0.75rem 1rem;
  border-radius: var(--border-radius);
  box-shadow: var(--shadow-lg);
  display: flex;
  align-items: center;
  gap: 0.75rem;
  min-width: 250px;
  animation: slideIn 0.3s ease-out;
}

@keyframes slideIn {
  from {
    transform: translateX(100%);
    opacity: 0;
  }

  to {
    transform: translateX(0);
    opacity: 1;
  }
}

.toast-success {
  border-left: 4px solid var(--success);
}

.toast-error {
  border-left: 4px solid var(--error);
}

.toast-info {
  border-left: 4px solid var(--info);
}

.toast-warning {
  border-left: 4px solid var(--warning);
}

/* ===== LOADING SPINNER ===== */
.spinner {
  border: 3px solid var(--gray-200);
  border-top-color: var(--primary);
  border-radius: 50%;
  width: 2rem;
  height: 2rem;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to {
    transform: rotate(360deg);
  }
}

.loading-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(255, 255, 255, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1500;
}

/* ===== UPLOAD ZONE ===== */
.upload-zone {
  border: 2px dashed var(--border-color);
  border-radius: var(--border-radius);
  padding: 2rem;
  text-align: center;
  background: var(--card-bg);
  transition: all 0.2s;
  cursor: pointer;
}

.upload-zone:hover,
.upload-zone.drag-over {
  border-color: var(--primary);
  background: var(--bg-tertiary);
}

.upload-zone input[type="file"] {
  display: none;
}

.uploader {
  margin: var(--spacing) auto;
  max-width: 600px;
}

.upload-icon {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.6;
}

.upload-text {
  color: var(--text-secondary);
}

.upload-text strong {
  color: var(--text-primary);
  font-size: 1rem;
}

.upload-hint {
  font-size: 0.875rem;
  color: var(--gray-500);
  margin-top: 0.5rem;
}

.upload-progress {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 1.5rem;
  box-shadow: var(--shadow-sm);
}

.progress-bar {
  background: var(--gray-200);
  border-radius: calc(var(--border-radius) / 2);
  height: 1rem;
  overflow: hidden;
  margin-bottom: 1rem;
}

.progress-fill {
  background: var(--primary);
  height: 100%;
  width: 0%;
  transition: width 0.3s ease;
}

.progress-text {
  text-align: center;
  color: var(--gray-700);
  font-weight: 500;
}

/* ===== FILTER PANEL (compact) ===== */
.filter-panel {
  display: flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.5rem;
  background: var(--bg-tertiary);
  border-radius: var(--border-radius);
  margin-bottom: 0.75rem;
}

.filter-search {
  flex: 1;
  min-width: 120px;
}

.filter-input {
  width: 100%;
  padding: 0.5rem 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.875rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.filter-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.1);
}

.filter-input::placeholder {
  color: var(--text-muted);
}

.filter-sort {
  display: flex;
  gap: 0.25rem;
  align-items: center;
}

.filter-select {
  padding: 0.5rem 0.5rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 0.8rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  cursor: pointer;
  transition: border-color 0.2s;
}

.filter-select:focus {
  outline: none;
  border-color: var(--primary);
}

.filter-order-btn {
  padding: 0.5rem 0.6rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  background: var(--bg-primary);
  color: var(--text-primary);
  font-size: 0.875rem;
  cursor: pointer;
  transition: all 0.2s;
}

.filter-order-btn:hover {
  background: var(--bg-tertiary);
  border-color: var(--gray-400);
}

/* ===== RESPONSIVE ===== */
/* v1.3.2: Планшеты (768-1024px) - отступ после Галерея */
@media (max-width: 1024px) and (min-width: 769px) {
  .logo-title {
    margin-right: 1rem;
  }

  .nav-btn {
    padding: 0.4rem 0.6rem;
    font-size: 0.8rem;
  }
}

@media (max-width: 768px) {

  /* Mobile Sidebar Logic */
  .app-layout {
    position: relative;
  }

  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    bottom: 0;
    width: 280px;
    z-index: 1000;
    transform: translateX(-100%);
    transition: transform 0.3s ease-in-out;
    box-shadow: var(--shadow-lg);
  }

  .sidebar.open {
    transform: translateX(0);
  }

  /* Mobile Overlay */
  .sidebar-overlay {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
    display: none;
    opacity: 0;
    transition: opacity 0.3s;
  }

  .sidebar-overlay.visible {
    display: block;
    opacity: 1;
  }

  /* Hamburger Menu Button (visible only on mobile) */
  .mobile-menu-btn {
    display: flex !important;
    /* Ensure it overrides any default hidden */
    align-items: center;
    justify-content: center;
    background: transparent;
    border: none;
    font-size: 1.5rem;
    color: var(--text-primary);
    cursor: pointer;
    padding: 0.5rem;
    margin-right: 0.5rem;
    order: 0;
  }

  /* Adjust Header content order to fit Hamburger */
  .header-content {
    flex-wrap: wrap;
    gap: 0.5rem;
  }

  .logo {
    order: 1;
    flex: 1;
  }

  .auth-controls {
    order: 2;
  }

  /* Hide Nav as it is moved to sidebar or not used */
  /* Wait, "nav-btn" logic was for tabs (images, videos etc). 
     They are now mostly redundant if we use Catalog/Sidebar navigation? 
     No, user might still strict-filter. But sidebar is main nav. */
  .nav {
    display: none;
    /* Hide top nav tabs on mobile if Sidebar is main nav */
  }

  .gallery {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
    gap: 1rem;
    padding: 1rem;
  }

  /* Filter: всё в одну строку */
  .filter-panel {
    flex-wrap: nowrap;
    gap: 0.5rem;
    padding: 1rem;
  }

  .filter-search {
    flex: 1;
    min-width: 0;
  }

  .filter-sort {
    flex-shrink: 0;
  }

  .main-content {
    width: 100%;
  }

  .toast {
    min-width: auto;
    max-width: calc(100vw - 2rem);
  }
}

/* v1.3.4: Мобильные экраны (<480px) - кнопки на 100% ширины */
@media (max-width: 480px) {
  /* .logo-title rule moved to larger breakpoint below */


  .nav {
    width: 100%;
    gap: 0.25rem;
  }

  .nav-btn {
    flex: 1;
    padding: 0.5rem 0.3rem;
    font-size: 0.75rem;
    text-align: center;
  }

  .btn-sm {
    padding: 0.35rem 0.6rem;
    font-size: 0.75rem;
  }

  .theme-toggle {
    padding: 0.3rem 0.5rem;
    font-size: 0.75rem;
  }

  .theme-label {
    font-size: 0.75rem;
  }

  .filter-search input {
    font-size: 0.8rem;
    padding: 0.4rem 0.6rem;
  }

  .filter-sort select {
    font-size: 0.75rem;
    padding: 0.35rem 0.5rem;
  }
}

/* ===== UTILITIES ===== */
.hidden {
  display: none !important;
}

.text-center {
  text-align: center;
}

.mt-1 {
  margin-top: 0.5rem;
}

.mt-2 {
  margin-top: 1rem;
}

.mt-3 {
  margin-top: 1.5rem;
}

.mt-4 {
  margin-top: 2rem;
}

.mb-1 {
  margin-bottom: 0.5rem;
}

.mb-2 {
  margin-bottom: 1rem;
}

.mb-3 {
  margin-bottom: 1.5rem;
}

.mb-4 {
  margin-bottom: 2rem;
}


/* Mobile PDF fullscreen mode */
@media (max-width: 1024px) {

  /* Fullscreen modal for PDF */
  .modal-overlay:has(.pdf-viewer-mobile) {
    padding: 0;
    background: #000;
  }

  .modal-content:has(.pdf-viewer-mobile) {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
  }

  .modal-media:has(.pdf-viewer-mobile) {
    max-width: 100vw;
    max-height: 100vh;
    width: 100vw;
    height: 100vh;
  }

  /* Filename at top */
  .modal-content:has(.pdf-viewer-mobile) .modal-info {
    position: fixed;
    top: 60px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    padding: 0.35rem 1rem;
    border-radius: var(--border-radius);
    margin: 0;
    z-index: 1020;
    max-width: 80vw;
  }

  .modal-content:has(.pdf-viewer-mobile) .modal-filename {
    font-size: 0.85rem;
    margin: 0;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
  }

  .modal-content:has(.pdf-viewer-mobile) .modal-filesize {
    display: none;
  }

  /* Hide global nav buttons for PDF (use pdf-controls instead) */
  .modal-content:has(.pdf-viewer-mobile)~.modal-prev,
  .modal-content:has(.pdf-viewer-mobile)~.modal-next {
    display: none;
  }
}

/* Auto-hide filename animation for PDF viewer */
.modal-info.auto-hide {
  animation: fadeInOut 3s ease-in-out forwards;
}

@keyframes fadeInOut {
  0% {
    opacity: 1;
  }

  60% {
    opacity: 1;
  }

  100% {
    opacity: 0;
    visibility: hidden;
  }
}

/* Video preview placeholder */
.video-preview-placeholder {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-tertiary);
}

.video-icon {
  font-size: 3rem;
  color: var(--text-secondary);
  opacity: 0.7;
}

/* Video play icon overlay (на превью) */
.video-play-icon {
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  font-size: 2.5rem;
  color: #fff;
  text-shadow: 0 2px 8px rgba(0, 0, 0, 0.5);
  pointer-events: none;
  opacity: 0.9;
}

/* Document icon overlay (на превью PDF) */
.document-play-icon {
  position: absolute;
  bottom: 0.5rem;
  right: 0.5rem;
  font-size: 1.5rem;
  background: rgba(255, 255, 255, 0.9);
  border-radius: 4px;
  padding: 0.25rem 0.5rem;
  pointer-events: none;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2);
}

/* ===== ADMIN PANEL ===== */
.admin-panel {
  background: var(--card-bg);
  border-radius: var(--border-radius);
  padding: 2rem;
  max-width: 500px;
  width: 90vw;
  max-height: 90vh;
  overflow-y: auto;
  color: var(--text-primary);
}

.admin-panel h2 {
  margin: 0 0 1.5rem 0;
  font-family: var(--font-heading);
  font-size: 1.5rem;
  color: var(--text-primary);
}

.admin-panel h3 {
  margin: 1.5rem 0 1rem 0;
  font-family: var(--font-heading);
  font-size: 1.1rem;
  color: var(--text-secondary);
}

.admin-panel .modal-close {
  position: absolute;
  top: 0.5rem;
  right: 0.5rem;
  background: var(--bg-tertiary);
  color: var(--text-secondary);
  width: 2rem;
  height: 2rem;
  font-size: 1.2rem;
}

.admin-panel .modal-close:hover {
  background: var(--bg-secondary);
  color: var(--text-primary);
}

.settings-form {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-secondary);
}

.form-input {
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: var(--border-radius);
  font-size: 1rem;
  background: var(--bg-primary);
  color: var(--text-primary);
  transition: border-color 0.2s, box-shadow 0.2s;
}

.form-input:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(228, 81, 22, 0.1);
}

.form-row {
  display: grid;
  grid-template-columns: 1fr 1fr;
  gap: 1rem;
}

.settings-divider {
  margin: 1.5rem 0;
  border: none;
  border-top: 1px solid var(--border-color);
}

.cache-info {
  font-size: 0.875rem;
  color: var(--text-muted);
  margin-bottom: 1rem;
}

.cache-buttons {
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.cache-buttons .btn {
  flex: 1;
  min-width: 140px;
  font-size: 0.875rem;
  padding: 0.5rem 0.75rem;
}

@media (max-width: 480px) {
  .admin-panel {
    padding: 1.5rem;
  }

  .form-row {
    grid-template-columns: 1fr;
  }

  .cache-buttons {
    flex-direction: column;
  }

  .cache-buttons .btn {
    width: 100%;
  }
}

/* ===== v1.3.13: FOOTER 50px ===== */
.site-footer {
  height: 50px;
  display: flex;
  align-items: center;
  justify-content: center;
  background: var(--bg-secondary);
  border-top: 1px solid var(--border-color);
  font-size: 0.75rem;
}

.site-footer a {
  color: var(--brand-orange);
  text-decoration: none;
  transition: color 0.2s;
}

.site-footer a:hover {
  color: var(--primary);
}

/* Drag and Drop */
.tree-item[draggable="true"] {
  cursor: grab;
}

.tree-item[draggable="true"]:active {
  cursor: grabbing;
}

.tree-content.drag-over {
  background-color: var(--bg-tertiary);
  outline: 2px dashed var(--primary);
  outline-offset: -2px;
  border-radius: 4px;
}

/* ===== v1.3.13: HOME PAGE ===== */
.home-page {
  padding: 2rem;
  max-width: 800px;
  margin: 0 auto;
}

.home-content {
  text-align: center;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 1.5rem;
}

.home-content h1 {
  font-size: 2rem;
  color: var(--primary);
  margin: 0;
}

.home-description {
  font-size: 1.25rem;
  color: var(--text-primary);
  font-weight: 500;
}

.home-instruction {
  font-size: 1rem;
  color: var(--text-muted);
  line-height: 1.6;
}

.home-logo {
  max-width: 200px;
  margin-top: 1rem;
  opacity: 0.8;
}

@media (max-width: 768px) {
  .home-content h1 {
    font-size: 1.5rem;
  }

  .home-description {
    font-size: 1rem;
  }

  .home-logo {
    max-width: 150px;
  }
}

/* Header Responsiveness */
.header-spacer {
  flex: 1;
}

@media (max-width: 768px) {
  .header-spacer {
    display: none;
  }

  .auth-controls {
    margin-left: auto;
  }

  /* Adjust logo title visibility/size to prevent overlap */
  .logo-title {
    font-size: 1rem;
  }
}

@media (max-width: 600px) {
  .logo-title {
    display: none;
  }
}