:root {
  --bg-primary: #ffffff;
  --bg-secondary: #ffffff;  /* Changé pour un fond complètement blanc */
  --text-primary: #191919; 
  --accent-color: #3b82f6;
  --error-color: #ef4444;
  --border-color: #e5e7eb;
}

/* Variables pour le thème sombre */
[data-theme="dark"] {
  --bg-primary: #191919;
  --bg-secondary: #191919; 
  --text-primary: #f3f4f6;
  --border-color: #d1d5db;
}

/* Style général */
body {
  font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", sans-serif;
  margin: 0;
  padding: 20px;
  background-color: var(--bg-secondary);
  color: var(--text-primary);
  min-height: 100vh;
  display: flex;
  justify-content: center;
  align-items: flex-start;  /* Changé pour aligner en haut */
  transition: background-color 0.3s ease, color 0.3s ease;
}

/* Conteneur principal */
.container {
  background-color: var(--bg-primary);
  padding: 24px;
  width: 100%;
  max-width: 400px;
  margin-top: 20px;
  border-radius: 0; 
}

/* Header et bouton thème */
.header {
  display: flex;
  justify-content: space-between;
  align-items: center;
  margin-bottom: 2rem;
  position: relative;
}

.header h1 {
  font-size: 1.25rem;
  font-weight: 600;
  color: var(--text-primary);
  margin: 0;
}

.header .theme-button {
  padding: 0.5rem;
  border-radius: 9999px;
  border: none;
  background-color: #f3f4f6;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
  transition: background-color 0.2s;
}

.header .theme-button:hover {
  background-color: #e5e7eb;
}

.connection-form {
  display: flex;
  flex-direction: column;
  gap: 1.5rem;
}

.form-group {
  display: flex;
  flex-direction: column;
  gap: 0.25rem;
}

.form-group label {
  font-size: 0.875rem;
  font-weight: 500;
  color: var(--text-primary);
}

.form-group input {
  width: 100%;
  padding: 0.75rem;
  border: 1px solid var(--border-color);
  border-radius: 0.375rem;
  font-size: 0.875rem;
  background-color: white;
  transition: border-color 0.2s;
}

.form-group input:focus {
  outline: none;
  border-color: var(--accent-color);
  box-shadow: 0 0 0 2px rgba(59, 130, 246, 0.1);
}

/* Écran de connexion */
.connection-screen h2 {
  font-size: 1.25rem;  /* Plus petit */
  font-weight: 600;
  margin-bottom: 1rem;
  text-align: left;  /* Aligné à gauche */
  color: var(--text-primary);
}


/* Boutons */
.btn {
  background-color: var(--accent-color);
  color: white;
  border: none;
  padding: 0.75rem 1rem;
  border-radius: 0.375rem;
  font-weight: 500;
  width: 100%;
  font-size: 0.875rem;
  cursor: pointer;
  transition: opacity 0.2s;
}

.btn:hover {
  opacity: 0.9;
}

.button-container {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 0.5rem;
  margin-top: 1rem;
  width: 100%;
}

/* Style pour le bouton de thème */
.theme-button {
  padding: 0.5rem;
  border-radius: 9999px;
  border: none;
  background-color: #f3f4f6;
  cursor: pointer;
  width: 32px;
  height: 32px;
  display: flex;
  align-items: center;
  justify-content: center;
}

[data-theme="light"] .theme-button {
  background: #f3f4f6;
}

[data-theme="dark"] .theme-button {
  background: #374151;
}

.theme-icon {
  font-size: 1.2rem;
}

/* Style commun pour les deux boutons */
.refresh-btn,
.disconnect-btn {
  min-width: 120px;
  margin: 0.25rem 0;
}

.disconnect-btn {
  background-color: var(--accent-color);
}

.disconnect-btn:hover {
  opacity: 0.9;
}

/* Seulement si vous voulez un espacement spécifique pour le refresh */
.refresh-btn {
  margin-bottom: 0.5rem;
}

/* Messages et états */
.loading {
  display: none;
  text-align: center;
  margin: 1rem 0;
  color: var(--accent-color);
}

.loading.active {
  display: block;
}

.error-message {
  color: var(--error-color);
  text-align: center;
  margin-top: 0.5rem;
  font-size: 0.875rem;
}

/* Grille Instagram */
.instagram-grid {
  display: grid;
  grid-template-columns: repeat(3, 1fr);
  gap: 10px;
  margin-top: 1.5rem;
}

.grid-item {
  aspect-ratio: 1/1;
  background-color: var(--bg-secondary);
  display: flex;
  justify-content: center;
  align-items: center;
  border-radius: 4px;
  overflow: hidden;
  position: relative;
}

.grid-item.empty {
  background-color: var(--bg-secondary);
}

.grid-item img {
  width: 100%;
  height: 100%;
  object-fit: cover;
}

.grid-item:hover .image-container img {
  transform: scale(1.05);
}

.date-badge {
  position: absolute;
  top: 8px;
  right: 8px;
  background-color: rgba(0,0,0,0.7);
  color: white;
  padding: 4px 8px;
  border-radius: 4px;
  font-size: 0.75rem;
  z-index: 2;
}

.image-container {
  width: 100%;
  height: 100%;
  position: relative;
  overflow: hidden;
  background-color: #f3f4f6;
  display: flex;
  align-items: center;
  justify-content: center;
}

.image-container img {
  width: 100%;
  height: 100%;
  object-fit: cover;
  transition: transform 0.3s ease;
}

.image-container.loaded img {
  opacity: 1;
}

.image-container.error {
  background-color: #fee2e2;
}

/* Styles spécifiques pour Notion */
@media screen and (max-width: 800px) {
  body {
      padding: 16px;
  }

  .container {
      padding: 16px;
  }

  .instagram-grid {
      gap: 8px;
  }

  .button-container {
    padding: 0;
  }
  
  .refresh-btn,
  .disconnect-btn {
    width: 100%;
    max-width: 200px; /* Limite la largeur sur petits écrans */
  }
}