/* --- Inherited Styles & Variables --- */
:root {
    --primary-color: #1abc9c; --primary-color-darker: #16a085; --secondary-color: #8696a7;
    --accent-color: #3498db; --light-bg: #f8f9fa; --white-bg: #ffffff;
    --dark-text: #34495e; --medium-text: #6c7a89; --light-text: #ecf0f1;
    --border-color: #e1e5e8; --footer-bg: #2c3e50;
    --font-primary: 'Cairo', 'Tajawal', sans-serif;
    --shadow-soft: 0 5px 15px rgba(0, 0, 0, 0.05); --shadow-medium: 0 8px 25px rgba(0, 0, 0, 0.08);
    --shadow-hover: 0 10px 30px rgba(26, 188, 156, 0.15);
    --border-radius-sm: 8px; --border-radius-md: 12px;
    --error-color: #e74c3c; /* Red for errors */
}
* { margin: 0; padding: 0; box-sizing: border-box; }
html { scroll-behavior: smooth; font-size: 16px; }
body {
    font-family: var(--font-primary); line-height: 1.7; color: var(--dark-text);
    background-color: var(--light-bg); direction: rtl; text-align: right;
    -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale;
    text-rendering: optimizeLegibility; display: flex; flex-direction: column; min-height: 100vh;
}
main { flex-grow: 1; }
.container { max-width: 900px; margin: 0 auto; padding: 0 20px; } /* Adjusted width */
h1, h2, h3 { font-weight: 700; margin-bottom: 1.2rem; line-height: 1.4; letter-spacing: -0.5px; color: #2c3e50; }
h1 { font-size: 2.5rem; text-align: center; margin-bottom: 1rem;}
h2 { font-size: 1.6rem; margin-bottom: 1.5rem; }
h3 { font-size: 1.2rem; font-weight: 600; color: var(--primary-color); }
p { margin-bottom: 1.3rem; color: var(--medium-text); font-size: 1.0rem; font-weight: 400; }
p.tool-description { text-align: center; max-width: 700px; margin: 0 auto 2.5rem auto; font-size: 1.05rem;}
a { color: var(--primary-color); text-decoration: none; transition: color 0.3s ease; }
a:hover { color: var(--primary-color-darker); }
.btn {
    display: inline-block; padding: 10px 25px; background-color: var(--primary-color); color: #fff;
    border: none; border-radius: var(--border-radius-sm); cursor: pointer; font-family: var(--font-primary);
    font-size: 0.95rem; font-weight: 600; text-align: center; transition: all 0.3s ease;
    box-shadow: 0 2px 6px rgba(26, 188, 156, 0.15);
}
.btn:hover { background-color: var(--primary-color-darker); transform: translateY(-2px); box-shadow: 0 4px 10px rgba(26, 188, 156, 0.25); }
.btn-secondary { background-color: var(--secondary-color); color: #fff; box-shadow: 0 2px 6px rgba(134, 150, 167, 0.15); }
.btn-secondary:hover { background-color: #718091; box-shadow: 0 4px 10px rgba(134, 150, 167, 0.25); }
.btn:disabled {
    opacity: 0.6;
    cursor: not-allowed;
    background-color: var(--secondary-color); /* Grey out disabled button */
    box-shadow: none;
    transform: none;
}


/* --- Header (Exact copy) --- */
.main-header { background-color: var(--white-bg); padding: 18px 0; border-bottom: 1px solid var(--border-color); position: sticky; top: 0; z-index: 1000; box-shadow: var(--shadow-soft); }
.main-header .container { max-width: 1160px; display: flex; justify-content: space-between; align-items: center; }
.logo { font-size: 1.9rem; font-weight: 700; color: var(--dark-text); } .logo a { color: inherit; }
.main-nav ul { list-style: none; display: flex; } .main-nav ul li { margin-right: 35px; } .main-nav ul li:last-child { margin-right: 0; }
.main-nav ul li a { color: var(--medium-text); font-weight: 600; padding: 8px 4px; position: relative; transition: color 0.3s ease; }
.main-nav ul li a:hover, .main-nav ul li a.active { color: var(--primary-color); }
.main-nav ul li a::after { content: ''; position: absolute; width: 0; height: 2.5px; display: block; margin-top: 8px; right: 50%; transform: translateX(50%); background: var(--primary-color); transition: width 0.4s ease; }
.main-nav ul li a:hover::after, .main-nav ul li a.active::after { width: 70%; }

/* --- Tool Area Styles --- */
.tool-section { padding: 50px 0; }
.tool-container {
    background-color: var(--white-bg); padding: 30px 35px 40px 35px;
    border-radius: var(--border-radius-md); box-shadow: var(--shadow-medium);
    border: 1px solid var(--border-color);
}

.text-areas-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns for text areas */
    gap: 30px;
    margin-bottom: 2rem;
}

.textarea-group label {
    display: block; margin-bottom: 0.7rem; font-weight: 600;
    color: var(--dark-text); font-size: 0.95rem;
}

.textarea-group textarea {
    width: 100%;
    padding: 15px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-primary);
    font-size: 1rem;
    line-height: 1.7;
    resize: vertical; /* Allow vertical resizing */
    min-height: 180px; /* Min height */
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fdfdfd;
}

.textarea-group textarea:focus {
    outline: none; border-color: var(--primary-color);
    box-shadow: 0 0 0 4px rgba(26, 188, 156, 0.1); background-color: var(--white-bg);
}
.textarea-group textarea::placeholder {
    color: var(--medium-text); opacity: 0.8;
}

/* Readonly styles for output */
#outputText {
    background-color: var(--light-bg);
    cursor: default;
}
#outputText::placeholder {
    font-size: 0.95rem;
}

