@import url('https://fonts.googleapis.com/css2?family=Cairo:wght@300;400;500;600;700;800;900&display=swap' );

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

:root {
    --primary-color: #1e40af;
    --primary-dark: #0369a1;
    --primary-light: #3b82f6;
    --white: #ffffff;
    --gray-light: #f5f5f5;
    --gray-dark: #333333;
    --border-color: #e0e0e0;
}

html {
    scroll-behavior: smooth;
    direction: rtl;
}

body {
    font-family: 'Cairo', sans-serif;
    background-color: var(--gray-light);
    color: var(--gray-dark);
}

/* ============ الرأس ============ */
.header {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 0.5rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    will-change: padding;
    transition: none;
}

.header.scrolled {
    padding: 0.3rem 1rem !important;
    transition: none;
}

.header-top {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 0.5rem;
}

.header-left {
    display: flex;
    gap: 1rem;
    align-items: center;
}

.menu-btn {
    background: none;
    border: none;
    color: var(--white);
    font-size: 1.5rem;
    cursor: pointer;
}

.language {
    font-size: 0.9rem;
    display: none;
}

.logo-container {
    flex: 1;
    text-align: center;
}

.logo {
    height: 35px;
    width: auto;
    margin-left: 0.5rem;
}

.logo-text {
    font-size: 1.5rem;
    font-weight: 700;
    letter-spacing: 0.5px;
}

/* ============ البحث ============ */
.search-container {
    display: flex;
    justify-content: center;
    margin-top: 0.5rem;
}

.search-form {
    display: flex;
    width: 100%;
    max-width: 500px;
    gap: 0.5rem;
}

.search-input {
    flex: 1;
    padding: 0.5rem 0.75rem;
    border: 2px solid var(--white);
    border-radius: 8px;
    font-family: 'Cairo', sans-serif;
    font-size: 0.9rem;
    background: var(--white);
    color: var(--gray-dark);
}

.search-input::placeholder {
    color: #999;
}

.search-input:focus {
    outline: none;
    box-shadow: 0 0 0 3px rgba(255, 255, 255, 0.3);
}

.search-btn {
    background: var(--white);
    border: none;
    padding: 0.5rem 1rem;
    border-radius: 8px;
    cursor: pointer;
    font-size: 0.9rem;
    color: var(--primary-color);
    font-weight: 600;
    transition: all 0.3s;
}

.search-btn:hover {
    background: var(--gray-light);
    transform: scale(1.05);
}

/* ============ الأقسام ============ */
.categories-header {
    background: var(--white);
    padding: 2rem 1rem;
    margin-bottom: 2rem;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
}

.categories-scroll {
    display: flex;
    justify-content: center;
    gap: 2rem;
    overflow-x: auto;
    padding: 0 1rem;
    flex-wrap: wrap;
}

.category-btn {
    display: flex;
    flex-direction: column;
    align-items: center;
    gap: 0.75rem;
    text-decoration: none;
    color: var(--gray-dark);
    transition: all 0.3s;
    cursor: pointer;
}

.category-btn:hover {
    transform: translateY(-5px);
}

.category-circle {
    width: 80px;
    height: 80px;
    border-radius: 50%;
    overflow: hidden;
    border: 3px solid var(--primary-color);
    display: flex;
    align-items: center;
    justify-content: center;
    background: var(--gray-light);
    box-shadow: 0 4px 12px rgba(30, 64, 175, 0.2);
    transition: all 0.3s;
}

.category-circle img {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

.category-icon {
    font-size: 2.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    width: 100%;
    height: 100%;
}

.category-btn:hover .category-circle {
    box-shadow: 0 6px 16px rgba(30, 64, 175, 0.4);
    border-color: var(--primary-light);
}

.category-btn span {
    font-weight: 600;
    font-size: 0.95rem;
    text-align: center;
    max-width: 100px;
}

/* ============ المحتوى الرئيسي ============ */
.main-content {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 1rem;
}

/* ============ قسم الأقسام ============ */
.category-section {
    margin-bottom: 3rem;
}

.category-header {
    display: flex;
    align-items: center;
    margin-bottom: 2rem;
    padding-bottom: 1rem;
    border-bottom: 3px solid var(--primary-color);
}

.category-header h2 {
    font-size: 1.8rem;
    color: var(--primary-color);
    font-weight: 700;
}

/* ============ شبكة المنتجات ============ */
.products-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
}

