/* ===== SECTION: General Styles ===== */

:root {
    --primary-text-color: #333;
    --secondary-text-color: #555;
    --main-background-color: #f4f7f6; /* Light grayish blue, softer than pure white */
    --container-background-color: #fff;
    --toolbox-header-bg: #2c3e50; /* Dark blue for header */
    --toolbox-header-text: #ecf0f1; /* Light grey/silver for header text */
    --toolbox-nav-bg: #34495e; /* Slightly lighter dark blue for nav */
    --toolbox-nav-text: #ecf0f1;
    --toolbox-accent: #3498db; /* Brighter blue accent for nav hover/active */
    --toolbox-accent-darker: #2980b9;
    --button-background-color: var(--toolbox-accent);
    --button-text-color: #fff;
    --button-hover-background-color: var(--toolbox-accent-darker);
    --card-background-color: #fff;
    --border-color: #ddd;
    --border-color-light: #eee;
    --table-header-background-color: var(--toolbox-nav-bg);
    --table-header-text-color: #fff;
    --table-row-even-background-color: #f9f9f9;
    --results-background-color: #eaf5ff; /* Light blue background for results */
    --results-border-color: #add8e6; /* Light blue border */
    --tool-icon-background-color: rgba(52, 152, 219, 0.1); /* Light blue from accent color */
    --tool-icon-color: var(--toolbox-accent);
    --notes-background-color: #f0f0f0;
    --notes-border-color: #ccc;
    --notes-section-background-color: #f9f9f9;
    --collapsible-content-background-color: #f9f9f9;
}

/* --- ELEMENT: Body --- */
body {
    font-family: 'Helvetica Neue', Arial, sans-serif;
    line-height: 1.6;
    margin: 0;
    padding: 0;
    background-color: var(--main-background-color);
    color: var(--primary-text-color);
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

/* --- LAYOUT: Main Container --- */
.container {
    width: 80%;
    max-width: 1200px;
    margin: 20px auto;
    padding: 20px;
    background-color: var(--container-background-color);
    box-shadow: 0 0 15px rgba(0, 0, 0, 0.1);
    border-radius: 8px;
    flex-grow: 1;
}

/* ===== SECTION: Toolbox Header & Navigation (New/Revised) ===== */
.toolbox-header {
    background-color: var(--toolbox-header-bg);
    color: var(--toolbox-header-text);
    padding: 20px 0;
    text-align: center;
}

/* Ensuring .container within toolbox-header and toolbox-nav uses the global .container padding for alignment */
.toolbox-header .container,
.toolbox-nav .container {
    width: 80%; /* Match global .container for consistency */
    max-width: 1200px; /* Match global .container */
    margin: 0 auto; /* Center it */
    padding: 0 20px; /* Use global .container padding */
    /* Reset background and shadow if they were on the .container itself previously for header/nav context */
    background-color: transparent;
    box-shadow: none;
    border-radius: 0;
}

.toolbox-header .header-content {
    /* No specific styles needed yet, text-align:center on .toolbox-header handles it */
    position: relative; /* Added for language switcher positioning */
}

.toolbox-header .logo-area {
    display: flex;
    align-items: center;
    justify-content: center;
    margin-bottom: 10px;
}

.toolbox-logo-img {
    height: 40px; 
    margin-right: 15px;
}

.toolbox-main-title {
    font-size: 2.2em;
    font-weight: 500;
    color: var(--toolbox-header-text);
}

.toolbox-tagline {
    font-size: 1em;
    color: var(--toolbox-header-text);
    margin: 0;
}

#langSwitchContainer {
    position: absolute;
    top: 10px; /* 根據實際佈局調整 */
    right: 15px; /* 根據實際佈局調整 */
    z-index: 10; /* 確保在其他元素之上 */
}

#langSwitchBtn {
    padding: 8px 15px; /* 調整內邊距 */
    font-size: 0.9rem; /* 調整字體大小 */
    /* 可以繼承或覆蓋 .btn 的其他樣式 */
    background-color: #f8f9fa; /* 淺色背景 */
    color: #333; /* 深色文字 */
    border: 1px solid #ccc;
    border-radius: 4px;
    text-decoration: none;
    transition: background-color 0.3s ease, color 0.3s ease;
}

#langSwitchBtn:hover {
    background-color: #e9ecef;
    color: #000;
}

.toolbox-nav {
    background-color: var(--toolbox-nav-bg);
}

