/* General Body Styles */
body {
    font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
    margin: 0;
    padding: 10px;
    background-color: #f4f7f6; /* Light background */
    display: flex;
    justify-content: center;
    align-items: flex-start; /* Align to top for longer content */
    min-height: 100vh;
    /* direction and text-align handled by JavaScript */
}

/* Main Container - NOW HALF WIDTH */
.container {
    background-color: #ffffff;
    border-radius: 7px; /* Matches previous good version */
    box-shadow: 0 4px 15px rgba(0, 0, 0, 0.1); /* Matches previous good version */
    padding: 10px; /* Matches previous good version */
    width: 98%;
    max-width: 650px; /* HALF of 950px - The requested change */
    display: flex;
    flex-direction: column;
    gap: 10px; /* Increased gap slightly for better separation */
    box-sizing: border-box;
    position: relative; 
}

/* Header Section (Title and Language Selector) */
.header-section {
    text-align: center;
    padding-bottom: 8px; 
    border-bottom: 1px solid #eee;
    margin-bottom: 10px; 
}

.app-title {
    color: #1976d2;       /* أزرق عصري */
    font-weight: bold;    /* خط بولد */
    font-size: 2.3em;     /* أكبر لشاشات الكمبيوتر */
    margin-bottom: 16px;  /* مسافة أسفل العنوان */
    text-align: center;
    line-height: 1.2;
}

.language-selector {
    display: flex;
    justify-content: center;
    gap: 8px;
    padding-top: 5px; 
    padding-bottom: 5px; 
}

.language-selector label {
    margin: 0;
    font-size: 0.8em;
    color: #555;
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 3px;
    position: relative;
}

/* Custom Radio Button Styles (retained from previous good version) */
.language-selector input[type="radio"] {
    appearance: none;
    -webkit-appearance: none;
    width: 12px;
    height: 12px;
    border: 2px solid #ccc;
    border-radius: 50%;
    outline: none;
    cursor: pointer;
    position: relative;
    display: inline-block;
    vertical-align: middle;
    flex-shrink: 0;
}

.language-selector input[type="radio"]:checked {
    border-color: #007bff;
    background-color: #007bff;
}

.language-selector input[type="radio"]:checked::before {
    content: '';
    display: block;
    width: 5px;
    height: 5px;
    background: white;
    border-radius: 50%;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
}

/* Main Content Area - New wrapper for columns */
.main-content {
    display: flex;
    flex-direction: column; /* Default stack on small screens */
    gap: 10px; /* Gap for sections within main-content */
}

/* Wrapper for the two main columns */
.main-content-columns-wrapper {
    display: flex;
    flex-direction: column; /* Default stack on small screens */
    gap: 10px; /* Gap between columns when stacked */
    flex-wrap: wrap; /* Allow columns to wrap */
    justify-content: center; /* Center columns when wrapped/stacked */
    align-items: flex-start; /* Align columns to the top */
}

/* Column styles */
.input-column,
.output-column {
    display: flex;
    flex-direction: column;
    gap: 5px; /* Space between cards within a column */
    /* flex: 1 1 45%; This was the previous flex */
    min-width: 98px; /* Adjusted min-width for narrower overall layout */
}

/* Input Cards (Location & Measurement) */
.input-card { 
    background-color: #e9ecef; /* Matches previous good version */
    border-radius: 6px; /* Matches previous good version */
    padding: 2px; /* Matches previous good version */
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.05); /* Matches previous good version */
    flex-grow: 1; /* Allow cards to grow and fill available space in their column */
}

.input-card h2 {
    color: #34495e;
    font-size: 1.1em; /* Matches previous good version */
    margin-bottom: 5px; 
    border-bottom: 1px solid #dcdfe4;
    padding-bottom: 5px; 
    text-align: center; 
}

.form-group {
    margin-bottom: 8px; /* Matches previous good version */
}

.form-group label {
    display: block;
    margin-bottom: 5px; 
    color: #4a6572;
    font-weight: bold;
    font-size: 0.9em; /* Matches previous good version */
}

/* General style for number and select inputs - ADJUSTED FONT SIZE */
.form-group input[type="number"],
.form-group input[type="date"], 
.form-group select {
    width: 98%; 
    height: 24px; /* Reduced height by half from 28px approx. for smaller look */
    padding: 0 4px; /* Matches previous good version */
    border: 1px solid #ced4da;
    border-radius: 5px;
    font-size: 0.9em; /* INCREASED FONT SIZE for desktop */
    background-color: #f8f9fa;
    box-sizing: border-box;
    line-height: 24px; /* Match new height for vertical centering */
    -webkit-appearance: none; 
    -moz-appearance: none;
    appearance: none;
}

/* Custom arrow for selects (retained) */
.form-group select {
    background-image: url('data:image/svg+xml;utf8,<svg fill="%234a6572" height="24" viewBox="0 0 24 24" width="24" xmlns="http://www.w3.org/2000/svg"><path d="M7 10l5 5 5-5z"/><path d="M0 0h24v24H0z" fill="none"/></svg>');
    background-repeat: no-repeat;
    background-position: right 5px top 50%; 
    background-size: 20px;
    padding-inline-end: 28px; 
}

/* RTL adjustment for select arrow (retained) */
[dir="rtl"] .form-group select {
    background-position: left 8px top 50%; 
    padding-inline-start: 28px; 
    padding-inline-end: 4px; 
}


