/* 
 * styles.css
 * Преміальний Apple-style дизайн для системи обліку будівельних матеріалів сервісу pro-rab.com.
 * Використовує змінні кольорів, сітку Inter, ефекти glassmorphic,
 * мікро-анімації та кастомні ефекти сканування.
 */

@import url('https://fonts.googleapis.com/css2?family=Inter:wght@300;400;500;600;700&display=swap');

:root {
  --bg-primary: #f5f5f7;
  --bg-secondary: #ffffff;
  --text-primary: #1d1d1f;
  --text-secondary: #86868b;
  --accent: #0071e3;
  --accent-light: #e8f3ff;
  --accent-dark: #005bb5;
  --border-color: rgba(0, 0, 0, 0.08);
  --border-focus: rgba(0, 113, 227, 0.4);
  --bg-hover: rgba(0, 0, 0, 0.03);
  --success: #34c759;
  --success-light: #eafaf1;
  --warning: #ff9500;
  --warning-light: #fff5e6;
  --danger: #ff3b30;
  --danger-light: #ffebeb;
  
  --shadow-sm: 0 2px 8px rgba(0, 0, 0, 0.04);
  --shadow-md: 0 8px 24px rgba(0, 0, 0, 0.06);
  --shadow-lg: 0 16px 40px rgba(0, 0, 0, 0.12);
  
  --font-family: 'Inter', -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
  
  --sidebar-width: 250px;
  --header-height: 70px;
}

* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: var(--font-family);
  background-color: var(--bg-primary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  overflow-x: hidden;
  -webkit-font-smoothing: antialiased;
}

/* ==========================================
 * LAYOUT STRUCUTRE
 * ========================================== */

.app-container {
  display: flex;
  width: 100%;
  min-height: 100vh;
  position: relative;
}

/* Sidebar */
.sidebar {
  width: var(--sidebar-width);
  background-color: var(--bg-secondary);
  border-right: 1px solid var(--border-color);
  display: flex;
  flex-direction: column;
  padding: 24px 16px;
  position: fixed;
  height: 100vh;
  z-index: 100;
}

.logo-container {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 12px 24px 12px;
  border-bottom: 1px solid var(--border-color);
  margin-bottom: 24px;
}

