/* ==========================================================================
   VARIABLES (Palette de couleurs et réglages globaux)
   ========================================================================== */
:root {
  --bg-body: #0f172a;          /* Slate 900 - Fond principal */
  --bg-surface: #1e293b;       /* Slate 800 - Cartes, Sidebar, Formulaires */
  --bg-surface-hover: #334155; /* Slate 700 - Survol */
  --primary: #ec4899;          /* Pink 500 - Couleur d'accentuation principale */
  --primary-hover: #be185d;    /* Pink 700 - Survol de l'accentuation */
  --text-main: #f8fafc;        /* Slate 50 - Texte principal */
  --text-muted: #94a3b8;       /* Slate 400 - Texte secondaire */
  --border-color: #334155;     /* Slate 700 - Bordures */
  
  --radius-sm: 6px;
  --radius-md: 12px;
  --shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.5), 0 2px 4px -1px rgba(0, 0, 0, 0.3);
  --shadow-hover: 0 10px 15px -3px rgba(236, 72, 153, 0.15);
}

/* ==========================================================================
   RESET & BASE
   ========================================================================== */
* {
  box-sizing: border-box;
  margin: 0;
  padding: 0;
}

body {
  font-family: 'Inter', 'Segoe UI', Roboto, Helvetica, Arial, sans-serif;
  background-color: var(--bg-body);
  color: var(--text-main);
  display: flex;
  min-height: 100vh;
  line-height: 1.5;
}

a {
  text-decoration: none;
  color: var(--primary);
  transition: color 0.2s ease;
}

a:hover {
  color: var(--primary-hover);
}

h1, h2, h3 {
  margin-bottom: 1rem;
}

/* ==========================================================================
   LAYOUT PRINCIPAL
   ========================================================================== */
/* Sidebar */
.sidebar {
  width: 240px;
  background-color: var(--bg-surface);
  height: 100vh;
  padding: 2rem 1rem;
  position: fixed;
  left: 0;
  top: 0;
  border-right: 1px solid var(--border-color);
  z-index: 100;
  box-shadow: var(--shadow);
}

.sidebar h2 {
  text-align: center;
  margin-bottom: 2rem;
  color: var(--primary);
  font-size: 1.5rem;
  display: flex;
  align-items: center;
  justify-content: center;
  gap: 0.5rem;
}

.sidebar a {
  display: block;
  padding: 0.8rem 1rem;
  color: var(--text-muted);
  border-radius: var(--radius-sm);
  margin-bottom: 0.5rem;
  font-weight: 500;
  transition: all 0.2s ease;
}

.sidebar a:hover {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
  transform: translateX(5px); /* Petit effet de translation sympa */
}

/* Main content */
.main {
  margin-left: 240px;
  padding: 2.5rem;
  flex: 1;
  width: calc(100% - 240px);
}

.main > h1 {
  font-size: 2rem;
  margin-bottom: 2rem;
  border-bottom: 2px solid var(--border-color);
  padding-bottom: 0.8rem;
}

/* ==========================================================================
   CARTES DES ANIMES (La liste)
   ========================================================================== */
.anime-container {
  display: grid;
  /* CSS Grid : crée des colonnes dynamiques d'au moins 280px */
  grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
  gap: 2rem;
  width: 100%;
}

.anime-card {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  overflow: hidden; /* Pour que l'image respecte les bords arrondis */
  box-shadow: var(--shadow);
  display: flex;
  flex-direction: column;
  transition: transform 0.2s ease, box-shadow 0.2s ease, border-color 0.2s ease;
  border: 1px solid var(--border-color);
}

.anime-card:hover {
  transform: translateY(-6px);
  box-shadow: var(--shadow-hover);
  border-color: var(--primary);
}

.anime-card img {
  width: 100%;
  height: 350px;
  object-fit: cover; /* Garde les proportions de l'image sans l'écraser */
  display: block;
}

.anime-info {
  padding: 1.5rem;
  display: flex;
  flex-direction: column;
  flex-grow: 1;
}

.anime-title {
  font-size: 1.2rem;
  font-weight: 700;
  margin-bottom: 0.8rem;
  color: var(--text-main);
}

.badge {
  display: inline-block;
  background: var(--bg-surface-hover);
  color: var(--text-main);
  padding: 0.2rem 0.8rem;
  border-radius: 20px;
  font-size: 0.75rem;
  font-weight: 600;
  margin-right: 0.5rem;
  margin-bottom: 1rem;
  border: 1px solid var(--border-color);
}

/* Le synopsis */
.anime-info p {
  font-size: 0.9rem;
  margin-bottom: 0.8rem;
}

.anime-info p:first-of-type {
  color: var(--text-muted);
  /* Coupe intelligemment le texte après 3 lignes */
  display: -webkit-box;
  -webkit-line-clamp: 3;
  -webkit-box-orient: vertical;
  overflow: hidden;
  margin-bottom: 1.5rem;
  flex-grow: 1; /* Pousse les boutons et status vers le bas */
}

/* ==========================================================================
   BOUTONS & ACTIONS
   ========================================================================== */
