<template>
  <div class="modern-profile-view">
    <!-- Header Section -->
    <div class="profile-header">
      <div class="container">
        <div class="header-content">
          <div class="profile-title">
            <h1 class="title-gradient">Мой профиль</h1>
            <p class="subtitle">Управление личными данными и настройками</p>
          </div>
          <div class="header-actions">
            <button 
              class="action-btn primary"
              @click="toggleEditMode"
              :disabled="loading"
            >
              <i class="icon" :class="isEditMode ? 'bi-eye' : 'bi-pencil'"></i>
              {{ isEditMode ? 'Просмотр' : 'Редактировать' }}
            </button>
          </div>
        </div>
      </div>
    </div>

    <!-- Loading State -->
    <div v-if="loading && initialLoading" class="loading-section">
      <div class="loading-spinner">
        <div class="spinner"></div>
        <p>Загрузка профиля...</p>
      </div>
    </div>

    <!-- Error State -->
    <div v-if="error" class="error-section">
      <div class="container">
        <div class="error-card">
          <i class="bi-exclamation-triangle"></i>
          <h3>Ошибка загрузки</h3>
          <p>{{ error }}</p>
          <button class="retry-btn" @click="fetchProfileDataLocal">Попробовать снова</button>
        </div>
      </div>
    </div>

    <!-- Main Content -->
    <div v-if="profileData && !initialLoading" class="main-content">
      <div class="container">
        <div class="profile-layout">
          
          <!-- Profile Card Section -->
          <div class="profile-card-section">
            <div class="profile-card">
              <!-- Avatar Section -->
              <div class="avatar-section">
                <div class="avatar-container">
                  <img 
                    v-if="mainPhoto" 
                    :src="mainPhoto.url" 
                    :alt="profileData.name"
                    class="avatar-image"
                  >
                  <div v-else class="avatar-placeholder">
                    <i class="bi-person"></i>
                  </div>
                  <div class="avatar-overlay" v-if="isEditMode">
                    <button class="change-avatar-btn" @click="scrollToPhotos">
                      <i class="bi-camera"></i>
                    </button>
                  </div>
                </div>
                <div class="user-info">
                  <h2 class="user-name">{{ profileData.name || 'Не указано' }}</h2>
                  <p class="user-email">{{ profileData.email }}</p>
                  <div class="user-badges">
                    <span class="badge verified">Подтвержден</span>
                    <span class="badge member-since">С {{ formatShortDate(profileData.createdAt) }}</span>
                  </div>
                </div>
              </div>

              <!-- Stats Section -->
              <div class="stats-section">
                <div class="stat-item">
                  <span class="stat-value">{{ profileData.photos?.length || 0 }}</span>
                  <span class="stat-label">Фото</span>
                </div>
                <div class="stat-item">
                  <span class="stat-value">{{ profileData.matches?.length || 0 }}</span>
                  <span class="stat-label">Совпадения</span>
                </div>
                <div class="stat-item">
                  <span class="stat-value">{{ getProfileCompletion() }}%</span>
                  <span class="stat-label">Заполнено</span>
                </div>
              </div>
            </div>
          </div>

          <!-- Details Section -->
          <div class="details-section">
            <!-- Basic Info -->
            <div class="info-card">
              <div class="card-header">
                <h3><i class="bi-person-lines-fill"></i> Основная информация</h3>
              </div>
              <div class="card-content">
                <div class="info-grid">
                  <div class="info-item">
                    <label>Дата рождения</label>
                    <span>{{ profileData.dateOfBirth ? formatDate(profileData.dateOfBirth) : 'Не указана' }}</span>
                  </div>
                  <div class="info-item">
                    <label>Пол</label>
                    <span>{{ getGenderText(profileData.gender) }}</span>
                  </div>
                  <div class="info-item">
                    <label>Город</label>
                    <span>{{ profileData.location?.city || 'Не указан' }}</span>
                  </div>
                  <div class="info-item full-width">
                    <label>О себе</label>
                    <span class="bio-text">{{ profileData.bio || 'Расскажите о себе...' }}</span>
                  </div>
                </div>
              </div>
            </div>

            <!-- Photos Section -->
            <div class="info-card" id="photos-section">
              <div class="card-header">
                <h3><i class="bi-images"></i> Мои фотографии</h3>
                <div class="header-actions" v-if="isEditMode">
                  <button class="add-photo-btn" @click="triggerPhotoUpload">
                    <i class="bi-plus"></i>
                    Добавить фото
                  </button>
                </div>
              </div>
              <div class="card-content">
                <!-- Photo Grid -->
                <div v-if="profileData.photos && profileData.photos.length > 0" class="photo-grid">
                  <div 
                    v-for="photo in profileData.photos" 
                    :key="photo.public_id || photo._id" 
                    class="photo-item"
                    :class="{ 'main-photo': photo.isProfilePhoto }"
                  >
                    <img :src="photo.url" :alt="'Фото ' + profileData.name" class="photo-image">
                    <div v-if="photo.isProfilePhoto" class="main-badge">
                      <i class="bi-star-fill"></i>
                      Главное
                    </div>
                    <div v-if="isEditMode" class="photo-actions">
                      <button 
                        v-if="!photo.isProfilePhoto"
                        class="action-btn small primary"
                        @click="setAsMainPhoto(photo._id)"
                        :disabled="photoActionLoading"
                        title="Сделать главным"
                      >
                        <i class="bi-star"></i>
                      </button>
                      <button 
                        class="action-btn small danger"
                        @click="confirmDeletePhoto(photo._id)"
                        :disabled="photoActionLoading"
                        title="Удалить"
                      >
                        <i class="bi-trash"></i>
                      </button>
                    </div>
                  </div>
                </div>
                
                <!-- Empty State -->
                <div v-else class="empty-photos">
                  <i class="bi-image"></i>
                  <h4>Нет фотографий</h4>
                  <p>Добавьте фотографии, чтобы сделать профиль привлекательнее</p>
                  <button v-if="isEditMode" class="action-btn primary" @click="triggerPhotoUpload">
                    <i class="bi-plus"></i>
                    Добавить первое фото
                  </button>
                </div>
                
                <!-- Photo Messages -->
                <div v-if="photoActionError" class="alert error">
                  <i class="bi-exclamation-circle"></i>
                  {{ photoActionError }}
                </div>
                <div v-if="photoActionSuccess" class="alert success">
                  <i class="bi-check-circle"></i>
                  {{ photoActionSuccess }}
                </div>
              </div>
            </div>
          </div>
        </div>
      </div>
    </div>

    <!-- Edit Mode Components -->
    <EditProfileForm 
      v-if="isAuthenticated && !initialLoading && isEditMode" 
      @profile-updated="handleProfileUpdate"
      ref="editFormRef"
    />

    <!-- Hidden File Input -->
    <input 
      ref="fileInput"
      type="file" 
      multiple 
      accept="image/*" 
      @change="handlePhotoSelect"
      style="display: none;"
    >

    <!-- Delete Confirmation Modal -->
    <div class="modal-overlay" v-if="showDeleteModal" @click="closeDeleteModal">
      <div class="delete-modal" @click.stop>
        <div class="modal-header">
          <h3>Удалить фотографию</h3>
          <button class="close-btn" @click="closeDeleteModal">
            <i class="bi-x"></i>
          </button>
        </div>
        <div class="modal-content">
          <p>Вы уверены, что хотите удалить эту фотографию? Это действие нельзя отменить.</p>
        </div>
        <div class="modal-actions">
          <button class="action-btn secondary" @click="closeDeleteModal">Отмена</button>
          <button 
            class="action-btn danger" 
            @click="executeDeletePhoto"
            :disabled="photoActionLoading"
          >
            <span v-if="photoActionLoading" class="spinner-small"></span>
            Удалить
          </button>
        </div>
      </div>
    </div>

    <!-- No Data State -->
    <div v-if="!profileData && !initialLoading && !error" class="no-data-section">
      <div class="container">
        <div class="no-data-card">
          <i class="bi-person-x"></i>
          <h3>Данные профиля недоступны</h3>
          <p>Возможно, вы не авторизованы или произошла ошибка.</p>
          <router-link to="/login" class="action-btn primary">Войти в систему</router-link>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref, onMounted, computed, watch, nextTick } from 'vue';