.product-card {
    background: var(--white);
    border-radius: 12px;
    overflow: hidden;
    cursor: pointer;
    transition: all 0.3s;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.1);
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-8px);
    box-shadow: 0 8px 24px rgba(30, 64, 175, 0.2);
}

.product-image {
    width: 100%;
    height: 200px;
    overflow: hidden;
    background: var(--gray-light);
    display: flex;
    align-items: center;
    justify-content: center;
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover;
    transition: transform 0.3s;
}

.product-card:hover .product-image img {
    transform: scale(1.1);
}

.placeholder {
    font-size: 3rem;
    color: #ccc;
}

.product-info {
    padding: 1.5rem;
    flex: 1;
    display: flex;
    flex-direction: column;
}

.product-info h3 {
    font-size: 1.1rem;
    margin-bottom: 0.5rem;
    color: var(--gray-dark);
    font-weight: 600;
}

.product-info .description {
    font-size: 0.85rem;
    color: #666;
    margin-bottom: 1rem;
    flex: 1;
    line-height: 1.4;
}

.product-info .price {
    font-size: 1.3rem;
    font-weight: 700;
    color: var(--primary-color);
    margin-top: auto;
}

/* ============ النافذة المنبثقة ============ */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    z-index: 1000;
    animation: fadeIn 0.3s;
}

.modal.active {
    display: flex;
    align-items: center;
    justify-content: center;
}

@keyframes fadeIn {
    from {
        opacity: 0;
    }
    to {
        opacity: 1;
    }
}

.modal-overlay {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    cursor: pointer;
}

.modal-content {
    background: var(--white);
    border-radius: 16px;
    padding: 2rem;
    max-width: 600px;
    width: 90%;
    position: relative;
    z-index: 1001;
    max-height: 90vh;
    overflow-y: auto;
    animation: slideUp 0.3s;
}

@keyframes slideUp {
    from {
        transform: translateY(50px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

.modal-close {
    position: absolute;
    top: 1rem;
    right: 1rem;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    width: 40px;
    height: 40px;
    border-radius: 50%;
    font-size: 1.5rem;
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
}

.modal-close:hover {
    background: var(--primary-dark);
    transform: rotate(90deg);
}

.modal-image {
    width: 100%;
    height: auto;
    background: var(--gray-light);
    border-radius: 12px;
    overflow: hidden;
    margin-bottom: 1.5rem;
    display: flex;
    align-items: center;
    justify-content: center;
    max-height: 70vh;
}

.modal-image img {
    width: 100%;
    height: auto;
    object-fit: contain;
}

.modal-title {
    font-size: 1.8rem;
    color: var(--primary-color);
    margin-bottom: 1rem;
    font-weight: 700;
}

.modal-description {
    font-size: 1rem;
    color: #666;
    line-height: 1.6;
    margin-bottom: 1.5rem;
}

.modal-price {
    font-size: 1.8rem;
    font-weight: 700;
    color: var(--primary-color);
    text-align: center;
    padding: 1rem;
    background: var(--gray-light);
    border-radius: 8px;
}

/* ============ نتائج البحث ============ */
.search-results-section {
    background: var(--white);
    padding: 2rem;
    border-radius: 12px;
    margin-bottom: 2rem;
}

.search-results-section h2 {
    color: var(--primary-color);
    margin-bottom: 2rem;
    font-size: 1.5rem;
}

/* ============ الرسائل ============ */
.empty-message {
    text-align: center;
    padding: 3rem;
    color: #999;
}

.empty-message h3 {
    font-size: 1.5rem;
    margin-bottom: 1rem;
}

/* ============ Responsive ============ */
@media (max-width: 768px) {
    .header-top {
        flex-direction: column;
        gap: 1rem;
    }

    .search-form {
        max-width: 100%;
    }

    .categories-scroll {
        gap: 1rem;
    }

    .category-circle {
        width: 70px;
        height: 70px;
    }

    .category-btn span {
        font-size: 0.85rem;
        max-width: 80px;
    }

    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(200px, 1fr));
        gap: 1rem;
    }

    .product-image {
        height: 150px;
    }

    .category-header h2 {
        font-size: 1.4rem;
    }

    .modal-content {
        max-width: 95vw;
        width: 95vw;
        padding: 1.5rem 1rem;
        max-height: 95vh;
    }

    .modal-image {
        max-height: none;
        margin-bottom: 1rem;
    }

    .modal-title {
        font-size: 1.4rem;
    }

    .modal-price {
        font-size: 1.4rem;
    }
}

@media (max-width: 480px) {
    .products-grid {
        grid-template-columns: repeat(auto-fill, minmax(150px, 1fr));
        gap: 0.75rem;
    }

    .product-image {
        height: 120px;
    }

    .product-info {
        padding: 1rem;
    }

    .product-info h3 {
        font-size: 0.95rem;
    }

    .product-info .description {
        font-size: 0.8rem;
    }

    .product-info .price {
        font-size: 1.1rem;
    }

    .category-header h2 {
        font-size: 1.2rem;
    }

    .modal-content {
        max-width: 98vw;
        width: 98vw;
        padding: 1rem;
        max-height: 98vh;
    }

    .modal-image {
        max-height: none;
        margin-bottom: 0.75rem;
    }

    .modal-title {
        font-size: 1.2rem;
    }

    .modal-price {
        font-size: 1.2rem;
    }
}

/* ============ Footer ============ */
.footer {
    background: linear-gradient(135deg, var(--primary-color) 0%, var(--primary-dark) 100%);
    color: var(--white);
    padding: 3rem 1rem 1rem;
    margin-top: 3rem;
    border-top: 3px solid var(--primary-light);
}

.footer-content {
    max-width: 1200px;
    margin: 0 auto;
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr));
    gap: 2rem;
    margin-bottom: 2rem;
    text-align: center;
}