.toolbox-nav ul {
    list-style-type: none;
    padding: 0;
    margin: 0; 
    text-align: center;
}

.toolbox-nav ul li {
    display: inline-block;
}

.toolbox-nav ul li a {
    display: block;
    color: var(--toolbox-nav-text);
    text-decoration: none;
    padding: 14px 20px; 
    transition: background-color 0.3s ease, color 0.3s ease;
}

.toolbox-nav ul li a:hover, 
.toolbox-nav ul li a.active {
    background-color: var(--toolbox-accent);
    color: var(--button-text-color); /* Assuming --button-text-color is white or light */
}

/* ===== SECTION: Main Content ===== */

/* --- ELEMENT: Main --- */
main {
    padding: 20px 0;
}

/* --- ELEMENT: Headings --- */
h2 {
    color: var(--toolbox-header-bg); /* Using toolbox-header-bg as it's a dark blue */
    border-bottom: 2px solid var(--toolbox-accent);
    padding-bottom: 10px;
    margin-top: 0;
}

h3 {
    color: var(--toolbox-nav-bg); /* Using toolbox-nav-bg as it's a slightly lighter dark blue */
}

/* ===== SECTION: Forms ===== */

/* --- ELEMENT: Form --- */
form {
    margin-top: 20px;
}

/* --- COMPONENT: Form Group --- */
.form-group {
    margin-bottom: 20px;
}

.form-group label {
    display: block;
    margin-bottom: 8px;
    font-weight: bold;
    color: var(--secondary-text-color);
}

.form-group input[type="text"],
.form-group input[type="number"],
.form-group select,
.form-group textarea {
    width: 100%;
    padding: 12px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
}

.form-group input[type="text"]:focus,
.form-group input[type="number"]:focus,
.form-group select:focus,
.form-group textarea:focus {
    border-color: var(--toolbox-accent);
    outline: none;
    box-shadow: 0 0 5px rgba(52, 152, 219, 0.5); /* This rgba is related to toolbox-accent color, might need a variable if used elsewhere */
}


/* --- COMPONENT: Buttons --- */
button, input[type="submit"], .btn {
    background-color: var(--button-background-color);
    color: var(--button-text-color);
    padding: 12px 20px;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    font-size: 1.1em;
    transition: background-color 0.3s ease;
    text-decoration: none; /* For .btn used as a link */
    display: inline-block; /* For .btn used as a link */
}

button:hover, input[type="submit"]:hover, .btn:hover {
    background-color: var(--button-hover-background-color);
}

/* ===== SECTION: Tables ===== */

/* --- ELEMENT: Table --- */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

table th, table td {
    border: 1px solid var(--border-color);
    padding: 12px;
    text-align: left;
}

table th {
    background-color: var(--table-header-background-color);
    color: var(--table-header-text-color);
    font-weight: bold;
}

table tr:nth-child(even) {
    background-color: var(--table-row-even-background-color);
}

/* ===== SECTION: Results Area ===== */

/* --- COMPONENT: Results --- */
.results {
    margin-top: 30px;
    padding: 20px;
    background-color: var(--results-background-color);
    border: 1px solid var(--results-border-color);
    border-radius: 5px;
}

.results h3 {
    margin-top: 0;
    color: var(--toolbox-header-bg); /* Using toolbox-header-bg as it's a dark blue */
}

/* ===== SECTION: Footer (Revised for Toolbox) ===== */
.toolbox-footer { 
    text-align: center;
    padding: 30px 20px; 
    background-color: var(--toolbox-header-bg); 
    color: var(--toolbox-header-text);
    margin-top: auto; 
    position: relative; 
}

.toolbox-footer .container {
    /* Ensure the container inside footer does not inherit main .container styles like background/shadow */
    background-color: transparent;
    box-shadow: none;
    border-radius: 0;
    padding: 0 20px; /* Keep consistent padding with other containers */
    margin: 0 auto; /* Center content */
    width: 80%;
    max-width: 1200px;
}

.toolbox-footer p {
    margin: 5px 0;
    font-size: 0.9em;
}

.toolbox-footer .footer-powered-by {
    font-size: 0.8em;
    opacity: 0.8;
}

.toolbox-footer .footer-powered-by a {
    color: var(--toolbox-accent); 
    text-decoration: none;
}

.toolbox-footer .footer-powered-by a:hover {
    text-decoration: underline;
}

