/* ========== المتغيرات الأساسية ========== */
:root {
    --primary: #d1a056;
    --primary-dark: #b88b3c;
    --secondary: #3b170f;
    --secondary-light: #5f2a19;
    --gray-bg: #f9f9f9;
    --border: #eee;
    --text-dark: #3b170f;
    --text-muted: #666;
    --shadow: 0 5px 20px rgba(0, 0, 0, 0.05);
    --transition: all 0.3s ease;
}

body.dark-mode {
    --primary: #d1a056;
    --secondary: #f5f5f5;
    --gray-bg: #2d2d2d;
    --border: #444;
    --text-dark: #f5f5f5;
    --text-muted: #aaa;
    --shadow: 0 5px 20px rgba(0, 0, 0, 0.3);
}

* {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

/* ========== الهيدر المحسن والمتجاوب ========== */
.main-header {
    background: linear-gradient(135deg, #3b170f, #5f2a19);
    padding: 0.8rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1);
}

.header-container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 0 2rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 1rem;
}

.logo-link {
    text-decoration: none;
    display: inline-flex;
    flex-direction: column;
    line-height: 1.2;
}

.logo h1 {
    font-size: 1.8rem;
    margin: 0;
    color: #d1a056;
    font-weight: 800;
    letter-spacing: 1px;
}

.logo-subtitle {
    font-size: 0.7rem;
    color: rgba(255, 255, 255, 0.7);
    letter-spacing: 2px;
}

.header-actions {
    display: flex;
    align-items: center;
    gap: 1rem;
}

.back-link {
    background: rgba(255, 255, 255, 0.15);
    padding: 0.5rem 1.2rem;
    border-radius: 40px;
    color: white;
    text-decoration: none;
    font-weight: 500;
    transition: all 0.3s ease;
    display: inline-flex;
    align-items: center;
    gap: 0.5rem;
    font-size: 0.9rem;
    backdrop-filter: blur(4px);
}

.back-link:hover {
    background: #d1a056;
    transform: translateX(-5px);
}

/* ========== باقي محتوى الملف الشخصي ========== */
.profile-container {
    max-width: 1400px;
    margin: 2rem auto;
    padding: 0 1.5rem;
}

.breadcrumb {
    margin-bottom: 2rem;
    color: var(--text-muted);
}

.breadcrumb a {
    color: var(--primary);
    text-decoration: none;
}

.profile-layout {
    display: grid;
    grid-template-columns: 280px 1fr;
    gap: 2rem;
}

/* الشريط الجانبي */
.profile-sidebar {
    background: white;
    border-radius: 24px;
    padding: 1.5rem;
    box-shadow: var(--shadow);
    height: fit-content;
    position: sticky;
    top: 100px;
    transition: var(--transition);
}

.user-avatar {
    text-align: center;
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px solid var(--border);
}

.avatar-wrapper {
    position: relative;
    display: inline-block;
}

.avatar-image {
    width: 100px;
    height: 100px;
    border-radius: 50%;
    object-fit: cover;
    border: 3px solid var(--primary);
    cursor: pointer;
}

.avatar-edit-icon {
    position: absolute;
    bottom: 5px;
    right: 5px;
    background: var(--primary);
    color: white;
    border-radius: 50%;
    width: 28px;
    height: 28px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 0.8rem;
    cursor: pointer;
    transition: var(--transition);
    border: 2px solid white;
}

.avatar-edit-icon:hover {
    background: var(--primary-dark);
    transform: scale(1.05);
}

.user-name {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--text-dark);
    margin-top: 0.8rem;
}

.user-email {
    font-size: 0.85rem;
    color: var(--text-muted);
}

