/* 
 * Стили для админ-панели HVAC Solutions
 * На основе SB Admin Bootstrap Theme
 */

/* ========== Layout ========== */
#wrapper {
  display: flex;
}

#content-wrapper {
  background-color: #f8f9fc;
  width: 100%;
  overflow-x: hidden;
}

#content {
  flex: 1 0 auto;
}

.container-fluid {
  padding-left: 1.5rem;
  padding-right: 1.5rem;
}

/* ========== Sidebar ========== */
.sidebar {
  width: 14rem;
  min-height: 100vh;
}

.sidebar .nav-item {
  position: relative;
}

.sidebar .nav-item:last-child {
  margin-bottom: 1rem;
}

.sidebar .nav-link {
  text-align: left;
  padding: 1rem;
  width: 14rem;
  color: rgba(255, 255, 255, 0.8);
}

.sidebar .nav-link i {
  font-size: 0.85rem;
  margin-right: 0.5rem;
}

.sidebar .nav-link:hover {
  color: #fff;
  background-color: rgba(255, 255, 255, 0.1);
}

.sidebar .nav-item.active .nav-link {
  color: #fff;
  font-weight: 600;
  background-color: rgba(255, 255, 255, 0.15);
}

/* Sidebar Brand */
.sidebar-brand {
  height: 4.375rem;
  text-decoration: none;
  font-size: 1rem;
  font-weight: 800;
  padding: 1.5rem 1rem;
  text-align: center;
  text-transform: uppercase;
  letter-spacing: 0.05rem;
  z-index: 1;
  color: #fff !important;
}

.sidebar-brand-icon i {
  font-size: 2rem;
}

.sidebar-brand-text {
  display: inline;
}

/* Sidebar Heading */
.sidebar-heading {
  text-align: center;
  padding: 0 1rem;
  font-weight: 800;
  font-size: 0.65rem;
  color: rgba(255, 255, 255, 0.4);
  text-transform: uppercase;
  letter-spacing: 0.05rem;
}

/* Sidebar Divider */
.sidebar-divider {
  border-top: 1px solid rgba(255, 255, 255, 0.15);
  margin: 0 1rem 1rem;
}

/* Sidebar Toggle */
#sidebarToggle {
  width: 2.5rem;
  height: 2.5rem;
  text-align: center;
  margin-bottom: 1rem;
  cursor: pointer;
  background-color: rgba(255, 255, 255, 0.2);
}

#sidebarToggle:hover {
  background-color: rgba(255, 255, 255, 0.25);
}

#sidebarToggle::after {
  font-weight: 900;
  content: '\f104';
  font-family: 'Font Awesome 5 Free';
  margin-right: 0.1rem;
}

#sidebarToggle:hover::after {
  content: '\f104';
}

/* Sidebar Toggled State */
.sidebar.toggled {
  overflow: hidden;
}

/* Desktop: collapse sidebar */
@media (min-width: 768px) {
  .sidebar.toggled {
    width: 6.5rem !important;
  }

  .sidebar.toggled .sidebar-brand-text {
    display: none;
  }

  .sidebar.toggled .nav-link span {
    display: none;
  }
}

/* Mobile: hide sidebar by default, show when NOT toggled */
@media (max-width: 767px) {
  .sidebar {
    width: 14rem !important;
    position: fixed;
    top: 0;
    left: -14rem;
    height: 100vh;
    z-index: 1000;
    transition: left 0.3s ease;
  }
  
  /* Show sidebar when body has sidebar-toggled class */
  body.sidebar-toggled .sidebar {
    left: 0;
  }
  
  /* Overlay when sidebar is open */
  body.sidebar-toggled::before {
    content: '';
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.5);
    z-index: 999;
  }

  #content-wrapper {
    margin-left: 0;
  }
}