/* Output Card (Results Display) */
.output-card {
    background-color: #e0f2f7; /* Matches previous good version */
    border-radius: 5px; /* Matches previous good version */
    padding: 2px; /* Matches previous good version */
    box-shadow: 0 4px 8px 0 rgba(0, 0, 0, 0.05); /* Matches previous good version */
    display: unset;
    flex-direction: column;
    gap: 2px; /* Matches previous good version */
    visibility: hidden;
    opacity: 0;
    height: auto;
    max-height: 0;
    overflow: hidden;
    transition: visibility 0s, opacity 0.4s ease-in-out, max-height 0.4s ease-in-out;
    flex-grow: 1; /* Allow to fill space in output column */
}

.output-card.hidden {
    visibility: hidden;
    opacity: 0;
    max-height: 0;
}

.output-card.visible {
    visibility: visible;
    opacity: 1;
    max-height: 380px; /* Matches previous good version */
    transition: visibility 0s, opacity 0.4s ease-in-out, max-height 0.4s ease-in-out;
}

.output-card.male {
    background-color: #e0f2f7;
}

.output-card.female {
    background-color: #fce4ec;
}

.output-card h2 {
    color: #34495e;
    font-size: 1.1em; /* Matches previous good version */
    margin-bottom: 5px; 
    border-bottom: 1px solid #dcdfe4;
    padding-bottom: 5px; 
    text-align: center; 
}

.indicator-results {
    display: flex;
    flex-direction: column;
    gap: 5px; /* Matches previous good version */
    background-color: transparent;
    border: none;
    border-radius: 0;
    padding: 0;
    min-height: 10px;
    justify-content: center;
    align-items: center;
}

/* --- Indicator Name and Value Formatting (retained) --- */
.indicator-item {
    display: flex;
    flex-direction: column;
    align-items: center;
    background-color: #f8f9fa;
    border-radius: 6px;
    padding: 6px; /* Matches previous good version */
    box-shadow: 0 1px 4px rgba(0, 0, 0, 0.05);
    margin-bottom: 0;
    width: 98%;
    box-sizing: border-box;
    border: 1px solid #e0e0e0;
}

.indicator-name {
    font-weight: bold;
    color: #007bff;
    font-size: 0.95em; /* Matches previous good version */
    margin-bottom: 3px; 
    flex-shrink: 0;
    text-align: center;
    width: 100%;
}

.indicator-value {
    font-size: 0.85em; /* Matches previous good version */
    font-weight: bold;
    padding: 0;
    border-radius: 0;
    background-color: transparent;
    text-align: center;
    white-space: normal; 
    flex-grow: 1;
    display: flex;
    align-items: center;
    justify-content: center;
    flex-wrap: wrap;
    color: inherit;
}
/* --------------------------------------------------- */

/* Original Color grading for results (to be replaced or overridden) */
/* .severe-color { color: #dc3545; } */
/* .moderate-color { color: #fd7e14; } */
/* .normal-color { color: #28a745; } */

.indicator-value .sd-range-text {
    display: inline-block; /* يجب أن يكون inline-block */
    font-size: 0.9em; /* Matches previous good version */
    font-weight: normal;
    opacity: 0.9;
    vertical-align: middle; /* للمحاذاة العمودية */
    position: relative; /* لتمكين استخدام 'top' للتعديل الدقيق */
    top: 0px; /* للبدء من 0 ثم التعديل الدقيق إذا لزم الأمر */
    direction: ltr !important; /* التعديل الحاسم: فرض اتجاه النص LTR لهذا العنصر */
    unicode-bidi: isolate; /* يساعد في التعامل مع النص المختلط الاتجاهات */
}

/* Adjust margins based on overall page direction */
[dir="rtl"] .indicator-value .sd-range-text {
    margin-right: 8px; /* مسافة على اليمين عندما تكون الصفحة RTL (لغة عربية) */
}

[dir="ltr"] .indicator-value .sd-range-text {
    margin-left: 8px; /* مسافة على اليسار عندما تكون الصفحة LTR (لغة إنجليزية) */
}


.indicator-value.full-message {
    white-space: normal;
    flex-grow: 1;
    text-align: center;
}

/* Message Card */
.message-card {
    background-color: #f8f9fa; /* Matches previous good version */
    border-radius: 8px; /* Matches previous good version */
    padding: 1px; /* Matches previous good version */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* Matches previous good version */
    margin-top: 0; 
    flex-grow: 1; /* Allow to fill space in output column */
}

.message-card h2 {
    color: #34495e;
    font-size: 1.1em; /* Matches previous good version */
    margin-bottom: 5px; 
    border-bottom: 1px solid #dcdfe4;
    padding-bottom: 5px; 
    text-align: center; 
}

/* Specific alignment for message text based on HTML dir attribute (retained) */
.message-card .message-text {
    font-size: 0.9em; /* Matches previous good version */
    color: #4a6572;
    line-height: 1.5; 
    text-align: initial; 
}

/* Action Buttons Container (new structure for button grouping) */
.action-buttons-container {
    display: flex;
    flex-direction: column;
    gap: 10px; /* Gap between consent, single buttons, and button rows */
    margin-top: 15px; /* Spacing from the columns above */
    padding: 0 10px; /* Horizontal padding */
    width: 100%; /* Take full width of container */
    max-width: 450px; /* Constrain width to align with inputs/outputs better in smaller container */
    margin-left: auto; /* Center */
    margin-right: auto; /* Center */
}