.footer-logo {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    gap: 1rem;
}

.footer-logo-img {
    height: 80px;
    width: auto;
    filter: drop-shadow(0 2px 8px rgba(0, 0, 0, 0.2));
}

.footer-logo h3 {
    font-size: 1.5rem;
    font-weight: 700;
    margin: 0;
    letter-spacing: 0.5px;
}

.footer-section {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.footer-section h4 {
    font-size: 1.1rem;
    font-weight: 600;
    margin: 0;
    border-bottom: 2px solid var(--white);
    padding-bottom: 0.5rem;
}

.branches {
    display: flex;
    flex-direction: column;
    gap: 0.75rem;
}

.branch a {
    color: var(--white);
    text-decoration: none;
    font-size: 0.95rem;
    padding: 0.5rem;
    border-radius: 6px;
    transition: all 0.3s;
    display: inline-block;
}

.branch a:hover {
    background-color: rgba(255, 255, 255, 0.2);
    transform: translateX(-5px);
}

.social-links {
    display: flex;
    justify-content: center;
    gap: 1rem;
}

.social-icon {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 45px;
    height: 45px;
    background-color: rgba(255, 255, 255, 0.2);
    border-radius: 50%;
    color: var(--white);
    text-decoration: none;
    font-size: 1.2rem;
    font-weight: 700;
    transition: all 0.3s;
    border: 2px solid transparent;
}

.social-icon:hover {
    background-color: var(--white);
    color: var(--primary-color);
    transform: scale(1.1) translateY(-3px);
    border-color: var(--primary-color);
}

.social-icon.facebook {
    font-family: Arial, sans-serif;
}

.footer-bottom {
    text-align: center;
    padding-top: 1.5rem;
    border-top: 1px solid rgba(255, 255, 255, 0.3);
    font-size: 0.9rem;
}

.footer-bottom p {
    margin: 0;
    opacity: 0.9;
}

/* Responsive Footer */
@media (max-width: 768px) {
    .footer {
        padding: 2rem 1rem 1rem;
    }

    .footer-content {
        grid-template-columns: 1fr;
        gap: 1.5rem;
    }

    .footer-logo-img {
        height: 60px;
    }

    .footer-logo h3 {
        font-size: 1.2rem;
    }

    .social-links {
        gap: 0.75rem;
    }

    .social-icon {
        width: 40px;
        height: 40px;
        font-size: 1rem;
    }
}

/* ============ Sticky Header ============ */
.sticky-header {
    position: sticky;
    top: 0;
    background: var(--white);
    border-bottom: 2px solid var(--primary-color);
    z-index: 100;
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.1);
    display: none;
}