/* ========== Topbar ========== */
.topbar {
  height: 4.375rem;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.topbar .navbar-nav {
  display: flex;
  flex-direction: row;
  align-items: center;
}

.topbar .navbar-nav .nav-item {
  list-style: none;
}

.topbar .navbar-nav .nav-item .nav-link {
  height: 4.375rem;
  display: flex;
  align-items: center;
  padding: 0 0.75rem;
  color: #858796;
  text-decoration: none;
}

.topbar .navbar-nav .nav-item .nav-link:hover {
  color: #5a5c69;
}

.topbar .navbar-nav .nav-item .nav-link:focus {
  outline: none;
}

.topbar .navbar-nav .nav-item .dropdown-menu {
  border: none;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.topbar-divider {
  width: 0;
  border-right: 1px solid #e3e6f0;
  height: calc(4.375rem - 2rem);
  margin: auto 1rem;
}

.text-gray-600 {
  color: #858796 !important;
}

.small {
  font-size: 0.875rem;
  font-weight: 400;
}

/* ========== Cards ========== */
.card {
  border: none;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
}

.card .card-header {
  background-color: #f8f9fc;
  border-bottom: 1px solid #e3e6f0;
}

/* Stats Cards */
.card-stats {
  border-left: 4px solid;
}

.card-stats.border-primary {
  border-left-color: #4e73df;
}

.card-stats.border-success {
  border-left-color: #1cc88a;
}

.card-stats.border-info {
  border-left-color: #36b9cc;
}

.card-stats.border-warning {
  border-left-color: #f6c23e;
}

/* ========== Tables ========== */
.table {
  font-size: 0.875rem;
  margin-bottom: 0;
}

.table thead {
  background-color: #f8f9fc;
}

.table thead th {
  border-bottom: 2px solid #e3e6f0;
  font-weight: 600;
  text-transform: uppercase;
  font-size: 0.75rem;
  color: #858796;
  padding: 1rem 0.75rem;
  vertical-align: middle;
}

.table tbody tr {
  transition: all 0.2s ease;
}

.table tbody tr:hover {
  background-color: #f8f9fc;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(0,0,0,0.05);
}

.table tbody td {
  padding: 1rem 0.75rem;
  vertical-align: middle;
  border-bottom: 1px solid #e3e6f0;
}

.table .drag-handle {
  cursor: move;
  opacity: 0.5;
  transition: opacity 0.2s;
}

.table tr:hover .drag-handle {
  opacity: 1;
}

/* Table striping */
.table-striped tbody tr:nth-of-type(odd) {
  background-color: rgba(0, 0, 0, 0.02);
}

/* Improved badges in table */
.table .badge {
  font-size: 0.8rem;
  font-weight: 600;
  padding: 0.5rem 0.75rem;
  border-radius: 0.5rem;
}

/* Better button groups */
.btn-group-sm > .btn {
  padding: 0.4rem 0.6rem;
  font-size: 0.875rem;
}

.btn-group .btn {
  border-radius: 0.35rem !important;
  margin: 0 2px;
}

.btn-group .btn i {
  font-size: 1rem;
}

/* ========== Buttons ========== */
.btn {
  font-size: 0.875rem;
  border-radius: 0.35rem;
}

.btn-sm {
  font-size: 0.75rem;
}

.btn-icon-split {
  padding: 0;
  overflow: hidden;
  display: inline-flex;
  align-items: stretch;
  justify-content: center;
}

.btn-icon-split .icon {
  background: rgba(0, 0, 0, 0.15);
  display: inline-block;
  padding: 0.5rem 0.75rem;
}

.btn-icon-split .text {
  display: inline-block;
  padding: 0.5rem 1rem;
}

/* ========== Footer ========== */
.sticky-footer {
  padding: 2rem 0;
  flex-shrink: 0;
}

/* ========== Scroll to Top Button ========== */
.scroll-to-top {
  position: fixed;
  right: 1rem;
  bottom: 1rem;
  display: none;
  width: 2.75rem;
  height: 2.75rem;
  text-align: center;
  color: #fff;
  background: rgba(90, 92, 105, 0.5);
  line-height: 46px;
}

.scroll-to-top:focus,
.scroll-to-top:hover {
  color: white;
}

.scroll-to-top:hover {
  background: #5a5c69;
}

.scroll-to-top i {
  font-weight: 800;
}

/* ========== Bootstrap Gradient ========== */
.bg-gradient-primary {
  background-color: #4e73df;
  background-image: linear-gradient(180deg, #4e73df 10%, #224abe 100%);
  background-size: cover;
}

.bg-gradient-secondary {
  background-color: #858796;
  background-image: linear-gradient(180deg, #858796 10%, #60616f 100%);
  background-size: cover;
}

.bg-gradient-success {
  background-color: #1cc88a;
  background-image: linear-gradient(180deg, #1cc88a 10%, #13855c 100%);
  background-size: cover;
}

.bg-gradient-info {
  background-color: #36b9cc;
  background-image: linear-gradient(180deg, #36b9cc 10%, #258391 100%);
  background-size: cover;
}

.bg-gradient-warning {
  background-color: #f6c23e;
  background-image: linear-gradient(180deg, #f6c23e 10%, #dda20a 100%);
  background-size: cover;
}

.bg-gradient-danger {
  background-color: #e74a3b;
  background-image: linear-gradient(180deg, #e74a3b 10%, #be2617 100%);
  background-size: cover;
}

/* ========== Responsive ========== */
@media (max-width: 767px) {
  /* Mobile styles handled above in Sidebar Toggled State section */
  
  /* Services Table Mobile Styles */
  #servicesTable thead {
    display: none;
  }
  
  #servicesTable tbody {
    display: block;
  }
  
  #servicesTable tbody tr {
    display: flex;
    flex-direction: column;
    background: white;
    border-radius: 8px;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    margin-bottom: 15px;
    padding: 15px;
    border: 1px solid #e3e6f0;
  }
  
  #servicesTable tbody tr:hover {
    background: white;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
  }
  
  #servicesTable tbody td {
    display: block;
    padding: 8px 0;
    border: none;
    text-align: left !important;
  }
  
  /* Скрываем drag handle на мобильных */
  #servicesTable tbody td:first-child {
    display: none;
  }
  
  /* Заголовок и описание - сверху */
  #servicesTable tbody td:nth-child(2) {
    order: 1;
    padding-bottom: 12px;
    border-bottom: 1px solid #e3e6f0;
    margin-bottom: 12px;
  }
  
  #servicesTable tbody td:nth-child(2) strong {
    display: block;
    font-size: 1.1rem;
    margin-bottom: 6px;
  }
  
  #servicesTable tbody td:nth-child(2) small {
    display: block;
    font-size: 0.9rem;
    line-height: 1.4;
  }
  
  /* Категория - внизу, в самом конце */
  #servicesTable tbody td:nth-child(3) {
    order: 5;
    margin-top: 12px;
    padding-top: 12px;
    border-top: 2px solid #e3e6f0;
  }
  
  #servicesTable tbody td:nth-child(3) .badge {
    display: inline-block;
    margin-top: 4px;
  }
  
  /* Цена - после заголовка */
  #servicesTable tbody td:nth-child(4) {
    order: 2;
    text-align: left !important;
    padding: 8px 0;
  }
  
  #servicesTable tbody td:nth-child(4) .d-flex {
    flex-direction: row;
    align-items: baseline;
    gap: 6px;
  }
  
  /* Позиция - после цены */
  #servicesTable tbody td:nth-child(5) {
    order: 3;
    display: inline-block;
    padding: 4px 0;
    margin-right: 12px;
  }
  
  /* Действия - после позиции */
  #servicesTable tbody td:nth-child(6) {
    order: 4;
    text-align: left !important;
    padding-top: 12px;
    margin-top: 12px;
    border-top: 1px solid #e3e6f0;
  }
  
  #servicesTable tbody td:nth-child(6) .btn-group {
    width: 100%;
    display: flex;
    justify-content: flex-start;
  }
  
  #servicesTable tbody td:nth-child(6) .btn {
    flex: 0 0 auto;
  }
}