import { useAuth } from '@/auth';
import api from '@/services/api';
import EditProfileForm from '@/components/EditProfileForm.vue';

const { isAuthenticated, user: authUserFromStore, token, fetchUser } = useAuth(); 
const profileData = ref(null);
const loading = ref(true); 
const initialLoading = ref(true);
const error = ref('');
const isEditMode = ref(false);

// Для управления фото
const photoActionLoading = ref(false);
const photoActionError = ref('');
const photoActionSuccess = ref('');
const photoToDeleteId = ref(null);
const showDeleteModal = ref(false);
const fileInput = ref(null);
const editFormRef = ref(null);

// Computed properties
const mainPhoto = computed(() => {
  return profileData.value?.photos?.find(photo => photo.isProfilePhoto) || 
         profileData.value?.photos?.[0] || null;
});

// Methods
const toggleEditMode = () => {
  isEditMode.value = !isEditMode.value;
  if (isEditMode.value) {
    nextTick(() => {
      scrollToEdit();
    });
  }
};

const scrollToPhotos = () => {
  const photosSection = document.getElementById('photos-section');
  if (photosSection) {
    photosSection.scrollIntoView({ behavior: 'smooth', block: 'start' });
  }
};

const scrollToEdit = () => {
  if (editFormRef.value && editFormRef.value.$el) {
    editFormRef.value.$el.scrollIntoView({ behavior: 'smooth', block: 'start' });
  }
};

