/*
 * Smart Health Advisor - Main Stylesheet
 * Version: 37.0 (Optimized Print Layout)
 * Description: A complete overhaul for a modern, clean, and professional look.
 */

/* ---------------------------------- */
/* 1. Global Settings & Variables     */
/* ---------------------------------- */
:root {
    /* Color Palette */
    --primary-color: #2D8B78; /* A slightly more vibrant and modern green */
    --primary-darker: #246f60;
    --secondary-color: #4CAF50; /* A fresh green for success and positive actions */
    --accent-color: #F59E0B; /* A warm amber/gold for highlights and CTAs */
    --accent-darker: #d98c0a;

    /* Typography & Text */
    --dark-color: #343a40; /* Dark grey for body text, better than pure black */
    --muted-color: #6c757d; /* Lighter grey for subtitles and meta text */
    --light-color: #FFFFFF;

    /* Background & Borders */
    --bg-light-gray: #F9FAFB; /* A very subtle gray for the body background */
    --bg-white: #FFFFFF;
    --border-color: #E5E7EB; /* Light border for cards and inputs */

    /* System Colors */
    --success-color: #16A34A;
    --warning-color: #F59E0B;
    --danger-color: #DC2626;

    /* Fonts & Spacing */
    --font-family: 'Tajawal', sans-serif;
    --base-font-size: 16px;
    --border-radius-sm: 0.375rem; /* 6px */
    --border-radius-md: 0.5rem;   /* 8px */
    --border-radius-lg: 1rem;    /* 16px */
    --shadow-sm: 0 1px 2px 0 rgb(0 0 0 / 0.05);
    --shadow-md: 0 4px 6px -1px rgb(0 0 0 / 0.1), 0 2px 4px -2px rgb(0 0 0 / 0.1);
    --shadow-lg: 0 10px 15px -3px rgb(0 0 0 / 0.1), 0 4px 6px -4px rgb(0 0 0 / 0.1);
}

/* ---------------------------------- */
/* 2. Base & Reset Styles             */
/* ---------------------------------- */
* {
    box-sizing: border-box;
    margin: 0;
    padding: 0;
}

html {
    font-size: var(--base-font-size);
    scroll-behavior: smooth;
}

body {
    font-family: var(--font-family);
    line-height: 1.7;
    background-color: var(--bg-light-gray);
    color: var(--dark-color);
    direction: rtl;
    -webkit-font-smoothing: antialiased;
    -moz-osx-font-smoothing: grayscale;
    padding-bottom: 80px; /* Add padding to prevent content from being hidden by the bottom nav */
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 1.5rem;
}

.text-center {
    text-align: center;
}

/* ---------------------------------- */
/* 3. General Components              */
/* ---------------------------------- */

/* --- Buttons --- */
.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    font-family: var(--font-family);
    font-weight: 700;
    font-size: 1rem;
    padding: 0.75rem 1.5rem;
    border: 1px solid transparent;
    border-radius: var(--border-radius-md);
    cursor: pointer;
    text-decoration: none;
    transition: all 0.2s ease-in-out;
}
.btn:hover {
    transform: translateY(-2px);
    box-shadow: var(--shadow-md);
}
.btn.btn-lg {
    padding: 1rem 2.5rem;
    font-size: 1.125rem;
}
.btn.btn-sm {
    padding: 0.5rem 1rem;
    font-size: 0.9rem;
}

/* Button Variants */
.btn-primary {
    background-color: var(--primary-color);
    color: var(--light-color);
}
.btn-primary:hover {
    background-color: var(--primary-darker);
}
.btn-accent {
    background-color: var(--accent-color);
    color: var(--dark-color);
}
.btn-accent:hover {
    background-color: var(--accent-darker);
}
.btn-secondary {
    background-color: var(--light-color);
    color: var(--dark-color);
    border-color: var(--border-color);
}
.btn-secondary:hover {
    background-color: var(--bg-light-gray);
    border-color: var(--muted-color);
}


/* --- Forms --- */
.form-group {
    margin-bottom: 1.25rem;
}
.form-group label {
    display: block;
    font-weight: 600;
    margin-bottom: 0.5rem;
    font-size: 0.95rem;
}
.form-group input[type='text'],
.form-group input[type='number'],
.form-group input[type='file'],
.form-group input[type='password'],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 0.875rem 1rem;
    font-size: 1rem;
    font-family: var(--font-family);
    color: var(--dark-color);
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    transition: border-color 0.2s, box-shadow 0.2s;
}
.form-group input:focus,
.form-group select:focus,
.form-group textarea:focus {
    outline: none;
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 139, 120, 0.2);
}
.form-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    gap: 1.25rem;
}

