/* ---------- Déclaration des thèmes dynamiques ---------- */
body[data-theme="flashbooks"] {
    --main-color: #6B46C1;
    --secondary-color: #0EA5E9;
    --tertiary-color: #EC4899;
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.1);
    --theme-icon: url('../images/icons/icon-flashbooks-flaaash.jpg');
    background: linear-gradient(135deg, #0EA5E9, #7C3AED, #EC4899);
    background-size: cover;
    background-position: center;
}

body[data-theme="everything"] {
    --main-color: #6a436f;
    --secondary-color: #74A2D1;
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.15);
    --theme-icon: url('../images/Flaaash-AI.jpg');
    background-image: url('../images/themes/everything.jpg');
    background-size: cover;
    background-position: center;
    background: linear-gradient(135deg, #6a436f, #74A2D1);
}

body[data-theme="scottish"] {
    --main-color: #0070cd; /* Bleu spécifique à Scottish */
    --secondary-color: #03a9f4; /* Couleur secondaire Scottish */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/icon-scottish-flaaash.jpg');
    background-image: url('../images/themes/scottish.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="irish"] {
    --main-color: #009B48; /* Vert irlandais */
    --secondary-color: #FF883E; /* Orange irlandais */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/icon-irish-flaaash.jpg');
    background-image: url('../images/themes/irish.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="german"] {
    --main-color: #DD0000;  /* Red from German flag */
    --secondary-color: #000000;  /* Black from German flag */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-German.jpg');
    background-image: url('../images/themes/german.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="cfa"] {
    --main-color: #009BFF;
    --secondary-color: #4C5A6C;
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-CFA.jpg');
    background-image: url('../images/themes/cfa.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="latin"] {
    --main-color: #FFD700;  /* Gold color for Latin */
    --secondary-color: #8B0000;  /* Dark red, reminiscent of Roman colors */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-Latin.jpg');
    background-image: url('../images/themes/latin.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="brasilianPortuguese"] {
    --main-color: #009c3b;  /* Green from Brazilian flag */
    --secondary-color: #ffdf00;  /* Yellow from Brazilian flag */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-BrasilianPortuguese.jpg');
    background-image: url('../images/themes/brasilianPortuguese.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="french"] {
    --main-color: #002395;  /* Blue from French flag */
    --secondary-color: #ED2939;  /* Red from French flag */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-French.jpg');
    background-image: url('../images/themes/french.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="english"] {
    --main-color: #00247D;  /* Blue from Union Jack */
    --secondary-color: #CF142B;  /* Red from Union Jack */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-English.jpg');
    background-image: url('../images/themes/english.jpg');
    background-size: cover;
    background-position: center;
}

body[data-theme="spanish"] {
    --main-color: #AA151B;  /* Red from Spanish flag */
    --secondary-color: #F1BF00;  /* Yellow from Spanish flag */
    --text-color: white;
    --shadow-color: rgba(0, 0, 0, 0.2);
    --theme-icon: url('../images/icons/Flaaash-Learn-Spanish.jpg');
    background-image: url('../images/themes/spanish.jpg');
    background-size: cover;
    background-position: center;
}

/* Variables partagées par tous les thèmes */
:root {
    --font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    --background-color: #f5f5f5; /* Fond global */
    --default-text-color: #333333; /* Couleur de texte par défaut */
    --neutral-color:#dddddd; /* Gris */
}

/* Base Container */
body.theme-switcher {
    position: relative;
    min-height: 100vh;
}

body.theme-switcher::before {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background: 
        radial-gradient(circle at 1px 1px, rgba(107, 70, 193, 0.15) 2px, transparent 0) 0 0 / 40px 40px,
        radial-gradient(circle at 50% 50%, rgba(107, 70, 193, 0.15) 0%, transparent 70%) center/250% 250%,
        linear-gradient(to bottom right, #f8f9ff, #ffffff);
    z-index: -1;
    animation: 
        moveDots 15s linear infinite,
        glowLight 8s ease-in-out infinite alternate;
}

@keyframes moveDots {
    0% {
        background-position: 0 0, center, 0 0;
    }
    100% {
        background-position: 40px 40px, center, 0 0;
    }
}

@keyframes glowLight {
    0% {
        background-position: 0 0, -50% -50%, 0 0;
    }
    100% {
        background-position: 40px 40px, 150% 150%, 0 0;
    }
}

/* Header */
header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 15px 15px 15px 15px;
    background-color: var(--main-color);
    color: var(--text-color);
    box-shadow: 0 2px 4px var(--shadow-color);
    margin: 0;
    opacity: 0.99;
}

header img {
    margin: 0 auto;
    width: 65px;
    height: auto;
    transition: all 0.3s ease;
}

header button {
    background: none;
    border: none;
    color: var(--text-color);
    font-size: 1.9rem;
    margin-right: 15px;
    cursor: pointer;
}

/* Language Selector in Themes */
.language-selector {
    margin-right: 15px; /* Add margin to avoid touching screen edge */
}

.language-selector select {
    background: rgba(255, 255, 255, 0.15);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 6px;
    padding: 0.4rem 0.6rem;
    font-size: 0.85rem;
    color: var(--text-color);
    cursor: pointer;
    transition: all 0.2s ease;
    appearance: none;
    -webkit-appearance: none;
    -moz-appearance: none;
    background-image: url("data:image/svg+xml;charset=UTF-8,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 24 24' fill='none' stroke='white' stroke-width='2' stroke-linecap='round' stroke-linejoin='round'%3e%3cpolyline points='6,9 12,15 18,9'%3e%3c/polyline%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right 0.4rem center;
    background-size: 0.8rem;
    padding-right: 1.8rem;
}

.language-selector select:hover {
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.5);
}

.language-selector select:focus {
    outline: none;
    background: rgba(255, 255, 255, 0.25);
    border-color: rgba(255, 255, 255, 0.7);
    box-shadow: 0 0 0 2px rgba(255, 255, 255, 0.2);
}

.language-selector select option {
    background: var(--main-color);
    color: var(--text-color);
}

/* Keep language selector visible on mobile for themes page */

/* Hide user button only on theme switcher pages */
.theme-switcher header .arrow-right {
    visibility: hidden;
}

header .spacer {
    width: 40px;
}

/* Theme Container */
.theme-container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0.5rem;
    box-sizing: border-box;
}

/* Welcome Text */
.welcome-text {
    text-align: center;
    margin: 2rem auto 1rem auto;
    padding: 0 1rem;
}

.theme-title {
    font-size: 1.5rem;
    font-weight: 700;
    color: #2D3748;
    margin-bottom: 0.5rem;
}

/* Search Container */
.search-container {
    display: flex;
    justify-content: center;
    margin-bottom: 20px;
    padding: 0 20px;
    box-sizing: border-box;
}

.search-container input {
    width: 100%;
    max-width: 400px;
    padding: 12px;
    border: 1px solid #ddd;
    border-radius: 25px;
    font-size: 1rem;
    color: #333;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
}

.search-container input:focus {
    outline: 2px solid var(--main-color);
    box-shadow: 0 0 5px var(--shadow-color);
}

.search-container input::placeholder {
    color: #aaa;
}

/* Theme Grid */
.theme-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 20px;
    padding: 0 15px;
    justify-content: center;
    max-width: 1200px;
    margin: 0 auto;
}

/* Theme Cards */
.theme-card {
    position: relative;
    padding: 1.25rem;
    border-radius: 16px;
    border: 1px solid rgba(255, 255, 255, 0.5);
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    box-sizing: border-box;
    overflow: visible;
    margin-bottom: 0.5rem;
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    height: auto;
    background: rgba(255, 255, 255, 0.9) !important;
    backdrop-filter: blur(12px);
    -webkit-backdrop-filter: blur(12px);
    box-shadow: 
        0 8px 32px 0 rgba(31, 38, 135, 0.07),
        inset 0 0 0 1px rgba(255, 255, 255, 0.5);
}

.theme-card:hover {
    transform: translateY(-5px);
    border-color: var(--main-color);
}

.theme-image {
    width: 100%;
    height: auto;
    aspect-ratio: 16 / 9;
    display: block;
    border-radius: 8px;
    overflow: hidden;
}

.theme-caption {
    background: transparent;
    padding: 15px;
    text-align: left;
}

.theme-caption h3 {
    font-size: 1.1rem;
    margin: 0;
    color: #2D3748;
    font-weight: 600;
}

.theme-description {
    color: #718096;
    margin: 8px 0 0 0;
    font-size: 0.9rem;
}

.active-theme-label {
    display: inline-block;
    background-color: var(--main-color);
    color: var(--text-color);
    padding: 4px 8px;
    border-radius: 12px;
    font-size: 0.8em;
    margin-top: 8px;
}

.theme-card.active-theme {
    border: 2px solid var(--main-color);
}

/* Message "Aucun résultat" */
.no-results {
    text-align: center;
    font-size: 1.1rem;
    color: #b0b0b0;
    margin-top: 20px;
}

/* Responsive Design */
@media (max-width: 768px) {
    .theme-grid {
        grid-template-columns: repeat(2, 1fr);
        padding: 0 10px;
        gap: 15px;
    }

    .search-container {
        padding: 0 15px;
    }

    .theme-container {
        padding: 0.25rem;
    }

    .welcome-text {
        margin: 0.75rem auto;
        padding: 0 0.75rem;
    }

    .theme-icon {
        margin-bottom: 3rem;
    }

    .theme-teacher {
        bottom: 7px;
    }

    .theme-authors {
        bottom: 15px;
    }

    .teacher-portrait {
        width: 55px;
        height: 55px;
        margin-bottom: 0.3rem;
    }

    .teacher-name {
        font-size: 0.65rem;
        margin-bottom: 0.4rem;
    }
}

@media (min-width: 1200px) {
    .theme-grid {
        grid-template-columns: repeat(3, 1fr);
    }

    .theme-container {
        padding: 2rem;
    }
}

@media (max-width: 480px) {
    .theme-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 10px;
        padding: 0 8px;
    }
    
    .theme-card {
        padding: 0.9rem;
        margin-top: 0.75rem;
        margin-bottom: 0.25rem;
    }
    
    .theme-caption {
        padding: 8px;
    }
    
    .theme-caption h3 {
        font-size: 0.95rem;
    }
    
    .theme-description {
        font-size: 0.75rem;
    }

    .theme-icon {
        margin-bottom: 2.5rem;
    }

    .theme-teacher {
        bottom: 5px;
    }

    .theme-authors {
        bottom: 8px;
    }
}

.theme-icon-container {
    position: relative;
    margin-bottom: 0.5rem;
}

.theme-icon {
    width: 100%;
    height: auto;
    border-radius: 8px;
    object-fit: contain;
}

/* Base styles (mobile first) */
.theme-teacher {
    position: absolute;
    right: 50%;
    transform: translateX(50%);
    bottom: 7px;  /* Position originale mobile */
    z-index: 2;
}

.theme-authors {
    position: absolute;
    right: 50%;
    transform: translateX(50%);
    bottom: 10px;  /* Position originale mobile */
    z-index: 2;
    display: flex;
    justify-content: center;
}

.teacher-name,
.books-authors-text {
    font-size: 0.7rem;
    color: #2D3748;
    font-weight: 500;
    text-align: center;
    margin-top: 0.25rem;  /* Position originale mobile */
    margin-bottom: 0.15rem;
}

/* Tablet styles */
@media (min-width: 481px) and (max-width: 1024px) {
    .theme-teacher {
        bottom: -25px;
    }

    .theme-authors {
        bottom: -15px;
    }

    .teacher-name,
    .books-authors-text {
        margin-top: 1.5rem;
    }
}

/* Desktop styles */
@media (min-width: 1025px) {
    .theme-teacher {
        bottom: -25px;
    }

    .theme-authors {
        bottom: -15px;
    }

    .teacher-name,
    .books-authors-text {
        margin-top: 1.5rem;
    }
}

.theme-cfa .teacher-portrait {
    border-color: white;  /* Ensure white border for CFA theme */
}

.theme-authors .author-portrait {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    background: white;
    margin-left: -20px;
}

.theme-authors .author-portrait:first-child {
    margin-left: 0;
}

.teacher-portrait {
    width: 65px;
    height: 65px;
    border-radius: 50%;
    border: 2px solid white;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
    object-fit: cover;
    background: white;
}

.theme-card:hover .teacher-portrait,
.theme-card:hover .author-portrait {
    transform: scale(1.05);
    box-shadow: 0 4px 8px rgba(0, 0, 0, 0.15);
}

.theme-card h3 {
    text-align: center;
    margin: 0.5rem 0 1rem 0;
    padding-bottom: 0.5rem;
    position: relative;
}

.teacher-name span {
    display: block;
    margin-bottom: 0.05rem;
}

.teacher-name span + span {
    font-size: calc(0.7rem * 1.15);
    font-weight: 700;
}

.theme-description {
    text-align: center;
    margin: 0 auto;
    max-width: 90%;
}

@media (max-width: 768px) {
    .teacher-portrait {
        width: 50px;
        height: 50px;
    }
    
    .theme-authors .author-portrait {
        width: 50px;
        height: 50px;
        margin-left: -12px;
    }
    
    .teacher-name,
    .books-authors-text {
        font-size: 0.6rem;
    }
    
    .teacher-name span + span {
        font-size: calc(0.6rem * 1.15);
    }
}

@media (max-width: 480px) {
    .teacher-portrait {
        width: 45px;
        height: 45px;
    }
    
    .theme-authors .author-portrait {
        width: 45px;
        height: 45px;
        margin-left: -10px;
    }
    
    .teacher-name,
    .books-authors-text {
        font-size: 0.55rem;
    }
    
    .teacher-name span + span {
        font-size: calc(0.55rem * 1.15);
    }
}