const triggerPhotoUpload = () => {
  if (fileInput.value) {
    fileInput.value.click();
  }
};

const handlePhotoSelect = async (event) => {
  const files = event.target.files;
  if (!files || files.length === 0) return;

  // Передаем выбранные файлы в форму редактирования
  if (editFormRef.value && editFormRef.value.handlePhotoUpload) {
    await editFormRef.value.handlePhotoUpload(Array.from(files));
  }
  
  // Очищаем input
  event.target.value = '';
};

const getProfileCompletion = () => {
  if (!profileData.value) return 0;
  
  const fields = [
    profileData.value.name,
    profileData.value.bio,
    profileData.value.dateOfBirth,
    profileData.value.gender,
    profileData.value.location?.city,
    profileData.value.photos?.length > 0
  ];
  
  const completed = fields.filter(field => !!field).length;
  return Math.round((completed / fields.length) * 100);
};

const getGenderText = (gender) => {
  const genderMap = {
    'male': 'Мужской',
    'female': 'Женский',
    'other': 'Другой'
  };
  return genderMap[gender] || 'Не указан';
};

const formatDate = (dateString) => {
  if (!dateString) return '';
  const options = { year: 'numeric', month: 'long', day: 'numeric' };
  return new Date(dateString).toLocaleDateString('ru-RU', options);
};

const formatShortDate = (dateString) => {
  if (!dateString) return '';
  const date = new Date(dateString);
  return `${date.getMonth() + 1}.${date.getFullYear()}`;
};

const handleProfileUpdate = () => {
  // Обновляем данные после редактирования профиля
  fetchUser();
  clearMessages();
};

const clearMessages = () => {
  photoActionError.value = '';
  photoActionSuccess.value = '';
};

const fetchProfileDataLocal = async () => {
  loading.value = true; 
  error.value = '';
  
  if (!isAuthenticated.value || !token.value) {
    error.value = "Вы не авторизованы для просмотра этой страницы.";
    loading.value = false; 
    initialLoading.value = false;
    return;
  }

  try {
    await fetchUser(); 
  } catch (err) {
    console.error('[ProfileView] Ошибка при вызове fetchUser:', err);
    error.value = (err.response && err.response.data && err.response.data.message) 
                  ? err.response.data.message 
                  : 'Не удалось загрузить данные профиля. Попробуйте позже.';
  } finally {
    loading.value = false; 
    initialLoading.value = false;
  }
};

const setAsMainPhoto = async (photoId) => {
  photoActionLoading.value = true;
  clearMessages();
  
  try {
    const response = await api.setMainPhoto(photoId);
    await fetchUser();
    photoActionSuccess.value = response.data.message || 'Главное фото обновлено.';
    
    // Автоматически скрываем сообщение через 3 секунды
    setTimeout(() => {
      photoActionSuccess.value = '';
    }, 3000);
  } catch (err) {
    console.error('[ProfileView] Ошибка при установке главного фото:', err);
    photoActionError.value = err.response?.data?.message || 'Не удалось установить главное фото.';
  } finally {
    photoActionLoading.value = false;
  }
};

const confirmDeletePhoto = (photoId) => {
  photoToDeleteId.value = photoId;
  showDeleteModal.value = true;
  clearMessages();
};

const closeDeleteModal = () => {
  showDeleteModal.value = false;
  photoToDeleteId.value = null;
};

