:root {
    --primary-color: #3498db;
    --secondary-color: #2ecc71;
    --background-color: #f4f6f7;
    --text-color: #2c3e50;
    --card-shadow: 0 10px 20px rgba(0,0,0,0.1);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    transition: all 0.3s ease;
}

body {
    font-family: 'Cairo', 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    background-color: var(--background-color);
    color: var(--text-color);
    line-height: 1.6;
    direction: rtl;
    padding-bottom: 60px;
}

main {
    padding: 20px;
    max-width: 1200px;
    margin: 0 auto;
    margin-bottom: 70px;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

header {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    padding: 1.5rem 0;
    text-align: center;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
}

nav {
    background-color: rgba(255,255,255,0.1);
    padding: 1rem;
    border-radius: 10px;
}

nav ul {
    display: flex;
    justify-content: center;
    list-style: none;
}

nav ul li {
    margin: 0 15px;
}

nav ul li a {
    color: white;
    text-decoration: none;
    font-weight: bold;
    position: relative;
}

nav ul li a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    bottom: -5px;
    left: 50%;
    background-color: white;
    transition: all 0.3s ease;
}

nav ul li a:hover::after {
    width: 100%;
    left: 0;
}

.login-container, #admin-dashboard {
    background: white;
    border-radius: 15px;
    box-shadow: var(--card-shadow);
    padding: 30px;
    max-width: 500px;
    margin: 50px auto;
    text-align: center;
    animation: fadeIn 0.5s ease;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(-20px); }
    to { opacity: 1; transform: translateY(0); }
}

form {
    display: flex;
    flex-direction: column;
    gap: 15px;
}

form input, form textarea {
    padding: 12px;
    border: 2px solid #e0e0e0;
    border-radius: 8px;
    font-size: 16px;
    transition: all 0.3s ease;
}

form input:focus, form textarea:focus {
    border-color: var(--primary-color);
    outline: none;
    box-shadow: 0 0 0 3px rgba(52, 152, 219, 0.2);
}

form button {
    background: linear-gradient(135deg, var(--primary-color), var(--secondary-color));
    color: white;
    border: none;
    padding: 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    text-transform: uppercase;
    letter-spacing: 1px;
}

form button:hover {
    transform: translateY(-3px);
    box-shadow: 0 5px 15px rgba(0,0,0,0.1);
}

#books {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    gap: 15px;
    padding: 20px;
}

.book-card {
    background: white;
    border-radius: 15px;
    overflow: hidden;
    box-shadow: var(--card-shadow);
    transform: scale(1);
    transition: all 0.3s ease;
    width: 180px;
    display: flex;
    flex-direction: column;
}

.book-card img {
    width: 100%;
    height: 220px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.book-card div {
    padding: 10px;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.book-card h3 {
    font-size: 0.95rem;
    margin-bottom: 5px;
    font-weight: bold;
    color: var(--primary-color);
}

.book-card p {
    font-size: 0.8rem;
    margin-bottom: 5px;
    flex-grow: 1;
}

.book-card a {
    font-size: 0.8rem;
    padding: 8px;
    align-self: flex-start;
    margin-top: auto;
    width: 100%;
    text-align: center;
}

.book-card .download-btn {
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--primary-color);
    color: white;
    text-decoration: none;
    padding: 8px 12px;
    border-radius: 5px;
    margin-top: auto;
    width: 100%;
    transition: background-color 0.3s ease, transform 0.2s ease;
}

.book-card .download-btn span {
    margin-left: 5px;
    font-size: 1rem;
}

.book-card .download-btn:hover {
    background-color: darken(var(--primary-color), 10%);
    transform: scale(1.05);
}

footer {
    background: linear-gradient(45deg, #3494E6, #EC6EAD);
    color: white;
    padding: 20px;
    text-align: center;
    position: relative;
    overflow: hidden;
    box-shadow: 0 -4px 6px rgba(0, 0, 0, 0.1);
    transition: all 0.5s ease;
}

footer::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        rgba(255, 255, 255, 0.1) 0,
        rgba(255, 255, 255, 0.1) 10px,
        transparent 10px,
        transparent 20px
    );
    animation: moveBackground 10s linear infinite;
    z-index: 1;
}

