/* style.css */

:root {
    --primary-color: #6a11cb; /* Deep Violet */
    --primary-color-rgb: 106, 17, 203; /* Added for box-shadow */
    --secondary-color: #2575fc; /* Bright Blue */
    --accent-color: #fcb045; /* Warm Orange/Gold */
    --font-color: #333;
    --font-color-light: #f8f9fa;
    --bg-light: #ffffff;
    --bg-dark: #121212; /* Dark background for contrast */
    --bg-glass: rgba(255, 255, 255, 0.1);
    --border-light: rgba(255, 255, 255, 0.2);
    --shadow-light: rgba(0, 0, 0, 0.1);
    --shadow-dark: rgba(0, 0, 0, 0.3);
    --font-family-sans: 'Vazirmatn', 'Poppins', sans-serif; /* Added Vazirmatn */
    --font-family-serif: 'Georgia', serif;
    --transition-speed: 0.4s;
    --border-radius: 12px;
}

html, body {
    max-width: 100vw;
    overflow-x: hidden !important;
    box-sizing: border-box;
}

body {
    margin: 0;
    font-family: var(--font-family-sans);
    direction: rtl;
    text-align: right;
    color: var(--font-color);
    background: var(--bg-light);
    line-height: 1.7;
    font-size: 16px;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    overflow-x: hidden !important;
    padding: 0;
    box-sizing: border-box;
    width: 100%;
    max-width: 100vw;
    position: relative;
}

img, video {
    max-width: 100% !important;
    height: auto !important;
    display: block;
    object-fit: cover;
    border-radius: 10px;
    margin: 0 auto;
}

/* جلوگیری از اسکرول افقی و بیرون‌زدگی در موبایل */
html, body {
    max-width: 100vw;
    overflow-x: hidden;
}

/* Smooth scrolling */
html {
    scroll-behavior: smooth;
    font-size: 16px;
}

@media (max-width: 768px) {
    html {
        font-size: 14px;
    }
}

/* Custom Scrollbar */
::-webkit-scrollbar {
    width: 8px;
}
::-webkit-scrollbar-track {
    background: var(--bg-light);
}
::-webkit-scrollbar-thumb {
    background: var(--primary-color);
    border-radius: 10px;
}
::-webkit-scrollbar-thumb:hover {
    background: var(--secondary-color);
}

/* Hero Section Styling */
.hero {
    position: relative;
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%),
                url('../images/background.jpg') no-repeat center center; /* Removed fixed attachment for better mobile performance */
    background-blend-mode: multiply; /* Blend gradient with image */
    background-size: cover;
    height: 100vh;
    min-height: 350px;
    display: flex;
    align-items: center;
    justify-content: center;
    color: var(--font-color-light);
    overflow: hidden;
    text-align: center;
    padding: 30px 0 10px 0;
}

/* Apply fixed background only on desktop for parallax effect */
@media (min-width: 769px) {
    .hero {
        background-attachment: fixed;
    }
}

.hero .content {
    position: relative;
    z-index: 2;
    padding: 20px;
    max-width: 800px;
}

.hero h1 {
    font-size: clamp(1.5rem, 7vw, 2.5rem); /* Responsive font size */
    font-weight: 700;
    letter-spacing: 1px;
    margin-bottom: 10px;
    text-shadow: 2px 2px 8px var(--shadow-dark);
}

.hero p {
    font-size: 1rem;
    margin-bottom: 18px;
    text-shadow: 1px 1px 4px var(--shadow-dark);
}

.hero .cta-button {
    background: var(--accent-color);
    color: var(--bg-dark);
    padding: 8px 18px;
    border-radius: var(--border-radius);
    text-decoration: none;
    font-weight: 600;
    transition: background var(--transition-speed) ease;
    display: inline-block;
    box-shadow: 0 4px 15px var(--shadow-dark);
    font-size: 1rem;
}

/* Apply animations only on desktop */
@media (min-width: 769px) {
    .hero h1 {
        animation: fadeInDown 1s ease-out;
    }
    
    .hero p {
        animation: fadeInUp 1s ease-out 0.5s;
        animation-fill-mode: backwards;
    }
    
    .hero .cta-button {
        animation: zoomIn 1s ease-out 1s;
        animation-fill-mode: backwards;
        transition: background var(--transition-speed) ease, transform var(--transition-speed) ease;
    }
    
    .hero .cta-button:hover {
        transform: translateY(-3px) scale(1.05);
    }
}

.hero .cta-button:hover {
    background: darken(var(--accent-color), 10%);
    transform: translateY(-3px) scale(1.05);
}