/* NEW: Consent Checkbox Styling (retained from previous good version) */
.consent-checkbox-group {
    
    display: flex; 
    align-items: flex-start; 
    gap: 8px; 
    margin-bottom: 15px; 
    background-color: #f0f8ff;
    border: 1px solid #cceeff;
    border-radius: 5px;
    padding: 10px;
    
}

.consent-checkbox-group input[type="checkbox"] {
    flex-shrink: 0; 
    width: 18px; 
    height: 18px; 
    margin-top: 2px; 
    border: 2px solid #007bff; 
    border-radius: 3px; 
    appearance: none; 
    -webkit-appearance: none;
    cursor: pointer;
    position: relative;
    outline: none;
}

.consent-checkbox-group input[type="checkbox"]:checked {
    background-color: #007bff; 
    border-color: #007bff;
}

.consent-checkbox-group input[type="checkbox"]:checked::before {
    content: '✔'; 
    display: block;
    position: absolute;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    font-size: 14px;
    color: white;
}

.consent-label {
    font-size: 0.85em; 
    color: #333;
    cursor: pointer;
    line-height: 1.4; 
    flex-grow: 1; 
}

/* Buttons */
.btn {
    padding: 10px 15px; /* Matches previous good version */
    border: none;
    border-radius: 5px; /* Matches previous good version */
    cursor: pointer;
    font-size: 1em; /* Matches previous good version */
    font-weight: bold;
    transition: background-color 0.3s ease, transform 0.2s ease;
    text-align: center;
}

.btn:hover {
    transform: translateY(-2px);
}

.calculate-btn {
    background-color: #28a745;
    color: white;
}

.calculate-btn:hover {
    background-color: #218838;
}

.reset-btn {
    background-color: #6c757d;
    color: white;
}

.reset-btn:hover {
    background-color: #5a6268;
}

.secondary-btn { /* New style for 'View Growth' buttons */
    background-color: #6c757d; /* Grey/Blue for secondary actions */
    color: #fff;
    box-shadow: 0 4px 8px rgba(108, 117, 125, 0.2);
}

.secondary-btn:hover {
    background-color: #5a6268;
    transform: translateY(-2px);
    box-shadow: 0 6px 12px rgba(108, 117, 125, 0.3);
}

/* Button layout: single row for calculate/reset, horizontal row for view buttons */
.buttons-single-row { /* For calculate and reset buttons */
    display: flex;
    width: 100%;
}
.buttons-single-row .btn {
    flex-grow: 1; /* Button fills the row */
    min-width: unset; 
}

.buttons-row-horizontal { /* For view growth history/charts buttons */
    display: flex;
    gap: 10px; /* Space between the two buttons */
    flex-wrap: wrap; /* Allow wrapping on small screens */
    justify-content: center; /* Center buttons when wrapped */
    width: 100%;
}
.buttons-row-horizontal .btn {
    flex: 1 1 auto; /* Allow buttons to grow/shrink based on content, auto-width */
    min-width: 120px; /* Adjusted min-width for narrower overall layout */
}


/* Footer Details Card */
.footer-details-card {
    background-color: #f0f0f0; /* Matches previous good version */
    border-radius: 8px; /* Matches previous good version */
    box-shadow: 0 2px 8px rgba(0, 0, 0, 0.05); /* Matches previous good version */
    padding: 12px; /* Matches previous good version */
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 5px;
    margin-top: 15px; /* Spacing from buttons above */
    width: 68%;
    max-width: 950px; /* Constrain width to align with inputs/outputs better in smaller container */
    margin-left: auto; /* Center */
    margin-right: auto; /* Center */
}

.designer-info {
    font-size: 0.9em;
    color: #777;
    text-align: initial; 
    margin: 0;
}

.designer-info p {
    margin: 0;
}

.about-btn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.85em; /* Adjusted font size for smaller buttons */
    margin-inline-start: auto;
    background-color: #007bff;
    color: white;
}

.about-btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.articles-Btn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.85em; /* Adjusted font size for smaller buttons */
    margin-inline-start: auto;
    background-color: #007bff;
    color: white;
}

.articles-Btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}

.questions-Btn {
    flex-shrink: 0;
    padding: 8px 12px;
    font-size: 0.85em; /* Adjusted font size for smaller buttons */
    margin-inline-start: auto;
    background-color: #007bff;
    color: white;
}

.questions-Btn:hover {
    background-color: #0056b3;
    transform: translateY(-2px);
}


/* Ad Space (at the very bottom of the container) */
.ad-space {
    background-color: #f0f0f0; /* Matches previous good version */
    border: 1px dashed #ccc; /* Matches previous good version */
    padding: 15px; /* Matches previous good version */
    text-align: center;
    color: #777;
    border-radius: 8px; /* Matches previous good version */
    margin-top: 15px;
    font-size: 0.85em;
    width: 100%;
    max-width: 450px; /* Constrain width to align with other central elements */
    margin-left: auto; /* Center */
    margin-right: auto; /* Center */
}

.ad-space a {
    color: #007bff;
    text-decoration: none;
    font-weight: bold;
}

