/* General Styles & Variables */
:root {
    --primary-color: #007bff;
    --secondary-color: #6c757d;
    --success-color: #28a745;
    --danger-color: #dc3545;
    --warning-color: #ffc107;
    --info-color: #17a2b8;
    --light-color: #f8f9fa;
    --dark-color: #343a40;
    --text-color: #212529;
    --bg-color: #ffffff;
    --border-color: #dee2e6;
    --link-color: var(--primary-color);
    --font-family: 'Cairo', sans-serif; /* Example modern Arabic font */
    --border-radius: 0.25rem;
    --box-shadow: 0 0.125rem 0.25rem rgba(0, 0, 0, 0.075);
}

/* Dark Mode Variables */
[data-theme="dark"] {
    --primary-color: #4da3ff;
    --secondary-color: #868e96;
    --success-color: #5cb85c;
    --danger-color: #d9534f;
    --warning-color: #f0ad4e;
    --info-color: #5bc0de;
    --light-color: #495057; /* Darker light */
    --dark-color: #e9ecef;  /* Lighter dark */
    --text-color: #f8f9fa;
    --bg-color: #212529;
    --border-color: #495057;
    --link-color: var(--primary-color);
}

/* Basic Reset & Body */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

body {
    font-family: var(--font-family);
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    direction: rtl; /* Right-to-left */
    transition: background-color 0.3s, color 0.3s;
}

a {
    color: var(--link-color);
    text-decoration: none;
    transition: color 0.2s;
}

a:hover {
    color: color-mix(in srgb, var(--link-color) 70%, black);
}

img {
    max-width: 100%;
    height: auto;
    display: block;
}

/* Container */
.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 15px;
}

/* Buttons */
.button {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
    font-weight: 600;
    text-align: center;
    vertical-align: middle;
    cursor: pointer;
    border: 1px solid transparent;
    border-radius: var(--border-radius);
    transition: color 0.15s ease-in-out, background-color 0.15s ease-in-out, border-color 0.15s ease-in-out, box-shadow 0.15s ease-in-out;
    background-color: var(--primary-color);
    color: #fff;
}

.button:hover {
    background-color: color-mix(in srgb, var(--primary-color) 85%, black);
    color: #fff;
}

.button-secondary {
    background-color: var(--secondary-color);
    color: #fff;
}

.button-secondary:hover {
    background-color: color-mix(in srgb, var(--secondary-color) 85%, black);
}

/* Header */
.site-header {
    background-color: color-mix(in srgb, var(--bg-color) 95%, black);
    padding: 1rem 0;
    border-bottom: 1px solid var(--border-color);
    box-shadow: var(--box-shadow);
    position: sticky;
    top: 0;
    z-index: 1000;
}

.header-content {
    display: flex;
    justify-content: space-between;
    align-items: center;
}

.logo a {
    font-size: 1.5rem;
    font-weight: bold;
    color: var(--text-color);
}

.main-nav ul {
    list-style: none;
    display: flex;
}

.main-nav ul li {
    margin-right: 1.5rem; /* Use margin-right in RTL */
}

.main-nav ul li a {
    font-weight: 500;
    color: var(--text-color);
}

.main-nav ul li a:hover {
    color: var(--primary-color);
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 0.75rem;
}

.header-actions span {
    font-size: 0.9rem;
}

.theme-toggle-button {
    background: none;
    border: none;
    font-size: 1.2rem;
    cursor: pointer;
    color: var(--text-color);
    padding: 0.25rem;
}

/* Slider Section Placeholder */
.slider-section {
    margin: 2rem 0;
    background-color: var(--light-color);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    min-height: 300px; /* Example height */
    display: flex;
    align-items: center;
    justify-content: center;
    overflow: hidden; /* For actual slider */
}

.slider {
    /* Basic styling for placeholder */
    text-align: center;
    font-size: 1.5rem;
    color: var(--secondary-color);
}

/* Updates Section Placeholder */
.updates-section {
    margin-bottom: 2rem;
    padding: 1.5rem;
    background-color: color-mix(in srgb, var(--bg-color) 98%, black);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
}

