:root {
    --bg-color: #fcf9f2; --text-main: #4a3f35; --text-muted: #8b7d6b;
    --primary: #e07a5f; --primary-hover: #d0654c; --secondary: #81b29a;
    --accent: #f2cc8f; --card-bg: #ffffff;
    --shadow-soft: 0 8px 30px rgba(74, 63, 53, 0.08);
    --shadow-hover: 0 12px 40px rgba(74, 63, 53, 0.12);
    --radius-lg: 24px; --radius-sm: 12px;
    --font-family: 'Baloo Bhaijaan 2', system-ui, sans-serif;
    --transition: all 0.3s cubic-bezier(0.25, 0.8, 0.25, 1);
}

/* Loader Styles */
.loader-wrapper {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: #ffffff; display: flex; justify-content: center; align-items: center;
    z-index: 10000; transition: opacity 0.6s ease, visibility 0.6s;
}
.loader-wrapper.fade-out { opacity: 0; visibility: hidden; }
.loader-content { text-align: center; }
.loader-spinner {
    width: 60px; height: 60px; border: 4px solid #f3f3f3;
    border-top: 4px solid #000; border-radius: 50%;
    animation: spin 1s cubic-bezier(0.68, -0.55, 0.27, 1.55) infinite;
    margin: 0 auto 15px;
}
.loader-text { font-size: 1.8rem; font-weight: 800; color: #000; letter-spacing: 1px; animation: pulse 1.5s infinite; }

@keyframes spin { 0% { transform: rotate(0deg); } 100% { transform: rotate(360deg); } }
@keyframes pulse { 0%, 100% { opacity: 1; transform: scale(1); } 50% { opacity: 0.6; transform: scale(0.95); } }

* { box-sizing: border-box; margin: 0; padding: 0; }
body {
    font-family: 'Baloo Bhaijaan 2', cursive;
    background-image: url('bg.jpg');
    background-size: 70%; /* تصغير الصورة لتبدو أبعد */
    background-position: center top;
    background-attachment: fixed;
    background-repeat: repeat; /* تكرار الصورة حتى لا تترك مساحة فارغة إذا كانت صغيرة */
    background-color: var(--bg-color);
    color: var(--text-main);
    min-height: 100vh;
    line-height: 1.6; direction: rtl; -webkit-font-smoothing: antialiased;
}

body.dashboard-active {
    background-image: none !important;
    background-color: #f8f9fa !important;
}

.container { max-width: 1200px; margin: 0 auto; padding: 0 24px; }

/* Header & Auth Actions */
.app-header { padding: 40px 0; margin-bottom: 20px; background: transparent; }
.header-content { display: flex; justify-content: center; align-items: center; position: relative; min-height: 80px; }
.header-titles { text-align: center; }
.app-title { font-size: 2.8rem; color: #000; margin-bottom: 0; cursor: pointer; transition: 0.2s; font-weight: 800; line-height: 1.1; }
.app-title:hover { opacity: 0.7; transform: scale(1.02); }
.app-subtitle { color: #555; font-size: 1.1rem; font-weight: 600; margin-top: 5px; }

#auth-buttons { position: absolute; right: 24px; top: 50%; transform: translateY(-50%); }

.header-auth-group { display: flex; align-items: center; gap: 12px; }
.header-login-btn { background: var(--primary); color: white; border: none; padding: 10px 24px; border-radius: 50px; font-size: 1.05rem; font-weight: 700; cursor: pointer; display: flex; align-items: center; gap: 8px; box-shadow: 0 4px 12px rgba(224, 122, 95, 0.2); transition: var(--transition); font-family: inherit; }
.header-login-btn:hover { background: var(--primary-hover); transform: translateY(-2px); box-shadow: 0 6px 16px rgba(224, 122, 95, 0.3); }
.user-badge { background: white; padding: 8px 16px; border-radius: 50px; font-weight: 600; color: var(--text-main); display: flex; align-items: center; gap: 8px; border: 1px solid #eee; box-shadow: 0 2px 8px rgba(0,0,0,0.02); font-size: 0.95rem; }
.header-icon-btn { background: white; border: 1px solid #eee; padding: 10px; border-radius: 50%; color: var(--text-muted); cursor: pointer; transition: 0.2s; display: flex; align-items: center; justify-content: center; box-shadow: 0 2px 8px rgba(0,0,0,0.02); }
.header-icon-btn:hover { background: #fdfdfd; color: var(--primary); border-color: var(--primary); transform: scale(1.1); }
#auth-buttons { position: absolute; right: 24px; top: 40px; display: flex; gap: 10px; z-index: 100; }

/* Grid */
.products-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(200px, 1fr)); gap: 24px; padding: 20px 0 80px; }
.related-grid { grid-template-columns: repeat(auto-fill, minmax(180px, 1fr)); padding: 20px 0; }

.product-card {
    background: var(--card-bg); border-radius: var(--radius-lg);
    box-shadow: var(--shadow-soft); overflow: hidden; transition: var(--transition);
    cursor: pointer; display: flex; flex-direction: column;
}
.product-card:hover { transform: translateY(-6px); box-shadow: var(--shadow-hover); }

.product-image-wrapper { width: 100%; aspect-ratio: 1; background: var(--accent); overflow: hidden; }
.product-image-wrapper img { width: 100%; height: 100%; object-fit: cover; transition: 0.5s ease; }
.product-card:hover .product-image-wrapper img { transform: scale(1.05); }

.product-content { padding: 20px; display: flex; flex-direction: column; gap: 8px; }
.product-title { font-size: 1.4rem; font-weight: 700; color: var(--text-main); }
.product-price { font-weight: 700; color: var(--secondary); font-size: 1.1rem; }

/* Full Product Page */
.back-btn { display: inline-flex; align-items: center; gap: 8px; background: none; border: none; font-size: 1.1rem; color: var(--text-muted); cursor: pointer; font-family: inherit; margin-bottom: 24px; padding: 10px; border-radius: 8px; transition: var(--transition); }
.back-btn:hover { color: var(--primary); background: rgba(0,0,0,0.05); }
.full-product { display: grid; grid-template-columns: 1fr 1fr; gap: 40px; background: var(--card-bg); border-radius: var(--radius-lg); box-shadow: var(--shadow-soft); overflow: hidden; margin-bottom: 60px; }
.full-image-container { width: 100%; height: 100%; min-height: 500px; background: var(--accent); }
.full-image { width: 100%; height: 100%; object-fit: cover; }
.full-details { padding: 40px; display: flex; flex-direction: column; gap: 24px; }
.full-title { font-size: 2.5rem; color: var(--primary); line-height: 1.2; }
.full-price { font-size: 1.8rem; color: var(--secondary); font-weight: 700; }
.full-desc { font-size: 1.2rem; color: var(--text-muted); line-height: 1.8; }
.stats-row { display: flex; gap: 16px; align-items: center; }
.stat-badge { display: flex; align-items: center; gap: 6px; background: #f4f3ec; padding: 8px 16px; border-radius: 20px; font-weight: 600; }
.star-icon { color: #ddd; cursor: pointer; transition: 0.2s; font-size: 1.2rem; }
.star-icon:hover, .star-icon.active { color: var(--accent); }
.full-actions { display: flex; gap: 16px; margin-top: auto; }
.action-btn-main { padding: 12px 24px; border-radius: 50px; font-weight: 700; font-size: 1.1rem; border: none; cursor: pointer; transition: 0.3s; flex: 1; display: flex; justify-content: center; align-items: center; gap: 10px; font-family: inherit; }
.btn-like { background: #fce4ec; color: #d81b60; border: 1px solid #f8bbd0; }
.btn-like:hover { background: #f8bbd0; color: #c2185b; border-color: #f48fb1; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(216, 27, 96, 0.2); }
.btn-like.active { background: #d81b60; color: white; border-color: #d81b60; }
.btn-like.active:hover { background: #ad1457; border-color: #ad1457; }
.btn-save { background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; }
.btn-save:hover { background: #bbdefb; color: #0d47a1; border-color: #90caf9; transform: translateY(-2px); box-shadow: 0 4px 15px rgba(21, 101, 192, 0.2); }
.related-title { font-size: 1.8rem; margin-bottom: 20px; color: var(--text-main); }

@media (max-width: 900px) {
    .full-product { grid-template-columns: 1fr; }
    .full-image-container { min-height: 300px; }
    .full-details { padding: 24px; }
    .full-actions { flex-direction: column; }
}

/* Comments Section */
.comments-section { background: var(--card-bg); border-radius: var(--radius-lg); padding: 40px; box-shadow: var(--shadow-soft); margin-bottom: 60px; border: 1px solid rgba(0,0,0,0.03); }
.comments-list { display: flex; flex-direction: column; gap: 15px; }
.comment-item { background: #fafafa; padding: 20px; border-radius: 16px; border: 1px solid #eee; transition: 0.2s; }
.comment-item:hover { background: #fffcfb; border-color: #f2cc8f; }
.comment-header { display: flex; justify-content: space-between; margin-bottom: 12px; font-size: 0.95rem; color: var(--text-muted); }
.comment-user { font-weight: 700; color: #555; font-size: 1.1rem; display: flex; align-items: center; gap: 8px; }
.admin-user-comment { color: #d81b60 !important; font-weight: 800; }
.comment-body { font-size: 1.1rem; line-height: 1.6; color: var(--text-main); }
.admin-reply-box { margin-top: 15px; background: #fffaf0; border-right: 4px solid var(--accent); padding: 15px; border-radius: 12px; }
.admin-reply-label { font-weight: 700; color: var(--text-main); font-size: 0.95rem; margin-bottom: 5px; display: flex; align-items: center; gap: 5px; }
.admin-reply-action { margin-top: 15px; display: flex; gap: 10px; flex-wrap: wrap; }
.reply-input { flex: 1; min-width: 200px; padding: 10px 15px; border: 2px solid #eee; border-radius: 10px; font-family: inherit; font-size: 0.95rem; outline: none; transition: 0.2s; }
.reply-input:focus { border-color: var(--secondary); background: white; }

/* Dashboard Professional */
.dashboard-header-main { display: flex; justify-content: space-between; align-items: flex-start; margin-bottom: 30px; flex-wrap: wrap; gap: 20px; }
.dash-main-title { font-size: 2.2rem; color: #bbdefb; margin: 0 0 5px 0; font-weight: 700; transition: 0.3s; cursor: default; }
.dash-main-title:hover { color: #1976d2; }
.dash-subtitle { color: var(--text-muted); font-size: 1.1rem; }
.dash-header-actions { display: flex; gap: 15px; }

.dash-stats { display: grid; grid-template-columns: repeat(auto-fit, minmax(200px, 1fr)); gap: 20px; margin-bottom: 40px; }
.stat-card { background: white; padding: 25px; border-radius: 20px; display: flex; align-items: center; gap: 20px; box-shadow: 0 4px 15px rgba(0,0,0,0.03); border: 1px solid rgba(0,0,0,0.05); }
.stat-icon { font-size: 2.2rem; background: #fdfaf6; padding: 15px; border-radius: 16px; box-shadow: inset 0 2px 4px rgba(0,0,0,0.02); }
.stat-data span { display: block; font-size: 2.2rem; font-weight: 700; color: var(--text-main); line-height: 1; margin-bottom: 5px; }
.stat-data label { color: var(--text-muted); font-size: 1.05rem; font-weight: 500; }

.dashboard-list { display: flex; flex-direction: column; gap: 16px; margin-bottom: 60px; }
.dash-list-item { display: flex; align-items: center; justify-content: space-between; background: white; padding: 16px 24px; border-radius: 16px; box-shadow: 0 2px 10px rgba(0,0,0,0.02); border: 1px solid rgba(0,0,0,0.04); transition: 0.3s; flex-wrap: wrap; gap: 15px; }
.dash-list-item:hover { box-shadow: 0 10px 25px rgba(0,0,0,0.06); transform: translateY(-3px); border-color: rgba(0,0,0,0.08); }
.dash-item-info { display: flex; align-items: center; gap: 20px; flex: 1; min-width: 250px; }
.dash-item-img { width: 75px; height: 75px; border-radius: 12px; object-fit: cover; box-shadow: 0 2px 8px rgba(0,0,0,0.1); }
.dash-item-title { font-size: 1.3rem; font-weight: 700; color: var(--text-main); margin-bottom: 6px; }
.dash-item-meta { display: flex; gap: 15px; color: var(--text-muted); font-size: 0.95rem; font-weight: 500; }
.dash-item-actions { display: flex; gap: 10px; }
.dash-btn { padding: 10px 16px; border-radius: 10px; border: none; font-family: inherit; font-weight: 600; font-size: 1rem; cursor: pointer; transition: 0.2s; display: flex; align-items: center; gap: 6px; }
.dash-btn.view { background: #fce4ec; color: #d81b60; border: 1px solid #f8bbd0; }
.dash-btn.view:hover { background: #f8bbd0; color: #c2185b; transform: translateY(-2px); }
.dash-btn.delete { background: #ffebee; color: #c62828; }
.dash-btn.delete:hover { background: #ffcdd2; transform: translateY(-2px); }

/* Professional Auth UI */
.auth-container { background: var(--card-bg); padding: 40px; border-radius: 24px; width: 90%; max-width: 420px; position: relative; box-shadow: 0 20px 40px rgba(0,0,0,0.2); animation: slideUp 0.4s cubic-bezier(0.16, 1, 0.3, 1); }
@keyframes slideUp { from { transform: translateY(40px); opacity: 0; } to { transform: translateY(0); opacity: 1; } }
.auth-header { text-align: center; margin-bottom: 24px; }
.auth-title { font-size: 1.8rem; color: var(--primary); margin-bottom: 8px; }
.auth-subtitle { color: var(--text-muted); font-size: 0.95rem; }



.floating-group { position: relative; margin-bottom: 20px; }
.floating-input { width: 100%; padding: 16px 16px 12px; border: 2px solid #eee; border-radius: 12px; font-family: inherit; font-size: 1rem; outline: none; transition: 0.3s; background: #fafafa; }
.floating-input:focus { border-color: var(--primary); background: white; }
.floating-label { position: absolute; right: 16px; top: 50%; transform: translateY(-50%); color: #888; transition: 0.2s ease; pointer-events: none; padding: 0 4px; }
.floating-input:focus ~ .floating-label, .floating-input:not(:placeholder-shown) ~ .floating-label { top: -2px; font-size: 0.85rem; color: var(--primary); background: white; }

.password-toggle { position: absolute; left: 16px; top: 16px; background: none; border: none; color: #888; cursor: pointer; outline: none; }
.password-strength { font-size: 0.8rem; color: #ef476f; margin-top: 6px; padding-right: 4px; display: none; font-weight: 500; transition: color 0.3s;}
.floating-input:focus ~ .password-strength { display: block; }
.password-strength.good { color: #06d6a0; }

.auth-options { display: flex; justify-content: space-between; align-items: center; font-size: 0.9rem; margin-bottom: 24px; }
.remember-me { display: flex; align-items: center; gap: 8px; color: var(--text-muted); cursor: pointer; user-select: none; }
.forgot-pass { color: var(--secondary); text-decoration: none; font-weight: 600; }
.forgot-pass:hover { text-decoration: underline; }

.auth-submit { display: flex; justify-content: space-between; align-items: center; padding: 16px 24px; border-radius: 14px; font-size: 1.1rem; }
.btn-arrow { transition: 0.3s; }
.auth-submit:hover .btn-arrow { transform: translateX(-5px); }

.auth-footer { text-align: center; margin-top: 24px; font-size: 0.95rem; color: var(--text-muted); }
.switch-link { color: var(--primary); font-weight: 700; cursor: pointer; text-decoration: none; transition: 0.2s; }
.switch-link:hover { color: var(--primary-hover); text-decoration: underline; }

/* Utilities - Other */
.modal-overlay { position: fixed; top:0; left:0; width:100%; height:100%; background: rgba(0,0,0,0.5); backdrop-filter: blur(4px); display: flex; align-items: center; justify-content: center; z-index: 1000; }
.modal-content { background: white; padding: 40px; border-radius: var(--radius-lg); width: 90%; max-width: 450px; position: relative; max-height: 90vh; overflow-y: auto; }
.icon-btn { background: none; border: none; cursor: pointer; color: var(--text-muted); }
.modal-close { position: absolute; top: 15px; left: 15px; font-size: 20px; font-weight: bold; padding: 10px; background: #f5f5f5; border-radius: 50%; width: 40px; height: 40px; display: flex; justify-content: center; align-items: center; transition: 0.2s; }
.modal-close:hover { background: #e0e0e0; color: #333; transform: scale(1.05); }
.toast-container { position: fixed; bottom: 20px; right: 20px; z-index: 2000; }
.toast { background: white; padding: 15px 25px; margin-top: 10px; border-radius: 8px; box-shadow: var(--shadow-soft); display: flex; align-items: center; gap: 10px; border-right: 4px solid var(--primary); font-weight: bold; animation: slideIn 0.3s; }
.toast.error { border-color: #ef476f; }
@keyframes slideIn { from { transform: translateX(100%); } to { transform: translateX(0); } }

/* Core Utilities (Buttons & Forms) */
.btn-primary { padding: 12px 28px; background: #e3f2fd; color: #1565c0; border: 1px solid #bbdefb; border-radius: 50px; font-size: 1.1rem; font-weight: 700; cursor: pointer; font-family: inherit; transition: 0.3s; box-shadow: 0 4px 12px rgba(21, 101, 192, 0.1); display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-primary:hover { background: #bbdefb; color: #0d47a1; transform: translateY(-2px); box-shadow: 0 6px 16px rgba(21, 101, 192, 0.2); }

.btn-outline { background: transparent; border: 2px solid var(--primary); color: var(--primary); padding: 10px 24px; border-radius: 50px; font-size: 1.05rem; cursor: pointer; font-family: inherit; font-weight: 700; transition: 0.3s; display: inline-flex; align-items: center; justify-content: center; gap: 8px; }
.btn-outline:hover { background: var(--primary); color: white; box-shadow: 0 4px 15px rgba(224, 122, 95, 0.2); transform: translateY(-2px); }

.form-group { margin-bottom: 20px; text-align: right; }
.form-label { display: block; margin-bottom: 8px; font-weight: 600; color: var(--text-main); font-size: 1.05rem; }
.form-input, .form-textarea { width: 100%; padding: 14px 16px; border: 2px solid #eee; border-radius: 12px; font-family: inherit; font-size: 1rem; transition: 0.3s; background: #fafafa; outline: none; }
.form-input:focus, .form-textarea:focus { border-color: var(--primary); background: white; box-shadow: 0 0 0 4px rgba(224, 122, 95, 0.1); }
.form-textarea { min-height: 120px; resize: vertical; }

.image-upload-area { display: block; padding: 30px 20px; text-align: center; border: 2px dashed #ccc; border-radius: 14px; cursor: pointer; background: #fafafa; transition: 0.3s; font-weight: 600; color: var(--text-muted); font-size: 1.1rem; margin-top: 5px; }
.image-upload-area:hover { border-color: var(--primary); color: var(--primary); background: #fffcfb; }
.modal-title { font-size: 1.8rem; color: var(--text-main); margin-bottom: 24px; text-align: center; font-weight: 700; }

/* Responsive adjustments for mobile devices */
@media (max-width: 600px) {
    .container { padding: 0 10px; }
    .products-grid { grid-template-columns: repeat(3, 1fr) !important; gap: 8px; padding-bottom: 40px; }
    .product-card { border-radius: 8px; }
    .product-content { padding: 6px; gap: 2px; }
    .product-title { font-size: 0.8rem; line-height: 1.2; }
    .product-price { font-size: 0.7rem; }
    
    .app-header { padding: 15px 0; margin-bottom: 10px; }
    .header-content { flex-direction: row; justify-content: center; position: relative; padding-top: 40px; }
    #auth-buttons { position: absolute; right: 10px; top: 0; transform: none; }
    
    .app-title { font-size: 2.2rem !important; }
    .app-subtitle { font-size: 1.1rem !important; }
    
    .dash-stats { grid-template-columns: repeat(2, 1fr); gap: 10px; }
    .dash-item-info { flex-direction: column; text-align: center; min-width: 100%; gap: 10px; }
    .dash-item-actions { width: 100%; justify-content: center; margin-top: 10px; }
}

.view-store-btn { background: #fce4ec !important; color: #d81b60 !important; border-color: #f8bbd0 !important; }
.view-store-btn:hover { background: #f8bbd0 !important; }