.ad-space a:hover {
    text-decoration: underline;
}

/* Modals (Growth History & Growth Charts) - Retained styles */
.modal {
    display: none; 
    position: fixed; 
    /* تم تغيير z-index لضمان ظهور النوافذ المنبثقة فوق المحتوى الآخر */
    z-index: 100; /* قيمة أعلى لضمان الظهور الصحيح */
    left: 0;
    top: 0;
    width: 100%; 
    height: 100%; 
    overflow: auto; 
    background-color: rgba(0,0,0,0.4); 
    padding-top: 60px;
    box-sizing: border-box;
}

.modal-content {
    background-color: #fefefe;
    margin: 5% auto;
    padding: 20px;
    border: 1px solid #888;
    border-radius: 8px;
    width: 98vw;         /* تقريبًا كل عرض الشاشة */
    max-width: 800px;   /* أو 98vw، حسب عدد الأعمدة والشاشة */
    min-width: 350px;
    box-shadow: 0 4px 8px 0 rgba(0,0,0,0.2), 0 6px 20px 0 rgba(0,0,0,0.19);
    position: relative;
    box-sizing: border-box;
    overflow-x: auto;    /* يضيف سكرول أفقي داخلي عند الحاجة */
}

.modal-content h2 {
    color: #34495e;
    font-size: 1.3em;
    margin-bottom: 15px;
    text-align: center;
    border-bottom: 1px solid #ddd;
    padding-bottom: 10px;
}

.modal-message {
    text-align: center;
    color: #777;
    margin-bottom: 15px;
    font-size: 1em;
}

.modal .close-button {
    color: #aaa;
    float: right;
    font-size: 28px;
    font-weight: bold;
    position: absolute;
    top: 10px;
    right: 20px; 
    left: auto; 
    cursor: pointer;
    transition: 0.3s;
}

.modal.rtl .close-button {
    right: auto;
    left: 20px; 
}

.modal .close-button:hover,
.modal .close-button:focus {
    color: #000;
    text-decoration: none;
}

/* Table styles (retained) */
.table-container {
    /*max-height: 400px; */
    /*overflow-y: auto;*/ 
    margin-top: 10px;
    border: 1px solid #e0e0e0;
    border-radius: 6px;
    box-shadow: inset 0 0 5px rgba(0,0,0,0.05);
}

#growthHistoryTable {
    width: 100%;
    border-collapse: collapse;
    margin-bottom: 15px;
    font-size: 0.85em;
}

#growthHistoryTable th,
#growthHistoryTable td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: center; 
}

#growthHistoryTable th {
    background-color: #f2f2f2;
    color: #333;
    font-weight: bold;
    position: sticky; 
    top: 0;
    z-index: 10; 
}

#growthHistoryTable tr:nth-child(even) {
    background-color: #f9f9f9;
}

#growthHistoryTable tr:hover {
    background-color: #f1f1f1;
}

/* RTL adjustments for modal and table (retained) */
.modal[dir="rtl"] .modal-content {
    margin: 5% auto;
}

.modal[dir="rtl"] .modal-content h2 {
    text-align: center; 
}

.modal[dir="rtl"] .close-button {
    float: left; 
    right: auto;
    left: 20px;
}

/* Make table content LTR for numbers and specific text */
#growthHistoryTable th,
#growthHistoryTable td {
    direction: ltr; 
}

#growthHistoryTable th#dateCol,
#growthHistoryTable td { 
    text-align: initial; /* Adjusted for consistency, dates/text can vary */
}

/* NEW: Style for the delete button in the history table */
.delete-btn-red-border {
    background-color: #dc3545; /* Bootstrap 'danger' red */
    color: white;
    border: 1px solid #dc3545; /* Red border */
    border-radius: 4px; /* Slightly rounded corners */
    padding: 6px 10px; /* Smaller padding for table cell */
    font-size: 0.75em; /* Smaller font size */
    cursor: pointer;
    transition: background-color 0.2s ease, border-color 0.2s ease, transform 0.2s ease;
    box-shadow: 0 2px 4px rgba(0, 0, 0, 0.1);
}

.delete-btn-red-border:hover {
    background-color: #c82333; /* Darker red on hover */
    border-color: #bd2130;
    transform: translateY(-1px);
}

/* NEW: Style for child order input in table */
.child-order-input {
    width: 50px; /* Small width */
    padding: 3px 5px;
    border: 1px solid #ccc;
    border-radius: 3px;
    font-size: 0.8em;
    text-align: center;
    box-sizing: border-box;
}

/* Responsive adjustments */
@media (min-width: 450px) { /* NEW BREAKPOINT for side-by-side columns */
    .main-content-columns-wrapper {
        flex-direction: row; /* Side-by-side columns on screens >= 450px */
        justify-content: space-between;
        align-items: flex-start;
    }

    .input-column {
        flex: 0 0 30%; /* Make input column approx 35% narrower and fixed width */
        /* min-width: unset; removed, flex-basis handles it */
    }

    .output-column {
        flex: 1; /* Allow output column to take up remaining space */
        /* min-width: unset; removed */
    }

    .input-column .input-card,
    .output-column .output-card,
    .output-column .message-card {
        width: 100%; /* Make cards fill their column */
    }
}