.action-buttons {
    display: flex;
    justify-content: center;
    flex-wrap: wrap;
    gap: 15px;
}
.action-buttons .btn {
    min-width: 150px; /* Ensure buttons have a decent size */
}

/* --- Footer (Exact copy) --- */
.main-footer { background-color: var(--footer-bg); color: var(--light-text); padding: 50px 0 30px 0; text-align: center; margin-top: auto; }
.main-footer .container { max-width: 1160px; display: flex; flex-direction: column; align-items: center; }
.footer-links { margin-bottom: 2rem; }
.footer-links a { color: var(--light-text); margin: 0 18px; font-size: 0.95rem; opacity: 0.75; transition: opacity 0.3s ease, color 0.3s ease; }
.footer-links a:hover { opacity: 1; color: var(--primary-color); }
.social-links { margin-bottom: 2rem; }
.social-links a { color: var(--light-text); margin: 0 12px; font-size: 1.7rem; opacity: 0.7; transition: opacity 0.3s ease, transform 0.3s ease, color 0.3s ease; }
.social-links a:hover { opacity: 1; transform: translateY(-3px); color: var(--primary-color); }
.copyright { font-size: 0.9rem; opacity: 0.6; line-height: 1.6; }
.copyright a { color: inherit; opacity: 0.8; text-decoration: underline; text-decoration-color: rgba(236, 240, 241, 0.3); transition: opacity 0.3s ease, text-decoration-color 0.3s ease; }
.copyright a:hover { opacity: 1; text-decoration-color: rgba(236, 240, 241, 0.7); }


/* --- Responsive Adjustments --- */
 @media (max-width: 768px) {
    h1 { font-size: 2rem;}
    .tool-section { padding: 40px 0; }
    .tool-container { padding: 25px 20px; }
    .text-areas-wrapper { grid-template-columns: 1fr; gap: 20px; } /* Stack text areas */
    .textarea-group textarea { min-height: 150px; }

     .main-header { padding: 15px 0;}
     .main-header .container { flex-direction: column; padding-bottom: 10px; }
    .logo { margin-bottom: 15px;}
    .main-nav ul { margin-top: 5px; padding-right: 0; justify-content: center; width:100%; flex-wrap: wrap;}
    .main-nav ul li { margin: 5px 10px; }
    .action-buttons .btn { min-width: 120px; padding: 8px 20px; font-size: 0.9rem;}
    .footer-links a { margin: 5px 10px;}
}
 @media (max-width: 576px) {
     h1 { font-size: 1.8rem;}
     p.tool-description { font-size: 1rem; margin-bottom: 1.5rem;}
     .textarea-group textarea { font-size: 0.95rem; }
     .action-buttons { flex-direction: column; align-items: center; gap: 10px;} /* Stack buttons */
     .action-buttons .btn { width: 100%; max-width: 250px;}
 }

/* --- FAQ Section Styling (Copied from Calorie Calculator) --- */
.faq-section {
    padding: 50px 0;
    background-color: var(--white-bg); /* Match tool background or slightly different */
    border-top: 1px solid var(--border-color);
}

.faq-container {
    max-width: 750px; /* Slightly narrower for FAQ */
    margin: 0 auto;
}

.faq-section h2 {
    margin-bottom: 2.5rem;
    color: var(--dark-text);
}

.faq-item {
    border-bottom: 1px solid var(--border-color);
    margin-bottom: 1rem;
}

.faq-item:last-child {
    border-bottom: none;
    margin-bottom: 0;
}

.faq-question {
    background-color: transparent;
    border: none;
    color: var(--dark-text);
    cursor: pointer;
    display: flex;
    justify-content: space-between;
    align-items: center;
    padding: 18px 5px; /* Padding for clickable area */
    text-align: right;
    width: 100%;
    font-family: var(--font-primary);
    font-size: 1.05rem;
    font-weight: 600;
    transition: background-color 0.2s ease, color 0.2s ease;
}

.faq-question:hover {
    background-color: rgba(26, 188, 156, 0.05); /* Subtle hover */
    color: var(--primary-color);
}

.faq-icon {
    font-size: 1.2rem;
    font-weight: bold;
    margin-right: 15px; /* Space icon from text */
    transition: transform 0.3s ease;
}

.faq-question[aria-expanded="true"] .faq-icon {
    transform: rotate(45deg);
}

.faq-answer {
    overflow: hidden;
    max-height: 0;
    opacity: 0;
    display: none; /* Initially hidden */
    padding: 0 15px; /* Padding left/right */
    transition: max-height 0.4s ease-out, opacity 0.3s ease-in-out, padding-top 0.4s ease-out, padding-bottom 0.4s ease-out;
}

.faq-answer.open {
    max-height: 500px; /* Adjust as needed, should be larger than any possible answer height */
    opacity: 1;
    padding-top: 10px;
    padding-bottom: 20px;
    display: block; /* Make visible when open class is added */
}

.faq-answer p {
    margin-bottom: 1rem;
    line-height: 1.8;
    font-size: 0.95rem;
    color: var(--medium-text);
}
.faq-answer p:last-child {
    margin-bottom: 0;
}