/* Global theme — modern creative look and feel (moved from users.css) */
:root {
  --bg-gradient: radial-gradient(1200px 600px at 10% 0%, #182233 0%, #0f1622 40%, #0b111a 100%);
  --card: rgba(255, 255, 255, 0.06);
  --card-strong: rgba(255, 255, 255, 0.12);
  --stroke: rgba(255, 255, 255, 0.10);
  --text: #e7edf6;
  --muted: #a9b6c7;
  --accent: #4f9cff;
  --accent-2: #7b61ff;
  --accent-3: #21d4fd;
  --danger: #ff6576;
  --success: #35d09f;
  --warning: #ffcc66;
  --shadow-1: 0 6px 20px rgba(0, 0, 0, 0.22);
  --shadow-2: 0 12px 28px rgba(0, 0, 0, 0.28);
}

/* Page base - фіксований фон для запобігання швам при скролі */
html {
  height: 100%;
}

html::before {
  content: '';
  position: fixed;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  background: var(--bg-gradient);
  background-size: cover;
  background-position: center;
  background-repeat: no-repeat;
  z-index: -1;
}

body {
  background: transparent;
  color: var(--text);
  min-height: 100vh;
  position: relative;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
}

/* Header slight frosting */
header {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.02));
  border-bottom: 1px solid var(--stroke);
}

/* Main container — override inline with !important for coherence */
main {
  /* margin: 24px auto !important; */
  background: linear-gradient(180deg, rgba(255,255,255,0.04), rgba(255,255,255,0.02));
  border-radius: 16px;
  box-shadow: var(--shadow-1);
}

/* Desktop: full width layout */
@media (min-width: 1200px) {
  main {
    max-width: none !important;
    width: 100% !important;
    margin: 24px 0 !important; /* убираем горизонтальные поля */
  }
  .main-contained {
    max-width: none !important;
    width: 100% !important;
    margin: 0 !important;
  }
}

/* Headings */
h2 {
  margin: 4px 0 14px 0;
  font-weight: 700;
  letter-spacing: 0.2px;
}
h3 {
  margin: 0 0 10px 0;
  font-weight: 600;
}