.back-to-top-btn {
    display: none; 
    position: fixed;
    bottom: 20px;
    right: 20px;
    background-color: var(--toolbox-accent);
    color: var(--button-text-color);
    border: none;
    border-radius: 50%; 
    width: 40px;
    height: 40px;
    font-size: 1.2em;
    line-height: 40px; 
    text-align: center;
    cursor: pointer;
    box-shadow: 0 2px 5px rgba(0,0,0,0.2);
    transition: opacity 0.3s ease, visibility 0.3s ease; 
    z-index: 999;
    opacity: 0; 
    visibility: hidden; 
}

.back-to-top-btn.visible { 
    display: block; 
    visibility: visible;
    opacity: 1;
}

.back-to-top-btn:hover {
    background-color: var(--toolbox-accent-darker);
}

/* ===== SECTION: Utility Classes ===== */

/* --- UTILITY: Text Alignment --- */
.text-center {
    text-align: center;
}

/* --- UTILITY: Margin --- */
.mt-1 { margin-top: 1rem; }
.mt-2 { margin-top: 2rem; }
.mb-1 { margin-bottom: 1rem; }
.mb-2 { margin-bottom: 2rem; }

/* ===== SECTION: Tool List Cards ===== */

/* --- LAYOUT: Tool Grid --- */
.tool-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); /* Responsive grid */
    gap: 20px;
    padding: 0;
    margin-top: 20px;
}

/* --- COMPONENT: Tool Card --- */
.tool-card {
    background-color: var(--card-background-color);
    border: 1px solid var(--border-color);
    border-radius: 8px;
    box-shadow: 0 4px 6px rgba(0,0,0,0.1);
    padding: 20px;
    display: flex;
    flex-direction: column;
    justify-content: space-between; /* Pushes button to the bottom */
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
}

.tool-card:hover {
    transform: translateY(-5px);
    box-shadow: 0 6px 12px rgba(0,0,0,0.15);
}

.tool-icon {
    width: 60px;
    height: 60px;
    background-color: var(--tool-icon-background-color);
    border-radius: 10px; /* Rounded corners from example */
    margin-bottom: 1rem; /* margin-bottom from example (15px is close to 1rem) */
    display: flex;
    align-items: center;
    justify-content: center;
    align-self: center; /* Center the icon block itself */
}

.tool-icon i {
    font-size: 28px; /* Icon size from example */
    color: var(--tool-icon-color);
    line-height: 1;
}

.tool-title {
    font-size: 1.25em;
    color: var(--toolbox-header-bg); /* Dark blue from toolbox-header-bg */
    margin-top: 0;
    margin-bottom: 1rem; /* Consistent spacing */
}
/* --- MODIFICATION: Inline Icon and Title in Tool Card --- */
.card-header-inline {
    display: flex;
    align-items: center;
    margin-bottom: 1rem; /* Maintain overall spacing from description */
}

.card-header-inline .tool-icon {
    margin-right: 10px; /* Space between icon and title */
    margin-bottom: 0; /* Override existing bottom margin */
    align-self: initial; /* Override existing align-self */
    /* Icon size and background are already defined, should be fine */
}

.card-header-inline .tool-title {
    margin-bottom: 0; /* Override existing bottom margin */
    /* Title font size and color are already defined */
}

/* Adjust description margin if title's bottom margin was removed */
.tool-description {
    /* margin-top: 1rem; /* Add top margin to compensate for removed title margin if needed. */
    /* Current .tool-title has margin-bottom: 1rem, and .card-header-inline now has margin-bottom: 1rem.
       So, the original spacing between title and description should be roughly preserved.
       If .card-header-inline didn't have margin-bottom, then .tool-description would need margin-top.
       Let's keep an eye on this during testing.
    */
}

.tool-description {
    font-size: 0.9em;
    color: var(--secondary-text-color);
    margin-bottom: 1rem; /* Consistent spacing */
    flex-grow: 1; /* Allows description to take available space */
}

.tool-card .btn {
    background-color: transparent;
    color: var(--toolbox-accent);
    border: 2px solid var(--toolbox-accent);
    padding: 10px 15px;
    text-align: center;
    text-decoration: none;
    display: inline-block;
    font-size: 0.9em;
    border-radius: 4px;
    transition: background-color 0.3s ease, color 0.3s ease;
    align-self: stretch; /* Make button stretch to full width */
}

.tool-card .btn:hover {
    background-color: var(--toolbox-accent);
    color: var(--button-text-color);
}

/* ===== SECTION: Home Page - Tool Category Summary ===== */