/* ========== Animations ========== */
.animated--grow-in {
  animation-name: growIn;
  animation-duration: 200ms;
  animation-timing-function: transform cubic-bezier(0.18, 1.25, 0.4, 1), opacity cubic-bezier(0, 1, 0.4, 1);
}

@keyframes growIn {
  0% {
    transform: scale(0.9);
    opacity: 0;
  }
  100% {
    transform: scale(1);
    opacity: 1;
  }
}

/* ========== Page Header ========== */
.page-header {
  margin-bottom: 1.5rem;
}

.page-header h1 {
  font-size: 1.75rem;
  font-weight: 600;
  color: #5a5c69;
  margin-bottom: 0;
}

.page-header .breadcrumb {
  background-color: transparent;
  padding: 0;
  margin-bottom: 0;
}

/* ========== Search and Filters ========== */
.search-filter-section {
  background: white;
  padding: 1.25rem;
  border-radius: 0.35rem;
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15);
  margin-bottom: 1.5rem;
}

/* ========== Badges ========== */
.badge {
  font-size: 0.75rem;
  font-weight: 700;
  padding: 0.375rem 0.5rem;
}

/* ========== Alerts ========== */
.alert {
  border: none;
  border-left: 4px solid;
}

.alert-success {
  border-left-color: #1cc88a;
  background-color: #d4edda;
  color: #0f6848;
}

.alert-danger {
  border-left-color: #e74a3b;
  background-color: #f8d7da;
  color: #721c24;
}

