/**=====================
     Modern User Profile CSS
     Version: 1.0
     Date: 25.10.2025
==========================**/

/* Light theme colors */
:root {
  --profile-bg: #ffffff;
  --profile-card-bg: #ffffff;
  --profile-text-primary: #1a1a2e;
  --profile-text-secondary: #6c757d;
  --profile-border: #e9ecef;
  --profile-hover: #f8f9fa;
  --profile-shadow: rgba(0, 0, 0, 0.08);
  --profile-gradient-start: #667eea;
  --profile-gradient-end: #764ba2;
  --profile-overlay: rgba(0, 0, 0, 0.3);
}

/* Dark theme colors */
[data-theme="dark"], .dark-mode {
  --profile-bg: #1a1d29;
  --profile-card-bg: #242837;
  --profile-text-primary: #e4e6eb;
  --profile-text-secondary: #b0b3b8;
  --profile-border: #3a3f51;
  --profile-hover: #2d3142;
  --profile-shadow: rgba(0, 0, 0, 0.3);
  --profile-gradient-start: #667eea;
  --profile-gradient-end: #764ba2;
  --profile-overlay: rgba(0, 0, 0, 0.5);
}

/* Main Profile Container */
.modern-user-profile {
  padding: 0;
  max-width: 1200px;
  margin: 0 auto;
}

.modern-user-profile .g-4 {
  --bs-gutter-x: 1.5rem;
  --bs-gutter-y: 1.5rem;
}

/* Profile Card */
.profile-card-modern {
  background: var(--profile-card-bg);
  border-radius: 24px;
  overflow: hidden;
  box-shadow: 0 4px 20px var(--profile-shadow);
  transition: all 0.3s ease;
  margin: 0 auto;
  margin-bottom: 1.5rem;
}

.profile-card-modern:hover {
  box-shadow: 0 8px 30px var(--profile-shadow);
  transform: translateY(-2px);
}

.profile-header-gradient {
  position: relative;
  height: 200px;
  background: linear-gradient(135deg, var(--profile-gradient-start) 0%, var(--profile-gradient-end) 100%);
  overflow: hidden;
}

.profile-cover-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background-size: cover;
  background-position: center;
  opacity: 0.6;
  transition: all 0.3s ease;
}

.profile-cover-overlay:hover {
  opacity: 0.85; /* только лёгкое затемнение без движения */
}

.profile-edit-btn {
  position: absolute;
  top: 20px;
  right: 20px;
  z-index: 10;
}

.btn-edit-profile {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 46px;
  height: 46px;
  background: rgba(255, 255, 255, 0.15);
  backdrop-filter: blur(10px);
  -webkit-backdrop-filter: blur(10px);
  border: 2px solid rgba(255, 255, 255, 0.2);
  border-radius: 50%;
  color: #ffffff;
  font-size: 20px;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  text-decoration: none;
}

.btn-edit-profile:hover {
  background: rgba(255, 255, 255, 0.25);
  color: #ffffff; /* убрали вращение всей кнопки */
}

.btn-edit-profile:hover .edit-tooltip {
  opacity: 1;
  visibility: visible;
  transform: translateX(-10px);
}

/* Вращаем только шестерёнку на hover */
.btn-edit-profile i {
  display: inline-block;
  transition: transform 0.35s ease;
}
.btn-edit-profile:hover i {
  transform: rotate(180deg); /* пол-оборота и стоп */
}

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

.edit-tooltip {
  position: absolute;
  right: 100%;
  top: 50%;
  transform: translateY(-50%);
  background: rgba(0, 0, 0, 0.8);
  color: #fff;
  padding: 6px 12px;
  border-radius: 8px;
  font-size: 13px;
  white-space: nowrap;
  opacity: 0;
  visibility: hidden;
  transition: all 0.3s ease;
  margin-right: 10px;
}

.profile-body-content {
  padding: 0 30px 30px;
  text-align: center;
}

.profile-avatar-wrapper {
  margin-top: -45px;
  margin-bottom: 15px;
}

.avatar-ring {
  position: relative;
  display: inline-block;
  padding: 4px;
  background: linear-gradient(135deg, var(--profile-gradient-start), var(--profile-gradient-end));
  border-radius: 50%;
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.3);
}