@media (max-width: 449px) { /* Screens smaller than 450px will stack columns */
    body {
        padding: 8px;
    }

    .container {
        padding: 12px; 
        border-radius: 6px;
        gap: 10px; 
    }

    .header-section {
        padding-bottom: 6px; 
        margin-bottom: 8px; 
    }

    .app-title {
        font-size: 1.3em;
    }

    .language-selector {
        gap: 10px;
    }

    .language-selector label {
        font-size: 0.75em; 
        gap: 4px;
    }

    .language-selector input[type="radio"] {
        width: 13px;
        height: 13px;
    }

    .language-selector input[type="radio"]:checked::before {
        width: 5px;
        height: 5px;
    }

    .main-content {
        gap: 15px; 
    }
    
    .main-content-columns-wrapper {
        flex-direction: column; /* Ensure columns stack on small screens */
        gap: 15px;
    }

    .input-column,
    .output-column {
        min-width: unset; 
        width: 100%; /* Take full width on small screens */
    }

    /* Apply common mobile styles to all cards */
    .input-card, .output-card, .message-card, .footer-details-card, .ad-space {
        padding: 10px; 
        width: 88%; 
        max-width: unset; 
        min-width: unset;
    }
    
    .input-card h2,
    .output-card h2,
    .message-card h2 {
        font-size: 1.05em; 
        margin-bottom: 5px;
        padding-bottom: 5px;
    }

    .form-group label {
        font-size: 0.85em; 
        margin-bottom: 3px;
    }

    /* Inputs on mobile - Adjusted height and font size for small screens */
    .form-group input[type="number"],
    .form-group input[type="date"],
    .form-group select {
        height: 28px; /* Slightly larger height for better tap target on phones */
        padding: 0 8px; 
        font-size: 1em; /* INCREASED FONT SIZE for mobile */
        line-height: 28px; 
    }

    .action-buttons-container {
        gap: 10px; 
        margin-top: 15px; 
        padding: 0;
        width: 96%; 
        max-width: unset; 
        margin-left: auto;
        margin-right: auto;
    }

    .btn {
        width: auto;
        font-size: 1em; 
        padding: 10px 15px; 
    }
    
    .buttons-row-horizontal {
        flex-direction: column; /* Stack side-by-side buttons on very small screens */
    }

    .output-card.visible {
        max-height: 350px; 
    }

    .indicator-name {
        font-size: 0.9em; 
    }

    .indicator-value {
        font-size: 0.8em; 
    }

    .indicator-value .sd-range-text {
        font-size: 0.8em; /* Matches previous good version */
        /* مسافة على اليمين عندما تكون الصفحة RTL (لغة عربية) */
        /* هذه القيمة يجب أن تكون صريحة هنا لضمان التطبيق في الميديا كويري */
        margin-right: 8px; 
        /* مسافة على اليسار عندما تكون الصفحة LTR (لغة إنجليزية) */
        margin-left: initial; /* أو 0 لإلغاء أي تأثير سابق */
        
        position: relative; /* لإعطاء تحكم دقيق في الموقع */
        top: 0px; /* تم التعديل: لرفع النص قليلاً وتحقيق المحاذاة الدقيقة */
        direction: ltr !important; /* التعديل الحاسم: فرض اتجاه النص LTR لهذا العنصر */
        unicode-bidi: isolate; /* يساعد في التعامل مع النص المختلط الاتجاهات */
    }

    /* Override for LTR mode inside media query - if needed (redundant if direction:ltr!important works) */
    [dir="ltr"] .indicator-value .sd-range-text {
        margin-left: 8px;
        margin-right: initial;
    }

    .message-card .message-text {
        font-size: 0.85em; 
    }

    /* Footer Details Card on mobile */
    .footer-details-card {
        /*flex-direction: column;*/
        flex-direction: row;
        flex-wrap: wrap;
        justify-content: center;
        align-items: center;
        padding: 10px;
        gap: 8px;
        max-width: unset; 
        margin-left: unset;
        margin-right: unset;
    }
    .designer-info {
        text-align: center;
        /*width: 100%;*/
    }
    .designer-info p {
        font-size: 1.05em; /* أو أي حجم يناسبك */
        font-weight: bold;  /* (اختياري) لجعله أكثر وضوحاً */
        letter-spacing: 0.5px; /* (اختياري) لزيادة التباعد قليلاً */
        }

    .about-btn {
        margin-inline-start: unset;
        margin-top: 10px;
        width: auto;
        font-size: 0.8em; 
        padding: 8px 12px;
    }

    /* Ad Space section on mobile */
    .ad-space {
        padding: 12px;
        margin-top: 15px;
        font-size: 0.8em;
    }

    /* Modal on mobile */
    .modal-content {
        width: 95%; 
        margin: 20px auto; 
        padding: 15px;
    }

    .modal-content h2 {
        font-size: 1.2em;
    }

    .modal-message {
        font-size: 0.95em;
    }

    #growthHistoryTable {
        font-size: 0.75em; 
    }

    #growthHistoryTable th,
    #growthHistoryTable td {
        padding: 7px; 
    }
    /* Mobile specific style for the new delete button class */
    .delete-btn-red-border {
        padding: 5px 8px;
        font-size: 0.7em;
    }
    .child-order-input {
        width: 35px; /* Even smaller width on very small screens */
        font-size: 0.7em;
    }
}

