:root {
    --primary-color: #d32f2f;
    --bg-color: #f4f4f4;
    --card-bg: #ffffff;
    --text-color: #333;
    --header-bg: #2c3e50;
    --header-text: #ecf0f1;
}

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* Header & Nav */
header {
    background-color: var(--header-bg);
    color: var(--header-text);
    padding: 1rem 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    position: sticky;
    top: 0;
    z-index: 1500;
}

.logo {
    font-size: 1.5rem;
    font-weight: bold;
    cursor: pointer;
    user-select: none;
}

#dm-indicator {
    background-color: #f39c12;
    color: white;
    padding: 4px 10px;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: bold;
    margin-left: 15px;
    display: flex;
    align-items: center;
    gap: 5px;
    box-shadow: 0 0 10px rgba(243, 156, 18, 0.5);
    animation: pulse-dm 2s infinite;
}

@keyframes pulse-dm {
    0% { transform: scale(1); }
    50% { transform: scale(1.05); }
    100% { transform: scale(1); }
}

nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
    gap: 15px;
}

nav button {
    background: none;
    border: none;
    color: #bdc3c7;
    cursor: pointer;
    font-size: 1rem;
    padding: 5px 10px;
    transition: color 0.3s, border-bottom 0.3s;
    border-bottom: 2px solid transparent;
}

nav button:hover, nav button.active {
    color: white;
    border-bottom: 2px solid var(--primary-color);
}

/* Scroll to Top Button */
#scroll-top {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 50px;
    height: 50px;
    background-color: var(--primary-color);
    color: white;
    border: none;
    border-radius: 50%;
    cursor: pointer;
    display: none; /* Hidden by default */
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    box-shadow: 0 4px 10px rgba(0,0,0,0.3);
    z-index: 1000;
    transition: transform 0.2s, background-color 0.2s;
}

#scroll-top:hover {
    transform: scale(1.1);
    background-color: #b71c1c;
}

/* Main Content */
main {
    flex: 1;
    padding: 2rem;
    max-width: 1200px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

/* Welcome Page */
.welcome-page {
    max-width: 900px;
    margin: 0 auto;
}

.welcome-hero {
    text-align: center;
    padding: 3rem 1rem 2rem;
}

.welcome-hero h1 {
    font-size: 2.5rem;
    color: var(--header-bg);
    margin: 0 0 0.5rem;
}

.welcome-subtitle {
    font-size: 1.2rem;
    color: #777;
    margin: 0;
}

.welcome-content {
    background: var(--card-bg);
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 2px 10px rgba(0,0,0,0.08);
}

.welcome-content > p {
    font-size: 1.05rem;
    line-height: 1.7;
    color: #555;
    text-align: center;
}

.welcome-features {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(200px, 1fr));
    gap: 20px;
    margin: 2rem 0;
}

.welcome-card {
    text-align: center;
    padding: 1.5rem 1rem;
    border-radius: 8px;
    background: var(--bg-color);
    transition: transform 0.2s;
}

.welcome-card:hover {
    transform: translateY(-3px);
}

.welcome-card i {
    font-size: 2rem;
    color: var(--primary-color);
    margin-bottom: 0.75rem;
}

.welcome-card h3 {
    margin: 0 0 0.5rem;
    color: var(--header-bg);
}

.welcome-card p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.welcome-cta {
    text-align: center;
    font-style: italic;
    color: #999 !important;
    margin-bottom: 0 !important;
}

/* Cards Grid */
.grid-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 20px;
}

.card {
    background: var(--card-bg);
    border-radius: 8px;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
    padding: 1.5rem;
    transition: transform 0.2s, box-shadow 0.2s;
    height: 300px; 
    overflow: hidden;
    position: relative;
    cursor: pointer;
    display: flex;
    flex-direction: column;
}

