/* -- CSS Variables for Theming -- */
:root {
    --bg-color: #f4f7f9;
    --text-color: #333;
    --header-bg: #ffffff;
    --header-border: #e0e0e0;
    --box-bg: #ffffff;
    --box-border: #bdc3c7;
    --box-border-hover: #3498db;
    --title-color: #2c3e50;
    --link-color: #3498db;
    --footer-bg: #2c3e50;
    --footer-text: #ecf0f1;
    --secondary-btn-bg: #95a5a6;
    --error-color: #e74c3c;
    --danger-btn-bg: #c0392b;
    --kofi-color: #FF5E5B; /* Ko-fi's brand color */
    --special-link-color: #e74c3c; /* New color for special nav link */
}

.dark-mode {
    --bg-color: #1a202c;
    --text-color: #e2e8f0;
    --header-bg: #2d3748;
    --header-border: #4a5568;
    --box-bg: #2d3748;
    --box-border: #4a5568;
    --box-border-hover: #63b3ed;
    --title-color: #ffffff;
    --link-color: #63b3ed;
    --footer-bg: #111827;
    --footer-text: #a0aec0;
    --secondary-btn-bg: #4a5568;
    --error-color: #f56565;
    --danger-btn-bg: #9b2c2c;
    --special-link-color: #f56565; /* Brighter red for dark mode */
}

/* -- General Styles -- */
body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    margin: 0;
    background-color: var(--bg-color);
    color: var(--text-color);
    line-height: 1.6;
    transition: background-color 0.3s, color 0.3s;
}

html[dir="rtl"] body {
    text-align: right;
}

.container {
    max-width: 1200px;
    margin: 0 auto;
    padding: 0 20px;
}

img, svg {
    max-width: 100%;
    height: auto;
}

/* -- Header, Navigation, and Profile Styles -- */
.main-header {
    background-color: var(--header-bg);
    padding: 10px 0;
    border-bottom: 1px solid var(--header-border);
    transition: background-color 0.3s, border-bottom 0.3s;
}

.main-header .container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 20px;
    flex-wrap: wrap;
}

.logo-link {
    display: flex;
    align-items: center;
    gap: 12px;
    text-decoration: none;
    flex-shrink: 0;
}

html[dir="rtl"] .logo-link {
    flex-direction: row-reverse;
}

.site-logo {
    height: 45px;
    width: auto;
}

.logo-link h1 {
    margin: 0;
    font-size: 24px;
    color: var(--title-color);
}

.header-center {
    display: flex;
    align-items: center;
    gap: 15px;
    flex-grow: 1;
    justify-content: center;
    flex-wrap: wrap;
}

.theme-toggle-btn {
    background: none;
    border: none;
    cursor: pointer;
    padding: 5px;
    color: var(--text-color);
    flex-shrink: 0;
}

.lang-selector {
    padding: 5px 8px;
    border-radius: 5px;
    border: 1px solid var(--header-border);
    background-color: var(--bg-color);
    color: var(--text-color);
    font-size: 14px;
    cursor: pointer;
}

.main-nav {
    display: flex;
    flex-wrap: wrap;
    justify-content: center;
    align-items: center;
    gap: 10px 25px;
}

.main-nav a {
    text-decoration: none;
    color: var(--link-color);
    font-weight: 500;
    padding: 5px 0;
    cursor: pointer;
    transition: color 0.2s;
}

.nav-radiology {
    color: var(--special-link-color) !important;
    font-weight: 700;
}

.profile-section {
    display: flex;
    align-items: center;
    gap: 15px;
    font-weight: bold;
    flex-shrink: 0;
}
html[dir="rtl"] .profile-section {
    flex-direction: row-reverse;
}

.profile-info {
    display: flex;
    flex-direction: column;
    align-items: flex-end;
    gap: 4px;
}
html[dir="rtl"] .profile-info {
    align-items: flex-start;
}

.profile-picture {
    height: 50px;
    width: 50px;
    border-radius: 50%;
    object-fit: cover;
    border: 2px solid var(--header-border);
}

.kofi-button {
    background-color: var(--kofi-color);
    color: white !important;
    text-decoration: none;
    padding: 4px 10px;
    border-radius: 5px;
    font-size: 13px;
    font-weight: bold;
    transition: transform 0.2s;
    text-align: center;
}
.kofi-button:hover {
    transform: scale(1.05);
}

.moon-icon { display: none; }
.dark-mode .sun-icon { display: none; }
.dark-mode .moon-icon { display: block; }

/* *** NEW: Pre-Title Style *** */
.pre-title {
    font-size: 18px;
    margin-bottom: 15px;
    font-weight: 500;
}
.pre-title a {
    color: var(--special-link-color);
    text-decoration: none;
    border-bottom: 2px solid transparent;
    transition: border-bottom 0.2s;
}
.pre-title a:hover {
    border-bottom: 2px solid var(--special-link-color);
}

