/* ============================================
   DOCUMENT PAGE STYLES - CALENDAR INSPIRED
   ============================================ */

/* Page Header */
.page-header {
  margin-bottom: 2rem;
  padding: 2rem 0 1.5rem 0;
  border-bottom: 2px solid #e7ebf3;
  position: relative;
}

.page-header::before {
  content: '';
  position: absolute;
  bottom: -2px;
  left: 0;
  width: 80px;
  height: 2px;
  background: linear-gradient(90deg, #135bec, #3b82f6);
}

.page-title {
  font-size: 2.25rem;
  font-weight: 800;
  line-height: 1.2;
  color: #0d121b;
  margin: 0 0 0.5rem 0;
  letter-spacing: -0.02em;
}

.page-subtitle {
  font-size: 1.05rem;
  color: #6b7280;
  margin: 0;
  font-weight: 400;
}

/* Tabs */
.documents-tabs {
  margin: 1.5rem 0;
  border-bottom: 2px solid #f3f4f6;
  padding-bottom: 0;
}

.tab-button {
  background: none;
  border: none;
  padding: 0.75rem 1.25rem;
  cursor: pointer;
  font-size: 0.95rem;
  border-bottom: 3px solid transparent;
  color: #6b7280;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border-radius: 8px 8px 0 0;
  font-weight: 600;
  letter-spacing: 0.01em;
}

.tab-button:hover {
  color: #135bec;
  background-color: #f8f9fc;
  border-bottom-color: #93c5fd;
}

.tab-button.active {
  border-bottom: 3px solid #135bec;
  color: #135bec;
  font-weight: 700;
  background-color: #f0f5ff;
}

/* Grid Layout */
.content-grid {
  display: grid;
  grid-template-columns: 1fr;
  gap: 0;
  margin-top: 2rem;
}

@media (min-width: 768px) {
  .content-grid {
    grid-template-columns: 280px 1fr;
    gap: 2.5rem;
  }
}

.sidebar {
  width: 100%;
}

.documents-section {
  width: 100%;
}

/* Sticky Sidebar */
.sticky-sidebar {
  position: sticky;
  top: 1.5rem;
  align-self: flex-start;
}

/* Search Bar */
.search-section {
  margin-bottom: 1.5rem;
}

.search-container {
  display: block;
  position: relative;
}

.search-input-wrapper {
  display: flex;
  align-items: center;
  border: 2px solid #e7ebf3;
  border-radius: 10px;
  background-color: #fff;
  height: 48px;
  box-shadow: 0 1px 3px rgba(0, 0, 0, 0.06);
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
}

.search-input-wrapper:focus-within {
  border-color: #135bec;
  box-shadow: 0 0 0 4px rgba(19, 91, 236, 0.12);
}

.search-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 0 14px;
  color: #6b7280;
  transition: color 0.2s;
}

.search-input-wrapper:focus-within .search-icon {
  color: #135bec;
}

.search-input {
  flex: 1;
  border: none;
  background-color: transparent;
  padding: 0.5rem 0.5rem 0.5rem 0;
  font-size: 0.95rem;
  color: #0d121b;
  outline: none;
}

.search-input::placeholder {
  color: #9ca3af;
}

/* Filter Styles */
.filter-title {
  font-size: 0.8rem;
  font-weight: 700;
  color: #0d121b;
  margin: 0 0 1rem 0;
  padding-bottom: 0.75rem;
  border-bottom: 2px solid #f3f4f6;
  text-transform: uppercase;
  letter-spacing: 0.05em;
}