/* Universal button upgrade */
button, .btn-signup, .btn-light {
  position: relative;
  appearance: none;
  outline: none;
  border: 0;
  color: #0c1220;
  font-weight: 600;
  letter-spacing: 2px;
  border-radius: 5px;
  padding: 10px 14px;
  cursor: pointer;
  background: linear-gradient(120deg, #e9f2ff, #d9e7ff 40%, #e9f2ff);
  background-size: 220% 220%;
  transition: transform .15s ease, box-shadow .2s ease, background-position .35s ease, filter .2s ease;
  /* box-shadow: 0 6px 15px rgba(79, 156, 255, .18); */
  overflow: hidden;
  will-change: transform, box-shadow, background-position;
}

.btn-signup {
  color: #09121f;
  background-image: linear-gradient(120deg, #9fd4ff, #6ab3ff 45%, #9fd4ff);
  box-shadow: 0 8px 22px rgba(106, 179, 255, .26);
}

.btn-light {
  background-image: linear-gradient(120deg, #f6f7fb, #e9ebf4 45%, #f6f7fb);
  box-shadow: 0 6px 16px rgba(33, 44, 69, .18);
}

button:hover, .btn-signup:hover, .btn-light:hover {
  transform: translateY(-1px);
  background-position: 85% 15%;
  box-shadow: 0 14px 28px rgba(79, 156, 255, .28);
  filter: saturate(1.05);
}

button:active, .btn-signup:active, .btn-light:active {
  transform: translateY(0) scale(.98);
  box-shadow: 0 6px 14px rgba(79, 156, 255, .20);
}

/* Shine sweep on hover */
button::after, .btn-signup::after, .btn-light::after {
  content: "";
  position: absolute;
  inset: 0;
  background: linear-gradient(100deg, transparent 35%, rgba(255,255,255,.35) 48%, transparent 65%);
  transform: translateX(-130%);
  transition: transform .6s ease;
  pointer-events: none;
  mix-blend-mode: screen;
}
button:hover::after, .btn-signup:hover::after, .btn-light:hover::after {
  transform: translateX(130%);
}

/* Gentle attention pulse for "add" actions */
#btnAddUser, #btnAddDepartment {
  animation: floatPulse 3.2s ease-in-out infinite;
}
@keyframes floatPulse {
  0%, 100% { transform: translateY(0); box-shadow: 0 8px 22px rgba(106,179,255,.26); }
  50% { transform: translateY(-2px); box-shadow: 0 14px 30px rgba(106,179,255,.32); }
}

/* Danger styles (delete buttons in modals) */
#userDelete, #departmentDelete {
  background: linear-gradient(120deg, #ffb3bd, #ff8998 45%, #ffb3bd);
  color: #1a0f12 !important;
  box-shadow: 0 8px 22px rgba(255, 101, 118, .26);
}

/* Inputs */
input.form-styling, select.form-styling, textarea.form-styling, input[type="text"], input[type="password"], select {
  width: 100%;
  box-sizing: border-box;
  padding: 10px 12px;
  border-radius: 10px;
  background: rgba(255,255,255,0.08);
  border: 1px solid rgba(255,255,255,0.16);
  color: var(--text);
  outline: none;
  transition: border-color .2s ease, box-shadow .2s ease, background .2s ease;
}
input.form-styling::placeholder, textarea.form-styling::placeholder {
  color: var(--muted);
}
input.form-styling:focus, select.form-styling:focus, textarea.form-styling:focus,
input[type="text"]:focus, input[type="password"]:focus, select:focus {
  border-color: rgba(79,156,255,.65);
  box-shadow: 0 0 0 4px rgba(79,156,255,.18);
  background: rgba(255,255,255,0.12);
}

/* Стилі для випадаючих списків (select) */
select.form-styling, select {
  appearance: none;
  -webkit-appearance: none;
  -moz-appearance: none;
  background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23a9b6c7' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 12px center;
  background-size: 16px;
  padding-right: 40px;
  cursor: pointer;
}

/* Стилі для option елементів */
select.form-styling option, select option {
  background: rgba(15,22,34,0.95);
  color: var(--text);
  padding: 8px 12px;
  border: none;
}

select.form-styling option:hover, select option:hover {
  background: rgba(79,156,255,0.2);
}

select.form-styling option:checked, select option:checked {
  color: var(--text);
}

/* Спеціальні стилі для випадаючих списків техніків */
#technician_id, #taskTechFilter {
  background: rgba(15,22,34,0.8);
  backdrop-filter: blur(10px);
  border: 1px solid rgba(255,255,255,0.15);
}

#technician_id:focus, #taskTechFilter:focus {
  background: rgba(15,22,34,0.9);
  border-color: rgba(79,156,255,.65);
  box-shadow: 0 0 0 4px rgba(79,156,255,.18);
}

#technician_id option, #taskTechFilter option {
  background: rgba(15,22,34,0.98);
  color: #e7edf6;
  padding: 10px 12px;
}

#technician_id option:hover, #taskTechFilter option:hover {
  background: rgba(79,156,255,0.25);
}

#technician_id option:checked, #taskTechFilter option:checked {
  background: rgba(79,156,255,0.4);
  font-weight: 600;
}

/* Color input larger */
#colorRow input[type="color"], #userColor[type="color"] {
  -webkit-appearance: none;
  appearance: none;
  width: 44px;
  height: 28px;
  border: 1px solid rgba(255,255,255,.24);
  border-radius: 8px;
  background: transparent;
  padding: 0;
  cursor: pointer;
}
#colorRow input[type="color"]::-webkit-color-swatch {
  border: none;
  border-radius: 6px;
}
#colorRow input[type="color"]::-moz-color-swatch {
  border: none;
  border-radius: 6px;
}
.btnAddDepartmentStyle{
  margin-bottom: 15px;
}

/* Tables */
.styled-table {
  width: 100% !important;
  border-collapse: separate;
  border-spacing: 0;
  background: rgba(255,255,255,0.04);
  border: 1px solid var(--stroke);
  border-radius: 12px;
  overflow: hidden;
  box-shadow: var(--shadow-1);
}
.styled-table thead th {
  background: linear-gradient(180deg, rgba(255,255,255,0.10), rgba(255,255,255,0.06));
  color: var(--text);
  text-align: left;
  padding: 12px 12px;
  font-weight: 700;
  border-bottom: 1px solid var(--stroke);
}
.styled-table tbody td {
  padding: 10px 12px;
  color: var(--text);
  border-bottom: 1px solid rgba(255,255,255,0.06);
}
.styled-table tbody tr:nth-child(even) {
  background: rgba(255,255,255,0.03);
}
.styled-table tbody tr:hover {
  background: rgba(79,156,255,0.10);
  transition: background .25s ease;
}

