:root {
    --primary-color: #007bff;
    --secondary-color: #f8f9fa;
    --border-color: #dee2e6;
    --text-color: #212529;
    --bg-color: #ffffff;
    --container-bg: #fdfdfd;
}

html { scroll-behavior: smooth; }
*, *::before, *::after { box-sizing: border-box; }

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    margin: 0; 
    background-color: var(--secondary-color);
    color: var(--text-color); 
    line-height: 1.6;
}

/* --- Header & Navigation --- */
header { 
    background-color: var(--bg-color); padding: 1rem 2rem;
    border-bottom: 1px solid var(--border-color); box-shadow: 0 2px 4px rgba(0,0,0,0.05);
    position: sticky; top: 0; z-index: 1000;
}
.header-content {
    max-width: 1000px; margin: 0 auto; display: flex;
    justify-content: space-between; align-items: center;
}
header h1 {
    margin: 0; font-size: 1.5rem; color: var(--primary-color);
}
header nav a {
    margin-left: 20px; text-decoration: none; color: #495057;
    font-weight: 500; transition: color 0.2s ease-in-out;
}
header nav a:hover { color: var(--primary-color); }

/* --- Main Layout & Content --- */
.main-container {
    max-width: 900px; margin: 0 auto; padding: 2rem 1rem;
}
section {
    padding-top: 2rem; 
    margin-top: -2rem; 
}
section[id] {
    scroll-margin-top: 80px; /* Adjust based on your header height */
}
h2 {
    font-size: 1.8rem; color: #343a40;
    border-bottom: 2px solid var(--primary-color);
    padding-bottom: 10px; margin-bottom: 1.5rem;
}
h3 { font-size: 1.3rem; margin-top: 1.5rem; margin-bottom: 0.75rem; color: #495057; }

/* --- Tool Styles --- */
.hash-generator-container {
    display: flex; gap: 20px; padding: 20px; background-color: var(--container-bg);
    border: 1px solid var(--border-color); border-radius: 8px; box-shadow: 0 4px 12px rgba(0,0,0,0.05);
    margin-bottom: 3rem;
}
.column { display: flex; flex-direction: column; }
.input-column, .output-column { flex: 1; }
.action-column {
    flex-grow: 0; flex-shrink: 0; justify-content: center; align-items: center;
}
textarea {
    width: 100%; height: 250px; padding: 10px; border: 1px solid var(--border-color);
    border-radius: 5px; font-family: "Courier New", Courier, monospace;
    font-size: 0.9rem; resize: vertical;
}
textarea:focus {
    outline: none; border-color: var(--primary-color); box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}
.controls-container {
    margin-top: 15px; display: flex; justify-content: space-between;
    align-items: flex-start; gap: 20px;
    flex-wrap: wrap; 
}
.file-input-wrapper { 
    position: relative; display: inline-block;
    white-space: nowrap; 
}
.file-input-label {
    background-color: #6c757d; color: white; padding: 8px 15px;
    border-radius: 5px; cursor: pointer;
}
.file-input-label:hover { background-color: #5a6268; }
#file-input { display: none; }
#file-info { display: flex; align-items: center; gap: 10px; margin-top: 10px; font-size: 0.9em; }
#clear-file-btn {
    background: #dc3545; color: white; border: none; width: 20px; height: 20px;
    border-radius: 50%; cursor: pointer; font-weight: bold; line-height: 18px; text-align: center;
}
.algorithm-selector-wrapper { display: flex; align-items: center; gap: 8px; }
#hash-algorithm { padding: 8px; border-radius: 5px; border: 1px solid var(--border-color); }
#generate-btn {
    background-color: var(--primary-color); color: white; border: none;
    padding: 15px 30px; font-size: 1.1rem; font-weight: bold;
    border-radius: 50px; cursor: pointer; transition: background-color 0.2s ease;
}
#generate-btn:hover { background-color: #0056b3; }
.hidden { display: none !important; }