/* ---------------------------------- */
/* 4. Layout & Reusable Sections      */
/* ---------------------------------- */
.site-header {
    background: var(--bg-white);
    box-shadow: var(--shadow-sm);
    padding: 1rem 0;
    position: sticky;
    top: 0;
    z-index: 1000;
    border-bottom: 1px solid var(--border-color);
}
.site-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
}
.site-header .logo a {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
    text-decoration: none;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.site-header .main-nav {
    display: none; /* Hide on mobile by default */
}
.site-header .main-nav ul {
    display: flex;
    gap: 0.5rem;
    list-style: none;
}
.site-header .main-nav ul li a {
    text-decoration: none;
    padding: 0.5rem 1rem;
    font-weight: 600;
    color: var(--muted-color);
    border-radius: var(--border-radius-sm);
    transition: all 0.2s ease;
}
.site-header .main-nav ul li a:hover {
    color: var(--dark-color);
    background-color: var(--bg-light-gray);
}
.site-header .main-nav ul li a.active {
    color: var(--primary-color);
    background-color: rgba(45, 139, 120, 0.1);
}

.site-main {
    padding: 0; 
}

.site-footer {
    background: var(--dark-color);
    color: var(--light-color);
    text-align: center;
    padding: 2.5rem 0;
    margin-top: 0; 
}

/* Generic content card */
.content-box {
    background: var(--bg-white);
    padding: 2rem;
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 2rem;
}

/* ---------------------------------- */
/* 5. Page-Specific Styles            */
/* ---------------------------------- */

/* --- Homepage (New Styles) --- */
.homepage-hero {
    padding: 6rem 0;
    text-align: center;
    color: var(--light-color);
    background-size: cover;
    background-position: center;
    position: relative;
}
.hero-content h1 {
    font-size: 3.2rem;
    font-weight: 800;
    line-height: 1.2;
    margin-bottom: 1.5rem;
    text-shadow: 0 2px 4px rgba(0,0,0,0.5);
}
.hero-content .hero-subtitle {
    font-size: 1.25rem;
    color: var(--light-color);
    max-width: 750px;
    margin: 0 auto 2.5rem auto;
    line-height: 1.8;
    opacity: 0.95;
}
.hero-buttons {
    display: flex;
    justify-content: center;
    gap: 1rem;
    flex-wrap: wrap;
}
.section-container {
    padding: 5rem 0;
}
.section-container.bg-light {
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    border-bottom: 1px solid var(--border-color);
}
.section-header {
    text-align: center;
    margin-bottom: 4rem;
    max-width: 750px;
    margin-left: auto;
    margin-right: auto;
}
.section-header h2 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 1rem;
}
.section-header p {
    font-size: 1.1rem;
    color: var(--muted-color);
}

/* --- Features Grid (Homepage & Analyze Page) --- */
.features-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 1.5rem;
}
.feature-card {
    background-color: var(--bg-white);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    padding: 2rem 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-sm);
    transition: transform 0.3s ease, box-shadow 0.3s ease;
}
.feature-card:hover {
    transform: translateY(-8px);
    box-shadow: var(--shadow-lg);
}
.feature-icon {
    width: 60px;
    height: 60px;
    margin: 0 auto 1.5rem auto;
    background-color: rgba(45, 139, 120, 0.1);
    color: var(--primary-color);
    border-radius: 50%;
    display: flex;
    align-items: center;
    justify-content: center;
}
.feature-icon i {
    font-size: 2.2rem;
}
.feature-card h3 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}
.feature-card p {
    color: var(--muted-color);
    line-height: 1.8;
}

/* --- Alternating Layout with Icons (New) --- */
.alternating-layout {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    align-items: center;
    gap: 2rem;
    margin-bottom: 4rem;
}
.alternating-layout:last-child {
    margin-bottom: 0;
}
.alternating-layout.reverse {
    direction: ltr; /* Flip direction for reverse layout on desktop */
}

.layout-icon-container {
    display: flex;
    align-items: center;
    justify-content: center;
    width: 280px;
    height: 280px;
    background-color: rgba(45, 139, 120, 0.08);
    border-radius: 50%;
    margin: 0 auto; /* Center on mobile */
    box-shadow: 0 0 0 15px rgba(45, 139, 120, 0.05);
}
.layout-icon-container svg {
    width: 120px;
    height: 120px;
    color: var(--primary-color);
}

.alternating-layout .layout-text {
    direction: rtl; /* Ensure text content is always RTL */
    text-align: center; /* Center text on mobile */
}
.alternating-layout .layout-text h3 {
    font-size: 2.2rem;
    font-weight: 700;
    margin-bottom: 1rem;
}
.alternating-layout .layout-text p {
    font-size: 1.1rem;
    line-height: 1.8;
    color: var(--muted-color);
    margin-bottom: 1.5rem;
}
.alternating-layout .layout-text ul {
    list-style: none;
    padding: 0;
    display: inline-block; /* Allow centering */
    text-align: right; /* Align text inside list */
}
.alternating-layout .layout-text ul li {
    display: flex;
    align-items: flex-start;
    gap: 0.75rem;
    font-size: 1.1rem;
    margin-bottom: 1rem;
}
.alternating-layout .layout-text ul li i {
    color: var(--secondary-color);
    font-size: 1.4rem;
    margin-top: 4px;
}

.cta-section {
    background: var(--dark-color);
    color: white;
    padding: 5rem 1.5rem;
    text-align: center;
}
.cta-section h2 {
    font-size: 2.5rem;
    margin-bottom: 1rem;
}
.cta-section p {
    font-size: 1.2rem;
    margin-bottom: 2.5rem;
    opacity: 0.9;
    max-width: 600px;
    margin-left: auto;
    margin-right: auto;
}