/* Very Small Mobile Adjustments (e.g., iPhone SE/old devices) */
@media (max-width: 450px) { /* Even smaller breakpoint for very narrow phones */
    .container {
        padding: 1px;
        gap: 1px;
    }
    .header-section {
        padding-bottom: 5px;
        margin-bottom: 5px;
    }
    .app-title {
        font-size: 1.5em;
    }
    .language-selector {
        gap: 8px;
    }
    .language-selector label {
        font-size: 0.7em;
    }
    .language-selector input[type="radio"] {
        width: 11px;
        height: 11px;
    }
    .language-selector input[type="radio"]:checked::before {
        width: 4px;
        height: 4px;
    }
    .main-content {
        gap: 10px;
    }
    
    .main-content-columns-wrapper {
        gap: 10px;
    }

    .input-card {
        padding: 8px;
        margin: auto;
    }
    .input-card h2 {
        font-size: 0.9em;
        margin-bottom: 4px;
        padding-bottom: 4px;
    }
    .form-group {
        margin-bottom: 8px;
    }
    .form-group label {
        font-size: 0.8em;
        margin-bottom: 2px;
    }
    .form-group input[type="number"],
    .form-group input[type="date"],
    .form-group select {
        height: 24px; /* Maintain the smaller height for very small screens */
        padding: 0 6px; 
        font-size: 0.85em; /* INCREASED FONT SIZE for very small screens */
        line-height: 24px; 
    }
    .action-buttons-container {
        gap: 8px;
        margin-top: 10px;
    }
    .btn {
        font-size: 0.9em;
        padding: 8px 12px;
    }
    .output-card {
        padding: 10px;
        gap: 6px;
    }
    .output-card.visible {
        max-height: 290px; 
    }
    .output-card h2 {
        font-size: 0.9em;
        margin-bottom: 4px;
        padding-bottom: 4px;
        margin: auto;
    }
    .indicator-results {
        gap: 3px;
    }
    .indicator-item {
        padding: 6px;
    }
    .indicator-name {
        font-size: 0.8em;
        margin-bottom: 2px;
    }
    .indicator-value .sd-range-text {
        font-size: 0.8em; /* Matches previous good version */
        /* مسافة على اليمين عندما تكون الصفحة RTL (لغة عربية) */
        margin-right: 8px; 
        /* مسافة على اليسار عندما تكون الصفحة LTR (لغة إنجليزية) */
        margin-left: initial; 
        
        position: relative; /* لإعطاء تحكم دقيق في الموقع */
        top: 0px; /* تم التعديل: لرفع النص قليلاً وتحقيق المحاذاة الدقيقة */
        direction: ltr !important; /* التعديل الحاسم: فرض اتجاه النص LTR لهذا العنصر */
        unicode-bidi: isolate; /* يساعد في التعامل مع النص المختلط الاتجاهات */
    }

    /* Override for LTR mode inside very small media query */
    [dir="ltr"] .indicator-value .sd-range-text {
        margin-left: 8px;
        margin-right: initial;
    }

    .message-card {
        padding: 10px;
    }
    .message-card h2 {
        font-size: 0.9em;
        margin-bottom: 4px;
        padding-bottom: 4px;
    }
    .message-card .message-text {
        font-size: 0.8em;
    }
    .footer-details-card {
        padding: 8px;
        gap: 6px;
    }
    .designer-info p {
    font-size: 1.05em; /* أو أي حجم يناسبك */
    font-weight: bold;  /* (اختياري) لجعله أكثر وضوحاً */
    letter-spacing: 0.5px; /* (اختياري) لزيادة التباعد قليلاً */
    }

    .about-btn {
        font-size: 0.75em;
        padding: 7px 10px;
    }
    .ad-space {
        padding: 10px;
        margin-top: 12px;
        font-size: 0.75em;
    }
    /* Modal on very small mobile */
    .modal-content {
        padding: 12px;
        margin: 15px auto;
    }
    .modal-content h2 {
        font-size: 1.1em;
    }
    #growthHistoryTable {
        font-size: 0.65em; 
    }

    #growthHistoryTable th,
    #growthHistoryTable td {
        padding: 7px; 
    }
    .delete-btn-red-border {
        padding: 5px 8px;
        font-size: 0.65em; /* Smaller font for very small screens */
    }
    .child-order-input {
        width: 35px; /* Even smaller width on very small screens */
        font-size: 0.7em;
    }
}

/* --- New Styles for Indicator Colors (ألوان المؤشرات الجديدة) --- */

/* أخضر غامق بولد - Normal / طبيعي */
.normal-color {
    color: #228B22; /* أخضر غامق */
    font-weight: bold;
}

/* برتقالي غامق بولد - Moderate / متوسط */
.moderate-color {
    color: #FF8C00; /* برتقالي غامق */
    font-weight: bold;
}

/* أحمر غامق بولد - Severe / شديد */
.severe-color {
    color: #B22222; /* أحمر داكن */
    font-weight: bold;
}

/* لضمان تطبيق الألوان على المؤشرات الرئيسية أيضاً (تعزيز القاعدة) */
/* هذه القواعد ستضمن أن أي عنصر يحمل فئة اللون سيظهر باللون والخط العريض */
.indicator-value.normal-color,
.message-card .message-text .normal-color {
    color: #228B22;
    font-weight: bold;
}

.indicator-value.moderate-color,
.message-card .message-text .moderate-color {
    color: #FF8C00;
    font-weight: bold;
}

