/* ------------------- */
/* CSS Variables & Reset */
/* ------------------- */
:root {
    --primary-color: #ffffff;
    --accent-color: #3CAB5A;
    --danger-color: #e74c3c;
    --secondary-color: #7f8c8d;
    --text-color: #333333;
    --text-light: #666666;
    --border-color: #eaeaea;
    --section-bg: #f9f9f9;
    --header-bg: rgba(255, 255, 255, 0.9);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    --transition-speed: 0.3s;
}

/* Dark Mode Variables */
body.dark-mode {
    --primary-color: #1a1a1a;
    --text-color: #f0f0f0;
    --text-light: #a0a0a0;
    --border-color: #333333;
    --section-bg: #242424;
    --header-bg: rgba(26, 26, 26, 0.9);
    --shadow: 0 4px 6px rgba(0, 0, 0, 0.2);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html {
    scroll-behavior: smooth;
    font-size: 16px;
}

body {
    font-family: 'Vazirmatn', 'Open Sans', sans-serif;
    color: var(--text-color);
    background-color: var(--primary-color);
    line-height: 1.8;
    transition: background-color var(--transition-speed), color var(--transition-speed);
}

h1, h2, h3, h4 {
    font-family: 'Vazirmatn', 'Poppins', sans-serif;
    font-weight: 700;
    color: var(--text-color);
}

h1 { font-size: 2.8rem; }
h2 { font-size: 2.2rem; margin-bottom: 1.5rem; }
h3 { font-size: 1.4rem; }

section {
    padding: 5rem 0;
}

.container {
    width: 90%;
    max-width: 1100px;
    margin: 0 auto;
}

/* ------------------- */
/* Header & Navigation */
/* ------------------- */
.header {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    z-index: 1000;
    padding: 1rem 0;
    background-color: var(--header-bg);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    box-shadow: var(--shadow);
    transition: background-color var(--transition-speed);
}

.navbar {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo {
    font-family: 'Poppins', sans-serif;
    font-size: 1.8rem;
    font-weight: 700;
    text-decoration: none;
    color: var(--accent-color);
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.logo-img {
    height: 30px;
    width: auto;
    display: block;
}

.nav-links {
    display: none;
    list-style: none;
}

.nav-links.active {
    display: flex;
    flex-direction: column;
    position: absolute;
    top: 100%;
    right: 0;
    left: auto;
    width: 100%;
    background-color: var(--header-bg);
    padding: 1rem 0;
}

.nav-item {
    padding: 1rem;
    text-align: center;
}

.nav-link {
    text-decoration: none;
    color: var(--text-color);
    font-weight: 600;
    transition: color var(--transition-speed);
}

.nav-link:hover {
    color: var(--accent-color);
}

.nav-link.active-page {
    color: var(--accent-color);
    font-weight: 700;
}

.nav-right {
    display: flex;
    align-items: center;
    gap: 1.5rem;
}

.theme-switcher {
    cursor: pointer;
    font-size: 1.4rem;
}

.nav-toggle {
    display: block;
    font-size: 1.5rem;
    cursor: pointer;
}

/* ------------------- */
/* Hero Section        */
/* ------------------- */
#hero {
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
    text-align: center;
    padding-top: 5rem;
    background: url('hero-bg.jpg') no-repeat center center/cover;
    position: relative;
}

.hero-content {
    position: relative;
    z-index: 2;
    max-width: 800px;
    background-color: rgba(255, 255, 255, 0.2);
    backdrop-filter: blur(10px);
    -webkit-backdrop-filter: blur(10px);
    border: 1px solid rgba(255, 255, 255, 0.3);
    border-radius: 15px;
    padding: 3rem 2rem;
    box-shadow: var(--shadow);
    color: #000;
}

body.dark-mode .hero-content {
    background-color: rgba(0, 0, 0, 0.3);
    border: 1px solid rgba(255, 255, 255, 0.1);
    color: #fff;
}

.hero-content .logo-large {
    height: 100px;
    margin-bottom: 2rem;
    display: block;
    margin-left: auto;
    margin-right: auto;
}

.hero-content h1 {
    color: inherit;
}

.hero-content .subheadline {
    font-size: 1.2rem;
    color: inherit;
    margin: 1.5rem 0 2.5rem;
    font-weight: 400;
}

.cta-button {
    display: inline-block;
    background-color: var(--accent-color);
    color: #fff;
    padding: 0.8rem 2rem;
    text-decoration: none;
    border-radius: 50px;
    font-weight: 600;
    transition: transform var(--transition-speed), background-color var(--transition-speed);
    border: none;
    cursor: pointer;
}

.cta-button:hover {
    transform: translateY(-3px);
    background-color: #33984e;
}

.cta-button.danger {
    background-color: var(--danger-color);
}
.cta-button.danger:hover {
    background-color: #c0392b;
}
.cta-button.secondary {
    background-color: var(--secondary-color);
}
.cta-button.secondary:hover {
    background-color: #6c7a7b;
}

/* ------------------- */
/* General Sections    */
/* ------------------- */
#introduction, #who-we-are, #why-us, #contact {
    background-color: var(--section-bg);
}

body.dark-mode #introduction, body.dark-mode #who-we-are, body.dark-mode #why-us, body.dark-mode #contact {
    background-color: var(--section-bg);
}