/* Keyframe animations for hero */
@keyframes fadeInDown {
    from { opacity: 0; transform: translateY(-30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes fadeInUp {
    from { opacity: 0; transform: translateY(30px); }
    to { opacity: 1; transform: translateY(0); }
}

@keyframes zoomIn {
    from { opacity: 0; transform: scale(0.8); }
    to { opacity: 1; transform: scale(1); }
}

/* Container */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 16px;
    box-sizing: border-box;
    overflow-x: hidden;
}

section {
    padding: 80px 20px; /* Increased padding */
    background: var(--bg-light);
    margin: 0; /* Remove default section margin if body has bg */
    border-bottom: 1px solid #e0e0e0; /* Subtle separator */
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
}

/* Mobile optimizations for sections */
@media (max-width: 768px) {
    section {
        padding: 50px 15px;
    }
    .container {
        padding: 0 12px;
    }
}

section:last-of-type {
    border-bottom: none;
}

/* Section heading */
section h2 {
    text-align: center;
    font-size: clamp(1.8rem, 4vw, 2.8rem);
    margin-bottom: 50px; /* Increased margin */
    color: var(--primary-color);
    font-weight: 700;
    position: relative;
}

section h2::after {
    content: '';
    display: block;
    width: 70px;
    height: 4px;
    background: var(--accent-color);
    margin: 15px auto 0;
    border-radius: 2px;
}

/* Navigation Styling */
#main-nav {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    background: transparent; /* Initially transparent */
    padding: 15px 0;
    transition: background var(--transition-speed) ease, padding var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
}

#main-nav.nav-scrolled {
    background: rgba(18, 18, 18, 0.85); /* Dark, slightly transparent */
    backdrop-filter: blur(10px);
    padding: 10px 0;
    box-shadow: 0 2px 10px var(--shadow-dark);
}

#main-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: relative; /* اطمینان از موقعیت نسبی برای آیتم‌های absolute */
}

#main-nav .logo {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--font-color-light);
    text-decoration: none;
    transition: color var(--transition-speed) ease;
}

#main-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

#main-nav li {
    margin: 0 10px; /* Adjusted margin */
}

#main-nav a {
    color: var(--font-color-light);
    text-decoration: none;
    padding: 8px 12px;
    font-weight: 500;
    transition: color var(--transition-speed) ease, background-color var(--transition-speed) ease;
    position: relative;
    border-radius: var(--border-radius);
    font-size: 0.95rem;
}

#main-nav a:hover,
#main-nav a.active {
    color: var(--accent-color);
}

/* Underline effect for nav links */
#main-nav a::after {
    content: '';
    position: absolute;
    width: 0;
    height: 2px;
    background: var(--accent-color);
    bottom: -2px; /* Adjusted position */
    left: 50%;
    transform: translateX(-50%);
    transition: width var(--transition-speed) ease;
}

#main-nav a:hover::after,
#main-nav a.active::after {
    width: 60%; /* Underline doesn't span full width for a subtle look */
}

/* Hamburger Menu */
.hamburger {
    display: none; /* Hidden by default, only shown in mobile */
    cursor: pointer;
    padding: 10px;
    z-index: 1001;
    background: transparent;
    border: none;
    outline: none;
    position: relative; /* Ensure proper stacking context */
    margin-left: 10px;
    touch-action: manipulation; /* Improve touch handling */
    -webkit-tap-highlight-color: transparent; /* Remove tap highlight on mobile */
    visibility: hidden; /* Ensure it's hidden on desktop */
    opacity: 0;
}

.hamburger .bar {
    display: block;
    width: 25px;
    height: 3px;
    margin: 5px auto;
    background-color: var(--font-color-light);
    transition: all 0.3s ease-in-out;
    border-radius: 2px;
}

/* Improved active state animation */
.hamburger.active .bar:nth-child(1) {
    transform: translateY(8px) rotate(45deg);
    background-color: var(--accent-color); /* Highlight when active */
}
.hamburger.active .bar:nth-child(2) {
    opacity: 0;
    transform: translateX(-20px); /* Slide out animation */
}
.hamburger.active .bar:nth-child(3) {
    transform: translateY(-8px) rotate(-45deg);
    background-color: var(--accent-color); /* Highlight when active */
}

@media (max-width: 768px) {
    /* حذف کامل منوی همبرگری در موبایل */
    .hamburger {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
    
    /* حذف کامل ناوبری در موبایل */
    #main-nav ul.nav-menu {
        display: none !important;
        visibility: hidden !important;
        opacity: 0 !important;
    }
}

/* Sticky Nav states */
#main-nav.scroll-down {
    transform: translateY(-100%);
}

#main-nav.scroll-up {
    transform: translateY(0);
}

@media (max-width: 900px) {
    /* Improved mobile menu styles */
    #main-nav ul.nav-menu {
        position: fixed;
        top: 60px;
        right: 0;
        width: 100%;
        background: rgba(18, 18, 18, 0.98);
        backdrop-filter: blur(10px);
        -webkit-backdrop-filter: blur(10px);
        flex-direction: column;
        display: none;
        z-index: 1000;
        padding: 20px 0;
        box-shadow: 0 5px 15px rgba(0, 0, 0, 0.3);
        transition: transform 0.3s ease, opacity 0.3s ease;
        transform: translateY(-10px);
        opacity: 0;
        pointer-events: none;
    }
    
    /* Active state with animation */
    #main-nav ul.nav-menu.active { 
        display: flex; 
        transform: translateY(0);
        opacity: 1;
        pointer-events: auto;
    }
    
    /* Make menu items take full width */
    #main-nav li { 
        width: 100%; 
        margin: 0; 
        text-align: center;
    }
    
    /* Prevent body scroll when menu is open */
    body.menu-open {
        overflow: hidden;
    }
    #main-nav a { display: block; text-align: center; padding: 15px 0; font-size: 1.1rem; }
}

/* About Section */
#about {
    background: var(--bg-light);
}

.about-content {
    display: flex;
    flex-wrap: wrap;
    gap: 18px;
}

.about-image {
    flex: 1 1 180px;
    max-width: 95vw;
    margin: 0 auto 10px auto;
    border-radius: var(--border-radius);
    overflow: hidden;
    box-shadow: 0 15px 35px var(--shadow-light);
    position: relative;
}