.alert-warning {
  border-left-color: #f6c23e;
  background-color: #fff3cd;
  color: #856404;
}

.alert-info {
  border-left-color: #36b9cc;
  background-color: #d1ecf1;
  color: #0c5460;
}

/* ========== Additional Utility Classes ========== */
.text-gray-800 {
  color: #5a5c69 !important;
}

.text-gray-600 {
  color: #858796 !important;
}

.text-gray-400 {
  color: #d1d3e2 !important;
}

.text-gray-300 {
  color: #dddfeb !important;
}

.text-primary {
  color: #4e73df !important;
}

.text-success {
  color: #1cc88a !important;
}

.text-info {
  color: #36b9cc !important;
}

.text-warning {
  color: #f6c23e !important;
}

.text-danger {
  color: #e74a3b !important;
}

.font-weight-bold {
  font-weight: 700 !important;
}

.text-uppercase {
  text-transform: uppercase !important;
}

.text-xs {
  font-size: 0.7rem !important;
}

.shadow {
  box-shadow: 0 0.15rem 1.75rem 0 rgba(58, 59, 69, 0.15) !important;
}

.shadow-sm {
  box-shadow: 0 0.125rem 0.25rem 0 rgba(58, 59, 69, 0.2) !important;
}

.h-100 {
  height: 100% !important;
}

.py-2 {
  padding-top: 0.5rem !important;
  padding-bottom: 0.5rem !important;
}

.py-3 {
  padding-top: 1rem !important;
  padding-bottom: 1rem !important;
}

.mb-0 {
  margin-bottom: 0 !important;
}

.mb-1 {
  margin-bottom: 0.25rem !important;
}

.mb-2 {
  margin-bottom: 0.5rem !important;
}

.mb-3 {
  margin-bottom: 1rem !important;
}

.mb-4 {
  margin-bottom: 1.5rem !important;
}

.me-1 {
  margin-right: 0.25rem !important;
}

.me-2 {
  margin-right: 0.5rem !important;
}

.mr-2 {
  margin-right: 0.5rem !important;
}

.ms-auto {
  margin-left: auto !important;
}

.border-left-primary {
  border-left: 0.25rem solid #4e73df !important;
}

.border-left-success {
  border-left: 0.25rem solid #1cc88a !important;
}

.border-left-info {
  border-left: 0.25rem solid #36b9cc !important;
}

.border-left-warning {
  border-left: 0.25rem solid #f6c23e !important;
}

/* ========== Form Check Group ========== */
.form-check-group {
  display: flex;
  flex-wrap: wrap;
  gap: 1rem;
  padding: 0.75rem;
  border: 1px solid #dee2e6;
  border-radius: 0.375rem;
  background-color: #f8f9fa;
}

.form-check-group .form-check {
  margin-bottom: 0;
}

/* ========== Form Styles ========== */
.detail-group {
  margin-bottom: 1.5rem;
  position: relative;
}

.detail-group .form-label {
  font-weight: 600;
  color: #5a5c69;
  margin-bottom: 0.5rem;
  font-size: 0.875rem;
  display: block;
}