const executeDeletePhoto = async () => {
  if (!photoToDeleteId.value) return;
  
  photoActionLoading.value = true;
  clearMessages();
  
  try {
    const response = await api.deletePhoto(photoToDeleteId.value);
    await fetchUser();
    photoActionSuccess.value = response.data.message || 'Фотография удалена.';
    closeDeleteModal();
    
    // Автоматически скрываем сообщение через 3 секунды
    setTimeout(() => {
      photoActionSuccess.value = '';
    }, 3000);
  } catch (err) {
    console.error('[ProfileView] Ошибка при удалении фото:', err);
    photoActionError.value = err.response?.data?.message || 'Не удалось удалить фотографию.';
    closeDeleteModal();
  } finally {
    photoActionLoading.value = false;
  }
};

// Watchers
watch(authUserFromStore, (newUser) => {
  if (newUser) {
    profileData.value = { ...newUser }; 
    console.log('[ProfileView] Данные профиля обновлены из authUserFromStore:', profileData.value);
  }
}, { immediate: true, deep: true }); 

// Lifecycle
onMounted(async () => {
  if (!authUserFromStore.value || Object.keys(authUserFromStore.value).length === 0) {
    await fetchProfileDataLocal();
  } else {
    profileData.value = { ...authUserFromStore.value };
    loading.value = false;
    initialLoading.value = false;
    console.log('[ProfileView] Данные профиля уже были в хранилище:', profileData.value);
  }
});
</script>

<style scoped>
@import url('https://cdn.jsdelivr.net/npm/bootstrap-icons@1.11.0/font/bootstrap-icons.css');

/* Global Reset and Base Styles */
.modern-profile-view {
  min-height: 100vh;
  background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
  font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
}

.container {
  max-width: 1200px;
  margin: 0 auto;
  padding: 0 20px;
}

/* Header Section */
.profile-header {
  background: rgba(255, 255, 255, 0.1);
  backdrop-filter: blur(10px);
  border-bottom: 1px solid rgba(255, 255, 255, 0.2);
  padding: 2rem 0;
  color: white;
}

.header-content {
  display: flex;
  justify-content: space-between;
  align-items: center;
  flex-wrap: wrap;
  gap: 1rem;
}