.about-image img {
    width: 100%;
    height: auto;
    display: block;
    transition: transform var(--transition-speed) ease, filter var(--transition-speed) ease;
}

.about-image:hover img {
    transform: scale(1.05);
    filter: saturate(1.2);
}

.about-text {
    flex: 2 1 300px;
}

.about-text p {
    margin-bottom: 20px;
    font-size: 1rem;
    color: #555;
}

.about-text .highlight {
    color: var(--primary-color);
    font-weight: 600;
}

@media (max-width: 700px) {
    .about-content {
        flex-direction: column;
        gap: 10px;
    }
    .about-image {
        max-width: 100vw;
    }
}

/* Gallery Section */
#gallery {
    background: #f0f2f5;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 !important;
    padding: 0 !important;
    box-sizing: border-box;
    overflow-x: hidden;
}

.filter-buttons {
    text-align: center;
    margin-bottom: 30px;
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    gap: 8px;
}

.filter-btn {
    background: transparent;
    border: 2px solid var(--primary-color);
    color: var(--primary-color);
    padding: 10px 20px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
    font-weight: 500;
    white-space: nowrap;
}

.filter-btn:hover,
.filter-btn.active {
    background: var(--primary-color);
    color: var(--font-color-light);
    transform: translateY(-2px);
    box-shadow: 0 5px 15px rgba(var(--primary-color-rgb), 0.3);
}

.gallery-wrapper {
    position: relative;
    width: 100% !important;
    max-width: 100% !important;
    margin: 0 auto !important;
    padding: 0 10px !important;
    box-sizing: border-box;
    min-height: 200px;
    overflow-x: hidden;
}

.gallery-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 12px;
    width: 100%;
    margin: 0 auto;
    padding: 0 2px;
    box-sizing: border-box;
    opacity: 1; /* Start visible for better performance */
}

.gallery-grid.loaded {
    opacity: 1;
}

/* Image placeholder for better loading UX */
.image-placeholder {
    background-color: #f0f0f0;
    width: 100%;
    height: 100%;
    position: absolute;
    top: 0;
    left: 0;
    border-radius: 10px;
}

.gallery-item {
    position: relative;
    width: 100%;
    border-radius: 10px;
    overflow: hidden;
    aspect-ratio: 1/1;
    background: #fff;
    box-shadow: 0 2px 8px rgba(0,0,0,0.04);
    cursor: pointer;
    min-width: 0;
    min-height: 90px;
    max-width: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

/* Apply hover effects only on desktop */
@media (min-width: 769px) {
    .gallery-item {
        transition: transform var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    }
    
    .gallery-item:hover {
        transform: translateY(-5px);
        box-shadow: 0 12px 25px var(--shadow-dark);
    }
}

.gallery-item img {
    width: 100% !important;
    height: 100% !important;
    object-fit: cover;
    object-position: center;
    display: block;
    border-radius: 10px;
    max-width: 100%;
    min-width: 0;
    opacity: 1 !important;
    background: none !important;
}

/* حذف کامل overlay از گالری */
.gallery-item-overlay {
    display: none !important;
}

/* Loading spinner and gallery enhancements */
.gallery-loading {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    background: rgba(255, 255, 255, 0.9);
    z-index: 10;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 3px solid rgba(var(--primary-color-rgb), 0.3);
    border-radius: 50%;
    border-top-color: var(--primary-color);
    animation: spin 1s ease-in-out infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

/* Image error state */
.image-error {
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    background: rgba(0, 0, 0, 0.7);
    color: #fff;
    padding: 10px 20px;
    border-radius: var(--border-radius);
    text-align: center;
    width: 80%;
    font-size: 0.9rem;
}

/* Articles Section */
#articles {
    background: var(--bg-light);
    overflow-x: hidden;
    width: 100%;
    max-width: 100%;
}

.articles-container {
    padding: 0 15px;
    max-width: 800px;
    margin: 0 auto;
    width: 100%;
    box-sizing: border-box;
}

.article-list {
    list-style: none;
    padding: 0;
    margin: 0;
    width: 100%;
}

.article-list-item {
    padding: 12px 0;
    border-bottom: 1px solid rgba(var(--primary-color-rgb), 0.1);
    width: 100%;
}

.article-list-item:last-child {
    border-bottom: none;
}

.article-list-item a {
    display: flex;
    flex-direction: column;
    align-items: flex-start;
    text-decoration: none;
    color: var(--font-color);
    transition: color 0.3s ease;
    gap: 3px;
    font-size: 1rem;
    padding: 0;
    width: 100%;
}

.article-list-item a:hover {
    color: var(--primary-color);
}

.article-list-title {
    font-size: 1rem;
    font-weight: 600;
    margin: 0;
    padding-left: 0;
    width: 100%;
    overflow: hidden;
    text-overflow: ellipsis;
}

.article-list-date {
    font-size: 0.85rem;
    color: #777;
    white-space: nowrap;
    margin-right: 0;
}

/* Footer */
footer {
    background: var(--bg-dark);
    color: rgba(255, 255, 255, 0.7);
    text-align: center;
    padding: 40px 20px;
    font-size: 0.9rem;
    width: 100%;
    max-width: 100%;
    box-sizing: border-box;
    overflow-x: hidden;
    position: relative;
}

@media (max-width: 768px) {
    footer {
        padding: 30px 15px;
    }
}

footer .social-links a {
    color: rgba(255, 255, 255, 0.7);
    margin: 0 10px;
    font-size: 1.5rem;
    transition: color var(--transition-speed) ease;
}

footer .social-links a:hover {
    color: var(--accent-color);
}

footer p {
    margin-top: 15px;
}

/* Login Page Enhancements */
.login-page {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--secondary-color) 100%);
}