button, .btn, .button-recherche {
  background-color: var(--bg-surface-hover);
  color: var(--text-main);
  border: 1px solid var(--border-color);
  padding: 0.6rem 1.2rem;
  border-radius: var(--radius-sm);
  cursor: pointer;
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.2s ease;
  display: inline-block;
  text-align: center;
}

button:hover, .btn:hover, .button-recherche:hover {
  background-color: var(--primary);
  border-color: var(--primary);
  color: #fff;
}

.action-buttons {
  margin-top: 1rem;
  padding-top: 1.2rem;
  border-top: 1px solid var(--border-color);
  display: flex;
  gap: 0.8rem;
}

.action-buttons form {
  flex: 1; /* Les boutons prennent 50% de la largeur chacun */
}

.action-buttons button {
  width: 100%;
}

/* Emoji boutons increment/decrement */
.btn-success, .btn-warning {
  background: none;
  border: none;
  padding: 0 0.4rem;
  font-size: 1.2rem;
  box-shadow: none;
}
.btn-success:hover, .btn-warning:hover {
  background: none;
  border: none;
  transform: scale(1.2);
}

/* ==========================================================================
   FORMULAIRES (Login, Modifier, Recherche)
   ========================================================================== */
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
  width: 100%;
  padding: 0.8rem 1rem;
  margin-bottom: 1.2rem;
  background-color: var(--bg-body);
  border: 1px solid var(--border-color);
  color: var(--text-main);
  border-radius: var(--radius-sm);
  font-family: inherit;
  transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus, select:focus, textarea:focus {
  outline: none;
  border-color: var(--primary);
  box-shadow: 0 0 0 3px rgba(236, 72, 153, 0.2); /* Halo rose au focus */
}

/* Conteneur pour modifier.php et login.php */
.form-container, form[method="POST"]:not(.action-buttons form) {
  max-width: 500px;
  background: var(--bg-surface);
  margin: 2rem auto;
  padding: 2.5rem;
  border-radius: var(--radius-md);
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
}

label {
  display: block;
  margin-bottom: 0.5rem;
  font-weight: 600;
  color: var(--text-muted);
}

/* ==========================================================================
   MENU DE TRI (Radio buttons sur l'index)
   ========================================================================== */
.wrapper {
  background-color: var(--bg-surface);
  border: 1px solid var(--border-color);
  border-radius: 34px;
  display: inline-flex; /* S'adapte à la taille du contenu */
  flex-wrap: wrap;
  padding: 6px;
  gap: 4px;
  margin-bottom: 2.5rem;
  box-shadow: var(--shadow);
}

.option {
  position: relative;
  height: 36px;
  border-radius: 34px;
}

.input {
  width: 100%;
  height: 100%;
  position: absolute;
  left: 0;
  top: 0;
  appearance: none;
  cursor: pointer;
  z-index: 2;
}

.tri {
  width: 100%;
  height: 100%;
  border-radius: 34px;
  display: flex;
  justify-content: center;
  align-items: center;
  padding: 0 20px;
  background-color: transparent;
  color: var(--text-muted);
  font-size: 0.9rem;
  font-weight: 600;
  transition: all 0.3s ease;
  border: none;
  cursor: pointer;
}

.input:checked + .tri {
  background-color: var(--primary);
  color: white;
  box-shadow: 0 2px 8px rgba(236, 72, 153, 0.4);
}

select.tri {
  appearance: none;
  -webkit-appearance: none;
  outline: none;
}

/* ==========================================================================
   CARTE DE RECHERCHE (API Jikan)
   ========================================================================== */
.anime-card-recherche {
  background: var(--bg-surface);
  border-radius: var(--radius-md);
  padding: 1.5rem;
  margin: 1.5rem auto;
  max-width: 800px;
  display: flex;
  gap: 2rem;
  box-shadow: var(--shadow);
  border: 1px solid var(--border-color);
  text-align: left;
}

.anime-card-recherche img {
  width: 180px;
  height: 260px;
  object-fit: cover;
  border-radius: var(--radius-sm);
  flex-shrink: 0;
}

/* Le conteneur du texte et formulaire de la recherche */
.anime-card-recherche > div, 
.anime-card-recherche form {
  flex-grow: 1;
  display: flex;
  flex-direction: column;
}

.anime-card-recherche h3 {
  color: var(--primary);
  font-size: 1.4rem;
  margin-top: 0;
}

/* ==========================================================================
   RESPONSIVE (Mobiles et Tablettes)
   ========================================================================== */
@media (max-width: 850px) {
  body {
    flex-direction: column;
  }

  .sidebar {
    width: 100%;
    height: auto;
    position: relative;
    padding: 1rem;
    display: flex;
    flex-direction: column;
    border-right: none;
    border-bottom: 1px solid var(--border-color);
  }

  .sidebar h2 {
    margin-bottom: 1rem;
  }

  .sidebar a {
    text-align: center;
  }

  .main {
    margin-left: 0;
    width: 100%;
    padding: 1.5rem;
  }

  /* Cartes de recherche passent en colonne sur mobile */
  .anime-card-recherche {
    flex-direction: column;
    align-items: center;
    text-align: center;
  }

  .anime-card-recherche img {
    width: 100%;
    max-width: 250px;
  }
}