.logo-icon {
  width: 32px;
  height: 32px;
  background: linear-gradient(135deg, #0071e3, #36d1dc);
  border-radius: 8px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: #fff;
  font-weight: 700;
  font-size: 16px;
  box-shadow: 0 4px 10px rgba(0, 113, 227, 0.3);
}

.logo-text {
  font-weight: 600;
  font-size: 16px;
  letter-spacing: -0.5px;
}

.nav-list {
  list-style: none;
  display: flex;
  flex-direction: column;
  gap: 6px;
  flex-grow: 1;
}

.nav-item {
  width: 100%;
}

.nav-link {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 12px 16px;
  color: var(--text-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  transition: all 0.2s ease;
  cursor: pointer;
}

.nav-link svg {
  width: 20px;
  height: 20px;
  stroke: var(--text-secondary);
  transition: stroke 0.2s ease;
}

.nav-link:hover {
  background-color: var(--bg-hover);
}

.nav-link.active {
  background-color: var(--accent-light);
  color: var(--accent);
  font-weight: 600;
}

.nav-link.active svg {
  stroke: var(--accent);
}

.sidebar-footer {
  padding: 12px;
  font-size: 11px;
  color: var(--text-secondary);
  text-align: center;
  border-top: 1px solid var(--border-color);
  margin-top: auto;
}

/* Main Content Area */
.main-content {
  flex-grow: 1;
  margin-left: var(--sidebar-width);
  padding: 32px 40px;
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  gap: 24px;
  width: calc(100% - var(--sidebar-width));
}

/* Header */
.app-header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 16px;
  margin-bottom: 8px;
}

.header-title h1 {
  font-size: 26px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

.header-title p {
  color: var(--text-secondary);
  font-size: 14px;
  margin-top: 4px;
}

.header-actions {
  display: flex;
  gap: 12px;
  align-items: center;
}

/* ==========================================
 * SHARED COMPONENTS & BUTTONS
 * ========================================== */

.btn {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 10px 18px;
  font-size: 14px;
  font-weight: 500;
  border-radius: 10px;
  border: 1px solid transparent;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  font-family: var(--font-family);
  box-shadow: var(--shadow-sm);
}

.btn:active {
  transform: scale(0.98);
}

.btn-primary {
  background-color: var(--accent);
  color: #fff;
}

.btn-primary:hover {
  background-color: var(--accent-dark);
}

.btn-secondary {
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  border: 1px solid var(--border-color);
}

.btn-secondary:hover {
  background-color: var(--bg-hover);
}

.btn-danger {
  background-color: var(--danger-light);
  color: var(--danger);
  border: 1px solid rgba(255, 59, 48, 0.1);
}

.btn-danger:hover {
  background-color: var(--danger);
  color: #fff;
}

.btn-icon-only {
  padding: 8px;
  border-radius: 8px;
}

/* Inputs and Forms */
.form-group {
  display: flex;
  flex-direction: column;
  gap: 8px;
  margin-bottom: 16px;
}

.form-label {
  font-size: 13px;
  font-weight: 600;
  color: var(--text-primary);
}

.form-control {
  width: 100%;
  padding: 10px 14px;
  font-size: 14px;
  font-family: var(--font-family);
  border: 1px solid var(--border-color);
  border-radius: 8px;
  background-color: var(--bg-secondary);
  transition: all 0.15s ease;
  color: var(--text-primary);
}

.form-control:focus {
  outline: none;
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-focus);
}

textarea.form-control {
  resize: vertical;
  min-height: 80px;
}

/* ==========================================
 * DASHBOARD VIEW
 * ========================================== */

.stats-grid {
  display: grid;
  grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
  gap: 20px;
  margin-bottom: 24px; /* Додано помітний відступ від нижніх блоків */
}

.stat-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  position: relative;
  overflow: hidden;
  transition: transform 0.2s ease, box-shadow 0.2s ease;
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.stat-icon-wrapper {
  width: 44px;
  height: 44px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  justify-content: center;
}

.stat-icon-wrapper svg {
  width: 24px;
  height: 24px;
}

.stat-card.blue .stat-icon-wrapper { background-color: var(--accent-light); color: var(--accent); }
.stat-card.green .stat-icon-wrapper { background-color: var(--success-light); color: var(--success); }
.stat-card.orange .stat-icon-wrapper { background-color: var(--warning-light); color: var(--warning); }
.stat-card.purple .stat-icon-wrapper { background-color: #f3e8ff; color: #a855f7; }

.stat-title {
  font-size: 13px;
  font-weight: 500;
  color: var(--text-secondary);
}

.stat-value {
  font-size: 28px;
  font-weight: 700;
  letter-spacing: -0.5px;
}

/* Перенаправлення з карток статистики */
.stat-card.clickable {
  cursor: pointer;
}
.stat-card.clickable:hover {
  border-color: var(--accent);
}

.dashboard-split {
  display: grid;
  grid-template-columns: 1.5fr 1fr;
  gap: 32px; /* Збільшено відступ */
  margin-top: 16px; /* Додатковий відступ зверху */
}

.dashboard-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 24px;
  box-shadow: var(--shadow-sm);
}

.card-header-row {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 20px;
}

.card-title {
  font-size: 16px;
  font-weight: 600;
  letter-spacing: -0.2px;
}

/* Quick Upload */
.quick-upload-area {
  border: 2px dashed var(--border-color);
  border-radius: 12px;
  padding: 32px 16px;
  text-align: center;
  cursor: pointer;
  transition: all 0.2s ease;
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 12px;
}

.quick-upload-area:hover {
  border-color: var(--accent);
  background-color: rgba(0, 113, 227, 0.01);
}

.quick-upload-icon {
  width: 48px;
  height: 48px;
  color: var(--accent);
}

/* Recent items list */
.recent-list {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.recent-item {
  display: flex;
  align-items: center;
  justify-content: space-between;
  padding: 12px;
  border-radius: 10px;
  border: 1px solid var(--border-color);
  transition: background-color 0.15s ease;
}

.recent-item:hover {
  background-color: var(--bg-hover);
}

.recent-info {
  display: flex;
  align-items: center;
  gap: 12px;
}

.recent-icon {
  width: 36px;
  height: 36px;
  border-radius: 8px;
  background-color: var(--bg-primary);
  display: flex;
  align-items: center;
  justify-content: center;
}

.recent-name {
  font-size: 13.5px;
  font-weight: 500;
}

.recent-meta {
  font-size: 11px;
  color: var(--text-secondary);
  margin-top: 2px;
}

.recent-amount {
  font-size: 14px;
  font-weight: 600;
}

/* ==========================================
 * FILE BROWSER / OBJECTS VIEW
 * ========================================== */

.folders-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
  gap: 20px;
}

.folder-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 16px;
  cursor: pointer;
  transition: all 0.2s cubic-bezier(0.16, 1, 0.3, 1);
  position: relative;
}

