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


body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: #f0f4f8;
    color: #333;
    padding: 20px;
    line-height: 1.6;
}


h1 {
    text-align: center;
    margin-bottom: 20px;
    font-size: 2em;
    color: #0d47a1;
}


.controls {
    display: flex;
    flex-direction: column;
    align-items: center;
    margin-bottom: 20px;
    gap: 10px;
}


.controls input[type="text"] {
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #90caf9;
    border-radius: 5px;
    transition: border-color 0.3s;
}

.controls input[type="text"]:focus {
    border-color: #42a5f5;
    outline: none;
}


.controls select {
    width: 100%;
    max-width: 400px;
    padding: 10px 15px;
    font-size: 1em;
    border: 2px solid #90caf9;
    border-radius: 5px;
    background-color: #fff;
    transition: border-color 0.3s;
}

.controls select:focus {
    border-color: #42a5f5;
    outline: none;
}


.periodic-table {
    display: grid;
    grid-template-columns: repeat(18, 60px);
    grid-auto-rows: 80px;
    grid-gap: 5px;
    justify-content: center;
    background-color: #fff;
    padding: 10px;
    border-radius: 10px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    overflow: auto;
}

/* Elementlar uchun umumiy uslublar */
.element {
    background-color: #e0f7fa;
    border: 1px solid #90caf9;
    border-radius: 5px;
    padding: 5px;
    text-align: center;
    position: relative;
    cursor: pointer;
    transition: transform 0.2s, background-color 0.2s, box-shadow 0.2s;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
    height: 100%;
}