footer p {
    position: relative;
    z-index: 2;
    font-weight: bold;
    text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    letter-spacing: 1px;
    font-size: 0.9rem;
    animation: colorShift 5s infinite alternate;
}

@keyframes moveBackground {
    0% {
        transform: rotate(0deg);
    }
    100% {
        transform: rotate(360deg);
    }
}

@keyframes colorShift {
    0% {
        color: white;
        text-shadow: 2px 2px 4px rgba(0, 0, 0, 0.3);
    }
    50% {
        color: #FFD700;
        text-shadow: 2px 2px 4px rgba(255, 215, 0, 0.5);
    }
    100% {
        color: #00FFFF;
        text-shadow: 2px 2px 4px rgba(0, 255, 255, 0.5);
    }
}

footer:hover {
    background: linear-gradient(135deg, #EC6EAD, #3494E6);
    transform: translateY(-5px);
    box-shadow: 0 -6px 12px rgba(0, 0, 0, 0.2);
}

@media (max-width: 768px) {
    footer {
        padding: 15px;
        font-size: 0.8rem;
    }
}

/* Section Buttons Styles */
#section-buttons {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 10px;
    margin-bottom: 30px;
}

.section-btn {
    background-color: var(--background-color);
    color: var(--text-color);
    border: 2px solid var(--primary-color);
    padding: 8px 12px;
    border-radius: 8px;
    cursor: pointer;
    font-weight: bold;
    transition: all 0.3s ease;
    font-size: 0.8rem;
}

.section-btn:hover {
    background-color: var(--primary-color);
    color: white;
}

.section-btn.active {
    background-color: var(--primary-color);
    color: white;
    box-shadow: 0 5px 15px rgba(52, 152, 219, 0.3);
}

#book-section {
    width: 100%;
    height: auto;
    min-height: 100px;
    max-height: 200px;
    overflow-y: auto;
}

/* Section Checkboxes Styles */
.sections-container {
    margin-bottom: 15px;
}

.section-checkboxes {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 10px;
}

.section-checkboxes label {
    display: flex;
    align-items: center;
    background-color: #f0f0f0;
    padding: 10px;
    border-radius: 5px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.section-checkboxes label:hover {
    background-color: #e0e0e0;
}

.section-checkboxes input[type="checkbox"] {
    margin-left: 10px;
    accent-color: #4CAF50;
}

.section-checkboxes label input:checked + span {
    font-weight: bold;
    color: #4CAF50;
}

@media (max-width: 768px) {
    #books {
        grid-template-columns: 1fr;
    }
    
    nav ul {
        flex-direction: column;
        align-items: center;
    }
    
    nav ul li {
        margin: 10px 0;
    }
}

/* Loading and Error States */
.loading {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 200px;
    color: var(--primary-color);
}

.error {
    background-color: #ff6b6b;
    color: white;
    padding: 15px;
    border-radius: 8px;
    text-align: center;
}

/* Edit Book Form Styles */
.edit-book-form {
    background-color: #f9f9f9;
    border: 1px solid #ddd;
    border-radius: 8px;
    padding: 20px;
    margin: 15px 0;
    box-shadow: 0 2px 5px rgba(0,0,0,0.1);
}

.edit-book-form h3 {
    margin-bottom: 15px;
    color: #333;
    text-align: center;
}

.edit-book-form label {
    display: block;
    margin-top: 10px;
    font-weight: bold;
}

.edit-book-form input, 
.edit-book-form textarea, 
.edit-book-form select {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    border: 1px solid #ddd;
    border-radius: 4px;
}

.edit-form-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 15px;
}

.edit-form-actions button {
    padding: 10px 15px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.save-btn {
    background-color: #4CAF50;
    color: white;
}

.cancel-btn {
    background-color: #f44336;
    color: white;
}

.admin-book-actions {
    display: flex;
    justify-content: space-between;
    margin-top: 10px;
}

.edit-btn, .delete-btn {
    padding: 5px 10px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    transition: background-color 0.3s ease;
}

.edit-btn {
    background-color: #2196F3;
    color: white;
    margin-right: 5px;
}

.delete-btn {
    background-color: #f44336;
    color: white;
}