.login-container {
    background: var(--bg-glass);
    border: 1px solid var(--border-light);
    box-shadow: 0 8px 32px var(--shadow-dark);
}

.login-container h2 {
    color: var(--font-color-light);
}
.login-container h2::after {
    background: var(--accent-color);
}

.login-container input[type="text"],
.login-container input[type="password"] {
    background: rgba(255, 255, 255, 0.15);
    color: var(--font-color-light);
    border-radius: var(--border-radius);
}
.login-container input::placeholder {
    color: rgba(255,255,255,0.6);
}

.login-container button[type="submit"] {
    background: var(--accent-color);
    color: var(--bg-dark);
    border-radius: var(--border-radius);
}
.login-container button[type="submit"]:hover {
    background: darken(var(--accent-color), 10%);
}

#login-msg {
    color: var(--font-color-light);
}

.back-to-site a {
    color: var(--accent-color);
}
.back-to-site a:hover {
    color: darken(var(--accent-color), 10%);
}

/* Admin Page Specific Styles */
body.admin-page-bg { /* Apply to body of admin.html if needed for specific background */
    background-color: #f0f2f5; /* Light grey background for admin area */
}

/* Admin Navigation */
nav.admin-nav {
    background-color: var(--bg-dark);
    padding: 10px 0;
    box-shadow: 0 2px 5px var(--shadow-dark);
}

nav.admin-nav .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

nav.admin-nav .logo a {
    font-size: 1.5rem;
    font-weight: 700;
    color: var(--font-color-light);
    text-decoration: none;
}

nav.admin-nav ul {
    list-style: none;
    margin: 0;
    padding: 0;
    display: flex;
}

nav.admin-nav li {
    margin: 0 10px;
}

nav.admin-nav a {
    color: var(--font-color-light);
    text-decoration: none;
    padding: 8px 12px;
    font-weight: 500;
    transition: color var(--transition-speed) ease;
    border-radius: var(--border-radius);
}

nav.admin-nav a:hover,
nav.admin-nav a.active {
    color: var(--accent-color);
}

/* Admin Section */
#admin {
    padding: 40px 20px; /* Reduced padding compared to front-end sections */
    background-color: var(--bg-light);
    margin-top: 20px; /* Space from nav */
    border-radius: var(--border-radius);
    box-shadow: 0 5px 15px var(--shadow-light);
}

#admin h2 {
    text-align: center;
    font-size: clamp(1.6rem, 3vw, 2.2rem);
    margin-bottom: 30px;
    color: var(--primary-color);
    font-weight: 700;
    position: relative;
}

#admin h2::after {
    content: '';
    display: block;
    width: 60px;
    height: 3px;
    background: var(--accent-color);
    margin: 10px auto 0;
    border-radius: 2px;
}

.admin-tabs {
    display: flex;
    justify-content: center;
    margin-bottom: 30px;
    border-bottom: 2px solid #eee;
}

.admin-tabs button {
    background: transparent;
    border: none;
    padding: 12px 25px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--font-color);
    cursor: pointer;
    transition: color var(--transition-speed) ease, border-bottom-color var(--transition-speed) ease;
    border-bottom: 3px solid transparent;
    margin: 0 5px -2px 5px; /* Negative margin to align border with container's border */
    border-top-left-radius: var(--border-radius);
    border-top-right-radius: var(--border-radius);
}

.admin-tabs button:hover {
    color: var(--secondary-color);
}

.admin-tabs button.active {
    color: var(--primary-color);
    border-bottom-color: var(--primary-color);
}

/* Admin Forms */
#articles-dashboard,
#gallery-dashboard {
    padding: 20px;
    background-color: #fdfdfd; /* Slightly off-white for form area */
    border-radius: var(--border-radius);
    box-shadow: inset 0 2px 4px rgba(0,0,0,0.05);
}

#articles-dashboard.hidden,
#gallery-dashboard.hidden {
    display: none;
}

#article-form,
#gallery-form {
    display: grid;
    gap: 20px;
}

#article-form label,
#gallery-form label {
    font-weight: 600;
    color: var(--primary-color);
    font-size: 0.95rem;
}

#article-form input[type="text"],
#article-form input[type="file"],
#article-form textarea,
#gallery-form input[type="file"] {
    width: 100%;
    padding: 12px;
    border: 1px solid #ccc;
    border-radius: var(--border-radius);
    font-family: var(--font-family-sans);
    font-size: 1rem;
    transition: border-color var(--transition-speed) ease, box-shadow var(--transition-speed) ease;
    box-sizing: border-box; /* Ensure padding doesn't increase width */
}

#article-form input[type="text"]:focus,
#article-form input[type="file"]:focus,
#article-form textarea:focus,
#gallery-form input[type="file"]:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(var(--primary-color-rgb), 0.2); /* Use RGB for box-shadow */
    outline: none;
}

#article-form textarea {
    resize: vertical;
    min-height: 150px;
}