.profile-avatar-img {
  width: 90px;
  height: 90px;
  border-radius: 50%;
  border: 4px solid var(--profile-card-bg);
  object-fit: cover;
  transition: all 0.3s ease;
}

.profile-avatar-img:hover {
  transform: scale(1.05);
}

.avatar-status-badge {
  position: absolute;
  bottom: 5px;
  right: 5px;
  width: 16px;
  height: 16px;
  background: #10b981;
  border: 3px solid var(--profile-card-bg);
  border-radius: 50%;
  box-shadow: 0 2px 8px rgba(16, 185, 129, 0.4);
  animation: pulse 2s infinite;
}

/* Profile Info */
.profile-info-section {
  margin-bottom: 24px;
}

.profile-name {
  font-size: 28px;
  font-weight: 700;
  color: var(--profile-text-primary);
  margin: 0 0 8px;
  letter-spacing: -0.5px;
}

.profile-role-badge {
  display: inline-block;
  padding: 6px 16px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border: 1px solid rgba(102, 126, 234, 0.2);
  border-radius: 20px;
  color: var(--profile-gradient-start);
  font-size: 13px;
  font-weight: 600;
  text-transform: uppercase;
  letter-spacing: 0.5px;
  margin-bottom: 8px;
}

.profile-login {
  color: var(--profile-text-secondary);
  font-size: 15px;
  margin: 0;
}

/* Stats Grid */
.profile-stats-grid {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 20px;
  padding: 24px 0;
  border-top: 1px solid var(--profile-border);
  border-bottom: 1px solid var(--profile-border);
  margin-bottom: 24px;
}

.stat-item {
  display: flex;
  align-items: center;
  gap: 12px;
}

.stat-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 44px;
  height: 44px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-radius: 12px;
  color: var(--profile-gradient-start);
  font-size: 20px;
  transition: all 0.3s ease;
}

.stat-icon:hover {
  transform: scale(1.1) rotate(5deg);
}

.stat-content {
  display: flex;
  flex-direction: column;
  align-items: flex-start;
}

.stat-value {
  font-size: 20px;
  font-weight: 700;
  color: var(--profile-text-primary);
  line-height: 1;
  margin-bottom: 4px;
}

.stat-label {
  font-size: 12px;
  color: var(--profile-text-secondary);
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.stat-divider {
  width: 1px;
  height: 40px;
  background: var(--profile-border);
}

/* Profile Actions */
.profile-actions {
  display: flex;
  flex-direction: column;
  gap: 12px;
}

.profile-actions button,
.profile-actions a {
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 8px;
  padding: 14px 24px;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.btn-message-user {
  background: linear-gradient(135deg, var(--profile-gradient-start), var(--profile-gradient-end));
  color: #ffffff !important;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.3);
  text-decoration: none;
}

.btn-message-user:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
  color: #ffffff;
}

/* Products Card */
.products-card-modern {
  background: var(--profile-card-bg);
  border-radius: 24px;
  padding: 24px;
  margin-bottom: 24px;
  box-shadow: 0 4px 20px var(--profile-shadow);
  transition: all 0.3s ease;
}

.products-card-modern:hover {
  box-shadow: 0 8px 30px var(--profile-shadow);
}

.products-card-header {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 20px;
}

.products-header-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-radius: 10px;
  color: var(--profile-gradient-start);
  font-size: 18px;
}

.products-title {
  margin: 0;
  font-size: 18px;
  font-weight: 700;
  color: var(--profile-text-primary);
}

.products-grid-modern {
  display: grid;
  grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
  gap: 16px;
  max-width: 100%;
  position: relative;
}

.products-grid-modern.compact {
  max-height: 480px;
  overflow: hidden;
  position: relative;
}

.products-grid-modern.compact::after {
  content: '';
  position: absolute;
  bottom: 0;
  left: 0;
  right: 0;
  height: 100px;
  background: linear-gradient(to bottom, transparent, var(--profile-card-bg));
  pointer-events: none;
}

.products-show-more {
  margin-top: 16px;
  text-align: center;
}