.tool-category-summary {
    margin-top: 30px; /* More space above the items */
    /* display: grid; Already handled by a previous style, but ensure it's there or defined if this is the only place */
    /* grid-template-columns: repeat(auto-fit, minmax(300px, 1fr)); */ /* Ensure this is active */
    /* gap: 20px; */ /* Ensure this is active */
}

.category-item {
    padding: 25px; /* Increased padding for icon and content */
    margin-bottom: 20px; 
    background-color: var(--card-background-color); 
    border-radius: var(--border-radius, 8px); 
    box-shadow: 0 2px 5px rgba(0,0,0,0.08); 
    text-align: center; 
    transition: transform 0.2s ease-in-out, box-shadow 0.2s ease-in-out;
    border-bottom: none; /* Removed separator from previous version */
}

.category-item:hover {
    transform: translateY(-3px);
    box-shadow: 0 4px 10px rgba(0,0,0,0.12);
}

.category-item:last-child {
    /* No specific style needed here unless it was for border-bottom */
}

.category-item h4 i {
    margin-right: 8px;
    /* Optional: Adjust vertical alignment if needed */
    /* vertical-align: middle; */
}

.category-icon {
    font-size: 2.5em; 
    color: var(--toolbox-accent); 
    margin-bottom: 15px;
    line-height: 1;
}

.category-item h4 {
    color: var(--toolbox-header-bg);
    margin-top: 0;
    margin-bottom: 10px;
    font-size: 1.25em; 
    border-bottom: none; 
    padding-bottom: 0;
}

.category-item p {
    font-size: 0.9em; 
    color: var(--secondary-text-color);
    line-height: 1.6;
}
/* ===== SECTION: FAQ Page Styles ===== */

/* --- COMPONENT: FAQ Item --- */
.faq-item {
    margin-bottom: 20px;
    border-bottom: 1px solid var(--border-color-light);
    padding-bottom: 15px;
}
.faq-item:last-child {
    border-bottom: none;
}
.faq-question {
    font-weight: bold;
    color: var(--toolbox-header-bg);
    margin-bottom: 8px;
    font-size: 1.1em;
}
.faq-answer {
    color: var(--secondary-text-color);
    padding-left: 15px;
}
/* ===== SECTION: Compact Layout Styles (General Purpose) ===== */

/* --- COMPONENT: Compact Form Group --- */
.compact-form-group {
    margin-bottom: 10px; /* Reduced from 20px */
}

.compact-form-group label {
    margin-bottom: 4px; /* Reduced from 8px */
    font-size: 0.9em; /* Slightly smaller label */
}

.compact-input,
.compact-form-group input[type="text"],
.compact-form-group input[type="number"],
.compact-form-group select,
.compact-form-group textarea {
    padding: 8px; /* Reduced from 12px */
    font-size: 0.95em; /* Slightly smaller font in input */
}

.compact-button,
.compact-form-group button {
    padding: 8px 15px; /* Reduced from 12px 20px */
    font-size: 1em; /* Reduced from 1.1em */
}

.compact-results {
    margin-top: 15px; /* Reduced from 30px */
    padding: 15px; /* Reduced from 20px */
}

.compact-results h3 {
    font-size: 1.2em; /* Adjust if needed */
    margin-bottom: 10px;
}

.compact-table th, .compact-table td {
    padding: 8px; /* Reduced from 12px */
    font-size: 0.9em;
}

/* ===== SECTION: Collapsible Component ===== */

/* --- COMPONENT: Collapsible Trigger --- */
.collapsible-trigger {
    cursor: pointer;
    color: var(--toolbox-accent);
    text-decoration: underline;
    display: inline-block;
    margin-bottom: 5px;
    font-size: 0.9em;
}

.collapsible-trigger::before {
    content: '▶ '; /* Show an arrow indicating it's expandable */
    font-size: 0.8em;
}

.collapsible-trigger.active::before {
    content: '▼ '; /* Change arrow when expanded */
}

.collapsible-content {
    display: none;
    padding: 10px;
    border: 1px solid var(--border-color-light);
    border-radius: 4px;
    background-color: var(--collapsible-content-background-color);
    font-size: 0.85em;
    margin-top: 5px;
}

.collapsible-content.active {
    display: block;
}

/* ===== SECTION: Input Group (Side-by-side) ===== */

/* --- LAYOUT: Input Group --- */
.input-group {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 15px; /* Space between items */
    align-items: flex-start; /* Align items to the top */
}