/* Make tables scrollable on very small screens without breaking layout */
@media (max-width: 680px) {
  main {
    padding: 16px;
  }
  .styled-table {
    display: block;
    overflow-x: auto;
    white-space: nowrap;
  }
  button, .btn-signup, .btn-light {
    padding: 10px 12px;
    font-size: 14px;
  }
  input.form-styling, select.form-styling, textarea.form-styling {
    font-size: 14px;
  }
}

/* Modals: smooth fade + pop card */
.modal {
  /* overlay handled inline; add animation when visible */
  transition: opacity .25s ease;
}
.modal.hidden {
  opacity: 0;
}
.modal:not(.hidden) {
  opacity: 1;
  animation: overlayFade .25s ease both;
}
.modal > div {
  background: linear-gradient(180deg, rgba(15,22,34,.9), rgba(15,22,34,.86));
  border: 1px solid var(--stroke) !important;
  border-radius: 14px !important;
  box-shadow: var(--shadow-2);
  transform: translateY(6px) scale(.98);
  animation: popIn .22s ease-out forwards;
}
@keyframes overlayFade {
  from { background-color: rgba(0,0,0,.0); }
  to   { background-color: rgba(0,0,0,.4); }
}
@keyframes popIn {
  to { transform: translateY(0) scale(1); }
}

/* Labels arrangement in modals (vertical rhythm) */
#modalUser label, #modalDepartment label {
  display: grid;
  grid-template-columns: 1fr;
  gap: 6px;
  margin: 8px 0;
  color: var(--muted);
}

/* Tiny utility buttons */
.btn-mini {
  border-radius: 10px;
  padding: 4px 8px;
  font-weight: 600;
  background: linear-gradient(120deg, #f2f5ff, #e7ecff 45%, #f2f5ff);
  color: #0d1728;
  border: 1px solid rgba(79,156,255,.25);
  transition: transform .12s ease, box-shadow .2s ease;
}
.btn-mini:hover { transform: translateY(-1px); box-shadow: 0 6px 16px rgba(79,156,255,.25); }
.btn-mini:active { transform: translateY(0) scale(.98); }

/* Links in header menu on hover (subtle) */
.header__link-list a {
  transition: color .2s ease, text-shadow .2s ease;
}
.header__link-list a:hover {
  color: #cfe3ff;
  text-shadow: 0 0 10px rgba(111, 171, 255, .5);
}

/* Toast styling with smooth in/out */
#toast {
  background: rgba(23, 33, 49, .92) !important;
  color: var(--text) !important;
  border: 1px solid rgba(255,255,255,0.10);
  backdrop-filter: blur(8px);
  box-shadow: var(--shadow-1);
  border-radius: 10px !important;
  transition: opacity .25s ease, transform .25s ease, visibility .25s ease;
  transform: translateY(-6px);
  visibility: visible;
}
#toast.hidden {
  opacity: 0;
  transform: translateY(-12px);
  visibility: hidden;
}

/* Subtle divider replacements where needed */
hr, .divider {
  border: none;
  height: 1px;
  background: var(--stroke);
  margin: 10px 0;
}

/* Tables action column buttons alignment (last column empty header) */
.styled-table td:last-child {
  white-space: nowrap;
}

/* Make inline page gaps nicer without touching HTML */
main > div[style*="display:flex"][style*="gap"] {
  margin: 12px 0 !important;
}

/* Focus outlines accessible */
button:focus-visible, .btn-signup:focus-visible, .btn-light:focus-visible, .btn-mini:focus-visible,
input:focus-visible, select:focus-visible, textarea:focus-visible {
  outline: 0;
  box-shadow: 0 0 0 4px rgba(79,156,255,.22), inset 0 0 0 1px rgba(79,156,255,.35);
}

/* Table row transition for content changes */
.styled-table tbody tr {
  transition: background .2s ease, color .2s ease;
}

/* --- Mobile cards (originally for users.html) --- */
.cards-list { display: none; }