.card:hover {
    transform: translateY(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.card::after {
    content: "";
    position: absolute;
    bottom: 0;
    left: 0;
    width: 100%;
    height: 60px;
    background: linear-gradient(to bottom, transparent, var(--card-bg));
    pointer-events: none;
}

/* HEADER DE CARTE AVEC IMAGE A DROITE */
.card-header {
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    border-bottom: 1px solid #eee;
    margin-bottom: 10px;
    padding-bottom: 5px;
}

.card h2 {
    color: var(--primary-color);
    margin: 0;
    font-size: 1.25rem;
    flex: 1;
    padding-right: 10px;
}

.card-image {
    width: 50px;
    height: 50px;
    flex-shrink: 0;
}

.card-image img {
    width: 100%;
    height: 100%;
    object-fit: contain;
}

/* IMAGE DANS LE MODAL - FLOAT RIGHT */
.modal-image {
    float: right;
    margin-left: 20px;
    margin-bottom: 15px;
    max-width: 250px;
}

.modal-image img {
    width: 100%;
    max-height: 300px;
    border-radius: 8px;
    box-shadow: 0 4px 10px rgba(0,0,0,0.2);
    cursor: zoom-in;
}

/* Nettoyage du float pour que le footer du modal reste en dessous */
.modal-body::after {
    content: "";
    display: table;
    clear: both;
}

.card .meta {
    font-size: 0.9rem;
    color: #666;
    margin-bottom: 1rem;
    font-style: italic;
}

.tags span {
    background: #eee;
    padding: 3px 8px;
    border-radius: 12px;
    font-size: 0.8rem;
    margin-right: 5px;
    display: inline-block;
    margin-bottom: 5px;
}

/* Footer */
footer {
    text-align: center;
    padding: 1rem;
    background: #e0e0e0;
    margin-top: auto;
}

/* Utilities */
.loading { color: #888; font-style: italic; }
.error { color: red; font-weight: bold; }

/* Toolbar */
.toolbar {
    position: sticky;
    top: 75px; /* Offset because of sticky header */
    z-index: 1000;
    background: rgba(255, 255, 255, 0.9);
    backdrop-filter: blur(10px);
    padding: 10px 20px;
    margin-bottom: 20px;
    border-radius: 8px;
    box-shadow: 0 4px 15px rgba(0,0,0,0.15);
    display: flex;
    gap: 15px;
    align-items: center;
    flex-wrap: wrap;
    border: 1px solid rgba(255, 255, 255, 0.3);
}

.toolbar input, .toolbar select {
    padding: 8px 12px;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-size: 0.9rem;
    outline: none;
}

.toolbar input:focus, .toolbar select:focus {
    border-color: var(--primary-color);
}

.toolbar .search-box {
    flex: 1;
    min-width: 200px;
}

.toolbar .sort-filter-group {
    display: flex;
    gap: 10px;
    align-items: center;
}

.toolbar label {
    font-size: 0.85rem;
    font-weight: bold;
    color: #555;
}

/* Barometer Physics */
#barometer-container {
    margin-top: 50px;
    display: flex;
    flex-direction: column;
    align-items: center;
}

.barometer {
    display: flex;
    flex-direction: column;
    align-items: center;
    background: white;
    padding: 30px;
    border-radius: 15px;
    box-shadow: 0 10px 30px rgba(0,0,0,0.1);
    border: 1px solid #eee;
    width: 100%;
    max-width: 850px;
    box-sizing: border-box;
}

.physics-world {
    position: relative;
    width: 100%;
    max-width: 800px;
    background: radial-gradient(ellipse at center, #1a1a2e 0%, #0f0f1a 60%, #0a0a12 100%);
    border-radius: 16px;
    box-shadow: inset 0 0 40px rgba(0,0,0,0.6), 0 4px 20px rgba(0,0,0,0.3);
    border: 2px solid #2a2a3e;
    overflow: hidden;
    margin-bottom: 20px;
}

.physics-canvas {
    width: 100%;
    height: auto;
}

.baro-interface {
    display: flex;
    width: 100%;
    justify-content: space-between;
    align-items: flex-start;
}

.baro-section {
    text-align: center;
    width: 150px;
}

.baro-section h3 {
    margin-top: 0;
    font-size: 1.1rem;
    color: #555;
}

.baro-section.positive .count {
    color: #27ae60;
    font-size: 3rem;
    font-weight: bold;
}

.baro-section.negative .count {
    color: #c0392b;
    font-size: 3rem;
    font-weight: bold;
}

.baro-mid-btns {
    display: flex;
    gap: 15px;
    margin-top: 10px;
}

.btn-use-point {
    background: #2c3e50 !important;
    color: white !important;
    border: none !important;
    padding: 10px 20px !important;
    border-radius: 25px;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.2s, background 0.2s;
    font-size: 0.8rem;
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 8px;
    box-shadow: 0 3px 6px rgba(0,0,0,0.15);
}

.btn-use-point.use-pos { background: #1b5e20 !important; }
.btn-use-point.use-neg { background: #7b1fa2 !important; }
.btn-use-point.red-btn { background: #c0392b !important; }

.btn-use-point:hover {
    transform: translateY(-2px);
    filter: brightness(1.1);
}

.baro-controls {
    margin-top: 10px;
    display: flex;
    justify-content: center;
    gap: 5px;
}

.baro-controls button {
    background: #f1f3f5;
    border: 1px solid #dee2e6;
    border-radius: 4px;
    padding: 4px 8px;
    cursor: pointer;
}

/* Notifications / Toasts */
#notification-container {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 5000;
    display: flex;
    flex-direction: column;
    gap: 10px;
}

.notification {
    background: #333;
    color: white;
    padding: 12px 24px;
    border-radius: 8px;
    box-shadow: 0 5px 15px rgba(0,0,0,0.3);
    display: flex;
    align-items: center;
    gap: 15px;
    min-width: 300px;
    animation: toastIn 0.3s ease-out;
    border-left: 5px solid #888;
}

.notification.error {
    border-left-color: #c0392b;
}

.notification.success {
    border-left-color: #27ae60;
}

.notification.info {
    border-left-color: #2980b9;
}

@keyframes toastIn {
    from { transform: translateY(20px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes toastOut {
    from { transform: translateY(0); opacity: 1; }
    to { transform: translateY(20px); opacity: 0; }
}

/* MODAL STYLES */
.modal-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    z-index: 3000;
    justify-content: center;
    align-items: center;
    padding: 20px;
    box-sizing: border-box;
    backdrop-filter: blur(5px);
}

.modal-content {
    background: white;
    padding: 2rem;
    border-radius: 8px;
    width: 100%;
    max-width: 900px;
    max-height: 90vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 10px 25px rgba(0,0,0,0.5);
    animation: slideIn 0.3s ease-out;
}

.modal-content h2 {
    color: var(--primary-color);
    margin-top: 0;
    border-bottom: 2px solid #eee;
    padding-bottom: 15px;
    margin-bottom: 20px;
}

.close-modal {
    position: absolute;
    top: 15px;
    right: 25px;
    font-size: 2.5rem;
    line-height: 2rem;
    cursor: pointer;
    color: #999;
    transition: color 0.2s;
    user-select: none;
    z-index: 10;
}

.close-modal:hover {
    color: var(--primary-color);
}

/* LIGHTBOX STYLES */
.lightbox-overlay {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.95);
    z-index: 4000;
    justify-content: center;
    align-items: center;
    animation: fadeIn 0.3s;
}

.lightbox-overlay img {
    max-width: 95%;
    max-height: 95vh;
    box-shadow: 0 0 20px rgba(0,0,0,0.5);
    border: 2px solid #333;
}

.close-lightbox {
    position: absolute;
    top: 20px;
    right: 30px;
    color: white;
    font-size: 3rem;
    cursor: pointer;
    user-select: none;
}

.close-lightbox:hover {
    color: var(--primary-color);
}

@keyframes slideIn {
    from { transform: translateY(30px); opacity: 0; }
    to { transform: translateY(0); opacity: 1; }
}

@keyframes fadeIn {
    from { opacity: 0; }
    to { opacity: 1; }
}

/* Responsive */
@media (max-width: 768px) {
    header {
        flex-direction: column;
        gap: 10px;
        padding: 1rem;
    }

    nav ul {
        flex-wrap: wrap;
        justify-content: center;
        gap: 8px;
    }

    main {
        padding: 1rem;
    }

    .grid-container {
        grid-template-columns: 1fr;
    }

    .toolbar {
        top: auto;
        position: relative;
        flex-direction: column;
    }

    .toolbar .sort-filter-group {
        flex-wrap: wrap;
    }

    .baro-interface {
        flex-direction: column;
        align-items: center;
        gap: 15px;
    }

    .baro-mid-btns {
        flex-direction: column;
        align-items: center;
    }

    .baro-section {
        width: auto;
    }

    .baro-section .count {
        font-size: 2rem;
    }

    .modal-content {
        max-width: 95vw;
        padding: 1rem;
    }

    .modal-image {
        float: none;
        margin: 0 auto 15px;
        max-width: 100%;
    }

    .welcome-hero h1 {
        font-size: 1.75rem;
    }

    .welcome-features {
        grid-template-columns: 1fr;
    }
}