.input-group .form-group {
    flex: 1; /* Allow form groups to grow */
    min-width: 200px; /* Minimum width before wrapping, adjust as needed */
    margin-bottom: 0; /* Remove default bottom margin as gap handles spacing */
}

/* --- MODIFIER: Compact Heading --- */
h2.compact-heading {
    padding-bottom: 5px; /* Reduced from 10px */
    margin-bottom: 15px; /* Add some margin below heading */
    font-size: 1.8em; /* Slightly smaller heading */
}

/* ===== SECTION: Tool Page Specific Styles ===== */

/* --- CONTAINER: Tool Section (General for tool pages) --- */
/* Reduce general vertical spacing for specific tool sections */
.tool-section .form-group {
    margin-bottom: 10px;
}
.tool-section .results {
    margin-top: 15px;
}
.tool-section p, .tool-section ul, .tool-section ol {
    margin-bottom: 0.5rem; /* Reduce default paragraph/list bottom margin */
    font-size: 0.95em; /* Slightly smaller paragraph font */
}

/* --- COMPONENT: Notes/Description in Tool Section --- */
.info-block { /* New general info block */
    font-size: 0.85em;
    margin-top: 10px;
    padding: 15px; /* Default padding */
    background-color: var(--notes-section-background-color); /* Use notes-section bg as a base */
    border-radius: 5px; /* Default border radius */
}

.tool-section .notes, .tool-section .description {
    /* Inherits from .info-block if HTML is updated to use it, or apply common styles here */
    font-size: 0.85em; /* Kept for specificity if not using .info-block directly */
    margin-top: 10px;
    padding: 8px; /* Specific padding for this context */
    background-color: var(--notes-background-color); /* Specific background */
    border-left: 3px solid var(--notes-border-color); /* Specific border */
    border-radius: 0; /* Override if inheriting from .info-block and don't want radius here */
}
/* --- LAYOUT: Tool Page Columns (Input/Output) --- */
.tool-layout-container {
    display: flex;
    flex-wrap: wrap; /* Allow wrapping on smaller screens */
    gap: 20px; /* Space between columns */
    margin-bottom: 20px; /* Space before notes section */
}

.input-column {
    flex: 1; /* Grow to take available space */
    min-width: 300px; /* Minimum width before wrapping */
    /* Optional: Add border or background for visual separation */
    /* border-right: 1px solid #eee; */
    /* padding-right: 20px; */
}

.output-column {
    flex: 1; /* Grow to take available space */
    min-width: 300px; /* Minimum width before wrapping */
    /* Optional: Add border or background for visual separation */
    /* padding-left: 20px; */
}

.output-column .results {
    margin-top: 0; /* Results div is now directly in the column */
}

/* --- COMPONENT: Notes Section (General for tool pages) --- */
.notes-section {
    /* margin-top: 20px; /* Already in .info-block if applied */
    /* padding: 15px; /* Already in .info-block */
    /* background-color: var(--notes-section-background-color); /* Already in .info-block */
    /* border-radius: 5px; /* Already in .info-block */
    border: 1px solid var(--border-color-light); /* Specific border for .notes-section */
    /* Combine with .info-block by adding .info-block class to the HTML element */
}

.notes-section h4 {
    margin-top: 0;
    color: var(--toolbox-nav-bg);
}

/* Adjust form margin within input column if needed */
.input-column .tool-form {
    margin-top: 0; /* Form is now directly in the column */
}

/* ===== SECTION: Responsive Media Queries ===== */

/* --- BREAKPOINT: Smaller Screens (max-width: 768px) --- */
@media (max-width: 768px) {
    .tool-layout-container {
        flex-direction: column;
    }
    .input-column, .output-column {
        min-width: 100%;
        border-right: none;
        padding-right: 0;
        padding-left: 0;
    }
}

/* Ensure .info-block is placed before .notes-section if .notes-section is to override/add to it */
/* Or, if .notes-section HTML elements will also have .info-block class, then the order is less critical for these specific properties */
.message-box {
    padding: 10px 15px;
    margin-bottom: 15px;
    border-radius: 4px;
    font-size: 0.9em;
    display: none; /* 預設隱藏 */
}
.message-box.error {
    background-color: #f8d7da;
    color: #721c24;
    border: 1px solid #f5c6cb;
}
.message-box.success {
    background-color: #d4edda;
    color: #155724;
    border: 1px solid #c3e6cb;
}
.message-box.info {
    background-color: #cce5ff;
    color: #004085;
    border: 1px solid #b8daff;
}