:root {
    --bg-color: #f8f9fa;
    --text-color: #212529;
    --border-color: #dee2e6;
    --primary-color: #007bff;
    --primary-hover: #0056b3;
    --secondary-bg: #e9ecef;
    --editor-bg: #ffffff;
    --button-text: #ffffff;
    --code-bg: #f1f1f1;
    --code-text: #333;
}

body.dark-mode {
    --bg-color: #212529;
    --text-color: #f8f9fa;
    --border-color: #495057;
    --primary-color: #0d6efd;
    --primary-hover: #0a58ca;
    --secondary-bg: #343a40;
    --editor-bg: #343a40;
    --button-text: #ffffff;
    --code-bg: #2c3034;
    --code-text: #e9ecef;
}

/* --- Full Height Layout --- */
html,
body {
    height: 100%;
    margin: 0;
    overflow: hidden;
    /* Prevent body scrollbars */
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
    background-color: var(--bg-color);
    color: var(--text-color);
    transition: background-color 0.3s, color 0.3s;
    display: flex;
    flex-direction: column;
}

.container {
    max-width: 1400px;
    margin: 0 auto;
    padding: 20px;
    width: 100%;
    display: flex;
    flex-direction: column;
    flex-grow: 1;
    /* Allow container to fill body */
    min-height: 0;
    /* Flexbox bug fix */
}

header,
.config-options {
    margin-bottom: 20px;
    flex-shrink: 0;
    /* Prevent header/options from shrinking */
}

h1,
h2 {
    border-bottom: 2px solid var(--border-color);
    padding-bottom: 10px;
    margin-top: 0;
}

/* --- Side-by-Side Layout --- */
.main-content {
    display: flex;
    flex-direction: row;
    gap: 20px;
    align-items: stretch;
    flex-grow: 1;
    min-height: 0;
}

.editor-container,
.output-container {
    flex: 1;
    min-width: 0;
    display: flex;
    flex-direction: column;
    background-color: var(--secondary-bg);
    padding: 15px;
    border-radius: 8px;
}

/* --- Editor and Output Box Styling --- */
.editor-toolbar {
    margin-bottom: 10px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-color);
}

.toolbar-button {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 4px;
    padding: 5px 10px;
    margin-right: 5px;
    cursor: pointer;
    font-size: 14px;
}

.toolbar-button:hover {
    background: #f0f0f0;
}

#editor {
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--editor-bg);
    outline: none;
    overflow-y: auto;
    flex-grow: 1;
}

#editor:focus {
    border-color: var(--primary-color);
    box-shadow: 0 0 0 2px rgba(0, 123, 255, 0.25);
}

.output-container .output-box {
    position: relative;
    flex: 1;
    display: flex;
    flex-direction: column;
    margin-bottom: 15px;
}

.output-container .output-box:last-child {
    margin-bottom: 0;
}

.output-container h3 {
    margin-top: 0;
    margin-bottom: 5px;
    font-size: 16px;
}

.output-box pre,
.output-box textarea {
    width: 100%;
    box-sizing: border-box;
    padding: 10px;
    border: 1px solid var(--border-color);
    border-radius: 4px;
    background-color: var(--code-bg);
    color: var(--code-text);
    font-family: "SF Mono", "Fira Code", "Consolas", monospace;
    font-size: 14px;
    flex-grow: 1;
}

.output-box pre {
    white-space: pre-wrap;
    word-wrap: break-word;
}

.output-box textarea {
    resize: none;
}

.copy-button {
    position: absolute;
    top: 5px;
    right: 5px;
    background-color: var(--primary-color);
    color: var(--button-text);
    border: none;
    border-radius: 4px;
    padding: 5px 10px;
    cursor: pointer;
    font-size: 12px;
    transition: background-color 0.2s;
    z-index: 10;
}

.copy-button:hover {
    background-color: var(--primary-hover);
}

/* --- Config Options Styling --- */
.config-options div {
    display: flex;
    align-items: center;
}

.config-options label {
    margin-left: 8px;
    cursor: pointer;
    user-select: none;
}

.config-options input[type="checkbox"] {
    transform: scale(1.2);
    cursor: pointer;
}

.config-options .sub-option {
    margin-top: 10px;
    margin-left: 25px;
}

.config-options input:disabled+label {
    color: #999;
    cursor: not-allowed;
}

body.dark-mode .config-options input:disabled+label {
    color: #888;
}

/* --- Theme Switcher --- */
.theme-switcher {
    position: absolute;
    top: 20px;
    right: 20px;
}

/* --- Link Panel Styling --- */
#link-panel {
    position: absolute;
    display: none;
    background-color: var(--bg-color);
    border: 1px solid var(--border-color);
    border-radius: 6px;
    padding: 8px;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 100;
    align-items: center;
    gap: 8px;
    transition: opacity 0.1s ease-in-out, transform 0.1s ease-in-out;
}

#link-url-input {
    border: 1px solid var(--border-color);
    border-radius: 4px;
    padding: 6px 8px;
    background-color: var(--editor-bg);
    color: var(--text-color);
    outline: none;
    width: 250px;
    font-size: 14px;
}

#link-url-input:focus {
    border-color: var(--primary-color);
}

#link-panel button {
    background: none;
    border: none;
    cursor: pointer;
    padding: 4px;
    border-radius: 4px;
    display: flex;
    align-items: center;
    justify-content: center;
}

#link-panel button:hover {
    background-color: var(--secondary-bg);
}

#link-panel button svg {
    width: 20px;
    height: 20px;
    fill: var(--text-color);
}