.user-card, .dept-card {
  background: linear-gradient(180deg, rgba(255,255,255,0.06), rgba(255,255,255,0.03));
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 12px;
  box-shadow: var(--shadow-1);
}

.user-card .uc-head {
  display: flex;
  justify-content: space-between;
  align-items: center;
  gap: 10px;
  margin-bottom: 8px;
}
.user-card .uc-title {
  font-weight: 700;
  color: var(--text);
}
.user-card .uc-role {
  display: inline-flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--muted);
  padding: 4px 8px;
  border: 1px solid rgba(255,255,255,0.12);
  border-radius: 999px;
  background: rgba(255,255,255,0.06);
}
.user-card .role-color {
  width: 10px;
  height: 10px;
  border-radius: 50%;
  display: inline-block;
  box-shadow: 0 0 0 2px rgba(255,255,255,0.12) inset;
}

.user-card .uc-body .uc-row {
  font-size: 14px;
  color: var(--text);
  opacity: .9;
  margin: 6px 0;
}

.user-card .uc-actions,
.dept-card .dc-actions {
  display: flex;
  justify-content: flex-end;
  margin-top: 8px;
}

.dept-card .dc-head {
  font-weight: 600;
  color: var(--text);
}

/* Mobile: hide tables, show cards */
@media (max-width: 680px) {
  .table-responsive,
  .styled-table {
    display: none !important;
  }
  .cards-list {
    display: grid;
    gap: 12px;
  }
}

/* Стилі для календарика (date picker) - темна тема */
input[type="date"] {
  background: rgba(15,22,34,0.9) !important;
  border: 1px solid rgba(255,255,255,0.2) !important;
  color: #e7edf6 !important;
  padding: 10px 12px;
  border-radius: 10px;
  font-size: 14px;
  cursor: pointer;
  backdrop-filter: blur(10px);
  color-scheme: dark !important; /* Форсуємо темну схему */
}

input[type="date"]:focus {
  background: rgba(15,22,34,0.95) !important;
  border-color: rgba(79,156,255,.65) !important;
  box-shadow: 0 0 0 4px rgba(79,156,255,.18) !important;
  outline: none;
}

/* Стилі для календарика WebKit (Chrome, Safari, Edge) */
input[type="date"]::-webkit-calendar-picker-indicator {
  background: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e7edf6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3e%3c/rect%3e%3cline x1='16' y1='2' x2='16' y2='6'%3e%3c/line%3e%3cline x1='8' y1='2' x2='8' y2='6'%3e%3c/line%3e%3cline x1='3' y1='10' x2='21' y2='10'%3e%3c/line%3e%3c/svg%3e") !important;
  background-size: 18px 18px;
  background-repeat: no-repeat;
  background-position: center;
  width: 24px;
  height: 24px;
  cursor: pointer;
  filter: brightness(1);
  opacity: 0.9;
}

input[type="date"]::-webkit-calendar-picker-indicator:hover {
  filter: brightness(1.3);
  opacity: 1;
}

/* Стилі для внутрішнього календарика WebKit */
input[type="date"]::-webkit-datetime-edit {
  color: #e7edf6 !important;
  background: transparent !important;
}

input[type="date"]::-webkit-datetime-edit-fields-wrapper {
  background: transparent !important;
  color: #e7edf6 !important;
}

input[type="date"]::-webkit-datetime-edit-text {
  color: #a9b6c7 !important;
}

input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
  color: #e7edf6 !important;
  background: transparent !important;
  padding: 2px 4px;
  border-radius: 4px;
}

input[type="date"]::-webkit-datetime-edit-month-field:focus,
input[type="date"]::-webkit-datetime-edit-day-field:focus,
input[type="date"]::-webkit-datetime-edit-year-field:focus {
  background: rgba(79,156,255,0.3) !important;
  color: #ffffff !important;
  outline: none;
}

/* Додаткові стилі для Firefox */
input[type="date"]::-moz-calendar-picker-indicator {
  background: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='%23e7edf6' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3crect x='3' y='4' width='18' height='18' rx='2' ry='2'%3e%3c/rect%3e%3cline x1='16' y1='2' x2='16' y2='6'%3e%3c/line%3e%3cline x1='8' y1='2' x2='8' y2='6'%3e%3c/line%3e%3cline x1='3' y1='10' x2='21' y2='10'%3e%3c/line%3e%3c/svg%3e") !important;
  background-size: 18px 18px;
  width: 24px;
  height: 24px;
}