.text-center {
    text-align: center;
}

.section-title {
    text-align: center;
    margin-bottom: 3rem;
}

.section-title::after {
    content: '';
    display: block;
    width: 60px;
    height: 4px;
    background: var(--accent-color);
    margin: 0.5rem auto 0;
    border-radius: 2px;
}

/* ------------------- */
/* Who We Are Section  */
/* ------------------- */
.who-we-are-layout {
    display: grid;
    grid-template-columns: 1fr;
    gap: 3rem;
    align-items: center;
}

.who-we-are-layout img {
    width: 100%;
    height: auto;
    border-radius: 10px;
    box-shadow: var(--shadow);
}

/* ------------------- */
/* Why Us Section      */
/* ------------------- */
.why-us-grid {
    display: grid;
    grid-template-columns: 1fr;
    gap: 2rem;
}

.why-us-card {
    background-color: var(--primary-color);
    padding: 2rem;
    text-align: center;
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
}

.why-us-card .icon {
    font-size: 2.5rem;
    color: var(--accent-color);
    margin-bottom: 1rem;
}

/* ------------------- */
/* Contact Section     */
/* ------------------- */
.contact-form {
    max-width: 600px;
    margin: 0 auto;
    text-align: right;
}

.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem;
    border-radius: 5px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: var(--text-color);
    font-family: 'Vazirmatn', 'Open Sans', sans-serif;
    font-size: 1rem;
    direction: rtl;
}
.form-group input[type="file"] {
    padding: 0.5rem;
    direction: ltr;
}

.form-group textarea {
    resize: vertical;
    min-height: 150px;
}

.contact-social {
    text-align: center;
    margin-top: 3rem;
}

.contact-social p {
    margin-bottom: 1rem;
}

/* ------------------- */
/* Footer              */
/* ------------------- */
.footer {
    padding: 2rem 0;
    text-align: center;
    background-color: var(--primary-color);
    border-top: 1px solid var(--border-color);
}

.footer-socials a {
    color: var(--text-light);
    font-size: 1.5rem;
    margin: 0 0.7rem;
    transition: color var(--transition-speed);
}

.footer-socials a:hover {
    color: var(--accent-color);
}

.footer p {
    margin-top: 1rem;
    font-size: 0.9rem;
    color: var(--text-light);
}

/* ------------------- */
/* Utility Classes     */
/* ------------------- */
.back-to-top {
    position: fixed;
    bottom: 2rem;
    left: 2rem;
    right: auto;
    background-color: var(--accent-color);
    color: #fff;
    width: 50px;
    height: 50px;
    border-radius: 50%;
    display: flex;
    justify-content: center;
    align-items: center;
    font-size: 1.5rem;
    text-decoration: none;
    opacity: 0;
    pointer-events: none;
    transition: opacity var(--transition-speed), transform var(--transition-speed);
    z-index: 999;
}

.back-to-top.visible {
    opacity: 1;
    pointer-events: auto;
}

.back-to-top:hover {
    transform: translateY(-5px);
}

.reveal {
    opacity: 0;
    transform: translateY(30px);
    transition: opacity 0.8s ease-out, transform 0.8s ease-out;
}

.reveal.active {
    opacity: 1;
    transform: translateY(0);
}

.hidden {
    display: none;
}
.error-message {
    color: var(--danger-color);
    margin-top: 1rem;
    text-align: center;
}
.success-message {
    color: var(--accent-color);
    margin-top: 1rem;
    text-align: center;
}

/* ------------------- */
/* STYLES FOR PRODUCTS PAGE */
/* ------------------- */
.products-page-main {
    padding-top: 8rem;
    padding-bottom: 5rem;
    background-color: var(--primary-color);
    min-height: 100vh;
}