.folder-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
  border-color: rgba(0, 113, 227, 0.3);
}

.folder-icon-row {
  display: flex;
  justify-content: space-between;
  align-items: flex-start;
}

.folder-icon {
  width: 44px;
  height: 44px;
  color: var(--warning);
}

.folder-name {
  font-size: 15px;
  font-weight: 600;
  word-break: break-word;
}

.folder-desc {
  font-size: 12px;
  color: var(--text-secondary);
  min-height: 32px;
  display: -webkit-box;
  -webkit-line-clamp: 2;
  -webkit-box-orient: vertical;
  overflow: hidden;
}

.folder-count {
  font-size: 11px;
  font-weight: 500;
  color: var(--text-secondary);
  background-color: var(--bg-primary);
  padding: 4px 8px;
  border-radius: 6px;
  align-self: flex-start;
}

/* File View inside Object */
.object-details-header {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 20px 24px;
  display: flex;
  justify-content: space-between;
  align-items: center;
  box-shadow: var(--shadow-sm);
}

.back-btn {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  color: var(--accent);
  cursor: pointer;
  font-size: 14px;
  font-weight: 500;
}

.back-btn:hover {
  text-decoration: underline;
}

.file-cards-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(260px, 1fr));
  gap: 20px;
}

.file-card {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 16px;
  box-shadow: var(--shadow-sm);
  display: flex;
  flex-direction: column;
  gap: 12px;
  transition: all 0.2s ease;
}

.file-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--shadow-md);
}

.file-thumbnail {
  height: 120px;
  background-color: var(--bg-primary);
  border-radius: 10px;
  display: flex;
  align-items: center;
  justify-content: center;
  color: var(--text-secondary);
  font-size: 12px;
  position: relative;
  overflow: hidden;
  border: 1px solid var(--border-color);
}

.file-thumbnail img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.file-thumbnail .pdf-preview-icon {
  font-size: 40px;
  color: var(--danger);
}

.file-card-details {
  display: flex;
  flex-direction: column;
  gap: 4px;
}

.file-card-name {
  font-size: 14px;
  font-weight: 600;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

/* ==========================================
 * TABLES (REGISTRY & MATERIALS)
 * ========================================== */

.table-controls {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 16px;
  flex-wrap: wrap;
  background-color: var(--bg-secondary);
  padding: 14px 22px;
  border-radius: 18px;
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-sm);
  margin-bottom: 12px;
}

.search-box {
  position: relative;
  max-width: 300px;
  width: 100%;
}

.search-box input {
  padding-left: 38px;
  height: 38px;
  border-radius: 8px;
  background-color: #f5f5f7;
  border: 1px solid transparent;
  transition: all 0.25s cubic-bezier(0.16, 1, 0.3, 1);
}

.search-box input:focus {
  background-color: var(--bg-secondary);
  border-color: var(--accent);
  box-shadow: 0 0 0 3px var(--border-focus);
}

.search-box svg {
  position: absolute;
  left: 12px;
  top: 50%;
  transform: translateY(-50%);
  width: 18px;
  height: 18px;
  stroke: var(--text-secondary);
  pointer-events: none;
}

.filter-group {
  display: flex;
  gap: 10px;
  align-items: center;
}

.filter-group select {
  height: 38px;
  padding: 0 12px;
  border-radius: 8px;
  border: 1px solid var(--border-color);
  background-color: var(--bg-secondary);
  font-size: 13px;
  font-weight: 500;
  color: var(--text-primary);
  cursor: pointer;
  transition: all 0.2s ease;
}