.profile-title h1 {
  margin: 0;
  font-size: 2.5rem;
  font-weight: 700;
  background: linear-gradient(45deg, #fff, #f0f0f0);
  -webkit-background-clip: text;
  -webkit-text-fill-color: transparent;
  background-clip: text;
}

.profile-title .subtitle {
  margin: 0.5rem 0 0 0;
  font-size: 1.1rem;
  opacity: 0.9;
}

/* Action Buttons */
.action-btn {
  display: inline-flex;
  align-items: center;
  gap: 0.5rem;
  padding: 0.75rem 1.5rem;
  border: none;
  border-radius: 50px;
  font-weight: 600;
  font-size: 0.9rem;
  text-decoration: none;
  transition: all 0.3s ease;
  cursor: pointer;
  position: relative;
  overflow: hidden;
}

.action-btn.primary {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.action-btn.secondary {
  background: #f8f9fa;
  color: #495057;
  border: 1px solid #dee2e6;
}

.action-btn.secondary:hover {
  background: #e9ecef;
  transform: translateY(-1px);
}

.action-btn.danger {
  background: linear-gradient(45deg, #ff6b6b, #ee5a24);
  color: white;
  box-shadow: 0 4px 15px rgba(238, 90, 36, 0.4);
}

.action-btn.danger:hover {
  transform: translateY(-2px);
  box-shadow: 0 6px 20px rgba(238, 90, 36, 0.6);
}

.action-btn.small {
  padding: 0.5rem 1rem;
  font-size: 0.8rem;
}

.action-btn:disabled {
  opacity: 0.6;
  cursor: not-allowed;
  transform: none !important;
}

/* Loading State */
.loading-section {
  display: flex;
  justify-content: center;
  align-items: center;
  min-height: 400px;
  color: white;
}

.loading-spinner {
  text-align: center;
}

.spinner {
  width: 50px;
  height: 50px;
  border: 4px solid rgba(255, 255, 255, 0.3);
  border-left: 4px solid white;
  border-radius: 50%;
  animation: spin 1s linear infinite;
  margin: 0 auto 1rem;
}

.spinner-small {
  width: 16px;
  height: 16px;
  border: 2px solid rgba(255, 255, 255, 0.3);
  border-left: 2px solid white;
  border-radius: 50%;
  animation: spin 0.8s linear infinite;
  display: inline-block;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

/* Error Section */
.error-section {
  padding: 4rem 0;
}

.error-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.error-card i {
  font-size: 3rem;
  color: #dc3545;
  margin-bottom: 1rem;
}

.error-card h3 {
  color: #495057;
  margin-bottom: 1rem;
}

.retry-btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 0.75rem 2rem;
  border-radius: 50px;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

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

/* Main Content */
.main-content {
  padding: 2rem 0 4rem;
}

.profile-layout {
  display: grid;
  grid-template-columns: 350px 1fr;
  gap: 2rem;
  align-items: start;
}

/* Profile Card */
.profile-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 2rem;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  position: sticky;
  top: 2rem;
}

.avatar-section {
  text-align: center;
  margin-bottom: 2rem;
}

.avatar-container {
  position: relative;
  display: inline-block;
  margin-bottom: 1rem;
}

.avatar-image {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  object-fit: cover;
  border: 4px solid white;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.avatar-placeholder {
  width: 120px;
  height: 120px;
  border-radius: 50%;
  background: linear-gradient(45deg, #e9ecef, #f8f9fa);
  display: flex;
  align-items: center;
  justify-content: center;
  border: 4px solid white;
  box-shadow: 0 8px 25px rgba(0, 0, 0, 0.15);
}

.avatar-placeholder i {
  font-size: 3rem;
  color: #6c757d;
}

.avatar-overlay {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.7);
  border-radius: 50%;
  display: flex;
  align-items: center;
  justify-content: center;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.avatar-container:hover .avatar-overlay {
  opacity: 1;
}

.change-avatar-btn {
  background: none;
  border: none;
  color: white;
  font-size: 1.5rem;
  cursor: pointer;
}

.user-name {
  font-size: 1.5rem;
  font-weight: 700;
  color: #2c3e50;
  margin: 0 0 0.5rem 0;
}

.user-email {
  color: #6c757d;
  margin: 0 0 1rem 0;
}

.user-badges {
  display: flex;
  gap: 0.5rem;
  justify-content: center;
  flex-wrap: wrap;
}

.badge {
  padding: 0.25rem 0.75rem;
  border-radius: 50px;
  font-size: 0.75rem;
  font-weight: 600;
}

.badge.verified {
  background: linear-gradient(45deg, #28a745, #20c997);
  color: white;
}

.badge.member-since {
  background: #e9ecef;
  color: #495057;
}

/* Stats Section */
.stats-section {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 1rem;
  margin-top: 2rem;
  padding-top: 2rem;
  border-top: 1px solid #e9ecef;
}

.stat-item {
  text-align: center;
}

.stat-value {
  display: block;
  font-size: 1.5rem;
  font-weight: 700;
  color: #667eea;
}

.stat-label {
  font-size: 0.8rem;
  color: #6c757d;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

/* Details Section */
.details-section {
  display: flex;
  flex-direction: column;
  gap: 2rem;
}

.info-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
  overflow: hidden;
}

.card-header {
  padding: 1.5rem 2rem;
  background: linear-gradient(45deg, #f8f9fa, #e9ecef);
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.card-header h3 {
  margin: 0;
  color: #495057;
  font-size: 1.2rem;
  display: flex;
  align-items: center;
  gap: 0.5rem;
}

.card-content {
  padding: 2rem;
}

.info-grid {
  display: grid;
  grid-template-columns: repeat(2, 1fr);
  gap: 1.5rem;
}

.info-item {
  display: flex;
  flex-direction: column;
  gap: 0.5rem;
}

.info-item.full-width {
  grid-column: 1 / -1;
}

.info-item label {
  font-weight: 600;
  color: #495057;
  font-size: 0.9rem;
  text-transform: uppercase;
  letter-spacing: 0.5px;
}

.info-item span {
  color: #6c757d;
  font-size: 1rem;
}

.bio-text {
  font-style: italic;
  line-height: 1.6;
}

/* Photo Grid */
.add-photo-btn {
  background: linear-gradient(45deg, #667eea, #764ba2);
  color: white;
  border: none;
  padding: 0.5rem 1rem;
  border-radius: 50px;
  font-size: 0.8rem;
  font-weight: 600;
  cursor: pointer;
  transition: all 0.3s ease;
}

.add-photo-btn:hover {
  transform: translateY(-2px);
  box-shadow: 0 4px 15px rgba(102, 126, 234, 0.4);
}

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

.photo-item {
  position: relative;
  border-radius: 15px;
  overflow: hidden;
  background: #f8f9fa;
  transition: transform 0.3s ease;
}

.photo-item:hover {
  transform: translateY(-5px);
}

.photo-item.main-photo {
  border: 3px solid #667eea;
}

.photo-image {
  width: 100%;
  height: 200px;
  object-fit: cover;
  display: block;
}

.main-badge {
  position: absolute;
  top: 10px;
  left: 10px;
  background: linear-gradient(45deg, #ffc107, #fd7e14);
  color: white;
  padding: 0.25rem 0.5rem;
  border-radius: 50px;
  font-size: 0.7rem;
  font-weight: 600;
  display: flex;
  align-items: center;
  gap: 0.25rem;
}

.photo-actions {
  position: absolute;
  bottom: 10px;
  right: 10px;
  display: flex;
  gap: 0.5rem;
  opacity: 0;
  transition: opacity 0.3s ease;
}

.photo-item:hover .photo-actions {
  opacity: 1;
}

/* Empty States */
.empty-photos {
  text-align: center;
  padding: 3rem;
  color: #6c757d;
}

.empty-photos i {
  font-size: 4rem;
  margin-bottom: 1rem;
  opacity: 0.5;
}

.empty-photos h4 {
  margin-bottom: 1rem;
}

.no-data-section {
  padding: 4rem 0;
}

.no-data-card {
  background: rgba(255, 255, 255, 0.95);
  backdrop-filter: blur(10px);
  border-radius: 20px;
  padding: 3rem;
  text-align: center;
  box-shadow: 0 10px 30px rgba(0, 0, 0, 0.2);
}

.no-data-card i {
  font-size: 3rem;
  color: #6c757d;
  margin-bottom: 1rem;
}

/* Alerts */
.alert {
  padding: 1rem 1.5rem;
  border-radius: 10px;
  margin: 1rem 0;
  display: flex;
  align-items: center;
  gap: 0.5rem;
  font-weight: 500;
}

.alert.error {
  background: rgba(220, 53, 69, 0.1);
  color: #721c24;
  border: 1px solid rgba(220, 53, 69, 0.2);
}

.alert.success {
  background: rgba(40, 167, 69, 0.1);
  color: #155724;
  border: 1px solid rgba(40, 167, 69, 0.2);
}

/* Modal */
.modal-overlay {
  position: fixed;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(0, 0, 0, 0.5);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 1000;
  backdrop-filter: blur(5px);
}

.delete-modal {
  background: white;
  border-radius: 20px;
  max-width: 500px;
  width: 90%;
  box-shadow: 0 20px 60px rgba(0, 0, 0, 0.3);
  overflow: hidden;
}

.modal-header {
  padding: 1.5rem 2rem;
  background: #f8f9fa;
  border-bottom: 1px solid #dee2e6;
  display: flex;
  justify-content: space-between;
  align-items: center;
}

.modal-header h3 {
  margin: 0;
  color: #495057;
}

.close-btn {
  background: none;
  border: none;
  font-size: 1.5rem;
  cursor: pointer;
  color: #6c757d;
  padding: 0;
}

.modal-content {
  padding: 2rem;
}

.modal-actions {
  padding: 1.5rem 2rem;
  background: #f8f9fa;
  border-top: 1px solid #dee2e6;
  display: flex;
  gap: 1rem;
  justify-content: flex-end;
}

/* Responsive Design */
@media (max-width: 768px) {
  .profile-layout {
    grid-template-columns: 1fr;
    gap: 1rem;
  }
  
  .profile-card {
    position: static;
  }
  
  .header-content {
    flex-direction: column;
    text-align: center;
  }
  
  .profile-title h1 {
    font-size: 2rem;
  }
  
  .info-grid {
    grid-template-columns: 1fr;
  }
  
  .stats-section {
    grid-template-columns: repeat(3, 1fr);
  }
  
  .photo-grid {
    grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
  }
}

@media (max-width: 480px) {
  .container {
    padding: 0 15px;
  }
  
  .profile-header {
    padding: 1.5rem 0;
  }
  
  .profile-title h1 {
    font-size: 1.8rem;
  }
  
  .card-content,
  .modal-content {
    padding: 1.5rem;
  }
}
</style>