.product-toolbar {
    display: flex;
    flex-wrap: wrap;
    justify-content: space-between;
    align-items: center;
    gap: 1.5rem;
    padding: 1.5rem;
    background-color: var(--section-bg);
    border-radius: 10px;
    margin-bottom: 2.5rem;
    box-shadow: var(--shadow);
}

.search-container {
    position: relative;
    flex-grow: 1;
    min-width: 250px;
}

#search-bar {
    width: 100%;
    padding: 0.8rem 1rem 0.8rem 3rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: var(--text-color);
    font-family: 'Vazirmatn', 'Open Sans', sans-serif;
    font-size: 1rem;
    transition: all var(--transition-speed);
}
#search-bar:focus {
    outline: none;
    border-color: var(--accent-color);
    box-shadow: 0 0 0 2px rgba(60, 171, 90, 0.3);
}

.search-container .fa-search {
    position: absolute;
    top: 50%;
    right: 1.2rem;
    transform: translateY(-50%);
    color: var(--text-light);
    font-size: 0.9rem;
}

#category-filter {
    padding: 0.8rem 1rem;
    border-radius: 50px;
    border: 1px solid var(--border-color);
    background-color: var(--primary-color);
    color: var(--text-color);
    font-family: 'Vazirmatn', 'Open Sans', sans-serif;
    font-size: 1rem;
    cursor: pointer;
    min-width: 180px;
}
#category-filter:focus {
    outline: none;
    border-color: var(--accent-color);
}

.view-toggle button {
    background-color: var(--primary-color);
    border: 1px solid var(--border-color);
    color: var(--text-light);
    font-size: 1.2rem;
    padding: 0.6rem 0.9rem;
    cursor: pointer;
    transition: all var(--transition-speed);
}

.view-toggle button:first-of-type {
    border-top-right-radius: 8px;
    border-bottom-right-radius: 8px;
    border-left: none;
}

.view-toggle button:last-of-type {
    border-top-left-radius: 8px;
    border-bottom-left-radius: 8px;
}

.view-toggle button.active {
    background-color: var(--accent-color);
    color: #fff;
    border-color: var(--accent-color);
}
.view-toggle button:not(.active):hover {
    background-color: var(--section-bg);
    color: var(--text-color);
}

#product-list {
    display: grid;
    gap: 1.5rem;
    transition: grid-template-columns 0.3s ease;
}

#product-list.grid-view {
    grid-template-columns: repeat(auto-fill, minmax(280px, 1fr));
}

#product-list.list-view {
    grid-template-columns: 1fr;
}

.product-card {
    background-color: var(--primary-color);
    border-radius: 10px;
    box-shadow: var(--shadow);
    border: 1px solid var(--border-color);
    overflow: hidden;
    transition: all 0.3s ease;
    display: flex;
    flex-direction: column;
}

.product-card.hide {
    display: none;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.1);
}

body.dark-mode .product-card:hover {
    box-shadow: 0 8px 15px rgba(0, 0, 0, 0.3);
}

.product-card img {
    width: 100%;
    height: 250px;
    object-fit: cover;
    transition: transform 0.3s ease;
}

.product-card:hover img {
    transform: scale(1.05);
}

.product-info {
    padding: 1.5rem;
    flex-grow: 1;
    display: flex;
    flex-direction: column;
}

.product-info h3 {
    font-size: 1.5rem;
    margin-bottom: 0.5rem;
}

.product-category {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-bottom: 1rem;
    font-weight: 600;
}

.product-info p {
    font-size: 1rem;
    color: var(--text-light);
    flex-grow: 1;
    margin-bottom: 1.5rem;
}

#product-list.list-view .product-card {
    flex-direction: row;
    align-items: center;
}

#product-list.list-view .product-card img {
    width: 200px;
    height: 100%;
    min-height: 200px;
    max-height: 250px;
}

#product-list.list-view .product-card:hover img {
    transform: none;
}

/* ------------------- */
/* STYLES FOR ADMIN PAGE */
/* ------------------- */
.admin-page-main {
    padding-top: 8rem;
    padding-bottom: 5rem;
    min-height: 100vh;
}

.admin-form-container {
    max-width: 700px;
    margin: 0 auto 2.5rem auto;
    padding: 2.5rem;
    background-color: var(--section-bg);
    border-radius: 10px;
    box-shadow: var(--shadow);
}
.admin-form-container h2 {
    text-align: center;
    margin-bottom: 2rem;
}

.dashboard-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 2rem;
}