.filter-group select:hover {
  border-color: var(--text-secondary);
}

.table-container {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 18px;
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.03), 0 1px 3px rgba(0, 0, 0, 0.02);
  overflow: auto;
  max-height: 68vh;
  max-width: 100%;
  position: relative;
  margin-bottom: 16px;
}

.modern-table {
  width: 100%;
  border-collapse: separate;
  border-spacing: 0;
  text-align: left;
  font-size: 13px;
  table-layout: fixed;
}

.modern-table th {
  position: sticky;
  top: 0;
  z-index: 10;
  background-color: #fbfbfd;
  color: #515154;
  font-weight: 600;
  padding: 12px 14px;
  border-bottom: 2px solid rgba(0, 0, 0, 0.05);
  border-top: 1px solid rgba(0, 0, 0, 0.01);
  font-size: 11px;
  text-transform: uppercase;
  letter-spacing: 0.6px;
  user-select: none;
  white-space: normal;
  vertical-align: middle;
  text-align: center;
  transition: background-color 0.2s ease;
}

.modern-table th:first-child {
  border-top-left-radius: 17px;
}

.modern-table th:last-child {
  border-top-right-radius: 17px;
}

.modern-table th.sortable {
  cursor: pointer;
}

.modern-table th.sortable:hover {
  color: var(--text-primary);
  background-color: #f2f2f7;
}

.modern-table th svg {
  width: 12px;
  height: 12px;
  margin-left: 4px;
  display: inline-block;
  vertical-align: middle;
}

.modern-table td {
  padding: 11px 14px;
  border-bottom: 1px solid rgba(0, 0, 0, 0.04);
  color: #3a3a3c;
  white-space: nowrap;
  vertical-align: middle;
  text-overflow: ellipsis;
  overflow: hidden;
  transition: all 0.15s ease;
}

.modern-table tbody tr {
  transition: all 0.15s ease;
}

.modern-table tbody tr:last-child td {
  border-bottom: none;
}

.modern-table tbody tr:last-child td:first-child {
  border-bottom-left-radius: 17px;
}

.modern-table tbody tr:last-child td:last-child {
  border-bottom-right-radius: 17px;
}

.modern-table tbody tr:nth-child(even) {
  background-color: #fafafb;
}

.modern-table tbody tr:hover {
  background-color: #f2f2f7 !important;
}

/* Beautiful Left Accent Line on Row Hover */
.modern-table tbody tr:hover td:first-child {
  box-shadow: inset 3.5px 0 0 0 var(--accent);
}

.wrap-text {
  white-space: normal !important;
  word-break: break-word !important;
  line-height: 1.4;
}

/* Custom styled thin scrollbar for table container */
.table-container::-webkit-scrollbar {
  height: 6px;
  width: 6px;
}

.table-container::-webkit-scrollbar-track {
  background: transparent;
}

.table-container::-webkit-scrollbar-thumb {
  background: rgba(0, 0, 0, 0.12);
  border-radius: 10px;
}

.table-container::-webkit-scrollbar-thumb:hover {
  background: rgba(0, 0, 0, 0.25);
}

/* Логічне масштабування колонок реєстру файлів */
.col-filename { width: 18%; }
.col-object { width: 11%; }
.col-invoice { width: 10%; }
.col-date { width: 9%; }
.col-payment { width: 9%; }
.col-groups { width: 18%; }
.col-usage { width: 16%; }
.col-amount { width: 10%; }
.col-actions { width: 9%; }

/* Логічне масштабування колонок бази матеріалів */
.col-mat-num { width: 3%; }
.col-mat-name { width: 20%; }
.col-mat-invoice { width: 8%; }
.col-mat-obj { width: 8%; }
.col-mat-group { width: 10%; }
.col-mat-unit { width: 4%; }
.col-mat-qty { width: 5%; }
.col-mat-pr-novat { width: 7%; }
.col-mat-pr-vat { width: 7%; }
.col-mat-sum { width: 7%; }
.col-mat-sum-vat { width: 8%; }
.col-mat-note { width: 7%; }
.col-mat-act { width: 6%; }