/* --- Analyze Page (New Design) --- */
.analysis-container {
    max-width: 800px;
    margin: 2rem auto; /* Reduced top margin */
    background: var(--bg-white);
    padding: 1.5rem; /* Reduced padding for mobile */
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-lg);
    border: 1px solid var(--border-color);
}
.form-header {
    text-align: center;
    margin-bottom: 2rem;
}
.form-header h3 {
    font-size: 1.8rem;
    font-weight: 700;
    margin-bottom: 0.5rem;
}
.form-header p {
    color: var(--muted-color);
}
.form-divider {
    border: none;
    border-top: 1px solid var(--border-color);
    margin: 2rem 0;
}

/* --- **NEW** Input Method Selector Styles --- */
.input-method-selector {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
    margin-bottom: 2rem;
}
.input-method-selector label {
    flex: 1;
}
.input-method-selector input[type="radio"] {
    display: none;
}
.input-method-selector .method-card {
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 1.5rem 1rem;
    border: 2px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    cursor: pointer;
    transition: all 0.3s ease;
    text-align: center;
    background-color: var(--bg-light-gray);
    height: 100%;
}
.input-method-selector .method-card i {
    font-size: 2.5rem;
    color: var(--muted-color);
    margin-bottom: 0.75rem;
    transition: all 0.3s ease;
}
.input-method-selector .method-card strong {
    font-size: 1.1rem;
    color: var(--dark-color);
    display: block;
    transition: all 0.3s ease;
}
.input-method-selector .method-card small {
    font-size: 0.9rem;
    color: var(--muted-color);
    transition: all 0.3s ease;
}
.input-method-selector input[type="radio"]:checked + .method-card {
    background-color: var(--light-color);
    border-color: var(--primary-color);
    box-shadow: 0 0 0 3px rgba(45, 139, 120, 0.2), var(--shadow-md);
    transform: translateY(-5px);
}
.input-method-selector input[type="radio"]:checked + .method-card i {
    color: var(--primary-color);
}
.input-method-selector input[type="radio"]:checked + .method-card strong {
    color: var(--primary-color);
}

@keyframes spin {
    from { transform: rotate(0deg); }
    to { transform: rotate(360deg); }
}

/* --- Wellness Card / Packages Page --- */
.page-hero {
    background-color: var(--primary-darker);
    color: white;
    padding: 4rem 1.5rem;
    text-align: center;
    margin-bottom: 3rem;
}
.page-hero h1 {
    font-size: 2.5rem;
    font-weight: 800;
    margin-bottom: 0.5rem;
}
.page-hero p {
    font-size: 1.2rem;
    max-width: 700px;
    margin: 0 auto;
    opacity: 0.9;
}
.filters-container {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 0.75rem;
    margin-bottom: 3rem;
}
.filter-btn {
    background-color: var(--bg-white);
    color: var(--dark-color);
    border: 1px solid var(--border-color);
    padding: 0.7rem 1.5rem;
    border-radius: 50px; /* Pill shape */
    cursor: pointer;
    font-weight: 600;
    transition: all 0.2s ease;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}
.filter-btn:hover {
    border-color: var(--primary-color);
    transform: translateY(-2px);
}
.filter-btn.active {
    background-color: var(--primary-color);
    color: var(--light-color);
    border-color: var(--primary-color);
}
.packages-grid {
    display: grid;
    grid-template-columns: 1fr; /* Single column on mobile */
    gap: 1.5rem;
}
.package-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    overflow: hidden;
    display: flex;
    flex-direction: column;
    transition: all 0.3s ease;
}
.package-card:hover {
    transform: translateY(-5px);
    box-shadow: var(--shadow-lg);
}
.package-card-image {
    height: 220px;
    background-size: cover;
    background-position: center;
}
.package-card-content {
    padding: 1.5rem;
    display: flex;
    flex-direction: column;
    flex-grow: 1; /* Key for equal height footer */
}
.package-card-content h3 {
    font-size: 1.3rem;
    margin-bottom: 0.75rem;
}
.package-card-content p {
    color: var(--muted-color);
    flex-grow: 1; /* Pushes footer down */
    margin-bottom: 1.5rem;
}
.package-card-footer {
    display: flex;
    justify-content: space-between;
    align-items: center;
    margin-top: auto; /* Pushes footer to bottom */
}
.package-price .current {
    font-size: 1.5rem;
    font-weight: 800;
    color: var(--primary-color);
}
.package-price .original {
    font-size: 1rem;
    color: var(--muted-color);
    text-decoration: line-through;
    margin-right: 0.5rem;
}