.products-show-more button {
  background: linear-gradient(135deg, var(--profile-gradient-start), var(--profile-gradient-end));
  color: white;
  border: none;
  padding: 12px 32px;
  border-radius: 12px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
  box-shadow: 0 4px 12px rgba(102, 126, 234, 0.3);
}

.products-show-more button:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

.product-item-modern {
  position: relative;
  aspect-ratio: 3/4;
  border-radius: 12px;
  overflow: hidden;
  cursor: pointer;
  transition: all 0.3s ease;
  background: var(--profile-card-bg);
  border: 1px solid var(--profile-border);
  box-shadow: 0 2px 8px rgba(0, 0, 0, 0.06);
}

.product-item-modern:hover {
  transform: translateY(-4px);
  box-shadow: 0 8px 24px rgba(102, 126, 234, 0.15);
  border-color: var(--profile-gradient-start);
}

.product-item-modern:hover .product-overlay {
  opacity: 1;
}

.product-image-wrapper {
  width: 100%;
  height: 100%;
  background-size: cover;
  background-position: center;
  transition: all 0.3s ease;
  position: relative;
}

.product-item-modern:hover .product-image-wrapper {
  transform: scale(1.05);
}

.product-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: linear-gradient(180deg, transparent 0%, rgba(0, 0, 0, 0.7) 100%);
  display: flex;
  align-items: flex-end;
  justify-content: center;
  opacity: 0;
  transition: all 0.3s ease;
  padding: 12px;
}

.product-overlay i {
  font-size: 24px;
  color: #ffffff;
  filter: drop-shadow(0 2px 4px rgba(0, 0, 0, 0.3));
}

/* Wall Section */
.wall-section-modern {
  display: flex;
  flex-direction: column;
  gap: 20px;
}

/* Wall Composer */
.wall-composer {
  background: var(--profile-card-bg);
  border-radius: 24px;
  padding: 24px;
  box-shadow: 0 4px 20px var(--profile-shadow);
  transition: all 0.3s ease;
}

.composer-header {
  margin-bottom: 16px;
}

.composer-title {
  display: flex;
  align-items: center;
  gap: 10px;
  font-size: 18px;
  font-weight: 700;
  color: var(--profile-text-primary);
  margin: 0;
}

.composer-title i {
  color: var(--profile-gradient-start);
}

.composer-textarea {
  width: 100%;
  padding: 16px;
  background: var(--profile-hover);
  border: 2px solid var(--profile-border);
  border-radius: 16px;
  color: var(--profile-text-primary);
  font-size: 15px;
  resize: vertical;
  transition: all 0.3s ease;
  font-family: inherit;
}

.composer-textarea:focus {
  outline: none;
  border-color: var(--profile-gradient-start);
  box-shadow: 0 0 0 4px rgba(102, 126, 234, 0.1);
}

.composer-textarea::placeholder {
  color: var(--profile-text-secondary);
}

.composer-actions {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-top: 16px;
}

.composer-tools {
  display: flex;
  gap: 8px;
}

.tool-btn {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 10px 16px;
  background: var(--profile-hover);
  border: 1px solid var(--profile-border);
  border-radius: 10px;
  color: var(--profile-text-secondary);
  font-size: 14px;
  transition: all 0.3s ease;
  cursor: pointer;
}

.tool-btn:hover {
  background: var(--profile-border);
  color: var(--profile-text-primary);
}

.btn-submit-post {
  display: flex;
  align-items: center;
  gap: 8px;
  padding: 12px 24px;
  background: linear-gradient(135deg, var(--profile-gradient-start), var(--profile-gradient-end));
  color: #ffffff;
  border: none;
  border-radius: 12px;
  font-size: 15px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.btn-submit-post:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(102, 126, 234, 0.4);
}

/* Wall Posts */
.wall-posts-container {
  display: flex;
  flex-direction: column;
  gap: 16px;
}

.wall-post-item {
  background: var(--profile-card-bg);
  border-radius: 20px;
  padding: 24px;
  box-shadow: 0 4px 20px var(--profile-shadow);
  transition: all 0.3s ease;
  position: relative;
}