/* Badge tags for categories (уніфіковані та зменшені) */
.badge {
  display: inline-flex;
  align-items: center;
  justify-content: center;
  padding: 3.5px 7px;
  border-radius: 5px;
  font-size: 10px;
  font-weight: 600;
  letter-spacing: 0.1px;
  text-transform: uppercase;
  text-align: center;
  max-width: 100%;
  overflow: hidden;
  text-overflow: ellipsis;
  white-space: nowrap;
  border: 1px solid transparent;
  transition: all 0.2s ease;
}

.badge:hover {
  transform: translateY(-0.5px);
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.04);
}

.badge-gray {
  background-color: #f2f2f7;
  color: #8e8e93;
  border: 1px solid rgba(0, 0, 0, 0.05);
}

.badge-blue {
  background-color: #e8f3ff;
  color: #0071e3;
  border: 1px solid rgba(0, 113, 227, 0.14);
}

.badge-green {
  background-color: #eafaf1;
  color: #34c759;
  border: 1px solid rgba(52, 199, 89, 0.14);
}

.badge-warning {
  background-color: #fff5e6;
  color: #ff9500;
  border: 1px solid rgba(255, 149, 0, 0.14);
}

.badge-danger {
  background-color: #ffebeb;
  color: #ff3b30;
  border: 1px solid rgba(255, 59, 48, 0.14);
}

.badge-purple {
  background-color: #f3e8ff;
  color: #a855f7;
  border: 1px solid rgba(168, 85, 247, 0.14);
}

.badge-pink {
  background-color: #fce7f3;
  color: #db2777;
  border: 1px solid rgba(219, 39, 119, 0.14);
}

.badge-cyan {
  background-color: #ecfeff;
  color: #0891b2;
  border: 1px solid rgba(8, 145, 178, 0.14);
}

/* ==========================================
 * MODAL WINDOWS
 * ========================================== */

.modal-backdrop {
  position: fixed;
  top: 0;
  left: 0;
  width: 100vw;
  height: 100vh;
  background-color: rgba(0, 0, 0, 0.4);
  backdrop-filter: blur(8px);
  z-index: 1000;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  pointer-events: none;
  transition: opacity 0.25s ease;
}

.modal-backdrop.active {
  opacity: 1;
  pointer-events: auto;
}

.modal-container {
  background-color: var(--bg-secondary);
  border-radius: 20px;
  box-shadow: var(--shadow-lg);
  max-width: 500px;
  width: 90%;
  max-height: 85vh;
  display: flex;
  flex-direction: column;
  transform: scale(0.95);
  transition: transform 0.25s cubic-bezier(0.16, 1, 0.3, 1);
  overflow: hidden;
}

.modal-backdrop.active .modal-container {
  transform: scale(1);
}