.sticky-header.active {
    display: block;
}

.sticky-categories {
    display: flex;
    overflow-x: auto;
    padding: 0.75rem 1rem;
    gap: 0.5rem;
}

.sticky-category-link {
    padding: 0.5rem 1rem;
    background: var(--primary-light);
    color: var(--white);
    border-radius: 20px;
    text-decoration: none;
    font-size: 0.85rem;
    white-space: nowrap;
    transition: all 0.3s;
    font-weight: 600;
}

.sticky-category-link:hover {
    background: var(--primary-color);
    transform: scale(1.05);
}

/* ============ Product Card Improvements ============ */
.product-card {
    display: flex;
    flex-direction: column;
    height: 100%;
}

.product-image {
    flex-shrink: 0;
}

.product-info {
    flex-grow: 1;
    display: flex;
    flex-direction: column;
    justify-content: space-between;
}

.product-info h3 {
    font-size: 0.95rem;
    line-height: 1.3;
}

.product-info .description {
    margin: 0.3rem 0;
    font-size: 0.85rem;
    color: #666;
    line-height: 1.2;
    display: -webkit-box;
    -webkit-line-clamp: 2;
    -webkit-box-orient: vertical;
    overflow: hidden;
}

/* ============ Category Image ============ */
.category-circle .category-image {
    width: 100%;
    height: 100%;
    object-fit: cover;
}

/* ============ Edit Button ============ */
.edit-btn {
    position: absolute;
    top: 10px;
    right: 10px;
    background: var(--primary-color);
    color: var(--white);
    border: none;
    border-radius: 50%;
    width: 35px;
    height: 35px;
    cursor: pointer;
    font-size: 1.2rem;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all 0.3s;
    opacity: 0;
}

.product-card:hover .edit-btn {
    opacity: 1;
}

.edit-btn:hover {
    background: var(--primary-dark);
    transform: scale(1.1);
}

/* ============ Admin Panel Improvements ============ */
.admin-categories-table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 1.5rem;
}

.admin-categories-table th,
.admin-categories-table td {
    padding: 1rem;
    text-align: right;
    border-bottom: 1px solid #ddd;
}

.admin-categories-table th {
    background: var(--primary-color);
    color: var(--white);
    font-weight: 600;
}

.admin-categories-table tr:hover {
    background: #f9f9f9;
}

.admin-action-btn {
    padding: 0.5rem 1rem;
    margin: 0 0.25rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 0.9rem;
    transition: all 0.3s;
}

.admin-edit-btn {
    background: var(--primary-light);
    color: var(--white);
}

.admin-edit-btn:hover {
    background: var(--primary-color);
}

.admin-delete-btn {
    background: #ff6b6b;
    color: var(--white);
}

.admin-delete-btn:hover {
    background: #ff5252;
}

.admin-form-group {
    margin-bottom: 1.5rem;
}

.admin-form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--primary-color);
}

.admin-form-group input,
.admin-form-group textarea,
.admin-form-group select {
    width: 100%;
    padding: 0.75rem;
    border: 1px solid #ddd;
    border-radius: 4px;
    font-family: Cairo, sans-serif;
    font-size: 1rem;
}

.admin-form-group textarea {
    resize: vertical;
    min-height: 100px;
}

.admin-form-group input:focus,
.admin-form-group textarea:focus,
.admin-form-group select:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(0, 102, 204, 0.1);
}

.admin-submit-btn {
    background: var(--primary-color);
    color: var(--white);
    padding: 0.75rem 2rem;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1rem;
    font-weight: 600;
    transition: all 0.3s;
}

.admin-submit-btn:hover {
    background: var(--primary-dark);
    transform: translateY(-2px);
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
}
