body {
  font-family: Arial, sans-serif;
  background-color: #f8f8f8;
  margin: 0;
}

/* Styling for the form container */
#form-recherche-livre {
  background: white;
  padding: 20px;
  
  width: auto;
  max-width: none;
  margin: 24px auto;
}

/* Responsive improvement for very small screens */
@media (max-width: 400px) {
  #form-recherche-livre {
    padding: 15px;
  }
}

/* Responsive: for phones and small screens */
@media (max-width: 600px) {
  #form-recherche-livre {
    width: 98%;
    padding: 10px;
    border-radius: 0;
    box-shadow: none;
    margin: 0;
    max-width: 100vw;
  }

  .form-header {
    flex-direction: column !important;
    align-items: center !important;
    justify-content: center !important;
    margin-bottom: 16px;
  }
  .form-logo {
    margin: 0 0 8px 0 !important;
    width: 40px;
    height: 40px;
  }
  #form-recherche-livre h3,
  .centered-title {
    font-size: 1.1rem;
    margin-bottom: 14px;
  }
  #form-recherche-livre label {
    font-size: 0.98rem;
    margin: 10px 0 4px;
  }
  #form-recherche-livre select,
  #form-recherche-livre input,
  #form-recherche-livre button {
    font-size: 1rem;
    padding: 9px;
    margin: 7px 0;
  }
  .language-switcher-container {
    flex-direction: column;
    align-items: flex-start;
    gap: 6px;
    padding: 10px 0;
    margin-bottom: 18px;
  }
  /* Responsive Table: Prevent horizontal overflow, make scrollable on small screens */
  #resultats-recherche {
    width: 100%;
    overflow-x: auto;
    -webkit-overflow-scrolling: touch;
  }
  #resultats-recherche table {
    min-width: 480px; /* Adjust to fit your columns, or set to 100% if few columns */
  }
}

/* Keep all existing desktop styles below */

.form-header {
  display: flex;
  align-items: center;      /* Vertically center items */
  justify-content: center;  /* Horizontally center items */
  flex-direction: column;   /* Stack items vertically */
  margin-bottom: 20px;
}

/* Default LTR layout (logo on left) */
[dir="ltr"] .form-header {
  justify-content: flex-start;
  flex-direction: row-reverse;
}

[dir="ltr"] .form-logo {
  margin-right: 15px;
  margin-left: 0;
}

/* RTL layout (logo on right) */
[dir="rtl"] .form-header {
  justify-content: flex-end;
  flex-direction: row;
}

[dir="rtl"] .form-logo {
  margin-left: 15px;
  margin-right: 0;
}

.form-logo {
  width: 50px;
  height: 50px;
  border-radius: 50%;
}

/* Always center the title inside the form! */
#form-recherche-livre h3,
.centered-title {
  text-align: center !important;
  margin: 0 auto 20px auto;
  display: block;
  line-height: 1.5;
  font-size: 20px;
  font-weight: bold;
  color: #115b68;
}

/* Remove any direction-based text-align for h3 */
/* Keep direction for labels only */
[dir="rtl"] #form-recherche-livre label { text-align: right; }
[dir="ltr"] #form-recherche-livre label { text-align: left; }

/* Styling labels */
#form-recherche-livre label {
  display: block;
  margin: 15px 0 5px;
}

/* Styling select, input, and button elements */
#form-recherche-livre select,
#form-recherche-livre input,
#form-recherche-livre button {
  width: 100%;
  padding: 10px;
  margin: 10px 0;
  border: 1px solid #ccc;
  border-radius: 5px;
  box-sizing: border-box;
}

/* Radio buttons styling */
#form-recherche-livre input[type="radio"] {
  margin-right: 5px;
}

/* Styling the submit button */
#form-recherche-livre button {
  background-color: #115b68;
  color: white;
  border: none;
  cursor: pointer;
  transition: background-color 0.3s ease;
}

#form-recherche-livre button:hover {
  background-color: #0d4752;
}

/* Styling the results table */
#resultats-recherche table {
  width: 100%;
  border-collapse: collapse;
  margin-top: 20px;
}

#resultats-recherche th,
#resultats-recherche td {
  border: 1px solid #ccc;
  padding: 8px;
  text-align: center; /* Center align horizontally */
  vertical-align: middle; /* Center align vertically */
}

#resultats-recherche th {
  background-color: #f2f2f2;
  font-weight: bold;
}

#resultats-recherche tr:nth-child(even) {
  background-color: #f9f9f9;
}

/* Right-to-left styling for Arabic */
body[lang="ar"] {
  direction: rtl;
  text-align: right;
}

/* Left-to-right styling for English */
body[lang="en"] {
  direction: ltr;
  text-align: left;
}

/* Modern Language Switcher */
.language-switcher-container {
  display: flex;
  align-items: center;
  gap: 12px;
  margin-bottom: 30px;
  padding: 12px 0;
  border-bottom: 1px solid rgba(0,0,0,0.08);
}

.language-switcher-container > label:first-child {
  font-size: 0.9rem;
  font-weight: 500;
  color: white;
  margin-right: 8px;
}

.language-option {
  position: relative;
}

.language-option input[type="radio"] {
  position: absolute;
  opacity: 0;
  cursor: pointer;
}

.language-option label {
  display: inline-block;
  padding: 8px 16px;
  border-radius: 6px;
  background: #f1f3f4;
  color: black;
  font-size: 0.9rem;
  cursor: pointer;
  transition: all 0.3s cubic-bezier(0.4, 0, 0.2, 1);
  border: 1px solid transparent;
}

.language-option input[type="radio"]:checked + label {
  background: #0d4752;
  color: white;
  box-shadow: 0 1px 3px rgba(0,0,0,0.12);
}

.language-option input[type="radio"]:hover + label {
  background: #e8f0fe;
  color: #0d4752;
}

/* RTL Support */
[dir="rtl"] .language-switcher-container > label:first-child {
  margin-right: 0;
  margin-left: 8px;
}

/* Optional: Hide scroll bar for a cleaner look on some browsers */
#resultats-recherche {
  scrollbar-width: thin;
  scrollbar-color: #b3b3b3 #f8f8f8;
}
#resultats-recherche::-webkit-scrollbar {
  height: 6px;
  background: #f8f8f8;
}
#resultats-recherche::-webkit-scrollbar-thumb {
  background: #b3b3b3;
  border-radius: 3px;
}

/* Dark Mode Support */
@media (prefers-color-scheme: dark) {
  .language-switcher-container {
    border-bottom-color: rgba(255,255,255,0.08);
  }

  .language-switcher-container > label:first-child {
    color: #9aa0a6;
  }

  .language-option label {
    background: #3c4043;
    color: #e8eaed;
  }

  .language-option input[type="radio"]:hover + label {
    background: #5f6368;
    color: #e8eaed;
  }

  .language-option input[type="radio"]:checked + label {
    background: #0f7e94;
    color: #202124;
  }
}