#article-form button[type="submit"],
#gallery-form button[type="submit"] {
    background-color: var(--accent-color);
    color: var(--bg-dark);
    padding: 12px 25px;
    border: none;
    border-radius: var(--border-radius);
    font-size: 1.05rem;
    font-weight: 600;
    cursor: pointer;
    transition: background-color var(--transition-speed) ease, transform var(--transition-speed) ease;
    justify-self: start; /* Align button to the start of the grid cell */
}

#article-form button[type="submit"]:hover,
#gallery-form button[type="submit"]:hover {
    background-color: darken(var(--accent-color), 10%);
    transform: translateY(-2px);
}

/* Admin Lists (for articles/gallery items) */
.dashboard-list {
    margin-top: 30px;
    border-top: 1px solid #eee;
    padding-top: 20px;
}

.dashboard-list .list-item { /* Example style for a list item */
    background-color: #fff;
    padding: 15px;
    border-radius: var(--border-radius);
    margin-bottom: 15px;
    box-shadow: 0 2px 5px var(--shadow-light);
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.dashboard-list .list-item h4 {
    margin: 0 0 5px 0;
    color: var(--secondary-color);
}

.dashboard-list .list-item p {
    margin: 0;
    font-size: 0.9rem;
    color: #666;
}

.dashboard-list .list-item-actions button {
    background: transparent;
    border: 1px solid var(--accent-color);
    color: var(--accent-color);
    padding: 5px 10px;
    margin-left: 5px;
    border-radius: var(--border-radius);
    cursor: pointer;
    transition: all var(--transition-speed) ease;
}

.dashboard-list .list-item-actions button:hover {
    background: var(--accent-color);
    color: var(--bg-dark);
}

.dashboard-list .list-item-actions button.delete-btn {
    border-color: #e74c3c;
    color: #e74c3c;
}
.dashboard-list .list-item-actions button.delete-btn:hover {
    background: #e74c3c;
    color: var(--font-color-light);
}

/* Logout Button in Admin Nav */
#logout {
    background-color: var(--accent-color);
    color: var(--bg-dark) !important; /* Important to override general link color */
    padding: 8px 15px !important; /* Ensure padding is applied */
    border-radius: var(--border-radius);
    font-weight: 600;
}
#logout:hover {
    background-color: darken(var(--accent-color), 10%);
    color: var(--bg-dark) !important;
}

/* Responsive Admin Styles */
@media (max-width: 768px) {
    #admin {
        padding: 20px 15px;
        margin-top: 10px;
    }
    .admin-tabs button {
        padding: 10px 15px;
        font-size: 1rem;
    }
    #article-form, #gallery-form {
        gap: 15px;
    }
    #article-form label, #gallery-form label {
        font-size: 0.9rem;
    }
    #article-form input[type="text"],
    #article-form input[type="file"],
    #article-form textarea,
    #gallery-form input[type="file"],
    #article-form button[type="submit"],
    #gallery-form button[type="submit"] {
        font-size: 0.95rem;
        padding: 10px;
    }
    .dashboard-list .list-item {
        flex-direction: column;
        align-items: flex-start;
    }
    .dashboard-list .list-item-actions {
        margin-top: 10px;
    }
    .dashboard-list .list-item-actions button {
        margin-left: 0;
        margin-right: 5px; /* Adjust for RTL */
        margin-bottom: 5px;
    }

    nav.admin-nav .container {
        flex-direction: column;
        align-items: flex-start;
    }
    nav.admin-nav ul {
        margin-top: 10px;
        width: 100%;
        flex-direction: column;
    }
    nav.admin-nav li {
        margin: 5px 0;
        width: 100%;
    }
    nav.admin-nav a {
        display: block;
        text-align: center;
    }
    #logout {
        width: 100%;
        box-sizing: border-box;
        text-align: center;
    }
}

/* Responsive Design Adjustments */
@media (max-width: 1200px) {
    .container {
        padding: 0 30px;
    }
    
    .articles-container {
        grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
    }
}

@media (max-width: 992px) {
    .about-content {
        grid-template-columns: 1fr;
        text-align: center;
        gap: 30px;
    }
    
    .about-image {
        max-width: 400px;
        margin: 0 auto;
    }

    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    }

    section {
        padding: 60px 0;
    }
}

@media (max-width: 900px) {
    .container { max-width: 100vw; padding: 0 8px; }
    .gallery-grid { grid-template-columns: repeat(3, 1fr); }
}