.form-note {
    font-size: 0.9rem;
    color: var(--text-light);
    margin-top: 0.5rem;
}
#image-preview {
    max-width: 150px;
    height: auto;
    margin-top: 1rem;
    border-radius: 5px;
    border: 1px solid var(--border-color);
}

#cancel-edit-button {
    margin-right: 0.5rem;
}

.admin-product-list table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1rem;
    background-color: var(--primary-color);
    box-shadow: var(--shadow);
    border-radius: 10px;
    overflow: hidden;
}
.admin-product-list th,
.admin-product-list td {
    padding: 1rem;
    border-bottom: 1px solid var(--border-color);
    text-align: right;
    vertical-align: middle;
}
.admin-product-list th {
    background-color: var(--section-bg);
}
.table-img {
    width: 60px;
    height: 60px;
    object-fit: cover;
    border-radius: 5px;
}
.admin-actions {
    text-align: left;
    white-space: nowrap;
}
.admin-btn {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    padding: 0.5rem;
    margin: 0 0.25rem;
    border-radius: 5px;
    transition: all var(--transition-speed);
}
.admin-btn.edit {
    color: var(--accent-color);
}
.admin-btn.edit:hover {
    background-color: rgba(60, 171, 90, 0.1);
}
.admin-btn.delete {
    color: var(--danger-color);
}
.admin-btn.delete:hover {
    background-color: rgba(231, 76, 60, 0.1);
}

/* ------------------- */
/* Media Queries       */
/* ------------------- */
@media (min-width: 768px) {
    h1 { font-size: 3.5rem; }
    h2 { font-size: 2.5rem; }
    .nav-links {
        display: flex;
        flex-direction: row;
        gap: 2rem;
    }
    .nav-toggle { display: none; }
    .nav-links.active {
        position: static;
        flex-direction: row;
        width: auto;
        background-color: transparent;
        padding: 0;
    }
    .who-we-are-layout { grid-template-columns: 1fr 1fr; }
    .why-us-grid { grid-template-columns: 1fr 1fr; }
    #product-list.list-view .product-card img {
        height: 200px;
    }
}

@media (min-width: 1024px) {
    h1 { font-size: 4rem; }
    .why-us-grid { grid-template-columns: repeat(4, 1fr); }
}

@media (max-width: 768px) {
    .product-toolbar {
        flex-direction: column;
        align-items: stretch;
    }
    #product-list.list-view .product-card {
        flex-direction: column;
    }
    #product-list.list-view .product-card img {
        width: 100%;
        height: 250px;
    }
}

@media (max-width: 480px) {
    .view-toggle {
        display: flex;
        justify-content: center;
    }
    .view-toggle button {
        flex-grow: 1;
    }
}
/* ... all your existing styles ... */

/* --- NEW STYLES for Admin Panel Checkboxes --- */
.category-checkbox-container {
    max-height: 200px; /* Make it scrollable */
    overflow-y: auto;
    border: 1px solid var(--border-color);
    border-radius: 5px;
    padding: 0.75rem;
    background-color: var(--primary-color);
}
.category-checkbox-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.5rem 0.25rem;
    direction: rtl; /* Ensure item itself is RTL */
    text-align: right;
}
.category-checkbox-item input[type="checkbox"] {
    width: 18px;
    height: 18px;
    flex-shrink: 0;
}
.category-checkbox-item label {
    font-weight: 400;
    font-size: 1rem;
    color: var(--text-color);
    margin-bottom: 0; /* Override default form-group label margin */
}

/* --- NEW STYLES for Product Card Categories (Products Page) --- */
.product-categories-container {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
    justify-content: center; /* Center in grid view */
}
.product-grid.view-list .product-categories-container {
    justify-content: flex-start; /* Align left in list view (RTL: right) */
}
.product-category {
    font-size: 0.8rem;
    font-weight: 600;
    padding: 0.2rem 0.6rem;
    border-radius: 10px;
    background-color: var(--accent-color);
    color: #fff;
    display: inline-block;
}
/* Dark mode for category tag */
body.dark-mode .product-category {
    background-color: var(--accent-color);
    color: #fff;
}
/* Fallback for old single category span (if it's still used) */
.product-info > .product-category {
     margin-bottom: 0.5rem;
}

/* --- NEW STYLES for Admin Product List Categories --- */
.product-list-categories {
    display: flex;
    flex-wrap: wrap;
    gap: 0.4rem;
    margin-top: 0.5rem;
}
.product-category-tag {
    font-size: 0.75rem;
    padding: 0.2rem 0.5rem;
    border-radius: 5px;
    background-color: var(--section-bg);
    color: var(--text-light);
}
