/* ========================================
   TaskSnap - Modern Professional Styles
   ======================================== */

:root {
  --ts-primary: #dc3545;
  --ts-primary-dark: #b02a37;
  --ts-primary-light: #f8d7da;
  --ts-secondary: #6c757d;
  --ts-success: #198754;
  --ts-warning: #ffc107;
  --ts-info: #0dcaf0;
  --ts-dark: #212529;
  --ts-light: #f8f9fa;
  --ts-white: #ffffff;
  --ts-shadow: 0 2px 8px rgba(0,0,0,0.08);
  --ts-shadow-lg: 0 8px 24px rgba(0,0,0,0.12);
  --ts-radius: 12px;
  --ts-radius-sm: 8px;
  --ts-transition: all 0.2s ease;
}

/* ========================================
   Base Styles
   ======================================== */

body {
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, 'Helvetica Neue', Arial, sans-serif;
  background: linear-gradient(135deg, #f5f7fa 0%, #e4e8ec 100%);
  min-height: 100vh;
  display: flex;
  flex-direction: column;
}

.main-content {
  flex: 1;
}

/* ========================================
   Navbar
   ======================================== */

.bg-gradient-primary {
  background: linear-gradient(135deg, var(--ts-primary) 0%, var(--ts-primary-dark) 100%);
  box-shadow: var(--ts-shadow-lg);
}

.navbar {
  padding: 0.75rem 0;
}

.brand-icon {
  width: 36px;
  height: 36px;
  background: rgba(255,255,255,0.2);
  border-radius: var(--ts-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
}

.brand-container {
  background: var(--ts-white);
  padding: 0.4rem 1rem 0.4rem 0.5rem;
  border-radius: var(--ts-radius);
  text-decoration: none !important;
}

.brand-container:hover {
  background: #f8f9fa;
}

.brand-logo {
  height: 42px;
  width: auto;
  border-radius: var(--ts-radius-sm);
}

.navbar-brand {
  font-size: 1.25rem;
}

.nav-link {
  padding: 0.5rem 1rem !important;
  border-radius: var(--ts-radius-sm);
  transition: var(--ts-transition);
  font-weight: 600;
  font-size: 0.9rem;
  background: rgba(255,255,255,0.2);
  margin: 0 3px;
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.nav-link:hover {
  background: rgba(255,255,255,0.35);
  color: #ffffff !important;
}

.navbar-nav .dropdown-toggle::after {
  opacity: 0.9;
}

.navbar-brand {
  color: #ffffff !important;
  text-shadow: 0 1px 2px rgba(0,0,0,0.2);
}

.user-badge {
  background: rgba(255,255,255,0.1);
  border-radius: 50px;
  padding: 0.4rem 1rem !important;
}

.dropdown-menu {
  border: none;
  box-shadow: var(--ts-shadow-lg);
  border-radius: var(--ts-radius);
  padding: 0.5rem;
}

.dropdown-item {
  border-radius: var(--ts-radius-sm);
  padding: 0.6rem 1rem;
  font-weight: 500;
}

.dropdown-item:hover {
  background: var(--ts-light);
}

/* ========================================
   Cards
   ======================================== */

.card {
  border: none;
  border-radius: var(--ts-radius);
  box-shadow: var(--ts-shadow);
  transition: var(--ts-transition);
  overflow: hidden;
}

.card:hover {
  box-shadow: var(--ts-shadow-lg);
}

.card-header {
  background: var(--ts-white);
  border-bottom: 1px solid rgba(0,0,0,0.05);
  font-weight: 600;
  padding: 1rem 1.25rem;
}

.card-body {
  padding: 1.25rem;
}

.card-footer {
  background: var(--ts-light);
  border-top: 1px solid rgba(0,0,0,0.05);
}

/* ========================================
   Buttons
   ======================================== */

.btn {
  font-weight: 500;
  border-radius: var(--ts-radius-sm);
  padding: 0.5rem 1rem;
  transition: var(--ts-transition);
}

.btn-primary {
  background: var(--ts-primary);
  border-color: var(--ts-primary);
}

.btn-primary:hover {
  background: var(--ts-primary-dark);
  border-color: var(--ts-primary-dark);
  transform: translateY(-1px);
}

.btn-success {
  background: var(--ts-success);
  border-color: var(--ts-success);
}

.btn-success:hover {
  transform: translateY(-1px);
}

.btn-outline-primary {
  color: var(--ts-primary);
  border-color: var(--ts-primary);
}

.btn-outline-primary:hover {
  background: var(--ts-primary);
  border-color: var(--ts-primary);
}

.btn-outline-secondary:hover {
  transform: translateY(-1px);
}

/* ========================================
   Forms
   ======================================== */

.form-control, .form-select {
  border-radius: var(--ts-radius-sm);
  border: 2px solid #e9ecef;
  padding: 0.6rem 1rem;
  transition: var(--ts-transition);
}

.form-control:focus, .form-select:focus {
  border-color: var(--ts-primary);
  box-shadow: 0 0 0 3px rgba(220, 53, 69, 0.15);
}

.form-label {
  font-weight: 600;
  color: var(--ts-dark);
  margin-bottom: 0.5rem;
}

.input-group .btn {
  border-radius: 0 var(--ts-radius-sm) var(--ts-radius-sm) 0;
}

.input-group .form-control {
  border-radius: var(--ts-radius-sm) 0 0 var(--ts-radius-sm);
}

/* ========================================
   Tables
   ======================================== */

.table {
  margin-bottom: 0;
}

.table thead th {
  background: var(--ts-light);
  font-weight: 600;
  font-size: 0.8rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  color: var(--ts-secondary);
  border-bottom: none;
  padding: 1rem;
}

.table tbody td {
  padding: 1rem;
  vertical-align: middle;
  border-color: #f1f3f4;
}

.table-hover tbody tr {
  transition: var(--ts-transition);
  cursor: pointer;
}

.table-hover tbody tr:hover {
  background: rgba(220, 53, 69, 0.03);
}

/* ========================================
   Badges
   ======================================== */

.badge {
  font-weight: 500;
  padding: 0.45em 0.8em;
  border-radius: 50px;
  font-size: 0.75rem;
}

.bg-success {
  background: linear-gradient(135deg, #198754 0%, #157347 100%) !important;
}

.bg-warning {
  background: linear-gradient(135deg, #ffc107 0%, #e0a800 100%) !important;
}

.bg-info {
  background: linear-gradient(135deg, #0dcaf0 0%, #0aa2c0 100%) !important;
}

.bg-danger {
  background: linear-gradient(135deg, var(--ts-primary) 0%, var(--ts-primary-dark) 100%) !important;
}

/* ========================================
   Alerts
   ======================================== */

.alert {
  border: none;
  border-radius: var(--ts-radius);
  padding: 1rem 1.25rem;
  font-weight: 500;
}

.alert-success {
  background: linear-gradient(135deg, rgba(25, 135, 84, 0.1) 0%, rgba(25, 135, 84, 0.05) 100%);
  color: #0f5132;
}

.alert-danger {
  background: linear-gradient(135deg, rgba(220, 53, 69, 0.1) 0%, rgba(220, 53, 69, 0.05) 100%);
  color: #842029;
}

.alert-info {
  background: linear-gradient(135deg, rgba(13, 202, 240, 0.1) 0%, rgba(13, 202, 240, 0.05) 100%);
  color: #055160;
}

.alert-warning {
  background: linear-gradient(135deg, rgba(255, 193, 7, 0.15) 0%, rgba(255, 193, 7, 0.05) 100%);
  color: #664d03;
}

/* ========================================
   Stats Cards
   ======================================== */

.stat-card {
  background: var(--ts-white);
  border-radius: var(--ts-radius);
  padding: 1.5rem;
  text-align: center;
  box-shadow: var(--ts-shadow);
  transition: var(--ts-transition);
}

.stat-card:hover {
  transform: translateY(-2px);
  box-shadow: var(--ts-shadow-lg);
}

.stat-card .stat-icon {
  width: 56px;
  height: 56px;
  border-radius: var(--ts-radius);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.5rem;
  margin: 0 auto 1rem;
}

/* Иконки с контрастным фоном */
.stat-icon.bg-success, .bg-success.bg-opacity-10 {
  background: #d1f2eb !important;
  color: #0d6832 !important;
}

.stat-icon.bg-warning, .bg-warning.bg-opacity-10 {
  background: #fff3cd !important;
  color: #856404 !important;
}

.stat-icon.bg-primary, .bg-primary.bg-opacity-10 {
  background: #f8d7da !important;
  color: #a71d2a !important;
}

.stat-icon.bg-info, .bg-info.bg-opacity-10 {
  background: #d1ecf1 !important;
  color: #0c5460 !important;
}

.stat-icon.bg-danger, .bg-danger.bg-opacity-10 {
  background: #f8d7da !important;
  color: #a71d2a !important;
}

.stat-card .stat-value {
  font-size: 2rem;
  font-weight: 700;
  color: var(--ts-dark);
}

.stat-card .stat-label {
  color: var(--ts-secondary);
  font-size: 0.85rem;
  font-weight: 500;
}

/* ========================================
   Upload Area
   ======================================== */

.upload-area {
  border: 2px dashed #dee2e6;
  border-radius: var(--ts-radius);
  background: var(--ts-light);
  transition: var(--ts-transition);
  cursor: pointer;
}

.upload-area:hover, .upload-area.dragover {
  border-color: var(--ts-primary);
  background: rgba(220, 53, 69, 0.03);
}

.upload-area .upload-icon {
  width: 64px;
  height: 64px;
  background: linear-gradient(135deg, var(--ts-primary) 0%, var(--ts-primary-dark) 100%);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  color: var(--ts-white);
  font-size: 1.5rem;
}

/* ========================================
   Photo Grid
   ======================================== */

.photo-grid {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(120px, 1fr));
  gap: 0.75rem;
}

.photo-item {
  position: relative;
  aspect-ratio: 1;
  border-radius: var(--ts-radius-sm);
  overflow: hidden;
  box-shadow: var(--ts-shadow);
}

.photo-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: var(--ts-transition);
}

.photo-item:hover img {
  transform: scale(1.05);
}

.photo-item .delete-btn {
  position: absolute;
  top: 6px;
  right: 6px;
  width: 24px;
  height: 24px;
  border-radius: 50%;
  background: rgba(220, 53, 69, 0.9);
  border: none;
  color: white;
  font-size: 14px;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: var(--ts-transition);
}

.photo-item:hover .delete-btn {
  opacity: 1;
}

/* ========================================
   Search
   ======================================== */

.search-box {
  position: relative;
}

.search-suggestions {
  position: absolute;
  z-index: 1000;
  background: var(--ts-white);
  border-radius: var(--ts-radius);
  box-shadow: var(--ts-shadow-lg);
  max-height: 300px;
  overflow-y: auto;
  display: none;
  width: 100%;
  margin-top: 4px;
}

.search-suggestions .item {
  padding: 0.75rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f4;
  transition: var(--ts-transition);
}

.search-suggestions .item:last-child {
  border-bottom: none;
}

.search-suggestions .item:hover {
  background: var(--ts-light);
}

/* Address autocomplete */
.address-suggestions {
  position: absolute;
  z-index: 1000;
  background: var(--ts-white);
  border-radius: var(--ts-radius);
  box-shadow: var(--ts-shadow-lg);
  max-height: 200px;
  overflow-y: auto;
  display: none;
  width: 100%;
  margin-top: 4px;
}

.suggestion-item {
  padding: 0.65rem 1rem;
  cursor: pointer;
  border-bottom: 1px solid #f1f3f4;
  font-size: 0.9rem;
  transition: var(--ts-transition);
}

.suggestion-item:last-child {
  border-bottom: none;
}

.suggestion-item:hover {
  background: var(--ts-light);
}

/* ========================================
   Operations
   ======================================== */

.operation-row {
  background: var(--ts-light);
  padding: 0.75rem;
  border-radius: var(--ts-radius-sm);
  margin-bottom: 0.5rem;
}

.operation-list .operation-item {
  display: flex;
  justify-content: space-between;
  padding: 0.75rem 0;
  border-bottom: 1px solid #f1f3f4;
}

.operation-list .operation-item:last-child {
  border-bottom: none;
}

.operation-price {
  color: var(--ts-success);
  font-weight: 600;
}

.total-price {
  font-size: 1.25rem;
  font-weight: 700;
  color: var(--ts-success);
}

/* ========================================
   Quick Link Cards
   ======================================== */

.quick-link-card {
  transition: var(--ts-transition);
}

.quick-link-card:hover {
  transform: translateY(-2px);
}

.quick-link-icon {
  width: 48px;
  height: 48px;
  border-radius: var(--ts-radius-sm);
  display: flex;
  align-items: center;
  justify-content: center;
  font-size: 1.25rem;
  flex-shrink: 0;
}

/* ========================================
   Footer
   ======================================== */

.footer {
  background: var(--ts-white);
  border-top: 1px solid #e9ecef;
  margin-top: auto;
}

/* ========================================
   Page Headers
   ======================================== */

.page-header {
  margin-bottom: 1.5rem;
}

.page-title {
  font-size: 1.75rem;
  font-weight: 700;
  color: var(--ts-dark);
  margin: 0;
}

.page-subtitle {
  color: var(--ts-secondary);
  margin-top: 0.25rem;
}

/* ========================================
   Empty States
   ======================================== */

.empty-state {
  text-align: center;
  padding: 3rem 1rem;
}

.empty-state .empty-icon {
  width: 80px;
  height: 80px;
  background: var(--ts-light);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  margin: 0 auto 1rem;
  font-size: 2rem;
  color: var(--ts-secondary);
}

.empty-state .empty-title {
  font-weight: 600;
  color: var(--ts-dark);
  margin-bottom: 0.5rem;
}

.empty-state .empty-text {
  color: var(--ts-secondary);
}

/* ========================================
   Mobile Responsive
   ======================================== */

@media (max-width: 991.98px) {
  .navbar-collapse {
    background: rgba(0,0,0,0.15);
    border-radius: var(--ts-radius);
    margin-top: 1rem;
    padding: 1rem;
  }
  
  .navbar-nav {
    gap: 0.5rem;
  }
  
  .navbar-nav .nav-item {
    margin: 0;
  }
  
  .navbar-nav .nav-link {
    padding: 0.75rem 1rem !important;
    margin: 0 !important;
    border-radius: var(--ts-radius-sm);
  }
  
  .user-badge {
    margin: 0.5rem 0 !important;
    background: rgba(255,255,255,0.1);
    border-radius: var(--ts-radius-sm);
  }
  
  .navbar-nav .btn {
    width: 100%;
    margin-top: 0.25rem;
    padding: 0.6rem 1rem !important;
  }
  
  .navbar-nav.ms-auto {
    margin-top: 1rem;
    padding-top: 1rem;
    border-top: 1px solid rgba(255,255,255,0.1);
  }
}

@media (max-width: 767.98px) {
  .page-title {
    font-size: 1.5rem;
  }
  
  .stat-card {
    padding: 1rem;
  }
  
  .stat-card .stat-value {
    font-size: 1.5rem;
  }
  
  .stat-card .stat-icon {
    width: 48px;
    height: 48px;
    font-size: 1.25rem;
  }
  
  .card-header, .card-body {
    padding: 1rem;
  }
  
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
  
  .btn {
    padding: 0.5rem 0.75rem;
  }
  
  .d-flex.gap-2 {
    gap: 0.5rem !important;
  }

  /* Адаптивные таблицы - превращаем в карточки */
  .table-responsive {
    overflow: visible;
  }
  
  .table-mobile thead {
    display: none;
  }
  
  .table-mobile tbody {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
    padding: 0.75rem;
  }
  
  .table-mobile tbody tr {
    display: flex;
    flex-direction: column;
    background: var(--ts-light);
    border-radius: var(--ts-radius-sm);
    padding: 1rem;
    gap: 0.5rem;
    border: none !important;
  }
  
  .table-mobile tbody tr:hover {
    background: #e9ecef;
  }
  
  .table-mobile tbody td {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 0.25rem 0;
    border: none !important;
    font-size: 0.9rem;
  }
  
  .table-mobile tbody td::before {
    content: attr(data-label);
    font-weight: 600;
    color: var(--ts-secondary);
    font-size: 0.8rem;
    flex-shrink: 0;
    margin-right: 1rem;
  }
  
  .table-mobile tbody td:last-child {
    padding-top: 0.75rem;
    margin-top: 0.5rem;
    border-top: 1px solid #dee2e6 !important;
    justify-content: flex-end;
  }
  
  .table-mobile tbody td:last-child::before {
    display: none;
  }
  
  /* Скрываем некоторые колонки на мобильных */
  .table-mobile .hide-mobile {
    display: none !important;
  }
}

@media (max-width: 575.98px) {
  .container {
    padding-left: 1rem;
    padding-right: 1rem;
  }
  
  .photo-grid {
    grid-template-columns: repeat(3, 1fr);
  }
}

/* ========================================
   Utilities
   ======================================== */

.text-gradient {
  background: linear-gradient(135deg, var(--ts-primary) 0%, var(--ts-primary-dark) 100%);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.bg-gradient-light {
  background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
}

.rounded-lg {
  border-radius: var(--ts-radius) !important;
}

.shadow-hover {
  transition: var(--ts-transition);
}

.shadow-hover:hover {
  box-shadow: var(--ts-shadow-lg);
}

/* ========================================
   Photo Upload Progress
   ======================================== */

.upload-progress-item {
  display: flex;
  align-items: center;
  gap: 1rem;
  padding: 0.75rem;
  background: #f8f9fa;
  border-radius: var(--ts-radius-sm);
  margin-bottom: 0.75rem;
  animation: slideIn 0.3s ease;
}

.upload-progress-item.fade-out {
  animation: fadeOut 0.3s ease forwards;
}

@keyframes slideIn {
  from {
    opacity: 0;
    transform: translateY(-10px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes fadeOut {
  from {
    opacity: 1;
    transform: scale(1);
  }
  to {
    opacity: 0;
    transform: scale(0.95);
  }
}

.upload-progress-preview {
  width: 50px;
  height: 50px;
  border-radius: 6px;
  overflow: hidden;
  flex-shrink: 0;
}

.upload-progress-preview img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.upload-progress-info {
  flex: 1;
  min-width: 0;
}

.upload-progress-name {
  font-size: 0.85rem;
  font-weight: 500;
  margin-bottom: 0.5rem;
  white-space: nowrap;
  overflow: hidden;
  text-overflow: ellipsis;
}

.upload-progress-bar {
  height: 6px;
  background: #dee2e6;
  border-radius: 3px;
  overflow: hidden;
  margin-bottom: 0.25rem;
}

.upload-progress-fill {
  height: 100%;
  background: var(--ts-primary);
  border-radius: 3px;
  transition: width 0.2s ease;
}

.upload-progress-fill.bg-success {
  background: #28a745 !important;
}

.upload-progress-fill.bg-danger {
  background: #dc3545 !important;
}

.upload-progress-status {
  font-size: 0.75rem;
  color: var(--ts-secondary);
}

/* Photo grid animations */
.photo-item {
  transition: all 0.3s ease;
}

.photo-item.photo-new {
  opacity: 0;
  transform: scale(0.8);
}

.photo-item:not(.photo-new) {
  opacity: 1;
  transform: scale(1);
}

.photo-item.deleting {
  opacity: 0.5;
  pointer-events: none;
}

.photo-item.fade-out {
  opacity: 0;
  transform: scale(0.8);
}

/* Upload toast notifications */
.upload-toast {
  position: fixed;
  bottom: 20px;
  left: 50%;
  transform: translateX(-50%) translateY(100px);
  background: #333;
  color: white;
  padding: 0.75rem 1.5rem;
  border-radius: 8px;
  font-size: 0.9rem;
  z-index: 9999;
  opacity: 0;
  transition: all 0.3s ease;
  box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.upload-toast.error {
  background: #dc3545;
}

.upload-toast.show {
  opacity: 1;
  transform: translateX(-50%) translateY(0);
}

/* Upload area enhanced */
.upload-area {
  border: 2px dashed #dee2e6;
  border-radius: var(--ts-radius);
  transition: all 0.3s ease;
  cursor: pointer;
  background: #fafafa;
}

.upload-area:hover {
  border-color: var(--ts-primary);
  background: #fff5f5;
}

.upload-area.dragover {
  border-color: var(--ts-primary);
  background: #ffe5e5;
  transform: scale(1.02);
}

.upload-icon {
  font-size: 3rem;
  color: #dee2e6;
  margin-bottom: 1rem;
  transition: color 0.3s ease;
}

.upload-area:hover .upload-icon {
  color: var(--ts-primary);
}

/* Loading spinner */
.spinner-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: 9999;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
}

.spinner-overlay.show {
  opacity: 1;
  visibility: visible;
}