@media (max-width: 768px) {
    body {
        font-size: 15px;
        width: 100%;
        overflow-x: hidden;
    }

    .container {
        padding: 0 15px;
        width: 100%;
        max-width: 100%;
        overflow-x: hidden;
    }

    /* Header & Navigation */
    #main-nav {
        padding: 10px 0;
        width: 100%;
        max-width: 100%;
    }

    #main-nav .container {
        padding: 0 15px;
        display: flex;
        justify-content: space-between;
        align-items: center;
        width: 100%;
    }

    #main-nav .logo {
        font-size: 1.5rem;
        display: block;
    }

    #main-nav ul {
        display: none;
        flex-direction: column;
        position: fixed;
        top: 60px;
        right: 0;
        left: 0; /* Ensure full width */
        width: 100%;
        background: rgba(18, 18, 18, 0.98);
        backdrop-filter: blur(10px);
        padding: 20px 0;
        box-shadow: 0 5px 10px var(--shadow-dark);
        z-index: 1000;
        margin: 0;
    }

    #main-nav ul.active {
        display: flex;
    }

    #main-nav li {
        margin: 0;
        width: 100%;
        padding: 0;
    }

    #main-nav a {
        padding: 15px 20px;
        display: block;
        text-align: center;
        font-size: 1.1rem;
        width: 100%;
        box-sizing: border-box;
    }

    #main-nav a::after {
        display: none;
    }

    .hamburger {
        display: block;
        z-index: 1001;
    }    /* Hero Section */
    .hero {
        min-height: 450px; /* Shorter on mobile */
        padding: 20px 0;
    }

    .hero .content {
        width: 100%;
        padding: 20px 15px;
        box-sizing: border-box;
    }

    .hero h1 {
        font-size: clamp(1.8rem, 7vw, 2.8rem);
        margin-bottom: 15px;
    }

    .hero p {
        font-size: clamp(0.95rem, 4vw, 1.1rem);
        padding: 0 10px;
        margin-bottom: 20px;
    }

    .hero .cta-button {
        padding: 10px 20px;
        font-size: 0.95rem;
    }

    /* Sections */
    section {
        padding: 50px 15px;
        width: 100%;
        max-width: 100%;
        overflow: hidden;
    }

    section h2 {
        margin-bottom: 25px;
        font-size: clamp(1.5rem, 5vw, 2.2rem);
    }

    /* About Section */
    .about-content {
        grid-template-columns: 1fr;
        gap: 30px;
    }

    .about-image {
        max-width: 400px;
        margin: 0 auto;
    }

    /* Gallery */
    .gallery-wrapper {
        padding: 0 10px;
    }

    .filter-btn {
        padding: 8px 15px;
        font-size: 0.9rem;
    }

    .gallery-grid {
        grid-template-columns: repeat(2, 1fr);
        gap: 6px;
        padding: 0 1px;
    }

    .gallery-item {
        min-height: 90px;
        aspect-ratio: 1/1;
    }

    /* Articles */
    .articles-container {
        padding: 0 15px;
    }

    .article-list-item {
        padding: 12px 0;
    }

    .article-list-item a {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .article-list-title {
        font-size: 1rem;
        padding-left: 10px;
    }

    .article-list-date {
        margin-right: 0;
        font-size: 0.8rem;
    }

    /* Admin Panel */
    #admin {
        padding: 20px 15px;
        margin: 15px;
    }

    .admin-tabs {
        flex-wrap: wrap;
        gap: 10px;
    }

    .admin-tabs button {
        padding: 10px 15px;
        font-size: 0.95rem;
        flex: 1;
        min-width: 120px;
    }

    #articles-dashboard,
    #gallery-dashboard {
        padding: 15px;
    }

    #article-form,
    #gallery-form {
        gap: 15px;
    }

    #article-form input[type="text"],
    #article-form input[type="file"],
    #article-form textarea,
    #gallery-form input[type="file"] {
        padding: 10px;
        font-size: 0.95rem;
    }

    .dashboard-list .list-item {
        flex-direction: column;
        gap: 15px;
    }

    .dashboard-list .list-item-content {
        width: 100%;
    }

    .dashboard-list .list-item-actions {
        display: flex;
        gap: 10px;
        width: 100%;
    }

    .dashboard-list .list-item-actions button {
        flex: 1;
        margin: 0;
    }

    /* Login Page */
    .login-container {
        margin: 20px;
        padding: 20px;
    }

    .login-container input {
        padding: 12px;
        font-size: 0.95rem;
    }

    /* Footer */
    .footer-content {
        grid-template-columns: 1fr;
        gap: 30px;
        text-align: center;
    }

    .footer-links ul {
        justify-content: center;
    }
}

@media (max-width: 700px) {
    .gallery-grid { grid-template-columns: repeat(2, 1fr); }
    .container { padding: 0 4px; }
    .about-content { flex-direction: column; gap: 10px; }
    .about-image { max-width: 100vw; }
    .contact-content { flex-direction: column; gap: 10px; }
    .footer-content { flex-direction: column; gap: 0; text-align: center; }
    .footer-section { margin-bottom: 10px; }
}

@media (max-width: 600px) {
  html {
    font-size: 13px;
  }
  body {
    font-size: 15px;
    padding: 0;
    overflow-x: hidden;
  }
  .container {
    width: 100% !important;
    max-width: 100% !important;
    padding: 0 10px !important;
    overflow-x: hidden;
  }
  section {
    padding: 40px 0 30px 0;
    width: 100%;
    max-width: 100%;
    overflow: hidden;
  }
  /* Gallery fixes for mobile */
  .gallery-grid {
    grid-template-columns: repeat(2, 1fr);
    gap: 8px;
    padding: 0 5px;
  }
  .gallery-item {
    min-height: 140px;
    aspect-ratio: 1/1;
  }
  /* Make sure the grid doesn't overflow */
  #gallery {
    overflow-x: hidden;
  }
  .gallery-wrapper {
    width: 100% !important;
    max-width: 100% !important;
    overflow-x: hidden !important;
  }
  .filter-buttons {
    gap: 5px;
    margin: 0 5px 18px 5px;
    flex-wrap: wrap;
  }
  .filter-btn {
    padding: 7px 10px;
    font-size: 0.95rem;
    margin: 2px;
  }
  /* Article List */
  .article-list-item a {
    flex-direction: column;
    align-items: flex-start;
    gap: 2px;
    font-size: 1rem;
    padding: 0;
  }
  .article-list-title {
    font-size: 1rem;
    padding-left: 0;
  }
  .article-list-date {
    font-size: 0.85rem;
    margin-right: 0;
  }
  /* Footer */
  .footer-content {
    display: block !important;
    text-align: center;
    gap: 0;
  }
  .footer-section {
    margin-bottom: 18px;
  }
  .copyright {
    font-size: 0.85rem;
  }
  /* Contact */
  .contact-content {
    flex-direction: column;
    gap: 18px;
  }
  .contact-info, .contact-form {
    width: 100%;
    margin: 0 auto;
  }
  .form-group input, .form-group textarea {
    font-size: 1rem;
  }
  /* Back to top */
  #back-to-top {
    right: 10px;
    bottom: 10px;
    width: 38px;
    height: 38px;
    font-size: 1.1rem;
  }
}