.sidebar-menu {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.sidebar-menu-item {
    display: flex;
    align-items: center;
    gap: 1rem;
    padding: 0.8rem 1rem;
    border-radius: 14px;
    cursor: pointer;
    transition: var(--transition);
    color: var(--text-muted);
    font-weight: 500;
}

.sidebar-menu-item i {
    width: 24px;
    text-align: center;
}

.sidebar-menu-item:hover {
    background: rgba(209, 160, 86, 0.1);
    color: var(--primary);
    transform: translateX(-5px);
}

.sidebar-menu-item.active {
    background: linear-gradient(135deg, var(--primary), var(--primary-dark));
    color: white;
    box-shadow: 0 4px 12px rgba(209, 160, 86, 0.3);
}

.sidebar-menu-item.logout {
    margin-top: 1rem;
    border-top: 1px solid var(--border);
    padding-top: 1rem;
    color: #e74c3c;
}

.sidebar-menu-item.logout:hover {
    background: rgba(231, 76, 60, 0.1);
    color: #e74c3c;
}

/* المحتوى الرئيسي */
.profile-content {
    background: white;
    border-radius: 24px;
    padding: 2rem;
    box-shadow: var(--shadow);
    transition: var(--transition);
}

.profile-section {
    display: none;
    animation: fadeIn 0.4s ease;
}

.profile-section.active {
    display: block;
}

@keyframes fadeIn {
    from {
        opacity: 0;
        transform: translateY(10px);
    }
    to {
        opacity: 1;
        transform: translateY(0);
    }
}

.section-title {
    font-size: 1.6rem;
    margin-bottom: 1.8rem;
    padding-bottom: 0.8rem;
    border-bottom: 2px solid var(--border);
    display: flex;
    align-items: center;
    gap: 0.8rem;
    color: var(--text-dark);
}

.section-title i {
    color: var(--primary);
}

/* النماذج */
.form-group {
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block;
    margin-bottom: 0.5rem;
    font-weight: 600;
    color: var(--text-dark);
}

.form-group input,
.form-group textarea,
.form-group select {
    width: 100%;
    padding: 0.8rem 1rem;
    border: 2px solid var(--border);
    border-radius: 12px;
    font-family: inherit;
    font-size: 1rem;
    transition: var(--transition);
    background: white;
    color: var(--text-dark);
}

.form-group input:focus,
.form-group textarea:focus {
    border-color: var(--primary);
    outline: none;
    box-shadow: 0 0 0 3px rgba(209, 160, 86, 0.2);
}

.form-group input:read-only {
    background: var(--gray-bg);
    cursor: default;
}

.form-row {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.btn {
    padding: 0.8rem 1.5rem;
    border: none;
    border-radius: 12px;
    font-size: 1rem;
    font-weight: 600;
    cursor: pointer;
    transition: var(--transition);
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.6rem;
}

.btn-primary {
    background: linear-gradient(135deg, var(--secondary), var(--secondary-light));
    color: white;
}

.btn-primary:hover {
    transform: translateY(-2px);
    box-shadow: 0 8px 20px rgba(59, 23, 15, 0.3);
}

/* قائمة الطلبات */
.orders-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}

.order-item {
    border: 1px solid var(--border);
    border-radius: 16px;
    padding: 1.2rem;
    transition: var(--transition);
    background: white;
}

.order-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.status-badge {
    display: inline-block;
    padding: 0.2rem 0.8rem;
    border-radius: 50px;
    font-size: 0.75rem;
    font-weight: 600;
}

.status-pending { background: #f39c12; color: white; }
.status-processing { background: #3498db; color: white; }
.status-shipped { background: #9b59b6; color: white; }
.status-delivered { background: #27ae60; color: white; }
.status-cancelled { background: #e74c3c; color: white; }

/* العناوين */
.addresses-list {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(300px, 1fr));
    gap: 1.2rem;
    margin-bottom: 1.5rem;
}

.address-card {
    border: 1px solid var(--border);
    border-radius: 18px;
    padding: 1.2rem;
    transition: var(--transition);
    background: white;
}

.address-card.default {
    border-color: var(--primary);
    background: rgba(209, 160, 86, 0.05);
}

.address-card:hover {
    transform: translateY(-3px);
    box-shadow: 0 8px 20px rgba(0, 0, 0, 0.08);
}

.address-title {
    font-weight: 700;
    margin-bottom: 0.5rem;
    display: flex;
    justify-content: space-between;
    align-items: center;
    color: var(--text-dark);
}

.default-badge {
    background: var(--primary);
    color: white;
    padding: 0.2rem 0.6rem;
    border-radius: 50px;
    font-size: 0.7rem;
}

.address-text {
    color: var(--text-muted);
    line-height: 1.5;
    margin-bottom: 1rem;
    font-size: 0.9rem;
}

.address-actions {
    display: flex;
    gap: 0.8rem;
    justify-content: flex-end;
}

.address-actions button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 0.4rem;
    border-radius: 8px;
    transition: var(--transition);
    font-size: 1rem;
}

.address-actions .edit-address { color: #3498db; }
.address-actions .delete-address { color: #e74c3c; }
.address-actions .set-default { color: #27ae60; }

.address-actions button:hover {
    transform: scale(1.1);
    background: rgba(0, 0, 0, 0.05);
}

.btn-add-address {
    width: 100%;
    background: var(--gray-bg);
    border: 2px dashed var(--border);
    padding: 1rem;
    border-radius: 18px;
    cursor: pointer;
    transition: var(--transition);
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    color: var(--primary);
    font-weight: 600;
}

.btn-add-address:hover {
    background: rgba(209, 160, 86, 0.1);
    border-color: var(--primary);
    transform: translateY(-2px);
}

/* المودال */
.modal {
    display: none;
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.6);
    backdrop-filter: blur(4px);
    z-index: 2000;
    align-items: center;
    justify-content: center;
}

.modal.active {
    display: flex;
    animation: fadeIn 0.3s ease;
}

.modal-content {
    background: white;
    border-radius: 28px;
    padding: 2rem;
    max-width: 550px;
    width: 90%;
    max-height: 85vh;
    overflow-y: auto;
    position: relative;
    animation: modalSlideIn 0.4s cubic-bezier(0.2, 0.9, 0.4, 1.1);
}

@keyframes modalSlideIn {
    from {
        opacity: 0;
        transform: translateY(-50px) scale(0.95);
    }
    to {
        opacity: 1;
        transform: translateY(0) scale(1);
    }
}

.modal-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-bottom: 1.5rem;
}

.close-modal {
    font-size: 1.8rem;
    cursor: pointer;
    color: #999;
    transition: var(--transition);
    line-height: 1;
}

.close-modal:hover {
    color: #e74c3c;
    transform: rotate(90deg);
}

/* شاشة التحميل */
.loading-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(0, 0, 0, 0.7);
    backdrop-filter: blur(4px);
    z-index: 3000;
    display: none;
    align-items: center;
    justify-content: center;
    flex-direction: column;
    gap: 1rem;
}

.loading-overlay.active {
    display: flex;
}

.loading-spinner {
    width: 50px;
    height: 50px;
    border: 4px solid rgba(255, 255, 255, 0.3);
    border-top-color: var(--primary);
    border-radius: 50%;
    animation: spin 0.8s linear infinite;
}

@keyframes spin {
    to { transform: rotate(360deg); }
}

.loading-text {
    color: white;
    font-size: 1rem;
}

/* ========== التوافق مع الشاشات الصغيرة ========== */
@media (max-width: 768px) {
    .profile-container {
        padding: 0 0.8rem;
        overflow-x: hidden;
    }
    
    .profile-layout {
        display: flex;
        flex-direction: column;
    }
    
    .profile-sidebar {
        width: 100%;
        margin-bottom: 1rem;
        position: static;
        padding: 1rem;
    }
    
    .sidebar-menu {
        display: flex;
        flex-direction: row;
        flex-wrap: nowrap;
        overflow-x: auto;
        -webkit-overflow-scrolling: touch;
        scrollbar-width: thin;
        gap: 0.5rem;
        padding-bottom: 0.5rem;
    }
    
    .sidebar-menu-item {
        flex-shrink: 0;
        white-space: nowrap;
        padding: 0.5rem 1rem;
        font-size: 0.85rem;
    }
    
    .profile-content {
        padding: 1rem;
        width: 100%;
        overflow-x: hidden;
    }
    
    .form-row {
        flex-direction: column;
        gap: 0;
    }
    
    .addresses-list {
        grid-template-columns: 1fr;
    }
    
    .btn {
        width: 100%;
        justify-content: center;
    }
    
    .modal-content {
        width: 95%;
        padding: 1rem;
        max-height: 90vh;
    }
    
    .order-item {
        padding: 0.8rem;
    }
}

@media (max-width: 480px) {
    .header-container {
        flex-direction: column;
        text-align: center;
        gap: 0.5rem;
    }
    
    .logo h1 {
        font-size: 1.3rem;
    }
    
    .back-link span {
        font-size: 0.8rem;
    }
    
    .user-name {
        font-size: 1rem;
    }
    
    .section-title {
        font-size: 1.2rem;
    }
}

img, video, iframe, .address-card, .order-item {
    max-width: 100%;
    height: auto;
}
/* ========== الوضع المظلم (مكمل) ========== */
body.dark-mode .profile-sidebar,
body.dark-mode .profile-content,
body.dark-mode .modal-content,
body.dark-mode .order-item,
body.dark-mode .address-card {
    background: #2d2d2d;
}

body.dark-mode .form-group input,
body.dark-mode .form-group textarea {
    background: #3d3d3d;
    border-color: #555;
    color: #f5f5f5;
}

body.dark-mode .btn-outline {
    color: var(--primary);
    border-color: var(--primary);
}

body.dark-mode .address-card.default {
    background: #3d2a1f;
}