/* --- Content, Article & FAQ Section Styles --- */
.content-section {
    padding: 2rem; background-color: var(--bg-color);
    border: 1px solid var(--border-color); border-radius: 8px;
    margin-bottom: 2rem;
}
.section-intro { font-size: 1.1rem; color: #495057; margin-bottom: 1.5rem; }
.content-section article { margin-bottom: 2.5rem; }
.content-section article:last-child { margin-bottom: 0; }
.content-section ul, .content-section ol { padding-left: 25px; margin-top: 0.5rem; }
.content-section li { margin-bottom: 0.5rem; }

.faq-item { margin-bottom: 1.5rem; }
.faq-item h3 { border-bottom: none; font-size: 1.2rem; padding: 0; margin: 0 0 0.5rem 0; }

/* Styles for individual article pages (.content-page) */
.content-page {
    padding: 2rem; background-color: var(--bg-color);
    border: 1px solid var(--border-color); border-radius: 8px;
}
.content-page h1 { font-size: 2.2rem; margin-bottom: 0.5rem; }
.content-page .article-meta { color: #6c757d; margin-bottom: 2rem; font-style: italic; }
.content-page article p, .content-page article li { font-size: 1.1rem; line-height: 1.7; margin-bottom: 1rem; }

/* Article Promotion on Index Page */
.article-promo-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(280px, 1fr));
    gap: 20px;
    margin-top: 1.5rem;
    margin-bottom: 2rem;
}
.article-promo-card {
    display: block;
    background-color: var(--container-bg);
    border: 1px solid var(--border-color);
    padding: 20px;
    border-radius: 8px;
    text-decoration: none;
    color: var(--text-color);
    transition: transform 0.2s ease, box-shadow 0.2s ease;
}
.article-promo-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 8px 15px rgba(0,0,0,0.08);
}
.article-promo-card h3 { margin-top: 0; font-size: 1.25rem; }
.article-promo-card p { color: #495057; font-size: 0.95rem; }
.read-more { font-weight: bold; color: var(--primary-color); }

/* Styles for Images within articles */
.article-image {
    margin: 2rem auto;
    max-width: 600px; /* Adjust as needed */
    text-align: center;
}
.article-image img {
    max-width: 100%;
    height: auto;
    border-radius: 8px;
    box-shadow: 0 4px 8px rgba(0,0,0,0.1);
}
.article-image figcaption {
    font-size: 0.9rem;
    color: #6c757d;
    margin-top: 0.5rem;
    font-style: italic;
}

/* Comparison Table Styling */
.comparison-table-container {
    margin: 2rem 0;
    overflow-x: auto; /* For responsiveness on small screens */
}
table {
    width: 100%;
    border-collapse: collapse;
    border: 1px solid var(--border-color);
}
table th, table td {
    border: 1px solid var(--border-color);
    padding: 10px 12px;
    text-align: left;
}
table th {
    background-color: var(--secondary-color);
    font-weight: 600;
}
table tbody tr:nth-child(even) {
    background-color: #fcfcfc;
}

#bcrypt-controls {
    margin-top: 15px;
    padding: 15px;
    border: 1px dashed var(--border-color);
    border-radius: 5px;
    background-color: #fcfdff;
}

.bcrypt-mode-selector {
    display: flex;
    gap: 20px;
    margin-bottom: 15px;
}

.bcrypt-mode-selector label {
    cursor: pointer;
    display: flex;
    align-items: center;
    gap: 5px;
}

#bcrypt-cost-factor-wrapper {
    margin-bottom: 15px;
}

#bcrypt-cost-factor-wrapper label {
    display: block;
    margin-bottom: 5px;
    font-weight: 500;
}

#bcrypt-cost-factor-wrapper input[type="range"] {
    width: 100%;
    cursor: pointer;
}

#bcrypt-verify-input-wrapper textarea {
    height: 100px; /* Més petit per al camp del hash */
    margin-top: 5px;
}

#loader {
    border: 5px solid #f3f3f3; /* Gris clar */
    border-top: 5px solid var(--primary-color); /* Blau */
    border-radius: 50%;
    width: 40px;
    height: 40px;
    animation: spin 1s linear infinite;
}

@keyframes spin {
    0% { transform: rotate(0deg); }
    100% { transform: rotate(360deg); }
}

.output-message {
    padding: 20px;
    border-radius: 5px;
    font-size: 1.2rem;
    font-weight: bold;
    text-align: center;
    height: 100%;
    display: flex;
    align-items: center;
    justify-content: center;
}

.output-message.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}

.output-message.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}


.hidden {
    display: none !important;
}


footer { 
    text-align: center; margin-top: 3rem; padding: 2rem;
    border-top: 1px solid var(--border-color); color: #6c757d;
}
footer a { color: #6c757d; }

.related-articles-list {
    margin-top: 2.5rem;
    padding-top: 1.5rem;
    border-top: 1px solid var(--border-color);
}
.related-articles-list h4 {
    margin-top: 0;
    margin-bottom: 1rem;
    color: #495057;
}
.related-articles-list ul {
    list-style: none;
    padding-left: 0;
    margin: 0;
}
.related-articles-list li {
    margin-bottom: 0.5rem;
}
.related-articles-list a {
    text-decoration: none;
    color: var(--primary-color);
}
.related-articles-list a:hover {
    text-decoration: underline;
}

/* --- Responsive Design --- */
@media (max-width: 900px) {
    .hash-generator-container { flex-direction: column; }
}
@media (max-width: 600px) {
    .header-content { flex-direction: column; gap: 10px; }
    .main-container { padding: 1rem; }
    .controls-container {
        flex-direction: column; 
        align-items: stretch;
    }
    .algorithm-selector-wrapper { 
        justify-content: space-between; 
    }
    section[id] { scroll-margin-top: 120px; } /* Adjust if header height changes more */
}