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

body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background: #f5f5f5;
    color: #333;
    direction: rtl;
    padding: 20px;
}

.screen {
    display: none;
    padding: 20px;
}

.screen.active {
    display: block;
}

h1, h2 {
    text-align: center;
    margin-bottom: 20px;
    color: #2c3e50;
}

/* Subjects Grid */
#subjects-container {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
    gap: 20px;
    margin-bottom: 80px;
}

.subject-card {
    background: #fff;
    border-radius: 12px;
    padding: 20px;
    text-align: center;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.2s;
    height: 120px;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
}

.subject-card:hover {
    transform: translateY(-5px);
}

.subject-icon {
    font-size: 2rem;
    margin-bottom: 10px;
}

/* FAB Button */
.fab {
    position: fixed;
    bottom: 30px;
    right: 30px;
    width: 60px;
    height: 60px;
    border-radius: 50%;
    background: #ff6f61;
    color: white;
    font-size: 2rem;
    border: none;
    box-shadow: 0 4px 8px rgba(0,0,0,0.3);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
}

.fab:hover {
    background: #ff5252;
}

/* Header in Detail Screen */
.header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 10px 0;
    border-bottom: 2px solid #eee;
    margin-bottom: 20px;
}

.header button {
    padding: 8px 12px;
    margin-left: 10px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
}

#back-btn {
    background: #9e9e9e;
    color: white;
}

#edit-subject-btn {
    background: #2196F3;
    color: white;
}

#delete-subject-btn {
    background: #F44336;
    color: white;
}

/* Tabs */
.tabs {
    display: flex;
    margin-bottom: 20px;
}

.tab-btn {
    flex: 1;
    padding: 12px;
    border: none;
    color: white;
    font-weight: bold;
    cursor: pointer;
    border-radius: 8px 8px 0 0;
}

.tab-btn:hover {
    opacity: 0.9;
}

.tab-btn.active {
    box-shadow: 0 -3px 0 3px rgba(0,0,0,0.1) inset;
}

/* Tab Content */
.tab-pane {
    display: none;
}

.tab-pane.active {
    display: block;
}

/* Notes */
.note-item {
    background: #e8f5e9;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    cursor: pointer;
    word-wrap: break-word;
    max-height: 80px;
    overflow: hidden;
    position: relative;
}

.note-item.expanded {
    max-height: none;
}

/* PDFs */
.pdf-item {
    background: #e3f2fd;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.pdf-item:active {
    background: #bbdefb;
}

/* Image Categories */
.category-item {
    background: #ffebee;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    cursor: pointer;
}

.image-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
    margin-top: 10px;
}

.image-item {
    aspect-ratio: 1;
    background-size: cover;
    background-position: center;
    border-radius: 8px;
    cursor: pointer;
    position: relative;
}

.image-fullscreen {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.image-fullscreen img {
    max-width: 90%;
    max-height: 90%;
    object-fit: contain;
}

/* Audio Items */
.audio-item {
    background: #fff3e0;
    padding: 15px;
    border-radius: 8px;
    margin-bottom: 15px;
    display: flex;
    flex-direction: column;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 10px;
    margin-top: 10px;
}

audio {
    width: 100%;
}

/* Modal */
.hidden {
    display: none !important;
}

#modal-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 1000;
}

.modal {
    background: white;
    padding: 20px;
    border-radius: 12px;
    width: 90%;
    max-width: 500px;
    position: relative;
}

.close {
    position: absolute;
    top: 10px;
    left: 10px;
    font-size: 1.5rem;
    cursor: pointer;
}

input, textarea, select {
    width: 100%;
    padding: 10px;
    margin: 10px 0;
    border: 1px solid #ddd;
    border-radius: 6px;
}

button.save-btn {
    background: #4CAF50;
    color: white;
    padding: 10px 20px;
    border: none;
    border-radius: 6px;
    cursor: pointer;
    margin-top: 10px;
}

button.save-btn:hover {
    background: #388E3C;
}