.filter-options {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.filter-option {
  display: flex;
  align-items: center;
  gap: 0.75rem;
  padding: 0.875rem 1rem;
  border: 2px solid transparent;
  border-radius: 10px;
  cursor: pointer;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  background-color: #f9fafb;
  position: relative;
}

.filter-option:hover {
  background-color: #f0f5ff;
  border-color: #93c5fd;
  transform: translateX(3px);
}

.filter-option.selected {
  background: linear-gradient(135deg, #dbeafe 0%, #e6f0ff 100%);
  border-color: #135bec;
  box-shadow: 0 4px 12px rgba(19, 91, 236, 0.15);
  transform: translateX(3px);
}

.filter-radio {
  width: 1.125rem;
  height: 1.125rem;
  border: 2px solid #d1d5db;
  background-color: #fff;
  appearance: none;
  position: relative;
  border-radius: 50%;
  cursor: pointer;
  flex-shrink: 0;
  transition: all 0.2s ease;
}

.filter-radio:checked {
  border-color: #135bec;
  background-color: #135bec;
  box-shadow: 0 0 0 3px rgba(19, 91, 236, 0.1);
}

.filter-radio:checked::after {
  content: '';
  position: absolute;
  top: 50%;
  left: 50%;
  transform: translate(-50%, -50%);
  width: 6px;
  height: 6px;
  background-color: white;
  border-radius: 50%;
}

.filter-text {
  font-size: 0.9rem;
  color: #374151;
  margin: 0;
  font-weight: 500;
}

/* Document Cards - ПЛАШКИ НЕ ЧІПАЄМО */
.document-list {
  display: flex;
  flex-direction: column;
  gap: 1rem;
  margin-bottom: 1rem;
  max-width: 100%;
  overflow-x: hidden;
  width: 100%;
  padding: 0.5rem;
  box-sizing: border-box;
}

/* Loading animation styles */
.document-list.loading {
  display: flex;
  flex-direction: column;
  gap: 1rem;
}

.document-card.loading {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 1.5rem;
  border-radius: 12px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  min-height: 150px;
  pointer-events: none;
}

@keyframes loading-shimmer {
  0% {
    background-position: -200% 0;
  }
  100% {
    background-position: 200% 0;
  }
}

.document-card.loading .document-icon {
  width: 48px;
  height: 48px;
  border-radius: 6px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  flex-shrink: 0;
}

.document-card.loading .document-info {
  flex: 1;
  display: flex;
  flex-direction: column;
  gap: 0.75rem;
}

.document-card.loading .document-title {
  width: 70%;
  height: 1.2rem;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  border-radius: 4px;
  margin: 0;
}

.document-card.loading .document-desc {
  width: 100%;
  height: 0.9rem;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  border-radius: 4px;
  margin: 0;
}

.document-card.loading .document-desc + .document-desc {
  width: 80%;
}

.document-card.loading .document-meta {
  width: 60%;
  height: 0.8rem;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  border-radius: 4px;
  margin: 0;
}

.document-card.loading .download-link {
  width: 44px;
  height: 44px;
  border-radius: 10px;
  background: linear-gradient(90deg, #f0f0f0 25%, #e0e0e0 50%, #f0f0f0 75%);
  background-size: 200% 100%;
  animation: loading-shimmer 1.5s infinite;
  flex-shrink: 0;
}

/* Document Card - ПЛАШКИ БЕЗ ЗМІН */
.document-card {
  display: flex;
  align-items: flex-start;
  gap: 1rem;
  padding: 1.5rem;
  border: 1px solid #e7ebf3;
  border-radius: 12px;
  background-color: #fff;
  transition: all 0.3s ease;
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
  overflow: hidden;
  min-width: 0;
  flex: 1 1 auto;
  position: relative;
}

.document-card::before {
  content: '';
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  height: 3px;
  background: linear-gradient(90deg, #135bec, #3b82f6);
  opacity: 0;
  transition: opacity 0.3s ease;
}

.document-card:hover {
  box-shadow: 0 8px 24px rgba(0, 0, 0, 0.12);
  border-color: #135bec;
  transform: translateY(-4px);
}

.document-card:hover::before {
  opacity: 1;
}

.document-icon {
  width: 48px;
  height: 48px;
  display: flex;
  align-items: center;
  justify-content: center;
  border-radius: 6px;
  background-color: rgba(19, 91, 236, 0.1);
  color: #135bec;
  flex-shrink: 0;
  margin-top: 0.25rem;
}

.document-info {
  flex: 1;
  min-width: 0;
  overflow: hidden;
}

.document-title {
  font-size: 1.1rem;
  font-weight: 600;
  color: #0d121b;
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.document-desc {
  font-size: 0.9rem;
  color: #4c669a;
  margin: 0 0 0.5rem 0;
  line-height: 1.4;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.document-meta {
  font-size: 0.85rem;
  color: #6b7280;
  margin: 0;
  font-weight: 500;
  word-wrap: break-word;
  overflow-wrap: break-word;
  hyphens: auto;
}

.meta-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
  gap: 0.75rem;
  margin-top: 0.5rem;
}

.meta-item {
  display: flex;
  flex-direction: column;
  background-color: #f8fafc;
  padding: 0.6rem;
  border-radius: 6px;
  border: 1px solid #e2e8f0;
}

.meta-label {
  font-size: 0.7rem;
  color: #4c669a;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 0.2rem;
}

.meta-value {
  font-size: 0.85rem;
  color: #0d121b;
  font-weight: 500;
  word-break: break-word;
}

.download-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  border-radius: 10px;
  color: #4c669a;
  transition: all 0.3s ease;
  text-decoration: none;
  background: linear-gradient(135deg, #f0f5ff, #e6f0ff);
  flex-shrink: 0;
  margin-left: 0.5rem;
  min-width: 44px;
  max-width: 44px;
  flex: 0 0 44px;
  border: 1px solid #d1e0ff;
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.05);
}

.download-link:hover {
  background: linear-gradient(135deg, #e6f0ff, #d1e7ff);
  color: #135bec;
  transform: translateY(-3px);
  box-shadow: 0 4px 12px rgba(19, 91, 236, 0.2);
  border-color: #a3c8ff;
}

.regulation-images-btn {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  border-radius: 6px;
  color: #4c669a;
  transition: all 0.2s ease;
  text-decoration: none;
  background-color: #f8f9fc;
  flex-shrink: 0;
  margin-left: 0.5rem;
  border: none;
  cursor: pointer;
}

.regulation-thumbnails {
  display: flex;
  flex-wrap: wrap;
  gap: 0.75rem;
  margin-top: 1rem;
  padding-top: 0.5rem;
  border-top: 1px solid #e7ebf3;
  max-width: 100%;
  overflow-y: visible;
  padding-bottom: 5px;
  width: 100%;
}

.regulation-image-link {
  display: inline-block;
  flex: 0 0 auto;
  width: 80px;
  height: 80px;
  border-radius: 6px;
  overflow: hidden;
  border: 2px solid transparent;
  transition: all 0.2s ease;
  cursor: pointer;
  min-width: 80px;
  max-width: 80px;
}

.regulation-image-link:hover {
  border-color: #135bec;
  transform: scale(1.05);
  box-shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
}

.regulation-thumbnail {
  width: 100%;
  height: 100%;
  object-fit: cover;
  display: block;
}

.document-card.has-thumbnails .download-link {
  display: none;
}

.document-card.regulation-card.has-thumbnails {
  width: 100%;
  max-width: 100%;
  box-sizing: border-box;
}

.document-card.regulation-card.has-thumbnails .document-info {
  width: 100%;
  max-width: 100%;
  overflow: hidden;
}

.regulation-images-btn:hover {
  background-color: #e7ebf3;
  color: #135bec;
  transform: translateY(-2px);
}

.protocol-files {
  margin-top: 0.75rem;
  display: flex;
  flex-wrap: wrap;
  gap: 0.5rem;
}

.file-link {
  display: inline-flex;
  align-items: center;
  padding: 0.4rem 0.8rem;
  background-color: #f0f5ff;
  border-radius: 20px;
  font-size: 0.8rem;
  text-decoration: none;
  color: #135bec;
  transition: all 0.2s ease;
  border: 1px solid #cfd7e7;
}

.file-link:hover {
  background-color: #dbeafe;
  transform: translateY(-1px);
}

/* Pagination - Calendar Style */
.pagination {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
  margin-top: 2.5rem;
  padding-top: 1.5rem;
  border-top: 2px solid #f3f4f6;
  flex-wrap: wrap;
  max-width: 100%;
  overflow-x: auto;
}

.pagination-link {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 38px;
  height: 38px;
  border-radius: 10px;
  font-size: 0.9rem;
  font-weight: 600;
  text-decoration: none;
  color: #6b7280;
  transition: all 0.25s cubic-bezier(0.4, 0, 0.2, 1);
  border: 2px solid transparent;
  background: #f9fafb;
}

.pagination-link:hover:not(.disabled) {
  background-color: #f0f5ff;
  color: #135bec;
  border-color: #93c5fd;
  transform: translateY(-2px);
}

.pagination-link.active {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
  border-color: #2563eb;
  font-weight: 700;
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.pagination-link.disabled {
  color: #d1d5db;
  cursor: not-allowed;
  opacity: 0.5;
  background: #f9fafb;
}

.pagination-ellipsis {
  font-size: 0.9rem;
  color: #9ca3af;
  padding: 0 0.5rem;
}

/* Results count */
.results-count {
  font-size: 0.9rem;
  color: #6b7280;
  margin-top: 0.5rem;
  font-weight: 600;
  padding: 0.75rem 0;
  letter-spacing: 0.01em;
}

/* No results */
.no-results {
  text-align: center;
  padding: 3rem;
  color: #9ca3af;
  background: linear-gradient(135deg, #f9fafb 0%, #f3f4f6 100%);
  border-radius: 14px;
  border: 2px dashed #d1d5db;
}

.no-results p:first-child {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.5rem;
  color: #374151;
}

.no-results p:last-child {
  font-size: 0.9rem;
  margin: 0;
}

/* Loading indicator */
.loading-indicator {
  text-align: center;
  padding: 3rem;
  color: #6b7280;
}

/* Error message */
.error-message {
  text-align: center;
  padding: 2rem;
  color: #dc2626;
  background: linear-gradient(135deg, #fef2f2 0%, #fee2e2 100%);
  border: 2px solid #fecaca;
  border-radius: 14px;
  margin: 1rem 0;
}

.error-message p:first-child {
  font-weight: 700;
  margin-bottom: 0.5rem;
}

/* Modal styles */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background-color: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
}

.modal-content {
  background-color: white;
  padding: 2rem;
  border-radius: 14px;
  width: 90%;
  max-width: 500px;
  max-height: 90vh;
  overflow-y: auto;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
}

.modal-content h3 {
  margin-top: 0;
  margin-bottom: 1.5rem;
  color: #0d121b;
  font-size: 1.5rem;
  font-weight: 700;
}

.form-group {
  margin-bottom: 1rem;
}

.form-group label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: #0d121b;
}

.form-group input,
.form-group select,
.form-group textarea {
  width: 100%;
  padding: 0.75rem;
  border: 2px solid #e7ebf3;
  border-radius: 8px;
  font-size: 1rem;
  box-sizing: border-box;
  transition: border-color 0.2s;
}

.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
  border-color: #135bec;
  outline: none;
  box-shadow: 0 0 0 3px rgba(19, 91, 236, 0.1);
}

.form-group textarea {
  min-height: 100px;
  resize: vertical;
}

.form-actions {
  margin-top: 1.5rem;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

.form-actions button {
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 1rem;
  font-weight: 600;
  cursor: pointer;
  border: none;
  transition: all 0.2s;
}

.form-actions button[type="submit"] {
  background: linear-gradient(135deg, #3b82f6 0%, #2563eb 100%);
  color: white;
}

.form-actions button[type="submit"]:hover {
  background: linear-gradient(135deg, #2563eb 0%, #1e40af 100%);
  transform: translateY(-2px);
  box-shadow: 0 4px 12px rgba(37, 99, 235, 0.3);
}

.form-actions button[type="button"] {
  background-color: #f3f4f6;
  color: #374151;
}

.form-actions button[type="button"]:hover {
  background-color: #e5e7eb;
}

/* Spinner animation */
@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.spinner {
  display: inline-block;
  width: 20px;
  height: 20px;
  border: 2px solid #e7ebf3;
  border-top: 2px solid #135bec;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

/* Mobile responsiveness */
@media (max-width: 768px) {
  .page-header {
    text-align: center;
    padding: 1.5rem 0 1rem 0;
  }

  .page-header::before {
    left: 50%;
    transform: translateX(-50%);
  }

  .page-title {
    text-align: center;
    font-size: 1.875rem;
  }

  .page-subtitle {
    text-align: center;
    font-size: 0.95rem;
  }

  .content-grid {
    display: flex;
    flex-direction: column;
  }

  .documents-section {
    order: 2;
  }

  .sidebar {
    order: 1;
    width: 100%;
    margin-bottom: 1rem;
  }

  .sticky-sidebar {
    position: static;
  }

  .filter-panel {
    position: relative;
    border: 2px solid #e7ebf3;
    border-radius: 10px;
    background-color: #fff;
    overflow: hidden;
  }

  .filter-panel-header {
    padding: 1rem;
    background-color: #f8f9fc;
    border-bottom: 1px solid #e7ebf3;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
  }

  .filter-panel-header h3 {
    margin: 0;
    font-size: 1rem;
    font-weight: 700;
    color: #0d121b;
  }

  .filter-panel-toggle {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.25rem;
    border-radius: 4px;
    transition: transform 0.2s ease;
  }

  .filter-panel-toggle.expanded {
    transform: rotate(180deg);
  }

  .filter-panel-header-text {
    flex: 1;
    margin-left: 1rem;
    font-size: 0.8rem;
    color: #9ca3af;
    font-style: italic;
  }

  .filter-options-container {
    max-height: 0;
    overflow: hidden;
    transition: max-height 0.3s ease;
  }

  .filter-options-container.expanded {
    max-height: 100%;
  }

  .filter-options {
    padding: 1rem;
  }

  .filter-option {
    margin-bottom: 0.5rem;
  }

  .filter-option:not(:first-child) {
    display: none;
  }

  .filter-options.expanded .filter-option {
    display: flex;
  }

  .search-section {
    padding: 1rem;
    border-bottom: 1px solid #e7ebf3;
  }

  .documents-tabs {
    margin-top: 0;
    display: flex;
    justify-content: center;
    padding: 0 0 1.5rem 0;
    margin: 0;
  }

  .tab-button {
    padding: 0.4rem 0.75rem;
    font-size: 0.9rem;
  }

  .document-list {
    padding: 0;
  }

  .document-card {
    max-width: 100%;
    margin-left: auto;
    margin-right: auto;
    padding: 1rem;
    gap: 0.75rem;
  }

  .document-title {
    font-size: 1rem;
  }

  .document-desc {
    font-size: 0.85rem;
  }

  .document-meta {
    font-size: 0.75rem;
  }

  .document-icon {
    width: 40px;
    height: 40px;
  }

  .search-input {
    font-size: 0.9rem;
  }

  .filter-text {
    font-size: 0.85rem;
  }

  .meta-item {
    padding: 0.4rem;
  }

  .meta-label {
    font-size: 0.65rem;
  }

  .meta-value {
    font-size: 0.75rem;
  }

  .regulation-thumbnails {
    gap: 0.5rem;
    max-width: 100%;
    overflow-x: auto;
    padding-bottom: 5px;
  }

  .regulation-image-link {
    width: 80px;
    height: 80px;
    min-width: 80px;
    max-width: 80px;
    flex: 0 0 auto;
  }
}

@media (max-width: 480px) {
  .regulation-image-link {
    width: 70px;
    height: 70px;
    min-width: 70px;
    max-width: 70px;
  }
}

@media (max-width: 380px) {
  .regulation-image-link {
    width: 50px;
    height: 50px;
    min-width: 50px;
    max-width: 50px;
  }
}

@media (max-width: 320px) {
  .document-card {
    max-width: 320px;
    margin-left: auto;
    margin-right: auto;
    padding: 0.75rem;
    gap: 0.5rem;
  }

  .regulation-image-link {
    width: 50px !important;
    height: 50px !important;
    min-width: 50px !important;
    max-width: 50px !important;
  }

  .page-title {
    font-size: 1.3rem;
  }

  .document-title {
    font-size: 0.9rem;
  }

  .document-desc {
    font-size: 0.8rem;
  }

  .tab-button {
    padding: 0.3rem 0.5rem;
    font-size: 0.8rem;
  }
}
