@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;500;700&display=swap');

:root {
    /* Palette inspirée de index.css */
    --primary-orange: #ff6a00;
    --secondary-yellow: #FFE066;
    --bg-color: #fff2be;
    --text-dark: #222;
    --text-gray: #555;
    --card-base: #ffffff;
    --shadow-soft: 0 4px 15px rgba(0, 0, 0, 0.05);
    --shadow-hover: 0 15px 30px rgba(0, 0, 0, 0.1);

    /* Couleurs des familles (Ajustées pour fond clair - tons plus pastels/solides) */
    --col-alkali: #ff6b6b;
    --col-alkaline: #ff9f43;
    --col-transition: #feca57;
    --col-post-trans: #badc58;
    --col-metalloid: #6ab04c;
    --col-nonmetal: #48dbfb;
    --col-noble: #a55eea;
    --col-lanthanide: #fd79a8;
    --col-actinide: #e056fd;
    --col-unknown: #95afc0;
}

* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    background-color: var(--bg-color);
    color: var(--text-dark);
    font-family: 'Poppins', sans-serif;
    overflow-x: hidden;
    height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Header & Controls --- */
header {
    padding: 30px 20px;
    text-align: center;
    flex-shrink: 0;
    z-index: 10;
}

h1 {
    font-size: 3rem;
    margin-bottom: 10px;
    /* Gradient inspiré de --gradient-primary */
    background: linear-gradient(135deg, #ff6a00, #ff9500);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    text-transform: uppercase;
    letter-spacing: -1px;
    font-weight: 700;
}

.controls {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 12px;
    margin-top: 20px;
}

.filter-btn {
    background: var(--secondary-yellow);
    border: none;
    color: var(--text-dark);
    padding: 10px 20px;
    border-radius: 50px;
    /* Style "Badge" */
    cursor: pointer;
    transition: all 0.3s cubic-bezier(0.25, 1, 0.5, 1);
    font-size: 0.9rem;
    font-weight: 500;
    font-family: 'Poppins', sans-serif;
    box-shadow: var(--shadow-soft);
}

/* Quand on survole ou active, on utilise la couleur spécifique de la famille si dispo */
.filter-btn:hover,
.filter-btn.active {
    background: var(--btn-color, var(--primary-orange));
    color: #fff;
    transform: translateY(-2px);
    /* Ombre colorée pour matcher le bouton */
    box-shadow: 0 8px 20px -5px var(--btn-color, rgba(255, 106, 0, 0.4));
}

/* --- Main Layout --- */
.main-container {
    flex: 1;
    display: flex;
    overflow: hidden;
    position: relative;
}

.table-scroll-wrapper {
    flex: 1;
    overflow: auto;
    padding: 40px;
    display: flex;
    justify-content: center;
    align-items: flex-start;
}

/* --- Grid du Tableau --- */
.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 70px);
    /* Cellules un peu plus larges */
    grid-template-rows: repeat(10, 80px);
    /* Cellules plus hautes */
    gap: 8px;
    user-select: none;
    padding-bottom: 100px;
    transition: transform 0.3s;
}

/* --- Style de l'Atome (Carte) --- */
.element {
    background: var(--card-base);
    border-radius: 12px;
    /* Arrondi style index.css */
    position: relative;
    cursor: pointer;
    transition: all 0.4s cubic-bezier(0.25, 1, 0.5, 1);
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    opacity: 0;
    transform: translateY(20px);
    /* Animation style .nav-card */
    animation: popIn 0.5s forwards;
    box-shadow: var(--shadow-soft);
    border-bottom: 4px solid var(--elm-color);
    /* Ligne de couleur en bas */
    border-top: 1px solid transparent;
    border-left: 1px solid transparent;
    border-right: 1px solid transparent;
}

