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

body {
    font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Arial', sans-serif;
    background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
    min-height: 100vh;
    direction: rtl;
}

.screen {
    display: none;
    min-height: 100vh;
    animation: fadeIn 0.3s;
}

.screen.active {
    display: block;
}

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

/* الهيدر الرئيسي */
.main-header {
    background: rgba(255, 255, 255, 0.95);
    padding: 20px;
    text-align: center;
    box-shadow: 0 2px 10px rgba(0,0,0,0.1);
}

.main-header h1 {
    color: #6366f1;
    font-size: 2rem;
    font-weight: bold;
}

/* شبكة المواد */
.subjects-grid {
    display: grid;
    grid-template-columns: repeat(2, 1fr);
    gap: 20px;
    padding: 20px;
    max-width: 600px;
    margin: 0 auto;
}

.subject-card {
    aspect-ratio: 1;
    border-radius: 20px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.2rem;
    font-weight: bold;
    color: white;
    cursor: pointer;
    transition: transform 0.3s, box-shadow 0.3s;
    box-shadow: 0 4px 15px rgba(0,0,0,0.2);
}

.subject-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 25px rgba(0,0,0,0.3);
}

/* هيدر المادة */
.subject-header, .folder-header {
    background: #6366f1;
    padding: 15px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    color: white;
    box-shadow: 0 2px 10px rgba(0,0,0,0.2);
}

.back-btn, .edit-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    display: flex;
    align-items: center;
    justify-content: center;
}

.back-btn:hover, .edit-btn:hover {
    background: rgba(255,255,255,0.2);
    border-radius: 50%;
}

/* التبويبات */
.tabs {
    display: flex;
    background: white;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.tab-btn {
    flex: 1;
    padding: 15px;
    border: none;
    color: white;
    cursor: pointer;
    transition: opacity 0.3s;
    font-weight: bold;
}

.tab-btn:not(.active) {
    opacity: 0.7;
}

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

.tab-panel {
    display: none;
    padding: 20px;
    min-height: calc(100vh - 200px);
    background: rgba(255,255,255,0.9);
}

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

/* العناصر */
.items-container {
    display: flex;
    flex-direction: column;
    gap: 15px;
    padding-bottom: 80px;
}

.note-item {
    background: white;
    border-radius: 15px;
    padding: 15px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    cursor: pointer;
    transition: transform 0.3s;
}

.note-item:hover {
    transform: translateX(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.note-item h4 {
    color: #10b981;
    margin-bottom: 10px;
}

.note-item p {
    color: #666;
    overflow: hidden;
    text-overflow: ellipsis;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
}

.pdf-item, .audio-item {
    background: white;
    border-radius: 15px;
    padding: 15px 20px;
    box-shadow: 0 3px 10px rgba(0,0,0,0.1);
    display: flex;
    align-items: center;
    justify-content: space-between;
    transition: transform 0.3s;
}

.pdf-item:hover, .audio-item:hover {
    transform: translateX(-5px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.2);
}

.folder-item {
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    color: white;
    font-weight: bold;
    cursor: pointer;
    transition: transform 0.3s;
    box-shadow: 0 3px 10px rgba(0,0,0,0.2);
}

.folder-item:hover {
    transform: scale(1.05);
}

/* زر الإضافة العائم */
.fab {
    position: fixed;
    bottom: 20px;
    left: 20px;
    width: 56px;
    height: 56px;
    border-radius: 50%;
    border: none;
    color: white;
    font-size: 30px;
    cursor: pointer;
    box-shadow: 0 4px 12px rgba(0,0,0,0.3);
    transition: transform 0.3s;
    z-index: 100;
}

.fab:hover {
    transform: scale(1.1);
}

.fab.green { background: #10b981; }
.fab.blue { background: #3b82f6; }
.fab.red { background: #ef4444; }
.fab.yellow { background: #eab308; }

/* النوافذ المنبثقة */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.5);
    z-index: 200;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

.modal-content {
    background: white;
    padding: 25px;
    border-radius: 20px;
    width: 90%;
    max-width: 400px;
    animation: slideUp 0.3s;
}

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

.modal-content h3 {
    color: #6366f1;
    margin-bottom: 20px;
}

.modal-content input,
.modal-content textarea {
    width: 100%;
    padding: 12px;
    border: 2px solid #e5e7eb;
    border-radius: 10px;
    margin-bottom: 15px;
    font-size: 16px;
}

.modal-content textarea {
    min-height: 120px;
    resize: vertical;
}

.modal-buttons {
    display: flex;
    gap: 10px;
    justify-content: flex-end;
}

.modal-buttons button {
    padding: 10px 20px;
    border: none;
    border-radius: 10px;
    cursor: pointer;
    font-weight: bold;
    transition: opacity 0.3s;
}

.modal-buttons button:first-child {
    background: #6366f1;
    color: white;
}

.modal-buttons button:last-child {
    background: #e5e7eb;
    color: #666;
}

.modal-buttons button:hover {
    opacity: 0.8;
}

/* اختيار الألوان */
.color-picker {
    margin: 15px 0;
}

.color-picker label {
    display: block;
    margin-bottom: 10px;
    color: #666;
}

.colors {
    display: flex;
    gap: 10px;
}

.color-option {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    cursor: pointer;
    transition: transform 0.3s;
    border: 3px solid transparent;
}

.color-option:hover {
    transform: scale(1.1);
}

.color-option.selected {
    border-color: #333;
}

/* شبكة الصور */
.images-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(100px, 1fr));
    gap: 10px;
    padding: 20px;
}

.image-item {
    aspect-ratio: 1;
    border-radius: 10px;
    overflow: hidden;
    cursor: pointer;
    transition: transform 0.3s;
    box-shadow: 0 2px 8px rgba(0,0,0,0.2);
}

.image-item:hover {
    transform: scale(1.05);
}

.image-item img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* عارض الصور */
.image-viewer {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0,0,0,0.9);
    z-index: 300;
    align-items: center;
    justify-content: center;
}

.image-viewer.active {
    display: flex;
}

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

/* مشغل الصوت */
.audio-player {
    flex: 1;
}

.audio-name {
    font-weight: bold;
    color: #333;
    margin-bottom: 10px;
}

.audio-controls {
    display: flex;
    align-items: center;
    gap: 15px;
}

.play-btn {
    width: 40px;
    height: 40px;
    border-radius: 50%;
    background: #eab308;
    border: none;
    color: white;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: background 0.3s;
}

.play-btn:hover {
    background: #ca8a04;
}

.audio-progress {
    flex: 1;
    height: 4px;
    background: #e5e7eb;
    border-radius: 2px;
    overflow: hidden;
}

.progress-bar {
    height: 100%;
    background: #eab308;
    transition: width 0.1s;
}

.audio-time {
    color: #666;
    font-size: 12px;
    min-width: 80px;
    text-align: center;
}

/* التجاوب */
@media (max-width: 480px) {
    .subjects-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 15px;
        padding: 15px;
    }
    
    .tab-btn {
        font-size: 12px;
        padding: 12px 5px;
    }
}

/* التحميل */
.loading {
    display: inline-block;
    width: 20px;
    height: 20px;
    border: 3px solid rgba(255,255,255,0.3);
    border-radius: 50%;
    border-top-color: white;
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}