.indicator-value.severe-color,
.message-card .message-text .severe-color {
    color: #B22222;
    font-weight: bold;
}

/* تعريف لون افتراضي إذا لم يتم العثور على تطابق (مهم لتجنب مشاكل التنسيق) */
.default-text-color {
    color: #333; /* لون نص افتراضي رمادي داكن */
    font-weight: normal; 
}

/* --- New Styles for Buttons (ألوان الأزرار) --- */
/* Base button styles are defined globally, these will override for specific states */
.btn.btn-enabled {
    background-color: #28a745; /* أخضر */
    color: white;
    cursor: pointer;
    box-shadow: 0 4px 6px rgba(40, 167, 69, 0.3);
}

.btn.btn-enabled:hover {
    background-color: #218838; /* أخضر أغمق عند التحويم */
    box-shadow: 0 6px 8px rgba(33, 136, 56, 0.4);
}

.btn.btn-disabled {
    background-color: #ccc; /* رمادي */
    color: #666;
    cursor: not-allowed;
    box-shadow: none;
    opacity: 0.7; /* شفافية بسيطة */
}

.btn.btn-disabled:hover {
    background-color: #ccc; /* يبقى رمادي عند التحويم */
    box-shadow: none;
}


/* NEW: Network Status Modal Styles (أنماط نافذة حالة الشبكة) */
/* يعيد استخدام فئات .modal و .modal-content، فقط نحتاج لمعرفات محددة للعناصر الداخلية */
#networkStatusModal .modal-content {
    background-color: #f8d7da; /* أحمر فاتح للخطأ */
    border: 1px solid #dc3545; /* حدود حمراء */
    color: #721c24; /* نص أحمر داكن */
    text-align: center;
}

#networkStatusTitle {
    color: #721c24;
    font-size: 1.5em;
    margin-bottom: 10px;
    /* This will be set by JS to reflect current language */
}

#networkStatusMessage {
    font-size: 1.1em;
    line-height: 1.6;
    /* This will be set by JS to reflect current language */
}
.notification-bar {
    display: flex;
    align-items: center;
    justify-content: space-between;
    background-color: #f44336;
    color: #fff;
    font-weight: bold;
    font-size: 1rem;
    padding: 12px 18px;
    position: fixed;
    top: 0;
    right: 0;
    left: 0;
    z-index: 99999;
    box-shadow: 0 2px 8px rgba(44, 62, 80, 0.07);
    font-family: 'Tajawal', Arial, sans-serif;
    letter-spacing: 0.02em;
}
#notification-message {
    flex: 1;
    text-align: right;
    direction: rtl;
}
#notification-close {
    background: none;
    border: none;
    color: #fff;
    font-size: 1.5em;
    margin-left: 10px;
    cursor: pointer;
    line-height: 1;
}
@media (max-width: 767px) {
    .notification-bar {
        font-size: 0.93em;
        padding: 8px 10px;
    }
    #notification-close {
        font-size: 1.2em;
    }
}
.notification-bar {
    display: flex;
    justify-content: space-between;
    align-items: center;
    position: fixed;
    top: 0;
    left: 0;
    right: 0;
    background-color: #f44336;
    color: white;
    font-size: 1em;
    padding: 10px 15px;
    z-index: 9999;
    box-shadow: 0 2px 6px rgba(0, 0, 0, 0.2);
}

.notification-close {
    background: none;
    border: none;
    color: white;
    font-size: 1.5em;
    cursor: pointer;
    margin-right: 10px;
}

.notification-bar.hidden {
    display: none;
}
/* أزرار الأيقونات الدائرية للمشاركة والطباعة */
.icon-btn {
    background: #fff;
    border: none;
    border-radius: 50%;
    width: 46px;
    height: 46px;
    display: flex;
    align-items: center;
    justify-content: center;
    box-shadow: 0 2px 8px #0001;
    transition: box-shadow 0.2s, background 0.2s;
    cursor: pointer;
    margin: 0 4px;
}
.icon-btn:hover {
    background: #f4f4f4;
    box-shadow: 0 4px 12px #0002;
}
.icon-btn svg {
    pointer-events: none;
}
@media print {
    body * {
      visibility: hidden !important;
    }
    #growthHistoryModal,
    #growthHistoryModal * {
      visibility: visible !important;
    }
    #growthHistoryModal {
      position: absolute !important;
      left: 0; top: 0; width: 100vw; height: 100vh;
      background: #fff !important;
      box-shadow: none !important;
      z-index: 9999;
    }
    #growthHistoryModal .modal-content {
      box-shadow: none !important;
      background: #fff !important;
      width: 100vw !important;
      min-width: 100vw !important;
      max-width: 100vw !important;
      margin: 0 !important;
      padding: 0 5vw !important;
    }
    #growthHistoryModal .table-container {
        overflow: visible !important;
        max-width: none !important;
        width: 100vw !important;
        max-height: none !important;
    }
    #growthHistoryModal table {
      width: 100% !important;
      font-size: 1.1em !important;
    }
    #growthHistoryModal .close-button,
    #growthHistoryModal .growth-history-actions,
    #growthHistoryModal h2,
    #growthHistoryModal p.modal-message {
      display: none !important;
    }
  }
    .language-toggle-bar {
        margin-top: 10px;    /* مسافة من الأعلى (تحت العنوان) */
        display: flex;
        justify-content: center;
        align-items: center;
        width: 138px;
        margin: 0 auto 10px auto;
        background: #e3eafc;
        border-radius: 8px;
        box-shadow: 0 1px 7px rgba(25,118,210,0.09) inset;
        overflow: hidden;
        height: 38px;
        }
        .language-toggle-bar input[type="radio"] {
        display: none;
        }
        .language-toggle-bar label {
  flex: 1 1 60px;
  text-align: center;
  padding: 0;
  margin: 0;
  cursor: pointer;
  color: #1976d2;
  background: transparent;
  font-weight: 700;
  font-size: 1em;
  height: 38px;
  line-height: 38px;
  border-radius: 0;
  transition: background 0.22s, color 0.22s;
  user-select: none;
  outline: none;
  box-shadow: none;
}
.language-toggle-bar input[type="radio"]:checked + label {
  background: #1976d2;
  color: #fff;
  box-shadow: none;
  border-radius: 0;
}
.language-toggle-bar label:hover:not(:has(+ input[type="radio"]:checked)) {
  background: #d4dfff;
  color: #0056b3;
}
.language-toggle-bar label:first-of-type {
  border-radius: 8px 0 0 8px;
}
.language-toggle-bar label:last-of-type {
  border-radius: 0 8px 8px 0;
}
#growthHistoryTable th:nth-child(1),
#growthHistoryTable td:nth-child(1) {
    width: 60px;
    max-width: 80px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(2),