@media (max-width: 576px) {
    .gallery-grid {
        grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
        gap: 15px;
        padding: 0 5px;
    }

    .gallery-item {
        aspect-ratio: 1;
    }

    .article-list-item a {
        flex-direction: column;
        align-items: flex-start;
        gap: 5px;
    }

    .article-list-date {
        margin-right: 0;
        font-size: 0.8rem;
    }
}

@media (max-width: 500px) {
    html { font-size: 14px; }
    .container { padding: 0 2px; }
    .gallery-grid { grid-template-columns: 1fr; gap: 8px; }
    .gallery-item { min-height: 70px; }
}

@media (max-width: 480px) {
    /* Container */
    .container {
        padding: 0 12px;
        width: 100%;
        box-sizing: border-box;
    }

    /* Hero */
    .hero {
        min-height: 400px;
    }

    .hero h1 {
        font-size: clamp(1.5rem, 6vw, 1.8rem);
    }

    .hero p {
        font-size: 0.9rem;
        margin-bottom: 15px;
    }

    .hero .cta-button {
        padding: 8px 18px;
        font-size: 0.9rem;
    }

    /* Sections */
    section {
        padding: 40px 10px;
        width: 100%;
        max-width: 100%;
        box-sizing: border-box;
    }

    section h2 {
        font-size: 1.4rem;
        margin-bottom: 20px;
    }

    /* About */
    .about-image {
        max-width: 100%;
        margin-bottom: 15px;
    }

    .about-text p {
        font-size: 0.9rem;
    }

    /* Gallery */
    .gallery-grid {
        grid-template-columns: repeat(2, 1fr); /* Simplify to 2 columns on small screens */
        gap: 8px;
        width: 100%;
        box-sizing: border-box;
    }
    
    .gallery-item {
        aspect-ratio: 1/1;
        margin: 0;
        min-height: 130px;
    }

    .gallery-wrapper {
        padding: 0 8px;
        width: 100% !important;
        box-sizing: border-box;
    }
    
    #gallery {
        padding: 40px 0 !important;
    }
    
    .filter-buttons {
        margin-bottom: 15px;
    }
    
    .filter-btn {
        padding: 6px 10px;
        font-size: 0.85rem;
    }

    /* Articles */
    .articles-container {
        padding: 0 10px;
    }

    .article-list-item {
        padding: 10px 0;
    }

    .article-list-title {
        font-size: 0.95rem;
        padding-left: 5px;
    }

    .article-list-date {
        font-size: 0.8rem;
        margin-right: 5px;
    }

    /* Admin Panel */
    #admin {
        margin: 10px;
        padding: 15px 10px;
    }

    .admin-tabs button {
        padding: 8px 12px;
        font-size: 0.9rem;
    }

    .dashboard-list .list-item {
        margin: 0 0 15px 0;
        padding: 12px;
    }

    .dashboard-list .list-item-actions {
        flex-direction: column;
    }

    .dashboard-list .list-item-actions button {
        width: 100%;
        margin: 5px 0;
    }

    /* Footer */
    footer {
        padding: 30px 15px;
    }

    footer .social-links a {
        font-size: 1.3rem;
        margin: 0 8px;
    }
}

/* Fix for iPhone SE and other small devices */
@media (max-width: 360px) {
    .hero h1 {
        font-size: 1.4rem;
    }

    .hero p {
        font-size: 0.85rem;
    }

    .hero .cta-button {
        padding: 8px 16px;
        font-size: 0.85rem;
    }

    #main-nav .logo {
        font-size: 1.2rem;
    }

    .admin-tabs button {
        padding: 6px 10px;
        font-size: 0.85rem;
    }
}

/* Fix for landscape mode on mobile */
@media (max-height: 500px) and (orientation: landscape) {
    .hero {
        min-height: 400px;
    }

    .hero .content {
        padding: 10px;
    }

    #main-nav ul {
        max-height: 85vh;
        overflow-y: auto;
    }

    #main-nav a {
        padding: 10px 15px;
    }
}

/* Utility Classes */
.text-center { text-align: center; }
.mt-1 { margin-top: 1rem; }
.mb-1 { margin-bottom: 1rem; }

/* Image loading fade-in */
img {
    opacity: 1 !important;
    transition: opacity var(--transition-speed) ease-in-out;
    max-width: 100%;
    height: auto;
    display: block;
}

img.loaded {
    opacity: 1;
}

/* Utility: prevent horizontal scroll everywhere */
* { 
    box-sizing: border-box !important; 
}

/* Better scrollbar for mobile */
::-webkit-scrollbar { 
    width: 4px;
    background: transparent; 
}