.detail-group .form-label-wrapper {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.detail-group .form-label-wrapper .form-label {
  margin-bottom: 0;
  flex: 1;
}

.detail-group .form-label-wrapper .btn {
  margin-left: 0.5rem;
  white-space: nowrap;
  font-size: 0.75rem;
  padding: 0.375rem 0.75rem;
}

.detail-group .form-control,
.detail-group .form-select {
  border: 1px solid #d1d3e2;
  border-radius: 0.35rem;
  padding: 0.625rem 0.75rem;
  font-size: 0.875rem;
  transition: all 0.15s ease-in-out;
  background-color: #fff;
}

.detail-group .form-control:focus,
.detail-group .form-select:focus {
  border-color: #4e73df;
  box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
  outline: 0;
  background-color: #fff;
}

.detail-group .form-control-lg {
  padding: 0.75rem 1rem;
  font-size: 0.9375rem;
}

.detail-group .form-control-select {
  cursor: pointer;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
  padding-right: 2.5rem;
  appearance: none;
}

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

.detail-group .invalid-feedback {
  display: block;
  width: 100%;
  margin-top: 0.25rem;
  font-size: 0.875rem;
  color: #e74a3b;
}

.detail-group .form-text {
  margin-top: 0.25rem;
  font-size: 0.75rem;
  color: #858796;
}

/* Улучшенный стиль для блока с кнопкой создания */
.detail-group .form-label-with-action {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 0.5rem;
}

.detail-group .form-label-with-action .form-label {
  margin-bottom: 0;
  flex: 1;
}

.detail-group .form-label-with-action .btn-sm {
  font-size: 0.75rem;
  padding: 0.25rem 0.5rem;
  line-height: 1.5;
  border-radius: 0.25rem;
  font-weight: 500;
  transition: all 0.15s ease-in-out;
}

.detail-group .form-label-with-action .btn-outline-primary {
  border-color: #4e73df;
  color: #4e73df;
}

.detail-group .form-label-with-action .btn-outline-primary:hover {
  background-color: #4e73df;
  border-color: #4e73df;
  color: #fff;
  transform: translateY(-1px);
  box-shadow: 0 2px 4px rgba(78, 115, 223, 0.2);
}

.detail-group .form-label-with-action .btn-outline-primary:active {
  transform: translateY(0);
  box-shadow: 0 1px 2px rgba(78, 115, 223, 0.2);
}

/* Улучшенный стиль для select */
.detail-group select.form-control-select {
  background-color: #fff;
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
  background-repeat: no-repeat;
  background-position: right 0.75rem center;
  background-size: 16px 12px;
}

.detail-group select.form-control-select:focus {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%234e73df' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='M2 5l6 6 6-6'/%3e%3c/svg%3e");
}

/* Стили для формы действий */
.form-actions {
  margin-top: 2rem;
  padding-top: 1.5rem;
  border-top: 1px solid #e3e6f0;
  display: flex;
  gap: 0.75rem;
  justify-content: flex-start;
  align-items: center;
}

.form-actions .btn {
  min-width: 120px;
}

/* Улучшенные стили для карточек форм */
.card .card-body {
  padding: 1.5rem;
}

.card .card-body .row {
  margin-left: -0.75rem;
  margin-right: -0.75rem;
}

.card .card-body .row > [class*="col-"] {
  padding-left: 0.75rem;
  padding-right: 0.75rem;
}

/* Визуальное разделение секций формы */
.detail-group:not(:last-child) {
  border-bottom: 1px solid #f0f0f0;
  padding-bottom: 1.25rem;
}

.detail-group:last-child {
  margin-bottom: 0;
}

/* Улучшенный стиль для input групп */
.input-group {
  position: relative;
  display: flex;
  flex-wrap: wrap;
  align-items: stretch;
  width: 100%;
}

.input-group .form-control {
  position: relative;
  flex: 1 1 auto;
  width: 1%;
  min-width: 0;
}

/* Стили для файлов */
.detail-group input[type="file"] {
  padding: 0.5rem;
  border: 1px dashed #d1d3e2;
  border-radius: 0.35rem;
  background-color: #f8f9fc;
  transition: all 0.15s ease-in-out;
}

.detail-group input[type="file"]:hover {
  border-color: #4e73df;
  background-color: #f0f4ff;
}

.detail-group input[type="file"]:focus {
  border-color: #4e73df;
  box-shadow: 0 0 0 0.2rem rgba(78, 115, 223, 0.25);
  outline: 0;
}

/* Стили для списка файлов в форме */
.list-group {
  margin-top: 0.75rem;
  border-radius: 0.35rem;
  overflow: hidden;
}

.list-group-item {
  padding: 0.75rem 1rem;
  background-color: #fff;
  border: 1px solid #e3e6f0;
  display: flex;
  justify-content: space-between;
  align-items: center;
  transition: all 0.15s ease-in-out;
}

.list-group-item:not(:last-child) {
  border-bottom: none;
}

.list-group-item:hover {
  background-color: #f8f9fc;
  border-color: #d1d3e2;
}

.list-group-item .btn-outline-danger {
  border-color: #e74a3b;
  color: #e74a3b;
}

.list-group-item .btn-outline-danger:hover {
  background-color: #e74a3b;
  border-color: #e74a3b;
  color: #fff;
}

/* Адаптивность для форм */
@media (max-width: 767px) {
  .detail-group {
    margin-bottom: 1.25rem;
  }
  
  .detail-group:not(:last-child) {
    padding-bottom: 1rem;
  }
  
  .detail-group .form-label-with-action {
    flex-direction: column;
    align-items: flex-start;
    gap: 0.5rem;
  }
  
  .detail-group .form-label-with-action .btn-sm {
    width: 100%;
    justify-content: center;
  }
  
  .form-actions {
    flex-direction: column;
  }
  
  .form-actions .btn {
    width: 100%;
  }
  
  .card .card-body {
    padding: 1rem;
  }
}