/* Hover effekti */
.element:hover {
    transform: scale(1.05);
    background-color: #b3e5fc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Atom raqami */
.atomic-number {
    position: absolute;
    top: 5px;
    left: 5px;
    font-size: 0.75em;
    color: #555;
}

/* Belgisi */
.symbol {
    font-size: 1.5em;
    font-weight: bold;
    color: #0d47a1;
    margin-top: 15px;
}

/* Nomi */
.name {
    font-size: 0.85em;
    color: #333;
    margin-top: 5px;
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Atom og'irligi */
.atomic-weight {
    font-size: 0.75em;
    color: #777;
    margin-top: 5px;
}

/* ======================================================
   Element Guruhlari Ranglari
====================================================== */

.element.nonmetal {
    background-color: #ffecb3;
    border: 1px solid #ffd54f;
}

.element.metal {
    background-color: #c8e6c9;
    border: 1px solid #66bb6a;
}

.element.metalloid {
    background-color: #d1c4e9;
    border: 1px solid #7e57c2;
}

.element.halogen {
    background-color: #ffcdd2;
    border: 1px solid #e57373;
}

.element.noble-gas {
    background-color: #bbdefb;
    border: 1px solid #64b5f6;
}

.element.lanthanoid,
.element.actinide {
    background-color: #ffe0b2;
    border: 1px solid #ffb74d;
}

.element.transition-metal {
    background-color: #d7ccc8;
    border: 1px solid #a1887f;
}

.element.post-transition-metal {
    background-color: #f8bbd0;
    border: 1px solid #f48fb1;
}

/* ======================================================
   Modal Oynasi
====================================================== */

.modal {
    display: none; 
    position: fixed; 
    z-index: 1000; 
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.5); 
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.modal-content {
    background-color: #fff;
    padding: 20px 30px;
    border: 1px solid #888;
    width: 100%;
    max-width: 400px;
    border-radius: 10px;
    position: relative;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.3);
    animation: fadeIn 0.3s;
}

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

.close-button {
    color: #aaa;
    position: absolute;
    top: 10px;
    right: 15px;
    font-size: 28px;
    font-weight: bold;
    cursor: pointer;
    transition: color 0.3s;
}

.close-button:hover,
.close-button:focus {
    color: #000;
    text-decoration: none;
}

.modal-content h2 {
    margin-bottom: 15px;
    color: #0d47a1;
}

.modal-content p {
    margin-bottom: 10px;
    font-size: 1em;
}

/* ======================================================
   Responsiv Dizayn
====================================================== */

/* Katta ekranlar uchun */
@media (max-width: 1200px) {
    .periodic-table {
        grid-template-columns: repeat(18, 50px);
        grid-auto-rows: 70px;
    }

    .symbol {
        font-size: 1.3em;
    }

    .atomic-number {
        font-size: 0.7em;
    }

    .name {
        font-size: 0.75em;
    }

    .atomic-weight {
        font-size: 0.7em;
    }

    .controls input[type="text"],
    .controls select {
        max-width: 350px;
    }
}

/* O'rta ekranlar uchun */
@media (max-width: 992px) {
    .periodic-table {
        grid-template-columns: repeat(18, 40px);
        grid-auto-rows: 60px;
    }

    .symbol {
        font-size: 1.2em;
    }

    .atomic-number {
        font-size: 0.65em;
    }

    .name {
        font-size: 0.7em;
    }

    .atomic-weight {
        font-size: 0.65em;
    }

    .controls input[type="text"],
    .controls select {
        max-width: 300px;
    }
}

/* Planshetlar uchun */
@media (max-width: 768px) {
    .periodic-table {
        grid-template-columns: repeat(18, 35px);
        grid-auto-rows: 50px;
    }

    .symbol {
        font-size: 1em;
    }

    .atomic-number {
        font-size: 0.6em;
    }

    .name {
        font-size: 0.65em;
    }

    .atomic-weight {
        font-size: 0.6em;
    }

    .controls input[type="text"],
    .controls select {
        max-width: 250px;
    }

    /* Modal oynasini moslashtirish */
    .modal-content {
        padding: 15px 20px;
        max-width: 350px;
    }

    .modal-content h2 {
        font-size: 1.2em;
    }

    .modal-content p {
        font-size: 0.9em;
    }
}

/* Kichik ekranlar uchun */
@media (max-width: 576px) {
    .periodic-table {
        grid-template-columns: repeat(9, 35px);
        grid-auto-rows: 50px;
    }

    .element {
        padding: 3px;
    }

    .symbol {
        font-size: 0.9em;
    }

    .atomic-number {
        font-size: 0.5em;
    }

    .name {
        font-size: 0.6em;
    }

    .atomic-weight {
        font-size: 0.55em;
    }

    .controls input[type="text"],
    .controls select {
        max-width: 200px;
    }

    .modal-content {
        width: 90%;
        max-width: 300px;
    }

    .modal-content h2 {
        font-size: 1em;
    }

    .modal-content p {
        font-size: 0.85em;
    }
}

/* Juda kichik ekranlar uchun */
@media (max-width: 480px) {
    .periodic-table {
        grid-template-columns: repeat(4, 30px);
        grid-auto-rows: 45px;
    }

    .symbol {
        font-size: 0.8em;
    }

    .atomic-number {
        font-size: 0.45em;
    }

    .name {
        font-size: 0.55em;
    }

    .atomic-weight {
        font-size: 0.5em;
    }

    .controls input[type="text"],
    .controls select {
        max-width: 150px;
    }

    /* Modal oynasini yanada kichiklashtirish */
    .modal-content {
        width: 95%;
        max-width: 250px;
    }
}

/* ======================================================
   Scrollbar Stilini Yaxshilash
====================================================== */

.periodic-table {
    scrollbar-width: thin;
    scrollbar-color: #90caf9 #f0f4f8;
}

.periodic-table::-webkit-scrollbar {
    height: 8px;
    width: 8px;
}

.periodic-table::-webkit-scrollbar-track {
    background: #f0f4f8;
    border-radius: 10px;
}

.periodic-table::-webkit-scrollbar-thumb {
    background-color: #90caf9;
    border-radius: 10px;
    border: 2px solid #f0f4f8;
}

/* ======================================================
   Yana Takliflar va Qo'shimchalar
====================================================== */

/* Elementga tanlangan holat */
.element.selected {
    border: 2px solid #ff5722;
    box-shadow: 0 0 10px rgba(255, 87, 34, 0.5);
}

/* Responsive Modal */
@media (max-width: 768px) {
    .modal-content {
        padding: 15px 20px;
    }
}

/* Animatsion Hover Effekti */
.element {
    transition: transform 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.element:hover {
    transform: scale(1.05);
    background-color: #b3e5fc;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.2);
}

/* Qidiruv va Filter uchun Fokus holati */
.controls input[type="text"]:focus,
.controls select:focus {
    border-color: #42a5f5;
    outline: none;
}

/* Qidiruv va Filter Elementlarining Ko'rinishi */
.controls input[type="text"],
.controls select {
    box-shadow: inset 0 1px 3px rgba(0, 0, 0, 0.1);
}

/* ======================================================
   Yakuniy Qadamlar va Tavsiyalar
====================================================== */

/*
1. CSS o'zgarishlarini tekshiring:
   - Har bir media so'rovini turli qurilmalarda sinab ko'ring.
   - Elementlarning to'g'ri joylashganligini va matnlarning o'qilishi qulayligini ta'minlash.

2. Dizaynni yaxshilash:
   - Ranglarni o'zgartirish yoki o'zingizga yoqadigan rang sxemasini qo'llash.
   - Elementlarga qo'shimcha animatsiyalar yoki interaktiv effektlar qo'shish.

3. Modal oynani kengaytirish:
   - Agar qo'shimcha ma'lumotlar kerak bo'lsa, modal oynaga ularni qo'shing.
   - Elektron konfiguratsiyasi, qo'llanilish sohalari kabi qo'shimcha ma'lumotlarni ko'rsatish.

4. Accessibility:
   - ARIA atributlarini qo'shish orqali ekran o'qiydiganlar uchun qulaylik yaratish.
   - Yaxshi kontrast va kattaroq matn o'lchamlari bilan ko'rish qulayligini oshirish.

5. Performance optimizatsiyasi:
   - CSS faylini minify qilish va optimallashtirish.
   - Rasm yoki boshqa resurslardan foydalanishni kamaytirish, agar kerak bo'lsa.

6. Qo'shimcha Funksiyalar:
   - JavaScript orqali elementlarga qo'shimcha interaktivlik qo'shish, masalan, grafikalar yoki animatsiyalar.
   - Qidiruv va filtr funksiyalarini yanada kuchaytirish.

Agar sizga qo'shimcha yordam yoki boshqa uslublar kerak bo'lsa, bemalol so'rang!