::-webkit-scrollbar-thumb {
    background: rgba(var(--primary-color-rgb), 0.5);
    border-radius: 4px;
}

/* Optimize for mobile performance */
@media (max-width: 768px) {
    /* Enable hardware acceleration for better performance */
    body, div, section, nav {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
        -webkit-transform: translateZ(0);
        transform: translateZ(0);
    }
}

/* Optimize for low performance devices */
.low-performance-device .gallery-item img {
    transform: none !important;
    transition: none !important;
}

.low-performance-device .gallery-item {
    transition: none !important;
    transform: none !important;
    box-shadow: 0 2px 8px rgba(0,0,0,0.1) !important;
}

.low-performance-device .hero h1,
.low-performance-device .hero p,
.low-performance-device .hero .cta-button {
    animation: none !important;
}

.low-performance-device .filter-btn {
    transition: background-color 0.3s ease !important;
    transform: none !important;
    box-shadow: none !important;
}

.low-performance-device .filter-btn:hover,
.low-performance-device .filter-btn.active {
    transform: none !important;
    box-shadow: none !important;
}

.low-performance-device section {
    transition: none !important;
}

.low-performance-device .about-image img {
    transition: none !important;
    transform: none !important;
}

.low-performance-device .about-image:hover img {
    transform: none !important;
    filter: none !important;
}

/* Touch device optimizations */
@media (hover: none) and (pointer: coarse) {
    /* This specifically targets touch devices */
    .hero {
        background-attachment: scroll !important; /* Force scroll instead of fixed for better mobile performance */
    }
    
    img, .gallery-item img {
        transform: none !important;
        transition: opacity 0.3s ease !important; /* Keep only opacity transitions */
    }
    
    /* Remove hover effects that don't work well on touch devices */
    .filter-btn:hover, 
    .gallery-item:hover, 
    .article-list-item a:hover, 
    .hero .cta-button:hover,
    #main-nav a:hover {
        transform: none !important;
    }
    
    /* Improve scrolling performance */
    body, div, section {
        -webkit-backface-visibility: hidden;
        backface-visibility: hidden;
    }
}

/* Local Storage Gallery Lightbox */
.gallery-lightbox {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.9);
    display: none;
    justify-content: center;
    align-items: center;
    z-index: 10000;
    padding: 20px;
}

.lightbox-content {
    position: relative;
    max-width: 90%;
    max-height: 90%;
}

.lightbox-content img {
    max-width: 100%;
    max-height: 80vh;
    border: 3px solid white;
    box-shadow: 0 0 20px rgba(0, 0, 0, 0.5);
}

.lightbox-caption {
    color: #fff;
    text-align: center;
    padding: 10px;
    font-size: 16px;
    background-color: rgba(0, 0, 0, 0.7);
    border-radius: 0 0 5px 5px;
    margin-top: -5px;
}

.lightbox-close {
    position: absolute;
    top: -15px;
    right: -15px;
    background-color: rgba(0, 0, 0, 0.8);
    color: white;
    border: 2px solid white;
    font-size: 24px;
    cursor: pointer;
    width: 30px;
    height: 30px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 0;
    line-height: 1;
}

/* Loading and error states */
.loading,
.error,
.no-content {
    text-align: center;
    padding: 40px;
    margin: 20px auto;
    background-color: rgba(255, 255, 255, 0.8);
    border-radius: 10px;
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.1);
    max-width: 80%;
}

.loading::before {
    content: "";
    display: inline-block;
    width: 30px;
    height: 30px;
    margin-right: 10px;
    border: 3px solid var(--primary-color);
    border-radius: 50%;
    border-top-color: transparent;
    animation: spin 1s linear infinite;
}

.error {
    border-left: 4px solid #e74c3c;
    color: #e74c3c;
}

.no-content {
    border-left: 4px solid var(--secondary-color);
    color: #666;
}

@keyframes spin {
    to {
        transform: rotate(360deg);
    }
}

/* Backup/Restore Modal */
.modal {
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    bottom: 0;
    background-color: rgba(0, 0, 0, 0.7);
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 10000;
}

.modal.hidden {
    display: none;
}

.modal-content {
    background-color: white;
    border-radius: 10px;
    padding: 20px;
    width: 80%;
    max-width: 600px;
    max-height: 80vh;
    overflow-y: auto;
    position: relative;
    box-shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

.close-modal {
    position: absolute;
    top: 10px;
    right: 10px;
    font-size: 24px;
    cursor: pointer;
    color: #666;
}

.close-modal:hover {
    color: #000;
}

.backup-section,
.restore-section {
    margin: 20px 0;
    padding: 15px;
    border: 1px solid #ddd;
    border-radius: 5px;
}

.message {
    margin-top: 10px;
    padding: 10px;
    border-radius: 4px;
}

.message.error {
    background-color: #ffe6e6;
    color: #d33;
    border: 1px solid #ffb3b3;
}

.message.success {
    background-color: #e6ffe6;
    color: #3c763d;
    border: 1px solid #b3ffb3;
}

.btn {
    padding: 8px 16px;
    border-radius: 4px;
    cursor: pointer;
    font-weight: bold;
    border: none;
    margin-top: 10px;
}

.btn-primary {
    background-color: var(--primary-color);
    color: white;
}

.btn-warning {
    background-color: #ff9800;
    color: white;
}

.btn:hover {
    opacity: 0.9;
}
