/* --- 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; text-align: center; }
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); }


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

.converter-wrapper {
    display: grid;
    grid-template-columns: 1fr 1fr; /* Two columns for converters */
    gap: 30px;
    margin-bottom: 2.5rem;
}

.date-fieldset {
    border: 1px solid var(--border-color);
    border-radius: var(--border-radius-sm);
    padding: 20px;
    margin: 0; /* Reset default margin */
}

.date-fieldset legend {
    padding: 0 10px;
    font-weight: 600;
    color: var(--primary-color);
}

.date-inputs {
    display: grid;
    grid-template-columns: repeat(3, 1fr); /* Day, Month, Year */
    gap: 15px;
    margin-bottom: 1.5rem;
}

.form-group label {
    display: block; margin-bottom: 0.6rem; font-weight: 500;
    color: var(--dark-text); font-size: 0.9rem;
}

.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;
    -moz-appearance: textfield; /* Firefox */
}
/* 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; }

.convert-btn {
    display: block; /* Make button full width */
    width: 100%;
    margin-top: 0.5rem; /* Space above error */
}

.error-message {
    color: var(--error-color);
    font-size: 0.85rem;
    margin-top: 0.8rem;
    text-align: center;
    min-height: 1.2em; /* Reserve space */
}

/* Result Area */
#resultArea {
    margin-top: 2rem;
    padding: 25px;
    background-color: var(--light-bg);
    border-radius: var(--border-radius-sm);
    border: 1px solid var(--border-color);
    text-align: center;
}
#resultArea h2 {
    color: var(--primary-color);
    margin-bottom: 1rem;
}
#resultText {
    font-size: 1.2rem;
    font-weight: 600;
    color: var(--dark-text);
    margin-bottom: 1.5rem;
    line-height: 1.8;
}
#resultText strong {
    color: var(--primary-color-darker);
}

#clearResultBtn {
    font-size: 0.9rem;
    padding: 8px 20px;
}

/* --- 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; }
    .converter-wrapper { grid-template-columns: 1fr; gap: 25px; } /* Stack converters */
    .date-inputs { grid-template-columns: repeat(auto-fit, minmax(80px, 1fr)); } /* Flexible date inputs */

     .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: 1.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;}
     .date-fieldset { padding: 15px;}
     .date-inputs { gap: 10px; }
     .form-group input[type="number"], .form-group select { padding: 10px 12px; font-size: 0.9rem;}
     #resultText { font-size: 1rem; }
 }