.updates-section h2 {
    margin-bottom: 1rem;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 0.5rem;
    display: inline-block;
}

.updates-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(250px, 1fr)); /* Responsive grid */
    gap: 1rem;
}

.update-item {
    border: 1px solid var(--border-color);
    padding: 1rem;
    border-radius: var(--border-radius);
    background-color: var(--bg-color);
}

.update-item h3 a {
    color: var(--text-color);
}

/* Products Section */
.products-section {
    margin-bottom: 2rem;
}

.products-section h2 {
    text-align: center;
    margin-bottom: 2rem;
    font-size: 2rem;
    font-weight: bold;
}

.product-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* 3 products per row */
    gap: 1.5rem;
}

.product-card {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius);
    overflow: hidden;
    background-color: var(--bg-color);
    box-shadow: var(--box-shadow);
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    display: flex;
    flex-direction: column;
}

.product-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 0.5rem 1rem rgba(0, 0, 0, 0.15);
}

.product-image {
    height: 200px; /* Fixed height for image container */
    overflow: hidden;
    display: flex;
    align-items: center;
    justify-content: center;
    background-color: var(--light-color);
}

.product-image img {
    width: 100%;
    height: 100%;
    object-fit: cover; /* Scale image nicely */
}

.product-info {
    padding: 1rem;
    text-align: center;
    flex-grow: 1; /* Allow info to take remaining space */
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Push button to bottom */
}

.product-title {
    font-size: 1.1rem;
    font-weight: 600;
    margin-bottom: 0.5rem;
    color: var(--text-color);
}

.product-price {
    font-size: 1.2rem;
    font-weight: bold;
    color: var(--success-color);
    margin-bottom: 1rem;
}

.buy-button {
    width: 100%;
    margin-top: auto; /* Push to bottom */
}

/* Pagination */
.pagination {
    margin-top: 2rem;
    text-align: center;
}

.pagination ul {
    list-style: none;
    padding: 0;
    display: inline-flex;
    border-radius: var(--border-radius);
    overflow: hidden;
    border: 1px solid var(--border-color);
}

.pagination ul li {
    margin: 0; /* Remove default margin */
}

.pagination ul li a {
    display: block;
    padding: 0.5rem 1rem;
    color: var(--link-color);
    border-right: 1px solid var(--border-color); /* Use right border in RTL */
    transition: background-color 0.2s, color 0.2s;
}

.pagination ul li:first-child a {
    border-right: none;
}

.pagination ul li a:hover,
.pagination ul li a.active {
    background-color: var(--primary-color);
    color: #fff;
}

.pagination ul li a.active {
    cursor: default;
    pointer-events: none;
}

/* Footer */
.site-footer {
    background-color: var(--dark-color);
    color: var(--light-color);
    padding: 1.5rem 0;
    margin-top: 2rem;
    text-align: center;
    border-top: 1px solid color-mix(in srgb, var(--dark-color) 80%, white);
}

[data-theme="dark"] .site-footer {
    background-color: color-mix(in srgb, var(--bg-color) 90%, black);
    color: var(--secondary-color);
    border-top: 1px solid var(--border-color);
}

/* Responsive Adjustments */
@media (max-width: 992px) {
    .product-grid {
        grid-template-columns: repeat(2, 1fr); /* 2 columns on medium screens */
    }
    .header-content {
        flex-wrap: wrap;
    }
    .main-nav {
        order: 3; /* Move nav below logo and actions on smaller screens */
        width: 100%;
        margin-top: 1rem;
        justify-content: center;
    }
}

@media (max-width: 768px) {
    .admin-sidebar { /* Example for admin responsiveness */
        width: 100%;
        height: auto;
        position: static;
        box-shadow: none;
    }
    .admin-content {
        padding: 15px;
    }
    body {
        flex-direction: column; /* Stack admin sidebar and content */
    }
}

@media (max-width: 576px) {
    .product-grid {
        grid-template-columns: 1fr; /* 1 column on small screens */
    }
    .header-actions {
        gap: 0.5rem;
    }
    .button {
        padding: 0.4rem 0.8rem;
        font-size: 0.8rem;
    }
}