#growthHistoryTable td:nth-child(2) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(3),
#growthHistoryTable td:nth-child(3) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(4),
#growthHistoryTable td:nth-child(4) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(5),
#growthHistoryTable td:nth-child(5) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(6),
#growthHistoryTable td:nth-child(6) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(7),
#growthHistoryTable td:nth-child(7) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(8),
#growthHistoryTable td:nth-child(8) {
    width: 55px;
    max-width: 55px;
    min-width: 50px;
    text-align: center;
}
#growthHistoryTable th:nth-child(12),
#growthHistoryTable td:nth-child(12) {
    width: 60px;
    max-width: 75px;
    min-width: 50px;
    text-align: center;
}
@media (max-width: 600px) {
  .modal-content {
    width: 98vw !important;
    max-width: 98vw !important;
    padding: 5px !important;
    margin: 10px auto !important;
    border-radius: 6px;
  }
  .table-container {
    max-width: 98vw !important;
    overflow-x: auto !important;
    /* إضافة سكرول أفقي عند الحاجة */
  }
  #growthHistoryTable {
    font-size: 0.92em;  /* تصغير الخط قليلاً للجوال */
    min-width: 700px;   /* جدول بعرض أكبر من الشاشة ليظهر سكرول أفقي */
  }
  #growthHistoryTable th,
  #growthHistoryTable td {
    padding: 4px 4px;
    font-size: 0.92em;
  }
}
@media (max-width: 600px) {
  .scroll-hint-mobile {
    text-align: center;
    font-size: 0.93em;
    color: #1976d2;
    margin-bottom: 6px;
  }
}

/* تنسيقات حاوية أيقونات التواصل الاجتماعي */
.social-icons {
    margin-top: 15px; /* مسافة أعلى الأيقونات */
    display: flex;
    justify-content: center;
    gap: 15px; /* مسافة بين الأيقونات */
    width: 100%;
}

/* تنسيقات روابط الأيقونات */
.social-icons a {
    color: #555; /* لون الأيقونة */
    font-size: 24px; /* حجم الأيقونة */
    transition: color 0.3s ease; /* تأثير انسيابي عند التمرير */
}

/* تأثير عند التمرير على الأيقونات */
.social-icons a:hover {
    color: #000; /* لون أغمق عند التمرير */
}

/* تنسيقات للهواتف المحمولة */
@media (max-width: 768px) {
    .footer-details-card {
        flex-direction: column; /* عرض العناصر فوق بعضها */
        gap: 15px;
    }
    .designer-info {
        width: 100%;
    }
}

/*
  ======================================================
  تنسيقات بديلة لفئات Tailwind CSS
  ======================================================
*/

/* تنسيقات تعويضية لفئات Tailwind المفقودة */

.flex {
    display: flex;
}

.flex-col {
    flex-direction: column;
}

.justify-center {
    justify-content: center;
}

.items-center {
    align-items: center;
}

.p-2 {
    padding: 0.5rem; /* تعادل 8px */
}

.m-4 {
    margin: 1rem; /* تعادل 16px */
}

.text-2xl {
    font-size: 1.5rem; /* تعادل 24px */
}

.font-bold {
    font-weight: bold;
}

.text-gray-800 {
    color: #2d3748; /* لون رمادي داكن */
}

.bg-gray-100 {
    background-color: #f7fafc; /* لون رمادي فاتح للخلفية */
}

.rounded-lg {
    border-radius: 0.5rem; /* حواف مستديرة كبيرة */
}

.shadow-md {
    box-shadow: 0 4px 6px -1px rgba(0, 0, 0, 0.1), 0 2px 4px -1px rgba(0, 0, 0, 0.06);
}

/* قم بإضافة هذا السطر لتعويض الفئة المفقودة في الحاوية الرئيسية */
.container.m-4 {
    margin: 1rem;
}