/* Глобальна темна схема для календарика */
input[type="date"] {
  filter: invert(1) hue-rotate(180deg) brightness(0.8) contrast(1.2);
}

/* Компенсуємо інверсію тексту */
input[type="date"]::-webkit-datetime-edit,
input[type="date"]::-webkit-datetime-edit-fields-wrapper,
input[type="date"]::-webkit-datetime-edit-text,
input[type="date"]::-webkit-datetime-edit-month-field,
input[type="date"]::-webkit-datetime-edit-day-field,
input[type="date"]::-webkit-datetime-edit-year-field {
  filter: invert(1) hue-rotate(180deg) !important;
}

/* Стилі для каунтерів об'єктів */
.objects-counters {
  display: flex;
  gap: 16px;
  align-items: center;
  margin-left: auto;
  padding: 0 12px;
  flex-shrink: 0;
  min-width: fit-content;
}

.counter-item {
  display: flex;
  align-items: center;
  gap: 8px;
  background: linear-gradient(135deg, rgba(255,255,255,0.08), rgba(255,255,255,0.04));
  border: 1px solid var(--stroke);
  border-radius: 12px;
  padding: 8px 12px;
  backdrop-filter: blur(10px);
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
  transition: all 0.3s ease;
  position: relative;
  overflow: hidden;
  white-space: nowrap;
  min-width: fit-content;
  flex-shrink: 0;
}

.counter-item::before {
  content: '';
  position: absolute;
  top: 0;
  left: -100%;
  width: 100%;
  height: 100%;
  background: linear-gradient(90deg, transparent, rgba(255,255,255,0.1), transparent);
  transition: left 0.5s ease;
}

.counter-item:hover {
  background: linear-gradient(135deg, rgba(255,255,255,0.12), rgba(255,255,255,0.06));
  border-color: rgba(79,156,255,0.4);
  box-shadow: 0 6px 20px rgba(79,156,255,0.2);
  transform: translateY(-1px);
}

.counter-item:hover::before {
  left: 100%;
}

.counter-item span:first-child {
  color: var(--muted);
  font-size: 13px;
  font-weight: 500;
  letter-spacing: 0.3px;
  white-space: nowrap;
  flex-shrink: 0;
}

.counter-item span:last-child {
  color: var(--text);
  font-size: 16px;
  font-weight: 700;
  min-width: 24px;
  text-align: center;
  background: linear-gradient(135deg, var(--accent), var(--accent-2));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
  text-shadow: 0 0 20px rgba(79,156,255,0.3);
  white-space: nowrap;
  flex-shrink: 0;
}

/* Спеціальні стилі для різних типів каунтерів */
.counter-item:has(#activeObjectsCount) span:last-child {
  background: linear-gradient(135deg, var(--success), var(--accent-3));
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.counter-item:has(#suspendedObjectsCount) span:last-child {
  background: linear-gradient(135deg, var(--warning), #ff9f43);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

/* Стилі для search-wrapper щоб правильно розташувати каунтери */
.search-wrapper {
  display: flex !important;
  align-items: center;
  gap: 4px;
  margin-left: 12px;
  flex: 1;
  min-width: 0;
}

.search-wrapper input {
  flex: 1;
  min-width: 200px;
}

/* Адаптивність для мобільних пристроїв */
@media (max-width: 768px) {
  .search-wrapper {
    flex-direction: column;
    align-items: stretch;
    gap: 8px;
  }
  
  .objects-counters {
    flex-direction: column;
    gap: 8px;
    margin-left: 0;
    margin-top: 12px;
    padding: 0;
    width: 100%;
  }
  
  .counter-item {
    width: 100%;
    justify-content: space-between;
    padding: 10px 14px;
  }
  
  .counter-item span:first-child {
    font-size: 14px;
  }
  
  .counter-item span:last-child {
    font-size: 18px;
  }
}

@media (max-width: 480px) {
  .objects-counters {
    gap: 6px;
  }
  
  .counter-item {
    padding: 8px 12px;
    border-radius: 10px;
  }
  
  .counter-item span:first-child {
    font-size: 13px;
  }
  
  .counter-item span:last-child {
    font-size: 16px;
  }
}