/* -- Main Converter Section -- */
.converter-section { padding: 40px 0; text-align: center; }
.converter-section h1 { font-size: 32px; color: var(--title-color); margin-bottom: 10px; } /* Changed h2 to h1 */
.subtitle { font-size: 16px; color: var(--text-color); margin-bottom: 30px; }

.converter-box { background-color: var(--box-bg); border: 2px dashed var(--box-border); border-radius: 10px; padding: 25px; max-width: 600px; margin: 20px auto; transition: all 0.3s; }
.upload-area { padding: 20px; cursor: pointer; }
.upload-area.drag-over { border-color: var(--box-border-hover); background-color: rgba(52, 152, 219, 0.1); }
.upload-area p { margin: 10px 0; }

.btn { padding: 12px 24px; border: none; border-radius: 5px; cursor: pointer; font-size: 16px; font-weight: bold; transition: opacity 0.2s; text-decoration: none; display: inline-flex; align-items: center; justify-content: center; gap: 10px; color: white !important; }
.btn:hover { opacity: 0.9; }
.btn[disabled] { opacity: 0.7; cursor: not-allowed; }

.btn-primary { background-color: #3498db; }
.btn-convert { background-color: #2ecc71; }
.btn-secondary { background-color: var(--secondary-btn-bg); }
.btn-danger { background-color: var(--danger-btn-bg); }
.btn-download { background-color: #2ecc71; padding: 8px 16px; font-size: 14px; }

.conversion-options { margin-top: 30px; display: flex; justify-content: center; align-items: center; gap: 20px; flex-wrap: wrap; }
#output-options-container { display: flex; align-items: center; gap: 10px; }
#output-format { padding: 10px; border-radius: 5px; border: 1px solid #ccc; font-size: 16px; background-color: var(--box-bg); color: var(--text-color); }

.file-list-header { display: flex; justify-content: flex-end; max-width: 600px; margin: 20px auto 0; padding: 0 5px; }
html[dir="rtl"] .file-list-header { justify-content: flex-start; }


/* -- File & Results List Styles -- */
#results-container { margin-top: 40px; }
.file-list { margin-top: 10px; text-align: left; max-width: 600px; margin-left: auto; margin-right: auto; }
html[dir="rtl"] .file-list { text-align: right; }
.file-item { display: flex; align-items: center; background-color: var(--bg-color); padding: 10px 15px; border-radius: 5px; margin-bottom: 10px; border: 1px solid var(--header-border); gap: 15px; }
html[dir="rtl"] .file-item { flex-direction: row-reverse; }
.file-thumbnail { width: 40px; height: 40px; flex-shrink: 0; }
.file-details { flex-grow: 1; overflow: hidden; }
.file-name { font-weight: 500; display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.file-size { font-size: 14px; color: #7f8c8d; }
.remove-file-btn { background: none; border: none; color: var(--error-color); cursor: pointer; font-size: 24px; font-weight: bold; padding: 0 5px; }

.results-list { text-align: left; max-width: 700px; margin: 20px auto 0; }
html[dir="rtl"] .results-list { text-align: right; }
#results-container h3 { text-align: center; color: var(--title-color); font-size: 24px; margin-bottom: 20px; }
.result-item { display: flex; align-items: center; background-color: var(--box-bg); padding: 15px 20px; border-radius: 8px; margin-bottom: 15px; border: 1px solid var(--header-border); gap: 20px; }
html[dir="rtl"] .result-item { flex-direction: row-reverse; }
.result-thumbnail { width: 40px; height: 40px; flex-shrink: 0; color: var(--text-color); }
.result-details { flex-grow: 1; overflow: hidden; }
.original-name, .converted-name { display: block; white-space: nowrap; overflow: hidden; text-overflow: ellipsis; }
.original-name { font-size: 14px; color: #7f8c8d; margin-bottom: 5px; }
.converted-name { font-weight: bold; font-size: 16px; }
.converted-name.error { color: var(--error-color); font-weight: normal; }
.results-actions { margin-top: 30px; display: flex; justify-content: center; gap: 20px; }

.spinner { width: 20px; height: 20px; border: 3px solid rgba(255, 255, 255, 0.3); border-radius: 50%; border-top-color: #ffffff; animation: spin 1s ease-in-out infinite; }
@keyframes spin { to { transform: rotate(360deg); } }


/*
 ============================================
  Content Sections (How-To, Articles, Info)
 ============================================
*/
.how-to-guide-section, .articles-section, .info-section {
    padding: 40px 0;
    border-top: 1px solid var(--header-border);
}
.info-section {
    background-color: var(--box-bg);
}
.articles-section {
    background-color: var(--bg-color);
}
.how-to-guide-section {
    text-align: center;
    margin-top: 60px;
}
.info-section .container { display: flex; gap: 40px; flex-wrap: wrap; }
.info-column { flex: 1; min-width: 300px; }
.info-column h3 { font-size: 22px; color: var(--title-color); margin-bottom: 20px; }
.faq-item { margin-bottom: 20px; }
.faq-item h4 { margin-bottom: 5px; }
.faq-item p { margin-top: 0; color: var(--text-color); opacity: 0.9; }

/* -- How-To Guide Specific Styles -- */
.how-to-guide-section h2 { font-size: 28px; color: var(--title-color); margin-bottom: 30px; }
.video-container { position: relative; overflow: hidden; width: 100%; max-width: 800px; margin: 0 auto 40px; padding-top: 56.25%; border-radius: 8px; box-shadow: 0 4px 15px rgba(0,0,0,0.1); }
.video-container iframe { position: absolute; top: 0; left: 0; bottom: 0; right: 0; width: 100%; height: 100%; border: none; }
.guide-steps-container { display: flex; justify-content: center; gap: 30px; flex-wrap: wrap; text-align: left; max-width: 1200px; margin: 0 auto; }
html[dir="rtl"] .guide-steps-container { text-align: right; }
.guide-step { background: var(--box-bg); border-radius: 8px; padding: 20px; flex-basis: 300px; flex-grow: 1; border: 1px solid var(--header-border); }
.guide-step img { width: 100%; border-radius: 5px; margin-bottom: 15px; border: 1px solid var(--header-border); }
.guide-step h3 { font-size: 20px; color: var(--title-color); margin-bottom: 10px; }

/* -- Article Content Specific Styles -- */
.article-content { background-color: var(--box-bg); padding: 30px 40px; border-radius: 8px; max-width: 800px; margin: 0 auto 40px auto; border: 1px solid var(--header-border); }
.article-content:last-child { margin-bottom: 0; }
.article-content h2 { font-size: 28px; color: var(--title-color); margin-bottom: 15px; border-bottom: 2px solid var(--header-border); padding-bottom: 10px; }
.article-content h3 { font-size: 22px; color: var(--title-color); margin-top: 30px; }
.article-content p, .article-content li { margin-bottom: 15px; }
.article-content ul { list-style-position: inside; padding-left: 20px; }
html[dir="rtl"] .article-content ul { padding-left: 0; padding-right: 20px; }
.article-content img.inline-image { border: 1px solid var(--header-border); border-radius: 8px; margin: 15px 0; }

/* -- Articles Hub Page Styles -- */
.articles-hub-container { max-width: 900px; margin: 40px auto; padding: 20px; }
.articles-hub-container h1 { text-align: center; font-size: 32px; color: var(--title-color); margin-bottom: 30px; }
.article-preview-box { display: block; background-color: var(--box-bg); border: 1px solid var(--header-border); padding: 25px; border-radius: 8px; margin-bottom: 25px; text-decoration: none; color: var(--text-color); transition: transform 0.2s, box-shadow 0.2s; }
.article-preview-box:hover { transform: translateY(-5px); box-shadow: 0 4px 20px rgba(0,0,0,0.08); }
.article-preview-box h2 { color: var(--title-color); margin-top: 0; font-size: 24px; }
.article-preview-box p { opacity: 0.9; margin-bottom: 0; }
.article-preview-box.is-placeholder { opacity: 0.7; border-style: dashed; }
.article-preview-box.is-placeholder:hover { transform: none; box-shadow: none; }

/* -- Footer Styles -- */
.main-footer { text-align: center; padding: 20px 0; background-color: var(--footer-bg); color: var(--footer-text); }
.footer-content { max-width: 1200px; margin: 0 auto; padding: 0 20px; }
.footer-links { margin-top: 10px; }
.footer-links a { color: var(--link-color); text-decoration: none; margin: 0 10px; }
.footer-links a:hover { text-decoration: underline; }

/*
 ============================================
  Responsive Media Queries
 ============================================
*/
@media (max-width: 768px) {
    .main-header .container { flex-direction: column; gap: 20px; }
    .header-center { flex-direction: column; gap: 20px; order: 3; }
    .logo-link { order: 1; }
    .profile-section { order: 2; }
    .main-nav { flex-direction: column; gap: 15px; width: 100%; text-align: center; }
    .converter-section h1 { font-size: 26px; } /* Changed h2 to h1 */
    .subtitle { font-size: 15px; }
    .footer-links { display: flex; flex-direction: column; gap: 12px; }
    .article-content { padding: 20px; }
    .articles-hub-container { padding: 10px; }
}

@media (max-width: 480px) {
    .container { padding: 0 15px; }
    .converter-box { padding: 15px; }
    .result-item { flex-direction: column; align-items: flex-start; gap: 10px; padding: 15px; }
    html[dir="rtl"] .result-item { align-items: flex-end; }
    .result-item .btn-download { width: 100%; text-align: center; }
}

/*
 ============================================
  Animation for Radiology Link
 ============================================
*/
@keyframes glow {
  0% { text-shadow: 0 0 3px rgba(231, 76, 60, 0.4); }
  50% { text-shadow: 0 0 10px rgba(231, 76, 60, 0.9); }
  100% { text-shadow: 0 0 3px rgba(231, 76, 60, 0.4); }
}

.nav-radiology {
    animation: glow 2s ease-in-out infinite;
}