.modal-header {
  padding: 20px 24px;
  border-bottom: 1px solid var(--border-color);
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-title {
  font-size: 18px;
  font-weight: 700;
  letter-spacing: -0.3px;
}

.modal-close {
  background: none;
  border: none;
  cursor: pointer;
  color: var(--text-secondary);
  display: flex;
  align-items: center;
  justify-content: center;
  padding: 4px;
  border-radius: 50%;
  transition: background-color 0.15s ease;
}

.modal-close:hover {
  background-color: var(--bg-hover);
}

.modal-body {
  padding: 24px;
  overflow-y: auto;
  flex-grow: 1;
}

.modal-footer {
  padding: 16px 24px;
  border-top: 1px solid var(--border-color);
  display: flex;
  justify-content: flex-end;
  gap: 12px;
  background-color: rgba(0, 0, 0, 0.005);
}

/* Extended Verification Modal (large side-by-side) */
.modal-container.large {
  max-width: 1100px;
  width: 95%;
  height: 85vh;
  transition: max-width 0.2s ease, width 0.2s ease, height 0.2s ease, max-height 0.2s ease;
}

/* Модальне вікно розгорнуто на весь екран */
.modal-container.large.maximized {
  max-width: 98% !important;
  width: 98% !important;
  height: 96vh !important;
  max-height: 96vh !important;
  border-radius: 12px !important;
}

.verification-layout {
  display: grid;
  grid-template-columns: 1fr 1.3fr;
  height: 100%;
  overflow: hidden;
}

.document-preview-side {
  background-color: #e5e5ea;
  border-right: 1px solid var(--border-color);
  height: 100%;
  display: flex;
  align-items: center;
  justify-content: center;
  overflow: hidden;
  position: relative;
}

.document-preview-side iframe,
.document-preview-side img {
  width: 100%;
  height: 100%;
  object-fit: contain;
  background-color: #555;
}

.document-placeholder {
  text-align: center;
  color: var(--text-secondary);
  display: flex;
  flex-direction: column;
  gap: 8px;
}

.data-editing-side {
  height: 100%;
  display: flex;
  flex-direction: column;
  overflow: hidden;
  background-color: var(--bg-secondary);
}

.verification-header {
  padding: 12px 18px; /* Зменшено з 16px 20px */
  border-bottom: 1px solid var(--border-color);
  font-weight: 600;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.verification-form {
  padding: 12px 16px; /* Зменшено з 20px */
  overflow-y: auto;
  flex-grow: 1;
}

.materials-edit-table-container {
  border: 1px solid var(--border-color);
  border-radius: 8px;
  overflow-x: auto;
  margin-top: 10px; /* Зменшено з 16px */
}

.edit-table {
  width: 100%;
  border-collapse: collapse;
  font-size: 12px; /* Зменшено з 13px */
}

.edit-table th {
  background-color: var(--bg-primary);
  padding: 6px 8px; /* Зменшено з 8px 12px */
  font-weight: 600;
  text-align: left;
  border-bottom: 1px solid var(--border-color);
  white-space: nowrap;
}

.edit-table td {
  padding: 4px 6px; /* Зменшено з 8px 12px */
  border-bottom: 1px solid var(--border-color);
}

.edit-table input {
  padding: 4px 6px; /* Зменшено з 6px 8px */
  font-size: 12px; /* Зменшено з 13px */
  border: 1px solid var(--border-color);
  border-radius: 4px;
}

.edit-table .btn-delete-row {
  color: var(--danger);
  cursor: pointer;
  background: none;
  border: none;
}

/* ==========================================
 * LOCK SCREEN IN SETTINGS (SECURITY)
 * ========================================== */

.locked-screen-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 48px 24px;
  box-shadow: var(--shadow-sm);
  max-width: 400px;
  margin: 60px auto;
  text-align: center;
  gap: 16px;
}

.locked-icon {
  width: 64px;
  height: 64px;
  color: var(--accent);
  background-color: var(--accent-light);
  padding: 16px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
}

.locked-icon svg {
  width: 32px;
  height: 32px;
}

/* ==========================================
 * USER GUIDE / INSTRUCTION TAB
 * ========================================== */

.guide-container {
  display: flex;
  flex-direction: column;
  gap: 24px;
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  border-radius: 16px;
  padding: 32px;
  box-shadow: var(--shadow-sm);
  max-width: 900px;
  margin: 0 auto;
}

.guide-section {
  border-bottom: 1px solid var(--border-color);
  padding-bottom: 24px;
}

.guide-section:last-child {
  border-bottom: none;
  padding-bottom: 0;
}

.guide-step {
  display: flex;
  gap: 16px;
  margin-top: 16px;
  align-items: flex-start;
}

.step-number {
  width: 28px;
  height: 28px;
  background-color: var(--accent-light);
  color: var(--accent);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  font-weight: 700;
  font-size: 13px;
  flex-shrink: 0;
}

.guide-title {
  font-size: 18px;
  font-weight: 600;
  margin-bottom: 8px;
  display: flex;
  align-items: center;
  gap: 8px;
}

.guide-title svg {
  width: 22px;
  height: 22px;
  stroke: var(--accent);
}

.guide-desc {
  font-size: 14px;
  color: var(--text-secondary);
  line-height: 1.5;
}

/* ==========================================
 * ANIMATION: SCANNING LASER EFFECT
 * ========================================== */

.scanner-overlay {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: rgba(0, 113, 227, 0.03);
  z-index: 10;
  pointer-events: none;
}

.laser-line {
  position: absolute;
  width: 100%;
  height: 4px;
  background: linear-gradient(180deg, rgba(0, 113, 227, 0) 0%, rgba(0, 113, 227, 1) 50%, rgba(0, 113, 227, 0) 100%);
  box-shadow: 0 0 12px rgba(0, 113, 227, 0.8);
  top: 0;
  left: 0;
  animation: scanLoop 2.5s linear infinite;
  z-index: 11;
}

@keyframes scanLoop {
  0% { top: 0%; }
  50% { top: 100%; }
  100% { top: 0%; }
}

/* Scanning loading state box */
.loading-scan-box {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 16px;
  padding: 40px;
  text-align: center;
}

.spinner {
  width: 40px;
  height: 40px;
  border: 4px solid var(--accent-light);
  border-top-color: var(--accent);
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
}

@keyframes spin {
  to { transform: rotate(360deg); }
}

/* ==========================================
 * TOAST NOTIFICATIONS
 * ========================================== */

.toast-container {
  position: fixed;
  bottom: 24px;
  right: 24px;
  display: flex;
  flex-direction: column;
  gap: 10px;
  z-index: 9999;
}

.toast {
  background-color: var(--bg-secondary);
  border: 1px solid var(--border-color);
  box-shadow: var(--shadow-md);
  padding: 16px 20px;
  border-radius: 12px;
  display: flex;
  align-items: center;
  gap: 12px;
  min-width: 300px;
  max-width: 450px;
  transform: translateY(100px);
  opacity: 0;
  animation: toastSlideIn 0.3s cubic-bezier(0.16, 1, 0.3, 1) forwards;
}

.toast-icon {
  width: 24px;
  height: 24px;
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  flex-shrink: 0;
}

.toast.success .toast-icon { background-color: var(--success-light); color: var(--success); }
.toast.error .toast-icon { background-color: var(--danger-light); color: var(--danger); }
.toast.info .toast-icon { background-color: var(--accent-light); color: var(--accent); }

.toast-message {
  font-size: 13.5px;
  font-weight: 500;
  color: var(--text-primary);
  flex-grow: 1;
}

@keyframes toastSlideIn {
  to {
    transform: translateY(0);
    opacity: 1;
  }
}

.toast.fade-out {
  animation: toastFadeOut 0.2s ease forwards;
}

@keyframes toastFadeOut {
  to {
    opacity: 0;
    transform: translateY(-20px);
  }
}

/* ==========================================
 * UTILITY STYLES
 * ========================================== */

.hide {
  display: none !important;
}

.text-right { text-align: right; }
.text-center { text-align: center; }

.text-muted {
  color: var(--text-secondary) !important;
}

.nowrap {
  white-space: nowrap;
}

.fade-in {
  animation: fadeIn 0.2s ease-in-out forwards;
}

@keyframes fadeIn {
  from { opacity: 0; transform: translateY(4px); }
  to { opacity: 1; transform: translateY(0); }
}

/* Empty states */
.empty-state {
  display: flex;
  flex-direction: column;
  align-items: center;
  justify-content: center;
  gap: 12px;
  padding: 48px 24px;
  text-align: center;
  color: var(--text-secondary);
}

.empty-state-icon {
  width: 64px;
  height: 64px;
  color: #d1d1d6;
}

.empty-state-title {
  font-size: 16px;
  font-weight: 600;
  color: var(--text-primary);
}

.empty-state-desc {
  font-size: 13px;
  max-width: 320px;
}

/* Прибирання стрілочок-скролбарів з числових полів та скролбарів з текстових полів */
input[type="number"]::-webkit-outer-spin-button,
input[type="number"]::-webkit-inner-spin-button {
  -webkit-appearance: none;
  margin: 0;
}
input[type="number"] {
  -moz-appearance: textfield; /* Firefox */
}

input, textarea, select {
  scrollbar-width: none !important; /* Firefox */
}
input::-webkit-scrollbar, textarea::-webkit-scrollbar, select::-webkit-scrollbar {
  display: none !important; /* Chrome/Safari */
}

/* ==========================================
 * MOBILE RESPONSIVENESS & ADAPTIVE STYLES
 * ========================================== */

@media (max-width: 1024px) {
  :root {
    --sidebar-width: 200px;
  }
}

@media (max-width: 768px) {
  .app-container {
    flex-direction: column;
  }

  /* Transform vertical fixed sidebar into a sleek mobile top app bar */
  .sidebar {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: auto;
    padding: 10px 16px 6px 16px;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    flex-direction: column;
    gap: 8px;
    background-color: rgba(255, 255, 255, 0.96);
    backdrop-filter: blur(10px);
    box-shadow: 0 1px 10px rgba(0, 0, 0, 0.02);
  }

  .logo-container {
    border-bottom: none;
    margin-bottom: 0;
    padding: 0 0 2px 0;
    width: 100%;
    justify-content: center;
  }

  .logo-icon {
    width: 26px;
    height: 26px;
    font-size: 13px;
    border-radius: 6px;
  }

  .logo-text {
    font-size: 14px;
  }

  /* Horizontal scrolling navigation on mobile */
  .nav-list {
    flex-direction: row;
    overflow-x: auto;
    width: 100%;
    gap: 4px;
    padding-bottom: 4px;
    scrollbar-width: none; /* Hide scrollbars */
  }

  .nav-list::-webkit-scrollbar {
    display: none;
  }

  .nav-link {
    padding: 8px 12px;
    font-size: 12.5px;
    white-space: nowrap;
    justify-content: center;
    border-radius: 8px;
    background-color: #f5f5f7;
  }

  .nav-link.active {
    background-color: var(--accent-light);
  }

  .sidebar-footer {
    display: none;
  }

  /* Reset main content margins to accommodate top mobile app bar */
  .main-content {
    margin-left: 0;
    margin-top: 102px; /* Top bar clear height */
    padding: 16px;
    width: 100%;
    gap: 16px;
  }

  .app-header {
    flex-direction: column;
    align-items: stretch;
    gap: 12px;
    border-bottom: none;
    padding-bottom: 0;
  }

  .header-title h1 {
    font-size: 20px;
    text-align: center;
  }

  .header-title p {
    font-size: 12px;
    text-align: center;
  }

  .header-actions {
    width: 100%;
    justify-content: stretch;
    flex-wrap: wrap;
    gap: 8px;
  }

  .header-actions .btn {
    flex-grow: 1;
    font-size: 12.5px;
    padding: 8px 14px;
  }

  /* Dashboard stacks vertically */
  .dashboard-split {
    grid-template-columns: 1fr;
    gap: 16px;
    margin-top: 8px;
  }

  .stats-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .stat-card {
    padding: 16px;
    gap: 6px;
  }

  .stat-value {
    font-size: 20px;
  }

  .stat-icon-wrapper {
    width: 36px;
    height: 36px;
  }

  .stat-icon-wrapper svg {
    width: 18px;
    height: 18px;
  }

  /* Object lists & File Cards */
  .folders-grid {
    grid-template-columns: 1fr 1fr;
    gap: 12px;
  }

  .folder-card {
    padding: 14px;
    gap: 10px;
  }

  .folder-icon {
    width: 36px;
    height: 36px;
  }

  .file-cards-grid {
    grid-template-columns: 1fr;
    gap: 12px;
  }

  /* Table Controls full width */
  .table-controls {
    flex-direction: column;
    align-items: stretch;
    padding: 12px 16px;
    gap: 12px;
    border-radius: 14px;
  }

  .search-box {
    max-width: 100%;
  }

  .filter-group {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
    width: 100%;
  }

  .filter-group select {
    width: 100%;
    font-size: 12.5px;
    height: 38px;
  }

  .table-container {
    border-radius: 14px;
  }

  /* Verification Modal stacks vertically: top 38% height is preview, bottom is inputs */
  .modal-container.large {
    width: 98%;
    height: 94vh;
    max-height: 94vh;
    border-radius: 14px;
  }

  .verification-layout {
    grid-template-columns: 1fr;
    grid-template-rows: 35vh 1fr;
    height: 100%;
    overflow: hidden;
  }

  .document-preview-side {
    border-right: none;
    border-bottom: 1px solid var(--border-color);
    height: 35vh;
  }

  .data-editing-side {
    height: 100%;
  }

  .verification-form {
    padding: 12px 14px;
  }

  /* General modals layout */
  .modal-container {
    width: 95%;
    max-height: 90vh;
  }

  .modal-body {
    padding: 16px;
  }

  .modal-footer {
    padding: 12px 16px;
    flex-wrap: wrap;
    gap: 8px;
  }

  .modal-footer .btn {
    flex-grow: 1;
  }
}
