* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
    font-family: 'Cairo', sans-serif;
}

body {
    background: linear-gradient(180deg, #e8f4f8 0%, #ffffff 100%);
    overflow-x: hidden;
}

html {
    scroll-behavior: smooth;
}

/* Preloader */
.preloader {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: linear-gradient(135deg, #e8f4f8 0%, #cfe3f0 50%, #4a90c5 100%);
    display: flex;
    align-items: center;
    justify-content: center;
    z-index: 9999;
    transition: all 0.8s ease;
    overflow: hidden;
}

.preloader::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: repeating-linear-gradient(
        45deg,
        transparent,
        transparent 50px,
        rgba(3, 57, 108, 0.1) 50px,
        rgba(3, 57, 108, 0.1) 100px
    );
    animation: preloaderMove 20s linear infinite;
}

@keyframes preloaderMove {
    0% { transform: translate(0, 0) rotate(0deg); }
    100% { transform: translate(50px, 50px) rotate(360deg); }
}

.preloader.loaded {
    opacity: 0;
    visibility: hidden;
}

.preloader-content {
    text-align: center;
    position: relative;
    z-index: 10;
}

.loader-circle-container {
    position: relative;
    width: 200px;
    height: 200px;
    margin: 0 auto 50px;
}

.loader-circle {
    position: absolute;
    width: 100%;
    height: 100%;
    border: 8px solid transparent;
    border-top-color: #022145;
    border-right-color: #022145;
    border-bottom-color: #2b5a8f;
    border-left-color: #2b5a8f;
    border-radius: 50%;
    animation: spinCircle 2s linear infinite;
}

.loader-circle:nth-child(2) {
    width: 80%;
    height: 80%;
    top: 10%;
    left: 10%;
    border-top-color: #2b5a8f;
    border-right-color: #2b5a8f;
    border-bottom-color: #022145;
    border-left-color: #022145;
    animation: spinCircle 1.5s linear infinite reverse;
}

.loader-circle:nth-child(3) {
    width: 60%;
    height: 60%;
    top: 20%;
    left: 20%;
    border-top-color: #2b5a8f;
    border-right-color: #2b5a8f;
    border-bottom-color: #022145;
    border-left-color: #022145;
    animation: spinCircle 1s linear infinite;
}

@keyframes spinCircle {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.loader-logo {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 5rem;
    animation: logoScale 2s ease-in-out infinite;
    filter: drop-shadow(0 10px 20px rgba(2, 33, 69, 0.3));
}

@keyframes logoScale {
    0%, 100% { transform: translate(-50%, -50%) scale(1) rotate(0deg); }
    50% { transform: translate(-50%, -50%) scale(1.2) rotate(180deg); }
}

.loader-text {
    background: linear-gradient(135deg, #011528 0%, #022145 50%, #022145 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    font-size: 3rem;
    font-weight: 900;
    margin-bottom: 20px;
    animation: textSlide 3s ease-in-out infinite;
    letter-spacing: 3px;
}

@keyframes textSlide {
    0%, 100% { transform: translateX(0); }
    50% { transform: translateX(10px); }
}

.loader-subtitle {
    color: #022145;
    font-size: 1.4rem;
    font-weight: 700;
    margin-bottom: 50px;
    animation: subtitleBounce 2s ease-in-out infinite;
}

@keyframes subtitleBounce {
    0%, 100% { transform: translateY(0); opacity: 0.8; }
    50% { transform: translateY(-10px); opacity: 1; }
}

.loader-progress-container {
    width: 400px;
    height: 8px;
    background: white;
    border-radius: 20px;
    margin: 0 auto;
    overflow: hidden;
    box-shadow: 0 4px 20px rgba(2, 33, 69, 0.2);
    border: 2px solid #4a90c5;
}

.loader-progress {
    height: 100%;
    background: linear-gradient(90deg, #022145 0%, #022145 25%, #2b5a8f 50%, #2b5a8f 75%, #4a90c5 100%);
    border-radius: 20px;
    animation: progressBar 2.5s ease-in-out infinite;
    box-shadow: 0 0 20px rgba(2, 33, 69, 0.6);
}

@keyframes progressBar {
    0% { width: 0%; }
    50% { width: 60%; }
    100% { width: 100%; }
}

.loader-percentage {
    color: #011528;
    font-size: 1.8rem;
    font-weight: 900;
    margin-top: 20px;
    animation: percentagePulse 1s ease-in-out infinite;
}

@keyframes percentagePulse {
    0%, 100% { transform: scale(1); }
    50% { transform: scale(1.15); }
}

.loader-books {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-top: 40px;
}

.loader-book {
    font-size: 2.5rem;
    animation: bookFloat 2s ease-in-out infinite;
    filter: drop-shadow(0 5px 15px rgba(2, 33, 69, 0.3));
}

.loader-book:nth-child(1) { animation-delay: 0s; }
.loader-book:nth-child(2) { animation-delay: 0.3s; }
.loader-book:nth-child(3) { animation-delay: 0.6s; }
.loader-book:nth-child(4) { animation-delay: 0.9s; }
.loader-book:nth-child(5) { animation-delay: 1.2s; }

@keyframes bookFloat {
    0%, 100% { transform: translateY(0) rotate(0deg); opacity: 0.7; }
    50% { transform: translateY(-25px) rotate(15deg); opacity: 1; }
}

/* Navbar */
.navbar {
    background: linear-gradient(135deg, #011528 0%, #022145 50%, #022145 100%);
    padding: 15px 0;
    box-shadow: 0 4px 20px rgba(2, 33, 69, 0.3);
    position: sticky;
    top: 0;
    z-index: 1000;
    transition: all 0.3s ease;
    border-bottom: 3px solid #2b5a8f;
}

.navbar.scrolled {
    padding: 10px 0;
    box-shadow: 0 8px 32px rgba(2, 33, 69, 0.4);
}

.navbar-brand {
    color: white !important;
    font-size: 2rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 15px;
    transition: transform 0.3s ease;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.navbar-brand:hover {
    transform: scale(1.05);
}

.navbar-brand .logo-icon {
    font-size: 2.8rem;
    animation: logoFloat 3s ease-in-out infinite;
    filter: drop-shadow(0 4px 8px rgba(0, 0, 0, 0.2));
}

@keyframes logoFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.nav-link {
    color: rgba(255, 255, 255, 0.95) !important;
    font-weight: 600;
    font-size: 1.1rem;
    padding: 12px 25px !important;
    transition: all 0.3s ease;
    position: relative;
    border-radius: 50px;
    margin: 0 5px;
}

.nav-link::before {
    content: '';
    position: absolute;
    bottom: 8px;
    right: 25px;
    width: 0;
    height: 2px;
    background: white;
    transition: width 0.3s ease;
    border-radius: 2px;
}

.nav-link:hover::before,
.nav-link.active::before {
    width: calc(100% - 50px);
}

.nav-link:hover {
    color: white !important;
    background: rgba(255, 255, 255, 0.1);
    transform: translateY(-2px);
}

.nav-link.active {
    background: rgba(255, 255, 255, 0.15);
    color: white !important;
}

.btn-back {
    background: linear-gradient(135deg, #2b5a8f 0%, #4a90c5 100%);
    color: white;
    padding: 12px 30px;
    border-radius: 50px;
    font-weight: 700;
    text-decoration: none;
    display: inline-flex;
    align-items: center;
    gap: 10px;
    transition: all 0.4s ease;
    box-shadow: 0 5px 20px rgba(74, 144, 197, 0.4);
    border: none;
}

.btn-back:hover {
    transform: translateY(-3px);
    box-shadow: 0 10px 30px rgba(74, 144, 197, 0.6);
    color: white;
}

/* Main Content */
.main-wrapper {
    padding: 80px 0;
    min-height: calc(100vh - 80px);
}

.page-header {
    text-align: center;
    margin-bottom: 60px;
}

.page-title {
    font-size: 3.5rem;
    font-weight: 900;
    margin-bottom: 20px;
    background: linear-gradient(135deg, #011528 0%, #022145 50%, #03396c 100%);
    -webkit-background-clip: text;
    -webkit-text-fill-color: transparent;
    background-clip: text;
    animation: titleFadeIn 1s ease;
}

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

.page-subtitle {
    font-size: 1.4rem;
    color: #022145;
    font-weight: 600;
}

.action-buttons {
    display: flex;
    justify-content: center;
    gap: 20px;
    margin-bottom: 50px;
    flex-wrap: wrap;
}

.btn-add {
    background: linear-gradient(135deg, #011528 0%, #022145 100%);
    color: white;
    padding: 15px 40px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.2rem;
    border: none;
    cursor: pointer;
    display: inline-flex;
    align-items: center;
    gap: 12px;
    transition: all 0.4s ease;
    box-shadow: 0 8px 25px rgba(2, 33, 69, 0.4);
}

.btn-add:hover {
    transform: translateY(-5px);
    box-shadow: 0 15px 40px rgba(2, 33, 69, 0.6);
}

/* Tree Container */
.tree-container {
    max-width: 1400px;
    margin: 0 auto;
}

.category-main {
    background: linear-gradient(135deg, #011528 0%, #022145 50%, #03396c 100%);
    border-radius: 30px;
    padding: 40px;
    margin-bottom: 30px;
    box-shadow: 0 15px 45px rgba(2, 33, 69, 0.3);
    transition: all 0.4s ease;
    border: 2px solid rgba(255, 255, 255, 0.1);
    position: relative;
    overflow: hidden;
}

.category-main::before {
    content: '';
    position: absolute;
    top: -50%;
    left: -50%;
    width: 200%;
    height: 200%;
    background: linear-gradient(
        45deg,
        transparent,
        rgba(255, 255, 255, 0.05),
        transparent
    );
    transform: rotate(45deg);
    transition: all 0.6s ease;
}

.category-main:hover::before {
    left: 100%;
}

.category-main:hover {
    transform: translateY(-5px);
    box-shadow: 0 20px 55px rgba(3, 57, 108, 0.5);
}

.category-header {
    display: flex;
    align-items: center;
    gap: 25px;
    margin-bottom: 30px;
    position: relative;
    z-index: 2;
}

.category-icon {
    font-size: 4rem;
    filter: drop-shadow(0 5px 15px rgba(0, 0, 0, 0.3));
    animation: iconFloat 3s ease-in-out infinite;
}

@keyframes iconFloat {
    0%, 100% { transform: translateY(0); }
    50% { transform: translateY(-10px); }
}

.category-info {
    flex: 1;
}

.category-title {
    font-size: 2.2rem;
    font-weight: 900;
    color: white;
    margin-bottom: 10px;
    text-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

.category-description {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    line-height: 1.6;
}

.category-actions {
    display: flex;
    gap: 15px;
    position: relative;
    z-index: 2;
    flex-wrap: wrap;
}

.btn-action {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 12px 25px;
    border-radius: 50px;
    border: 2px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-weight: 700;
    font-size: 1rem;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 8px;
}

.btn-action:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(0, 0, 0, 0.2);
}

.subcategories {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    gap: 25px;
    margin-top: 30px;
    position: relative;
    z-index: 2;
}

.subcategory-card {
    background: rgba(255, 255, 255, 0.15);
    backdrop-filter: blur(10px);
    border-radius: 20px;
    padding: 30px;
    border: 2px solid rgba(255, 255, 255, 0.2);
    transition: all 0.4s ease;
}

.subcategory-card:hover {
    background: rgba(255, 255, 255, 0.25);
    transform: translateY(-5px);
    box-shadow: 0 10px 30px rgba(0, 0, 0, 0.3);
}

.subcategory-icon {
    font-size: 3rem;
    margin-bottom: 15px;
    filter: drop-shadow(0 3px 10px rgba(0, 0, 0, 0.2));
}

.subcategory-title {
    font-size: 1.5rem;
    font-weight: 800;
    color: white;
    margin-bottom: 10px;
}

.subcategory-description {
    font-size: 0.95rem;
    color: rgba(255, 255, 255, 0.85);
    line-height: 1.5;
    margin-bottom: 20px;
}

.subcategory-actions {
    display: flex;
    gap: 10px;
}

.btn-small {
    background: rgba(255, 255, 255, 0.2);
    color: white;
    padding: 8px 18px;
    border-radius: 50px;
    border: 1px solid rgba(255, 255, 255, 0.3);
    cursor: pointer;
    font-weight: 600;
    font-size: 0.9rem;
    transition: all 0.3s ease;
}

.btn-small:hover {
    background: rgba(255, 255, 255, 0.3);
    transform: translateY(-2px);
}

/* Modal Styles */
.modal-content {
    border-radius: 30px;
    border: none;
    box-shadow: 0 20px 60px rgba(2, 33, 69, 0.4);
    background: linear-gradient(180deg, #ffffff 0%, #f8fbfd 100%);
}

.modal-header {
    background: linear-gradient(135deg, #011528 0%, #022145 100%);
    color: white;
    border-radius: 30px 30px 0 0;
    padding: 30px;
    border: none;
}

.modal-title {
    font-size: 2rem;
    font-weight: 900;
    display: flex;
    align-items: center;
    gap: 15px;
}

.btn-close {
    filter: brightness(0) invert(1);
    opacity: 1;
}

.modal-body {
    padding: 40px;
}

.form-label {
    font-weight: 700;
    color: #022145;
    font-size: 1.1rem;
    margin-bottom: 12px;
}

.form-control, .form-select, .form-control:focus, .form-select:focus {
    border-radius: 15px;
    padding: 15px 20px;
    font-size: 1.05rem;
    border: 2px solid #cfe3f0;
    transition: all 0.3s ease;
}

.form-control:focus, .form-select:focus {
    border-color: #2b5a8f;
    box-shadow: 0 0 0 0.2rem rgba(43, 90, 143, 0.25);
}

textarea.form-control {
    min-height: 120px;
    resize: vertical;
}

/* Icon Selector */
.icon-selector {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(80px, 1fr));
    gap: 15px;
    margin-top: 15px;
}

.icon-option {
    background: white;
    border: 3px solid #cfe3f0;
    border-radius: 15px;
    padding: 20px;
    text-align: center;
    cursor: pointer;
    transition: all 0.3s ease;
    font-size: 2.5rem;
}

.icon-option:hover {
    background: #e8f4f8;
    transform: scale(1.1);
    border-color: #2b5a8f;
}

.icon-option.selected {
    background: linear-gradient(135deg, #011528 0%, #022145 100%);
    border-color: #022145;
    transform: scale(1.15);
    box-shadow: 0 10px 30px rgba(2, 33, 69, 0.4);
}

.icon-option input {
    display: none;
}

.modal-footer {
    padding: 30px 40px;
    border: none;
    gap: 15px;
}

.btn-submit {
    background: linear-gradient(135deg, #011528 0%, #022145 100%);
    color: white;
    padding: 15px 40px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    border: none;
    cursor: pointer;
    transition: all 0.4s ease;
    box-shadow: 0 8px 25px rgba(2, 33, 69, 0.4);
}

.btn-submit:hover {
    transform: translateY(-3px);
    box-shadow: 0 12px 35px rgba(2, 33, 69, 0.6);
}

.btn-cancel {
    background: #e8f4f8;
    color: #022145;
    padding: 15px 40px;
    border-radius: 50px;
    font-weight: 700;
    font-size: 1.1rem;
    border: 2px solid #cfe3f0;
    cursor: pointer;
    transition: all 0.3s ease;
}

.btn-cancel:hover {
    background: #cfe3f0;
    border-color: #2b5a8f;
}

/* Success Alert */
.alert-success {
    background: linear-gradient(135deg, #d4edda 0%, #c3e6cb 100%);
    border: 2px solid #28a745;
    border-radius: 20px;
    padding: 20px 30px;
    margin-bottom: 30px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #155724;
    box-shadow: 0 5px 20px rgba(40, 167, 69, 0.2);
    animation: slideDown 0.5s ease;
}

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

/* Footer */
.footer {
    background: linear-gradient(135deg, #011528 0%, #022145 100%);
    color: white;
    padding: 40px 0 20px;
    margin-top: 80px;
    border-top: 3px solid #2b5a8f;
}

.footer-content {
    text-align: center;
}

.footer h4 {
    font-size: 1.8rem;
    font-weight: 900;
    margin-bottom: 20px;
}

.footer p {
    font-size: 1.1rem;
    color: rgba(255, 255, 255, 0.9);
    margin-bottom: 10px;
}

.footer-copyright {
    text-align: center;
    padding-top: 30px;
    margin-top: 30px;
    border-top: 1px solid rgba(255, 255, 255, 0.2);
    color: rgba(255, 255, 255, 0.8);
}

/* Responsive */
@media (max-width: 991px) {
    .navbar-brand {
        font-size: 1.5rem;
    }

    .navbar-brand .logo-icon {
        font-size: 2rem;
    }

    .navbar-collapse {
        background: rgba(2, 33, 69, 0.95);
        backdrop-filter: blur(20px);
        margin-top: 20px;
        border-radius: 20px;
        padding: 20px;
        box-shadow: 0 10px 40px rgba(0, 0, 0, 0.3);
    }

    .nav-link {
        padding: 15px 20px !important;
        margin: 5px 0;
        border-radius: 12px;
    }

    .nav-link::before {
        display: none;
    }

    .page-title {
        font-size: 2.5rem;
    }

    .category-header {
        flex-direction: column;
        text-align: center;
    }

    .category-actions {
        justify-content: center;
        flex-wrap: wrap;
    }

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

@media (max-width: 768px) {
    .page-title {
        font-size: 2rem;
    }

    .category-title {
        font-size: 1.8rem;
    }

    .icon-selector {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 10px;
    }

    .icon-option {
        font-size: 2rem;
        padding: 15px;
    }

    .modal-body {
        padding: 25px;
    }

    .loader-progress-container {
        width: 280px;
    }
}

@media (max-width: 480px) {
    .loader-progress-container {
        width: 240px;
    }

    .action-buttons {
        flex-direction: column;
    }

    .btn-add {
        width: 100%;
        justify-content: center;
    }

    .category-actions {
        flex-direction: column;
        width: 100%;
    }

    .btn-action {
        width: 100%;
        justify-content: center;
    }
}

/* Icon Picker Button */
.btn-icon-picker {
    display: flex;
    align-items: center;
    gap: 12px;
    padding: 15px 25px;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #022145;
    border-radius: 15px;
    font-size: 1.1rem;
    font-weight: 600;
    color: #022145;
    cursor: pointer;
    transition: all 0.3s ease;
    width: 100%;
    justify-content: center;
}

.btn-icon-picker:hover {
    background: linear-gradient(135deg, #022145 0%, #2b5a8f 100%);
    color: white;
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(2, 33, 69, 0.3);
}

.btn-icon-picker span:first-child {
    font-size: 2rem;
}

/* Icon Picker Grid */
.icon-picker-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(70px, 1fr));
    gap: 12px;
    padding: 20px;
    max-height: 60vh;
    overflow-y: auto;
}

.icon-picker-item {
    width: 70px;
    height: 70px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 2rem;
    background: linear-gradient(135deg, #f8f9fa 0%, #e9ecef 100%);
    border: 2px solid #dee2e6;
    border-radius: 12px;
    cursor: pointer;
    transition: all 0.3s ease;
}

.icon-picker-item:hover {
    background: linear-gradient(135deg, #022145 0%, #2b5a8f 100%);
    border-color: #022145;
    transform: scale(1.15);
    box-shadow: 0 5px 15px rgba(2, 33, 69, 0.3);
}

.icon-picker-item.selected {
    background: linear-gradient(135deg, #022145 0%, #2b5a8f 100%);
    border-color: #022145;
    transform: scale(1.1);
    box-shadow: 0 5px 15px rgba(2, 33, 69, 0.4);
}

/* Icon Picker Modal */
#iconPickerModal .modal-body {
    padding: 10px;
}

#iconPickerModal .modal-dialog {
    max-width: 900px;
}

@media (max-width: 768px) {
    .icon-picker-grid {
        grid-template-columns: repeat(auto-fill, minmax(60px, 1fr));
        gap: 10px;
        padding: 15px;
    }

    .icon-picker-item {
        width: 60px;
        height: 60px;
        font-size: 1.8rem;
    }
}