.wall-post-item::after {
  content: '';
  position: absolute;
  left: 0;
  top: 50%;
  width: 4px;
  height: 0;
  background: linear-gradient(135deg, var(--profile-gradient-start), var(--profile-gradient-end));
  border-radius: 0 4px 4px 0;
  transition: height 0.3s ease;
  transform: translateY(-50%);
}

.wall-post-item:hover {
  box-shadow: 0 6px 25px var(--profile-shadow);
  transform: translateX(4px);
}

.wall-post-item:hover::after {
  height: 60%;
}

.post-header {
  margin-bottom: 16px;
}

.post-author {
  display: flex;
  align-items: center;
  gap: 14px;
}

.author-avatar {
  width: 48px;
  height: 48px;
  border-radius: 50%;
  overflow: hidden;
  border: 2px solid var(--profile-border);
}

.author-avatar img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.author-info {
  flex: 1;
}

.author-name {
  display: flex;
  align-items: center;
  gap: 8px;
  margin-bottom: 4px;
}

.author-name a {
  font-size: 16px;
  font-weight: 600;
  color: var(--profile-text-primary);
  text-decoration: none;
  transition: all 0.2s ease;
}

.author-name a:hover {
  color: var(--profile-gradient-start);
}

.verified-badge {
  color: #3b82f6;
  font-size: 16px;
}

.post-time {
  display: flex;
  align-items: center;
  gap: 6px;
  font-size: 13px;
  color: var(--profile-text-secondary);
}

.post-time i {
  font-size: 12px;
}

.post-content {
  margin-top: 12px;
}

.post-message {
  color: var(--profile-text-primary);
  font-size: 15px;
  line-height: 1.6;
  margin: 0 0 16px;
  white-space: pre-wrap;
}

.post-attachment {
  display: flex;
  align-items: center;
  gap: 12px;
  padding: 16px;
  background: var(--profile-hover);
  border: 1px solid var(--profile-border);
  border-radius: 12px;
  transition: all 0.3s ease;
}

.post-attachment:hover {
  background: var(--profile-border);
}

.attachment-icon {
  display: flex;
  align-items: center;
  justify-content: center;
  width: 40px;
  height: 40px;
  background: linear-gradient(135deg, rgba(102, 126, 234, 0.1), rgba(118, 75, 162, 0.1));
  border-radius: 10px;
  color: var(--profile-gradient-start);
  font-size: 18px;
}

.attachment-link {
  flex: 1;
  display: flex;
  align-items: center;
  justify-content: space-between;
  color: var(--profile-text-primary);
  text-decoration: none;
  font-size: 14px;
  font-weight: 500;
  transition: all 0.2s ease;
}

.attachment-link:hover {
  color: var(--profile-gradient-start);
}

/* Empty State */
.wall-empty-state {
  background: var(--profile-card-bg);
  border-radius: 20px;
  padding: 60px 24px;
  text-align: center;
  box-shadow: 0 4px 20px var(--profile-shadow);
}

.empty-icon {
  font-size: 64px;
  color: var(--profile-text-secondary);
  margin-bottom: 20px;
  opacity: 0.5;
}

.empty-text {
  font-size: 18px;
  font-weight: 600;
  color: var(--profile-text-primary);
  margin: 0 0 8px;
}

.empty-subtext {
  font-size: 14px;
  color: var(--profile-text-secondary);
  margin: 0;
}

/* Animations */
@keyframes fadeInUp {
  from {
    opacity: 0;
    transform: translateY(20px);
  }
  to {
    opacity: 1;
    transform: translateY(0);
  }
}

@keyframes pulse {
  0%, 100% {
    transform: scale(1);
  }
  50% {
    transform: scale(1.05);
  }
}

.profile-card-modern {
  animation: fadeInUp 0.6s ease-out;
}

.products-card-modern {
  animation: fadeInUp 0.8s ease-out;
}

.wall-composer {
  animation: fadeInUp 0.6s ease-out;
}

/* Responsive Design */
@media (max-width: 1200px) {
  .products-grid-modern {
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
  }
}

