/* ===== Base Styles ===== */
:root {
    --sidebar-width: 250px;
    --primary-color: #1e1e2d;
    --secondary-color: #a1a5b7;
    --hover-color: rgba(255, 255, 255, 0.1);
    --shadow: 0 4px 8px rgba(0, 0, 0, 0.1);
    --transition: all 0.3s ease;
    --border-radius: 8px;
    --image-height: 200px;
    --modal-bg: rgba(0, 0, 0, 0.7);
    --modal-hover: rgba(0, 0, 0, 0.9);
    --blur-intensity: 10px;
}

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

body {
    font-family: 'Poppins', sans-serif;
    background-color: #f5f8fa;
    line-height: 1.6;
    overflow-x: hidden;
}

/* ===== Layout Components ===== */
/* Sidebar */
.sidebar {
    width: var(--sidebar-width);
    background-color: var(--primary-color);
    color: white;
    height: 100vh;
    position: fixed;
    transition: var(--transition);
    z-index: 1000;
    box-shadow: 2px 0 10px rgba(0, 0, 0, 0.1);
}

.sidebar-header {
    padding: 20px;
    background-color: rgba(0, 0, 0, 0.1);
    border-bottom: 1px solid rgba(255, 255, 255, 0.1);
}

.sidebar-menu {
    padding: 20px 0;
}

.sidebar-menu a {
    color: var(--secondary-color);
    padding: 12px 20px;
    display: block;
    text-decoration: none;
    transition: var(--transition);
    margin: 2px 0;
    border-left: 3px solid transparent;
}

.sidebar-menu a:hover,
.sidebar-menu a.active {
    color: white;
    background-color: var(--hover-color);
    border-left: 3px solid #4dabf7;
}

/* Main Content */
.main-content {
    margin-left: var(--sidebar-width);
    padding: 20px;
    transition: var(--transition);
    min-height: 100vh;
}

/* ===== Gallery Components ===== */
.gallery-section {
    margin-bottom: 50px;
}

.section-title {
    margin-bottom: 20px;
    color: var(--primary-color);
    font-size: 1.8rem;
    padding-bottom: 10px;
    border-bottom: 2px solid #eee;
}

.gallery-section h5 {
    color: #666;
    margin-bottom: 20px;
    font-weight: normal;
}

.gallery-section .row {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 20px;
}

.image-container {
    position: relative;
    height: var(--image-height);
    border-radius: var(--border-radius);
    box-shadow: var(--shadow);
    transition: var(--transition);
    cursor: pointer;
    overflow: hidden;
    background-color: #f8f9fa;
    display: flex;
    align-items: center;
    justify-content: center;
}

.image-container:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0, 0, 0, 0.15);
}

.image-container img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    object-position: top;
    display: block;
    transition: var(--transition);
}

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

.image-title {
    position: absolute;
    bottom: 0;
    left: 0;
    right: 0;
    background: linear-gradient(to top, rgba(0, 0, 0, 0.8), rgba(0, 0, 0, 0.8));
    color: white;
    padding: 12px 8px;
    text-align: center;
    font-size: 0.9rem;
    text-shadow: 0 1px 2px rgba(0, 0, 0, 0.8);
    white-space: normal;
    word-break: break-word;
}

/* ===== Modal Components ===== */
.modal-backdrop {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    backdrop-filter: blur(var(--blur-intensity));
    background-color: var(--modal-bg);
    z-index: 1040;
    opacity: 1;
    transition: opacity 0.3s ease;
    width: 100vw;
    height: 100vh;
}

.modal-dialog {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100vh;
    margin: 0;
    z-index: 1045;
    pointer-events: none;
}

.modal-content {
    background: rgba(0 0 0 / 0.5);
    border: none;
    box-shadow: none;
    animation: fadeIn 0.3s ease;
    position: relative;
    border-radius: var(--border-radius);
    overflow: hidden;
    pointer-events: none;
    max-width: 100vw;
    max-height: 100vh;
    display: flex;
    flex-direction: column;
    justify-content: center;
    align-items: center;
    padding: 0;
}

.modal-body {
    display: flex;
    justify-content: center;
    align-items: center;
    height: 100%;
    width: 100%;
    padding: 0;
    margin: 0;
    pointer-events: none;
}

.modal-img {
    max-width: 90vw;
    max-height: 85vh;
    object-fit: contain;
    border-radius: calc(var(--border-radius) - 2px);
    box-shadow: 0 0 40px rgba(0, 0, 0, 0.8);
    background-color: rgba(0, 0, 0, 0.3);
    padding: 20px;
    pointer-events: none;
    margin: auto;
}