/* --- Profile Page --- */
.profile-container{
    margin: 4rem auto;
}
.profile-header {
    text-align: center;
    margin-bottom: 3rem;
}
.profile-header h1 {
    font-size: 2.5rem;
}
.profile-header p {
    font-size: 1.2rem;
    color: var(--muted-color);
    max-width: 600px;
    margin: 0.5rem auto 0 auto;
}
.kpi-grid {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns on mobile */
    gap: 1.5rem;
    margin-bottom: 3rem;
}
.kpi-card-profile {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    padding: 1.5rem;
    text-align: center;
    box-shadow: var(--shadow-md);
}
.kpi-card-profile .kpi-icon {
    font-size: 2.5rem;
    margin-bottom: 0.75rem;
    color: var(--primary-color);
}
.kpi-card-profile h4 {
    font-size: 1rem;
    color: var(--muted-color);
    margin-bottom: 0.25rem;
}
.kpi-card-profile p {
    font-size: 1.8rem;
    font-weight: 700;
}
.progress-history-list {
    display: flex;
    flex-direction: column;
    gap: 1rem;
}
.progress-item {
    background: var(--bg-light-gray);
    border-radius: var(--border-radius-md);
    padding: 1rem;
    display: grid;
    grid-template-columns: 1fr;
    align-items: center;
    gap: 1rem;
    border: 1px solid var(--border-color);
    transition: box-shadow 0.2s;
}
.progress-item:hover {
    box-shadow: var(--shadow-md);
}
.progress-item .item-date {
    font-weight: 700;
    font-size: 1.1rem;
    text-align: center;
    padding-bottom: 1rem;
    border-bottom: 1px solid var(--border-color);
}
.progress-item .item-metrics-grid {
    display: grid;
    grid-template-columns: repeat(3, 1fr);
    gap: 1rem;
    padding: 1rem 0;
}
.progress-item .item-metric {
    text-align: center;
}
.progress-item .item-metric span {
    display: block;
    font-size: 0.9rem;
    color: var(--muted-color);
}
.progress-item .item-metric strong {
    font-size: 1.2rem;
}
.progress-item .change-indicator {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.3rem;
    font-weight: 700;
    font-size: 1rem;
}
.change-indicator.positive { color: var(--success-color); }
.change-indicator.negative { color: var(--danger-color); }
.progress-item .item-action {
    text-align: center;
    padding-top: 1rem;
    border-top: 1px solid var(--border-color);
}
.progress-item .item-action a {
    text-decoration: none;
    font-weight: 600;
    color: var(--primary-color);
    padding: 0.5rem 1rem;
    border-radius: var(--border-radius-sm);
    transition: background-color 0.2s;
    display: inline-flex;
    align-items: center;
    gap: 0.25rem;
}
.progress-item .item-action a:hover {
    background-color: rgba(45, 139, 120, 0.1);
}


/* ---------------------------------- */
/* 6. Report Page - NEW STYLES        */
/* ---------------------------------- */
.report-wrapper {
    max-width: 950px;
    margin: 2rem auto;
}
.report-header {
    text-align: center;
    margin-bottom: 2rem;
}
.report-header h1 {
    font-size: 2.2rem;
}
.report-header p {
    font-size: 1.1rem;
}

.report-card {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    box-shadow: var(--shadow-md);
    margin-bottom: 1.5rem;
    overflow: hidden;
}
.report-card .card-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 1rem;
    font-size: 1.2rem;
    font-weight: 700;
    padding: 1rem 1.25rem;
    background-color: var(--bg-light-gray);
    border-bottom: 1px solid var(--border-color);
}
.report-card .card-header h3 {
    margin: 0;
    display: flex;
    align-items: center;
    gap: 0.75rem;
}
.report-card .card-header i {
    font-size: 1.5rem;
    color: var(--primary-color);
}
.report-card .card-body {
    padding: 1.5rem;
}
.plan-section {
    margin-bottom: 1.5rem;
    padding-bottom: 1.5rem;
    border-bottom: 1px dashed var(--border-color);
}
.plan-section:last-child {
    margin-bottom: 0;
    padding-bottom: 0;
    border-bottom: none;
}
.plan-title {
    font-size: 1.3rem;
    font-weight: 700;
    display: flex;
    align-items: center;
    gap: 0.5rem;
    margin-bottom: 0.5rem;
}
.plan-intro {
    font-size: 1rem;
    color: var(--muted-color);
    margin-bottom: 1rem;
    line-height: 1.8;
}

/* Summary Card */
.summary-card.status-border-ممتاز { border-right: 5px solid var(--success-color); }
.summary-card.status-border-جيد { border-right: 5px solid var(--warning-color); }
.summary-card.status-border-يحتاج-تحسين { border-right: 5px solid var(--danger-color); }
.summary-card .card-body p {
    font-size: 1.1rem; 
    line-height: 1.8;
}
.status-indicator {
    padding: 0.3rem 0.8rem;
    border-radius: 50px;
    font-weight: 700;
    font-size: 0.9rem;
}
.status-indicator.status-ممتاز { background-color: rgba(22, 163, 74, 0.1); color: var(--success-color); }
.status-indicator.status-جيد { background-color: rgba(245, 158, 11, 0.1); color: var(--warning-color); }
.status-indicator.status-يحتاج-تحسين { background-color: rgba(220, 38, 38, 0.1); color: var(--danger-color); }

/* --- New class for highlighting keywords --- */
.highlight-keyword {
    font-weight: 800; /* Bolder */
    color: var(--primary-darker);
    background-color: rgba(45, 139, 120, 0.1); /* Subtle highlight */
    padding: 0.1em 0.4em;
    border-radius: var(--border-radius-sm);
}

.highlight-keyword.negative {
    color: var(--danger-color);
    background-color: rgba(220, 38, 38, 0.1);
}