@keyframes popIn {
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.element:hover {
    transform: translateY(-8px) scale(1.1);
    z-index: 100;
    box-shadow: 0 15px 30px rgba(0, 0, 0, 0.15);
}

/* --- ÉTAT DIMMED (Non sélectionné) --- */
.periodic-table.filtering .element {
    opacity: 0.08;
    /* Presque invisible */
    transform: scale(0.85);
    filter: grayscale(100%);
    /* En gris */
    box-shadow: none;
    pointer-events: none;
    /* Désactive le clic et le hover */
}

/* --- ÉTAT HIGHLIGHT (Sélectionné) --- */
.periodic-table.filtering .element.highlight {
    opacity: 1;
    filter: grayscale(0%);
    transform: scale(1.15) translateY(-5px);
    /* Plus gros */
    z-index: 10;
    pointer-events: auto;
    /* Réactive les événements */

    /* Bordure complète colorée et ombre lumineuse */
    border: 2px solid var(--elm-color);
    box-shadow: 0 10px 30px -5px var(--elm-color);
}

.at-num {
    position: absolute;
    top: 5px;
    left: 8px;
    font-size: 0.7rem;
    color: var(--text-gray);
    font-weight: 500;
}

.symbol {
    font-size: 1.6rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 5px;
}

.name {
    font-size: 0.6rem;
    color: var(--text-gray);
    max-width: 90%;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    text-transform: capitalize;
}

/* --- Panneau de Détails (Style Carte Moderne) --- */
#detail-panel {
    position: fixed;
    right: -450px;
    top: 20px;
    bottom: 20px;
    width: 400px;
    background: #fff;
    border-radius: 24px 0 0 24px;
    /* Arrondi gauche */
    padding: 40px;
    box-shadow: -10px 0 40px rgba(0, 0, 0, 0.1);
    transition: right 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    z-index: 1000;
    display: flex;
    flex-direction: column;
    gap: 20px;
}

/* Responsive panel */
@media (max-width: 768px) {
    #detail-panel {
        border-radius: 24px 24px 0 0;
        top: auto;
        bottom: -100%;
        left: 0;
        right: 0;
        width: 100%;
        height: 80vh;
        transition: bottom 0.5s cubic-bezier(0.25, 1, 0.5, 1);
    }

    #detail-panel.active {
        bottom: 0;
        right: 0;
        /* Reset */
    }
}

/* Desktop active state */
@media (min-width: 769px) {
    #detail-panel.active {
        right: 0;
    }

    #detail-panel {
        border-radius: 24px 0 0 24px;
    }
}


.detail-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    margin-bottom: 10px;
}

.close-btn {
    background: var(--bg-color);
    border: none;
    color: var(--text-dark);
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.close-btn:hover {
    background: #ddd;
}

.big-symbol-container {
    width: 140px;
    height: 140px;
    background: var(--bg-color);
    border-radius: 30px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    margin: 0 auto;
    border: 4px solid var(--panel-color, #222);
    color: var(--text-dark);
    box-shadow: 0 10px 25px -5px var(--panel-color);
    /* Ombre colorée aussi ici */
}

.big-num {
    font-size: 1.1rem;
    align-self: flex-start;
    margin-left: 15px;
    color: var(--text-gray);
    font-weight: 600;
}

.big-sym {
    font-size: 4rem;
    font-weight: 700;
    line-height: 1;
}

.big-weight {
    font-size: 0.9rem;
    margin-top: 5px;
    color: var(--text-gray);
}

.detail-info h2 {
    font-size: 2.2rem;
    color: var(--text-dark);
    text-align: center;
    margin-bottom: 5px;
}

.detail-category {
    text-transform: uppercase;
    letter-spacing: 2px;
    font-size: 0.8rem;
    color: var(--primary-orange);
    text-align: center;
    font-weight: 700;
    margin-bottom: 30px;
    background: rgba(255, 106, 0, 0.1);
    /* hero-badge style */
    display: inline-block;
    padding: 5px 15px;
    border-radius: 20px;
    align-self: center;
}

.data-row {
    display: flex;
    justify-content: space-between;
    padding: 15px 0;
    border-bottom: 1px solid #eee;
    font-size: 1rem;
}

.data-label {
    color: var(--text-gray);
}

.data-value {
    font-weight: 600;
    color: var(--text-dark);
}

.wiki-link {
    margin-top: auto;
    text-align: center;
    background: var(--primary-orange);
    color: #fff;
    text-decoration: none;
    padding: 15px;
    border-radius: 12px;
    font-weight: 600;
    transition: transform 0.3s;
    box-shadow: 0 4px 15px rgba(255, 106, 0, 0.3);
}

.wiki-link:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(255, 106, 0, 0.4);
}

.back-btn {
    position: absolute;
    top: 20px;
    right: 20px;
    color: white;
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 10px;
    font-weight: 500;
    background: var(--text-dark);
    padding: 10px 20px;
    border-radius: 30px;
    box-shadow: var(--shadow-soft);
    transition: all 0.3s;
    z-index: 1000;
}

.back-btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-hover);
    background: #000;
}

@media (max-width: 1200px) {
    .periodic-table {
        transform: scale(0.85);
        transform-origin: top left;
    }
}