/* Modal Navigation buttons */
.modal-nav {
    position: absolute;
    top: 50%;
    width: 100%;
    display: flex;
    justify-content: space-between;
    transform: translateY(-50%);
    z-index: 1060;
    pointer-events: none;
}

.modal-nav button {
    background: rgba(0, 0, 0, 0.6);
    color: white;
    border: none;
    border-radius: 50%;
    width: 50px;
    height: 50px;
    font-size: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    cursor: pointer;
    opacity: 0.8;
    transition: all 0.3s ease;
    margin: 0 30px;
    pointer-events: auto;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
}

.modal-nav button:hover {
    background: var(--modal-hover);
    opacity: 1;
    transform: scale(1.2);
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.4);
}

.modal-nav #prevImage {
    left: 0;
}

.modal-nav #nextImage {
    right: 0;
}

/* Image counter */
.image-counter {
    position: absolute;
    bottom: 30px;
    left: 50%;
    transform: translateX(-50%);
    background: rgba(0, 0, 0, 0.7);
    color: white;
    padding: 10px 20px;
    border-radius: 30px;
    font-size: 1rem;
    z-index: 1060;
    font-weight: 500;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.3);
    pointer-events: none;
}

/* ===== Animations ===== */
@keyframes fadeIn {
    from {
        opacity: 0;
        transform: scale(0.95);
    }

    to {
        opacity: 1;
        transform: scale(1);
    }
}

/* ===== Utility Classes ===== */
.loading-spinner {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2000;
}

/* Toggle button for mobile */
.btn.btn-dark.d-md-none {
    position: fixed;
    top: 15px;
    left: 15px;
    z-index: 999;
    background-color: var(--primary-color);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
}

/* ===== Responsive Styles ===== */
@media (max-width: 768px) {
    .sidebar {
        width: 0;
        overflow: hidden;
    }

    .sidebar.active {
        width: var(--sidebar-width);
    }

    .main-content {
        margin-left: 0;
    }

    .main-content.active {
        margin-left: var(--sidebar-width);
    }

    .gallery-section .row {
        grid-template-columns: repeat(auto-fill, minmax(180px, 1fr));
    }

    .image-container {
        height: 160px;
    }
}

/* Dark mode support */
@media (prefers-color-scheme: dark) {
    body {
        background-color: #121212;
    }

    .main-content {
        background-color: #1e1e1e;
    }

    .gallery-section {
        color: #e0e0e0;
    }

    .section-title {
        border-bottom-color: #444;
    }

    .image-container {
        background-color: #2a2a2a;
    }
}

/* Additional styles to ensure proper modal closing behavior */
.modal-open {
    overflow: hidden;
}

.modal-open .modal {
    display: block;
}

/* Make sure the modal content is properly positioned */
.modal-content::after {
    content: '';
    position: absolute;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    z-index: 1055;
}

/* Ensure the modal is properly centered */
.modal-dialog {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: calc(100vh - 60px);
}

/* Make sure the image is properly contained */
.modal-body {
    display: flex;
    justify-content: center;
    align-items: center;
    width: 100%;
    height: 100%;
}

/* Ensure navigation buttons are always visible */
.modal-nav {
    position: fixed;
    top: 50%;
    left: 0;
    right: 0;
    transform: translateY(-50%);
    pointer-events: none;
    z-index: 1060;
}

/* Make navigation buttons more prominent */
.modal-nav button {
    width: 50px;
    height: 50px;
    background: rgba(0, 0, 0, 0.7);
    transition: all 0.3s ease;
}

.modal-nav button:hover {
    background: rgba(0, 0, 0, 0.9);
    transform: scale(1.1);
}

/* Position image counter better */
.image-counter {
    position: fixed;
    bottom: 20px;
    left: 50%;
    transform: translateX(-50%);
    z-index: 1060;
}

/* Add this inline style to center the tutorial link */
.sidebar-tutorial {
    text-align: center;
    padding: 15px;
    margin-top: 15px;
}

.sidebar-tutorial a {
    display: flex;
    flex-direction: column;
    align-items: center;
    text-decoration: none;
    color: white;
}

.sidebar-tutorial img {
    width: 200px;
    max-width: 100%;
    height: auto;
    margin: 10px 0;
}

.sidebar-tutorial-text {
    font-size: 0.9rem;
    color: #ccc;
    text-align: center;
    margin-bottom: 5px;
}