/* Metric Cards */
.analysis-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 1rem;
}
.metric-card {
    background-color: var(--bg-light-gray);
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-md);
    display: flex;
    flex-direction: column;
    text-align: center;
}
.metric-card .metric-header {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: 0.5rem;
    padding: 0.75rem;
    border-bottom: 1px solid var(--border-color);
}
.metric-card .metric-header i { color: var(--primary-color); font-size: 1.2rem; }
.metric-card .metric-header h4 { font-size: 1rem; margin: 0; }
.metric-card .metric-body {
    padding: 1rem;
}
.metric-card .metric-body .value {
    font-size: 2rem;
    font-weight: 800;
    color: var(--dark-color);
    display: block;
}
.metric-card .metric-body .range {
    font-size: 0.9rem;
    color: var(--muted-color);
    font-weight: 600;
}
/* **جديد**: تنسيق المعدل الطبيعي */
.metric-card .metric-body .normal-range {
    font-size: 0.8rem;
    font-weight: 400;
    color: var(--muted-color);
    margin-top: 0.25rem;
}

.metric-card .metric-footer {
    padding: 1rem;
    background-color: var(--bg-white);
    border-top: 1px solid var(--border-color);
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
}
.metric-card .metric-footer .interpretation {
    font-size: 0.95rem;
    line-height: 1.6;
}

/* **جديد**: تنسيق أعمدة التقرير */
.report-columns {
    display: grid;
    grid-template-columns: 1fr;
    gap: 1.5rem;
    align-items: flex-start;
}


/* --- Professional Tables (New) --- */
.diet-table-container, .workout-table-container, .supplements-table-container, .habit-tracker-table-container {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-lg);
    overflow-x: auto; /* Allow horizontal scroll on small tables */
    box-shadow: var(--shadow-sm);
}
.diet-table, .workout-table, .supplements-table, .habit-tracker-table {
    width: 100%;
    border-collapse: collapse;
}
.diet-table th, .diet-table td,
.workout-table th, .workout-table td,
.supplements-table th, .supplements-table td,
.habit-tracker-table th, .habit-tracker-table td {
    padding: 0.75rem;
    text-align: right;
    border-bottom: 1px solid var(--border-color);
    vertical-align: middle;
    font-size: 0.9rem;
}
.diet-table thead th, .workout-table thead th, .supplements-table thead th, .habit-tracker-table thead th {
    background-color: var(--bg-light-gray);
    font-weight: 700;
    font-size: 0.95rem;
}
.diet-table tbody tr:last-child td,
.workout-table tbody tr:last-child td,
.supplements-table tbody tr:last-child td,
.habit-tracker-table tbody tr:last-child td {
    border-bottom: none;
}
.diet-table tbody tr:hover,
.workout-table tbody tr:hover,
.supplements-table tbody tr:hover,
.habit-tracker-table tbody tr:hover {
    background-color: var(--bg-light-gray);
}
.workout-name, .supplement-name {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    font-weight: 600;
}
.workout-name i, .supplement-name i {
    font-size: 1.5rem;
    color: var(--primary-color);
}

/* --- Habit Tracker (New) --- */
.tracker-goals-header {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(150px, 1fr));
    gap: 1rem;
    background-color: var(--bg-light-gray);
    padding: 1rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 1.5rem;
    text-align: center;
}
.goal-item label {
    font-size: 0.9rem;
    font-weight: 600;
    color: var(--muted-color);
    display: block;
    margin-bottom: 0.25rem;
}
.goal-item .value {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--primary-color);
}
.goal-item .target {
    font-size: 1.2rem;
    font-weight: 700;
    color: var(--dark-color);
}
.habit-tracker-table td:not(:first-child) {
    width: 50px;
    height: 50px;
    border-left: 1px solid var(--border-color);
    cursor: pointer;
}
.habit-tracker-table td:last-child {
    border-left: none;
}


/* Smart Tip Card */
.smart-tip-card {
    background-color: #eef7ff;
    border-left: 5px solid #3b82f6;
}
.smart-tip-intro {
    text-align: center;
    margin-bottom: 1.5rem;
}
.smart-tip-intro h4 {
    font-size: 1.3rem;
    color: #1e3a8a;
    margin-bottom: 0.5rem;
}
.smart-tip-intro p {
    font-size: 1rem;
    color: #4a5568;
    max-width: 700px;
    margin: auto;
}
.package-features-list {
    list-style: none;
    padding: 0;
    margin: 1.5rem auto 0 auto;
    max-width: 500px;
}
.package-features-list li {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    background-color: rgba(255,255,255,0.6);
    padding: 0.75rem 1rem;
    border-radius: var(--border-radius-md);
    margin-bottom: 0.5rem;
    font-weight: 500;
}
.package-features-list li i {
    color: var(--secondary-color);
    font-size: 1.4rem;
}

/* Motivation Card */
.motivation-card {
    background: linear-gradient(45deg, var(--primary-color), var(--primary-darker));
    color: white;
    text-align: center;
    padding: 2rem;
}
.motivation-card p {
    font-size: 1.2rem;
    font-weight: 700;
    line-height: 1.8;
}

/* Report Actions */
.report-actions {
    display: flex;
    justify-content: center;
    gap: 1rem;
    margin-top: 2rem;
}

/* ---------------------------------- */
/* 7. Modal & Loader Styles           */
/* ---------------------------------- */

