/* --- 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: 800px; 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 20px; 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.9rem; 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); }


/* --- 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);
}

#tafqeetForm .input-area {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Number | Currency */
    gap: 20px 30px;
    margin-bottom: 1.5rem;
}

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

.form-group input[type="number"], .form-group select {
    width: 100%;
    padding: 12px 15px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-primary);
    font-size: 0.95rem;
    transition: border-color 0.3s ease, box-shadow 0.3s ease;
    background-color: #fdfdfd;
}
.form-group input[type="number"] { -moz-appearance: textfield; }
/* Hide arrows */
.form-group input[type=number]::-webkit-inner-spin-button,
.form-group input[type=number]::-webkit-outer-spin-button { -webkit-appearance: none; margin: 0; }

.form-group input[type="number"]:focus, .form-group select: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);
}
.form-group input[type="number"]::placeholder { color: var(--secondary-color); opacity: 0.7; }
.form-group select { cursor: pointer; }

.error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 0.5rem; /* Position below inputs */
    min-height: 1.2em;
    grid-column: 1 / -1; /* Span across columns */
    text-align: center;
}

.output-area {
    margin-top: 1.5rem;
    position: relative; /* For positioning the copy button */
}
.output-area label {
     display: block; margin-bottom: 0.7rem; font-weight: 600;
    color: var(--dark-text); font-size: 0.95rem;
}
#resultText {
    width: 100%;
    padding: 15px 20px;
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    font-family: var(--font-primary);
    font-size: 1.1rem; /* Larger result text */
    line-height: 1.8; /* More line spacing */
    resize: vertical;
    background-color: var(--light-bg); /* Readonly background */
    color: var(--dark-text);
    min-height: 100px;
    margin-bottom: 1rem; /* Space before potential copy button */
}
#resultText::placeholder {
    color: var(--medium-text);
    opacity: 0.8;
     font-size: 1rem; /* Slightly smaller placeholder */
}

.copy-btn {
    position: absolute;
    bottom: 10px; /* Position near bottom */
    left: 10px;   /* Position near left */
    padding: 6px 12px;
    font-size: 0.85rem;
    opacity: 0.8;
    transition: opacity 0.3s ease, background-color 0.3s ease;
}
.copy-btn:hover {
    opacity: 1;
}
.copy-btn:disabled {
    opacity: 0.5;
    cursor: not-allowed;
}
.copy-btn.copied {
    background-color: var(--primary-color-darker);
    color: #fff;
}
.copy-btn svg { /* Style for embedded SVG */
     width: 1em;
     height: 1em;
     margin-left: 6px; /* Space icon from text */
     vertical-align: -0.1em;
}


/* --- 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; }
     #tafqeetForm .input-area { grid-template-columns: 1fr; gap: 15px; } /* Stack inputs */
     .error-message { grid-column: auto; }

     .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; }
    #resultText { font-size: 1rem; }
    .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;}
     .form-group input[type="number"], .form-group select { padding: 10px 12px; font-size: 0.9rem;}
      #resultText { min-height: 80px; }
      .copy-btn { bottom: 8px; left: 8px; padding: 5px 10px; font-size: 0.8rem;}
 }