/* Admin Panel Specific Styles (Copied/Adapted from admin pages) */
.admin-sidebar {
    width: 250px;
    background-color: #343a40;
    color: #fff;
    padding: 20px;
    box-shadow: 2px 0 5px rgba(0,0,0,0.1);
    flex-shrink: 0;
}
.admin-sidebar h3 {
    margin-top: 0;
    border-bottom: 1px solid #495057;
    padding-bottom: 10px;
}
.admin-sidebar ul {
    list-style: none;
    padding: 0;
    margin: 20px 0;
}
.admin-sidebar ul li a {
    display: block;
    padding: 10px 15px;
    color: #adb5bd;
    text-decoration: none;
    border-radius: 4px;
    margin-bottom: 5px;
    transition: background-color 0.3s, color 0.3s;
}
.admin-sidebar ul li a:hover,
.admin-sidebar ul li a.active {
    background-color: #495057;
    color: #fff;
}
 .admin-sidebar .logout-link a {
    color: #dc3545; /* Red color for logout */
}
.admin-sidebar .logout-link a:hover {
    background-color: #dc3545;
    color: #fff;
}
.admin-content {
    flex-grow: 1;
    padding: 30px;
    background-color: var(--bg-color); /* Use theme variable */
}
.admin-content h1, .admin-content h2 {
    margin-top: 0;
    color: var(--text-color); /* Use theme variable */
    border-bottom: 1px solid var(--border-color); /* Use theme variable */
    padding-bottom: 15px;
    margin-bottom: 20px;
}
.form-section { background-color: color-mix(in srgb, var(--bg-color) 95%, black); padding: 20px; border: 1px solid var(--border-color); border-radius: 5px; margin-bottom: 30px; }
.form-group { margin-bottom: 15px; }
label { display: block; margin-bottom: 5px; font-weight: bold; color: var(--text-color); }
input[type="text"], input[type="email"], input[type="password"], input[type="number"], textarea, select, input[type="file"] {
    width: 100%;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    background-color: var(--bg-color);
    color: var(--text-color);
}
textarea { min-height: 100px; }
button[type="submit"] { padding: 10px 20px; background-color: var(--primary-color); color: white; border: none; border-radius: 4px; cursor: pointer; font-size: 16px; }
button[type="submit"]:hover { background-color: color-mix(in srgb, var(--primary-color) 85%, black); }
.cancel-button { background-color: var(--secondary-color); margin-right: 10px; }
.cancel-button:hover { background-color: color-mix(in srgb, var(--secondary-color) 85%, black); }
table { width: 100%; border-collapse: collapse; margin-top: 20px; background-color: var(--bg-color); }
th, td { border: 1px solid var(--border-color); padding: 8px; text-align: right; vertical-align: middle; }
th { background-color: var(--light-color); color: var(--text-color); }
.message { padding: 10px; margin-bottom: 15px; border-radius: 4px; text-align: center; }
.error { background-color: #f8d7da; color: #721c24; border: 1px solid #f5c6cb; }
.success { background-color: #d4edda; color: #155724; border: 1px solid #c3e6cb; }
td a { margin: 0 5px; color: var(--link-color); text-decoration: none; }
td a:hover { text-decoration: underline; }
td a.delete { color: var(--danger-color); }
td img.thumbnail { max-width: 50px; max-height: 50px; vertical-align: middle; margin-left: 10px; }
.current-image-display img { max-width: 100px; max-height: 100px; margin-top: 5px; display: block; }
.smtp-settings { border: 1px solid var(--border-color); padding: 15px; margin-top: 10px; border-radius: 4px; background-color: color-mix(in srgb, var(--bg-color) 95%, black); display: none; /* Hidden by default */ }
.smtp-settings legend { font-weight: bold; color: var(--text-color); }

/* Ensure admin layout remains flex in desktop */
@media (min-width: 769px) {
    body.admin-page {
        display: flex;
        flex-direction: row;
    }
}

/* Add class to body on admin pages if needed */
/* Example: <body class="admin-page"> */