/* --- Analysis Loader Modal (NEW) --- */
.loader-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(8px);
    -webkit-backdrop-filter: blur(8px);
    z-index: 3000;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 1rem;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s ease, visibility 0s 0.3s;
}
.loader-overlay.active {
    opacity: 1;
    visibility: visible;
    transition: opacity 0.3s ease;
}
.loader-modal {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    padding: 2.5rem;
    width: 100%;
    max-width: 500px;
    text-align: center;
    box-shadow: var(--shadow-lg);
    transform: scale(0.9);
    transition: transform 0.4s cubic-bezier(0.34, 1.56, 0.64, 1);
}
.loader-overlay.active .loader-modal {
    transform: scale(1);
}
.loader-modal .loader-icon i {
    font-size: 4rem;
    color: var(--primary-color);
    animation: pulse 2s infinite ease-in-out;
}
@keyframes pulse {
    0% { transform: scale(1); }
    50% { transform: scale(1.1); }
    100% { transform: scale(1); }
}
.loader-modal h3 {
    font-size: 1.5rem;
    margin: 1.5rem 0 0.5rem 0;
}
.loader-modal p {
    color: var(--muted-color);
    font-size: 1.1rem;
    margin-bottom: 2rem;
}
.progress-bar-container {
    height: 1.75rem;
    background-color: var(--border-color);
    border-radius: 50px;
    position: relative;
    overflow: hidden;
}
.progress-bar {
    height: 100%;
    width: 0%;
    background: linear-gradient(90deg, var(--primary-color), #34d399);
    border-radius: 50px;
    transition: width 0.4s ease-in-out;
    display: flex;
    align-items: center;
    justify-content: center;
}
.progress-bar-percentage {
    color: white;
    font-weight: 700;
    font-size: 0.9rem;
    text-shadow: 1px 1px 2px rgba(0,0,0,0.2);
}

/* **جديد**: قائمة خطوات التحميل الديناميكية */
.loader-steps {
    list-style: none;
    padding: 0;
    margin: 2rem 0 0 0;
    text-align: right;
    width: 100%;
}
.loader-step-item {
    display: flex;
    align-items: center;
    gap: 0.75rem;
    padding: 0.6rem 0;
    font-size: 1rem;
    color: var(--muted-color);
    opacity: 0.7;
    transition: all 0.4s ease;
    border-bottom: 1px solid var(--border-color);
}
.loader-step-item:last-child {
    border-bottom: none;
}
.loader-step-item i {
    font-size: 1.4rem;
    transition: all 0.3s;
}
.loader-step-item.active {
    color: var(--dark-color);
    font-weight: 600;
    opacity: 1;
}
.loader-step-item.active i {
    color: var(--primary-color);
    animation: spin 1.5s linear infinite;
}
.loader-step-item.completed {
    color: var(--muted-color);
    opacity: 1;
}
.loader-step-item.completed span {
    color: var(--muted-color);
    text-decoration: line-through;
}
.loader-step-item.completed i {
    color: var(--success-color);
    animation: none; /* Stop spinning */
}


/* --- Generic Package Modal --- */
.modal-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
    display: flex;
    align-items: center;
    justify-content: center;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.modal-overlay.active {
    opacity: 1;
    visibility: visible;
}
.modal-container {
    background: var(--bg-white);
    border-radius: var(--border-radius-lg);
    width: 90%;
    max-width: 650px;
    max-height: 90vh;
    box-shadow: var(--shadow-lg);
    transform: scale(0.95);
    transition: transform 0.3s;
    display: flex;
    flex-direction: column;
    overflow: hidden;
}
.modal-overlay.active .modal-container {
    transform: scale(1);
}
.modal-image-header {
    height: 220px; background-size: cover; background-position: center; position: relative;
    display: flex; align-items: flex-end; padding: 1.5rem; color: white;
}
.modal-image-header::after {
    content: ''; position: absolute; top: 0; left: 0; width: 100%; height: 100%;
    background: linear-gradient(to top, rgba(0,0,0,0.8), transparent);
}
.modal-image-header h2 { font-size: 2rem; font-weight: 800; z-index: 1; text-shadow: 1px 1px 5px rgba(0,0,0,0.7); }
.modal-close-btn {
    position: absolute; top: 15px; left: 15px; background: rgba(0,0,0,0.4); color: white;
    border: none; border-radius: 50%; width: 40px; height: 40px; font-size: 1.5rem;
    cursor: pointer; z-index: 2; display: flex; align-items: center; justify-content: center;
    transition: all 0.3s;
}
.modal-close-btn:hover { background: rgba(0,0,0,0.7); transform: rotate(90deg); }
.modal-body { padding: 1.5rem 2rem; overflow-y: auto; }
.modal-price-tag {
    display: flex; gap: 1rem; align-items: baseline; background-color: var(--bg-light-gray);
    color: var(--dark-color); padding: 1rem 1.5rem; border-radius: var(--border-radius-md); margin-bottom: 1.5rem;
}
.modal-price-tag .current-price { font-size: 2rem; font-weight: 800; color: var(--primary-color); }
.modal-price-tag .original-price { font-size: 1.2rem; opacity: 0.8; text-decoration: line-through; }
.modal-section { margin-bottom: 1.5rem; }
.modal-section h3 { display: flex; align-items: center; gap: 0.5rem; font-size: 1.2rem; color: var(--dark-color); margin-bottom: 0.75rem; }
.modal-section p { font-size: 1rem; line-height: 1.8; color: var(--muted-color); }
.modal-footer { padding: 1.5rem 2rem; background: var(--bg-light-gray); border-top: 1px solid var(--border-color); text-align: center; margin-top: auto; }


/* Mobile Side Nav */
.mobile-nav-overlay {
    position: fixed; top: 0; left: 0; width: 100%; height: 100%;
    background: rgba(17, 24, 39, 0.8);
    backdrop-filter: blur(5px);
    z-index: 2000;
    justify-content: flex-end; /* Align nav to the right */
    display: flex;
    opacity: 0;
    visibility: hidden;
    transition: opacity 0.3s, visibility 0.3s;
}
.mobile-nav-overlay.active {
    opacity: 1;
    visibility: visible;
}
.mobile-nav-overlay.active .mobile-nav {
    transform: translateX(0);
}
.mobile-nav {
    position: fixed;
    top: 0;
    right: 0;
    width: 80%;
    max-width: 320px;
    height: 100%;
    background: var(--bg-white);
    box-shadow: -5px 0 20px rgba(0,0,0,0.1);
    transform: translateX(100%);
    transition: transform 0.3s ease-in-out;
    display: flex;
    flex-direction: column;
}
.mobile-nav-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 1rem 1.5rem;
    border-bottom: 1px solid var(--border-color);
}
.mobile-nav-header .logo a {
    font-size: 1.2rem;
}
.mobile-nav-close {
    background: none;
    border: none;
    font-size: 2rem;
    color: var(--muted-color);
    cursor: pointer;
}
.mobile-nav ul {
    list-style: none;
    padding: 1rem 0;
}
.mobile-nav ul li a {
    display: block;
    padding: 1rem 1.5rem;
    text-decoration: none;
    color: var(--dark-color);
    font-weight: 600;
    font-size: 1.1rem;
    border-bottom: 1px solid var(--border-color);
    transition: background-color 0.2s;
}
.mobile-nav ul li a:hover {
    background-color: var(--bg-light-gray);
}