@media (max-width: 768px) {
  .profile-header-gradient {
    height: 160px;
  }
  
  .profile-avatar-img {
    width: 100px;
    height: 100px;
  }
  
  .profile-name {
    font-size: 24px;
  }
  
  .profile-stats-grid {
    flex-direction: column;
    gap: 16px;
  }
  
  .stat-divider {
    width: 100%;
    height: 1px;
  }
  
  .products-grid-modern {
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
  }
  
  .composer-actions {
    flex-direction: column;
    gap: 12px;
  }
  
  .composer-tools {
    width: 100%;
  }
  
  .btn-submit-post {
    width: 100%;
    justify-content: center;
  }
}

/* Reduced Motion */
@media (prefers-reduced-motion: reduce) {
  *,
  *::before,
  *::after {
    animation-duration: 0.01ms !important;
    animation-iteration-count: 1 !important;
    transition-duration: 0.01ms !important;
  }
}

/* Additional Fixes */

/* Улучшение видимости текста на темном фоне */
body.dark-only .modern-user-profile,
body[data-layout="dark-only"] .modern-user-profile {
  --profile-bg: #1a1d29;
  --profile-card-bg: #242837;
  --profile-text-primary: #e4e6eb;
  --profile-text-secondary: #b0b3b8;
  --profile-border: #3a3f51;
  --profile-hover: #2d3142;
}

/* Улучшение карточки профиля */
.profile-card-modern {
  border: 1px solid var(--profile-border);
}

/* Улучшение отступов в информации профиля */
.profile-body-content {
  padding: 0 24px 24px;
}

/* Улучшение видимости имени */
.profile-name {
  text-shadow: none;
  font-weight: 800;
}

/* Улучшение бейджа роли */
.profile-role-badge {
  font-weight: 700;
  padding: 8px 20px;
}

/* Улучшение composer */
.wall-composer {
  border: 1px solid var(--profile-border);
}

.composer-header {
  padding-bottom: 16px;
  border-bottom: 1px solid var(--profile-border);
}

.composer-body {
  padding-top: 16px;
}

/* Улучшение постов */
.wall-post-item {
  border: 1px solid var(--profile-border);
}

/* Улучшение каталога товаров */
.products-card-modern {
  border: 1px solid var(--profile-border);
}

.product-item-modern {
  border: 1px solid var(--profile-border);
  background: var(--profile-hover);
}

/* Улучшение кнопок */
.profile-actions button,
.profile-actions a,
#result_add_friends button,
#result_add_friends a {
  width: 100%;
  text-decoration: none;
  font-family: inherit;
}

/* Фикс для статистики */
.profile-stats-grid {
  padding: 20px 0;
  margin-bottom: 20px;
}

.stat-item {
  min-width: 100px;
}

/* Улучшение hover эффектов */
.profile-card-modern:hover {
  transform: translateY(-1px);
}

/* Улучшение теней для темной темы */
body.dark-only .profile-card-modern,
body[data-layout="dark-only"] .profile-card-modern {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

body.dark-only .wall-post-item,
body[data-layout="dark-only"] .wall-post-item {
  box-shadow: 0 4px 20px rgba(0, 0, 0, 0.4);
}

/* Фикс для аватара в постах */
.author-avatar {
  flex-shrink: 0;
}

/* Улучшение пустого состояния */
.wall-empty-state {
  border: 1px dashed var(--profile-border);
  background: var(--profile-hover);
}

/* Улучшение attachment */
.post-attachment {
  margin-top: 12px;
}

/* Responsive улучшения */
@media (max-width: 991px) {
  .profile-header-gradient {
    height: 180px;
  }
  
  .profile-avatar-img {
    width: 100px;
    height: 100px;
  }
  
  .profile-name {
    font-size: 24px;
  }
  
  .products-grid-modern {
    grid-template-columns: repeat(auto-fill, minmax(110px, 1fr));
    gap: 12px;
  }
}

@media (max-width: 768px) {
  .products-grid-modern {
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
  }
  
  .product-item-modern {
    aspect-ratio: 1;
  }
}

@media (max-width: 576px) {
  .products-grid-modern {
    grid-template-columns: repeat(2, 1fr);
    gap: 12px;
  }
}