/* Bottom Mobile Nav */
.bottom-mobile-nav {
    display: flex;
    position: fixed;
    bottom: 0;
    left: 0;
    right: 0;
    background-color: var(--bg-white);
    box-shadow: 0 -2px 10px rgba(0,0,0,0.1);
    z-index: 1000;
    border-top: 1px solid var(--border-color);
}
.bottom-mobile-nav a {
    flex: 1;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    padding: 0.5rem 0;
    text-decoration: none;
    color: var(--muted-color);
    font-size: 0.75rem;
    transition: color 0.2s;
}
.bottom-mobile-nav a i {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}
.bottom-mobile-nav a.active {
    color: var(--primary-color);
}
.bottom-mobile-nav a.bottom-nav-main-action {
    color: var(--light-color);
    transform: translateY(-20px);
}
.bottom-mobile-nav a.bottom-nav-main-action i {
    background-color: var(--primary-color);
    border-radius: 50%;
    width: 60px;
    height: 60px;
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.8rem;
    box-shadow: var(--shadow-lg);
    border: 4px solid var(--bg-white);
}
.bottom-mobile-nav a.bottom-nav-main-action span {
    color: var(--primary-color);
    font-weight: 700;
    margin-top: 0.25rem;
}

/* ---------------------------------- */
/* 8. Responsive & Print Styles       */
/* ---------------------------------- */
@media (min-width: 768px) {
    .analysis-container {
        padding: 2.5rem;
    }
    .features-grid {
        grid-template-columns: repeat(3, 1fr);
    }
    .packages-grid {
        grid-template-columns: repeat(auto-fill, minmax(320px, 1fr));
    }
    .alternating-layout {
        grid-template-columns: 1fr 1fr;
        gap: 4rem;
    }
    .alternating-layout .layout-text {
        text-align: right; /* Align text to the right on desktop */
    }
    .alternating-layout .layout-text ul {
        display: block; /* Reset from inline-block */
    }
    .kpi-grid {
        grid-template-columns: repeat(4, 1fr);
    }
    .analysis-grid {
        grid-template-columns: repeat(2, 1fr);
    }
    .progress-item {
        grid-template-columns: 1fr 1fr;
        gap: 2rem;
    }
    .progress-item .item-date {
        border-bottom: none;
        border-left: 1px solid var(--border-color);
        padding-bottom: 0;
        padding-left: 2rem;
        text-align: right;
    }
    .progress-item .item-metrics-grid {
        padding: 0;
    }
    .progress-item .item-action {
        grid-column: 1 / -1; /* Span full width */
        padding-top: 1rem;
        margin-top: 1rem;
        border-top: 1px solid var(--border-color);
    }
    .report-columns {
        grid-template-columns: 1fr 1fr;
    }
}

@media (min-width: 992px) {
    body {
        padding-bottom: 0; /* Remove padding on desktop */
    }
    .site-header .main-nav {
        display: block; /* Show main nav on desktop */
    }
    .bottom-mobile-nav {
        display: none; /* Hide bottom nav on desktop */
    }
    .progress-item {
        grid-template-columns: auto 1fr auto;
        gap: 1rem;
    }
    .progress-item .item-date {
        border-left: none;
        padding-left: 0;
    }
    .progress-item .item-action {
        grid-column: auto;
        border-top: none;
        margin-top: 0;
        padding-top: 0;
    }
    .analysis-grid {
        grid-template-columns: repeat(3, 1fr);
    }
}

/******************************************/
/* 9. PRINT STYLES - PROFESSIONAL REDESIGN */
/******************************************/
@media print {
    @page {
        size: A4;
        margin: 0.7cm;
    }
    body {
        background-color: #fff !important;
        color: #000 !important;
        font-size: 9pt;
        line-height: 1.4;
        -webkit-print-color-adjust: exact !important;
        color-adjust: exact !important;
        padding-bottom: 0;
    }
    .report-wrapper {
        max-width: 100%;
        margin: 0 !important;
        padding: 0 !important;
        box-shadow: none !important;
    }
    .report-card {
        box-shadow: none !important;
        border: 1px solid #e0e0e0;
        border-radius: var(--border-radius-md);
        margin-bottom: 0.4cm;
        page-break-inside: auto; /* **تعديل**: السماح للبطاقات الكبيرة بالتقسيم */
    }
    .report-card .card-header {
        padding: 0.4rem 0.6rem;
        font-size: 11pt; 
        background-color: #f8f9fa !important;
    }
    .report-card .card-body {
        padding: 0.6rem;
    }
    .report-header h1 { font-size: 18pt; margin-bottom: 0.2cm; }
    .report-header p { font-size: 10pt; }
    .summary-card .card-body p { font-size: 10pt; }
    
    .report-columns {
        display: block; /* **تعديل**: تحويل الأعمدة إلى كتل متتالية للطباعة */
        columns: 1;
    }

    /* **تعديل**: تنسيق شبكة التحليل للطباعة */
    .analysis-grid {
        grid-template-columns: repeat(3, 1fr) !important;
        gap: 0.3cm;
    }
    .metric-card {
        page-break-inside: avoid; /* منع تقسيم بطاقات المؤشرات الصغيرة */
    }
    .metric-card .metric-header { padding: 0.3rem; }
    .metric-card .metric-header h4 { font-size: 8pt; }
    .metric-card .metric-body { padding: 0.4rem; }
    .metric-card .metric-body .value { font-size: 13pt; }
    .metric-card .metric-body .range { font-size: 8pt; }
    .metric-card .metric-body .normal-range { font-size: 7pt; margin-top: 1px; }
    .metric-card .metric-footer { padding: 0.5rem; }
    .metric-card .metric-footer .interpretation { font-size: 7.5pt; line-height: 1.5; }

    /* --- Compact Tables Styling for Print --- */
    .plan-section { padding-bottom: 0; margin-bottom: 0; border: none;}
    .plan-title { font-size: 11pt; margin-bottom: 0.2cm; }
    .plan-intro { font-size: 8.5pt; margin-bottom: 0.3cm; line-height: 1.5; }
    
    .diet-table-container, .workout-table-container, .supplements-table-container, .habit-tracker-table-container {
        border-radius: var(--border-radius-md);
        overflow: hidden;
    }
    .diet-table, .workout-table, .supplements-table, .habit-tracker-table {
        width: 100%;
    }
    .diet-table th, .diet-table td,
    .workout-table th, .workout-table td,
    .supplements-table th, .supplements-table td {
        padding: 0.3rem;
        font-size: 7.5pt;
        text-align: right;
        border: 1px solid #eee;
    }
    .diet-table tr, .workout-table tr, .supplements-table tr {
        page-break-inside: avoid; /* **تعديل**: منع تقسيم صفوف الجداول */
    }
    .diet-table thead th, .workout-table thead th, .supplements-table thead th {
        font-size: 8pt;
        padding: 0.4rem 0.3rem;
    }
    .workout-name i, .supplement-name i { font-size: 1.2rem; }

    /* --- Habit Tracker & Motivation Print Styles --- */
    .habit-tracker-table td:not(:first-child) {
        height: 0.8cm;
    }

    /* --- Smart Tip card for print --- */
    .smart-tip-card { padding: 0.6rem; }
    .smart-tip-intro h4 { font-size: 10pt; }
    .smart-tip-intro p { font-size: 9pt; }
    .package-features-list li { font-size: 8pt; padding: 0.2rem 0.4rem; }
    
    /* --- Motivation card for print --- */
    .motivation-card { padding: 1rem; }
    .motivation-card p { font-size: 10pt; }

    /* Hide everything else */
    .no-print, .site-header, .site-footer, .page-hero, .filters-container, .report-actions, .modal-overlay, .smart-tip-card .btn, .bottom-mobile-nav, .loader-overlay {
        display: none !important;
    }
}
" in the document.

أعد ترتيب بطاقات "نظرة معمقة على مؤشرات جسمك" في التقرير المطبوع فقط لتكون بهذا الترتيب: الوزن، نسبة الدهون، الدهون الحشوية في الصف الأول، ثم كتلة العضلات، مؤشر كتلة الجسم، ومعدل الحرق اليومي في الصف الثاني. يجب أن يبقى الترتيب كما هو على الشا