/* Theme Variables (Dark Mode Default) */
:root {
    /* Backgrounds & Text */
    --bg-body: #121212;
    --text-color: #e0e0e0;
    --bg-container: #1e1e1e;

    /* Components */
    --bg-th: #333;
    --table-border: #ddd;
    --input-bg: #333;
    --input-text: #e0e0e0;
    --input-border: #555;
    --link-color: #4CAF50;
    --link-hover-color: #2b632d;
    --button-bg: #4CAF50;
    --border-color: #444;
    --select-bg: var(--input-bg);
    --select-text: var(--input-text);
    --select-border: var(--input-border);
    --button-hover-bg: #2b632d;
    --lock-color: #595959;
    --lock-color-hover: #373737;
}

/* Light Mode Color Overrides */
body.light-mode {
    --bg-body: #f9f9f9;
    --text-color: #333;
    --bg-container: white;
    --bg-th: #f2f2f2;
    --input-bg: #fff;
    --input-text: #333;
    --input-border: #ccc;
    --border-color: #ccc;
}

/* Global Styles (Spacing & Layout are defined here, colors via variables) */
body {
    font-family: Arial, sans-serif;
    display: flex;
    flex-direction: column;
    margin: 0;
    padding: 20px;
    background-color: var(--bg-body);
    color: var(--text-color);
}

a {
    color: var(--link-color);
    text-decoration: none;
    margin: 0 10px;
    transition: color 0.3s;
}

a:hover {
    text-decoration: underline;
    color: var(--link-hover-color);
}

h1 {
    text-align: center;
}

.container {
    max-width: 800px;
    margin: auto;
    background: var(--bg-container);
    padding: 20px;
    border-radius: 8px;
    box-shadow: 0 0 10px rgba(0, 0, 0, 0.1);
}

/* Button Styles */
.button {
    padding: 10px 20px;
    margin: 0 10px;
    background-color: var(--button-bg);
    color: white;
    font-size: 16px;
    cursor: pointer;
    border: none;
    border-radius: 5px;
    box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);
    transition: background-color 0.3s, box-shadow 0.3s;
}

.button:hover {
    background-color: var(--button-hover-bg);
    box-shadow: 0 6px 8px rgba(0, 0, 0, 0.15);
}

.button:disabled {
    background-color: #ccc;
    cursor: not-allowed;
}

/* General Button Element */
button {
    padding: 10px 15px;
    background-color: var(--button-bg);
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
    margin-top: 10px;
    transition: background-color 0.3s;
}

button:hover {
    background-color: var(--button-hover-bg);
}

/* Table Styles */
table {
    width: 100%;
    border-collapse: collapse;
    margin-top: 20px;
}

th, td {
    padding: 10px;
    text-align: left;
    border-bottom: 1px solid var(--table-border);
}

th {
    background-color: var(--bg-th);
    color: var(--text-color);
}

/* Input Styles */
input[type="text"] {
    width: calc(100% - 22px);
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    margin-top: 10px;
    background-color: var(--input-bg);
    color: var(--input-text);
}

input[type="number"] {
    width: calc(100% - 22px);
    padding: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    margin-top: 10px;
    background-color: var(--input-bg);
    color: var(--input-text);
}

/* Form Styles */
form label {
    display: block;
    margin-top: 15px;
    font-weight: bold;
    color: var(--text-color);
}

select,
form select, form selector,
form input,
form textarea {
    width: 100%;
    padding: 8px;
    margin-top: 5px;
    margin-bottom: 10px;
    border: 1px solid var(--input-border);
    border-radius: 4px;
    box-sizing: border-box;
    font-size: 1em;
    background-color: var(--input-bg);
    color: var(--input-text);
}

form select option, selector option {
    background-color: var(--select-bg);
    color: var(--select-text);
}

form textarea {
    min-height: 120px;
    resize: vertical;
}

.custom-alert-overlay {
    position: fixed;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
    display: flex;
    justify-content: center;
    align-items: center;
    z-index: 9999;
    background-color: rgba(0, 0, 0, 0.5);
}

.custom-alert {
    padding: 20px;
    border-radius: 5px;
    background-color: var(--bg-container);
    box-shadow: 0 2px 10px rgba(0, 0, 0, 0.2);
    max-width: 90%;
    width: 400px;
    color: var(--text-color);
}

.custom-alert h3 {
    margin: 0 0 15px 0;
    text-align: center;
}

.custom-alert p {
    margin-bottom: 20px;
    text-align: center;
}

.custom-alert-buttons {
    display: flex;
    gap: 10px;
    justify-content: center;
}

.custom-alert-confirm {
    padding: 8px 16px;
    background-color: #2a5885;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.custom-alert-cancel {
    padding: 8px 16px;
    background-color: #ff4444;
    color: white;
    border: none;
    border-radius: 4px;
    cursor: pointer;
}

.markdown-link {
    color: var(--link-color);
    text-decoration: underline;
}

.markdown-link:hover {
    color: var(--link-hover-color);
}

.no-load-indicator {
    font-size: 0.8em;
    color: #888;
    font-style: italic;
}

.external-image-container {
    margin: 10px 0;
    position: relative;
}

.external-image-warning {
    padding: 10px;
    border: 1px solid #ff9800;
    background-color: rgba(255, 152, 0, 0.1);
    margin-bottom: 10px;
}

.load-image-btn {
    background-color: var(--button-bg);
    color: white;
    border: none;
    padding: 5px 10px;
    cursor: pointer;
    border-radius: 3px;
}

.load-image-btn:hover {
    background-color: var(--button-hover-bg);
}

button.disabled,
button.btn.disabled {
    background-color: var(--lock-color) !important;
    opacity: 0.5 !important;
    pointer-events: none;
}

button.disabled:hover,
button.btn.disabled:hover {
    background-color: var(--lock-color-hover) !important;
}

/* --- Custom for search page --- */
.input-clear-btn {
    position: absolute;
    right: 8px;
    top: 50%;
    transform: translateY(-50%);
    background: #222;
    color: #aaa;
    border: none;
    border-radius: 50%;
    width: 20px;
    height: 20px;
    font-size: 16px;
    cursor: pointer;
    display: none;
    align-items: center;
    justify-content: center;
    z-index: 2;
    transition: background 0.2s, color 0.2s;
}

.input-clear-btn:hover {
    background: #444;
    color: #fff;
}

.field {
    position: relative;
}

/* Make sample container a positioning context for its clear button */
.sample {
    position: relative;
}

.field input:focus + .input-clear-btn,
.field input:not(:placeholder-shown) + .input-clear-btn,
.field textarea:focus + .input-clear-btn,
.field textarea:not(:placeholder-shown) + .input-clear-btn {
    display: flex;
}

/* Timeframe input style */
input[type="number"].timeframe {
    width: 90px;
    display: inline-block;
    margin-left: 8px;
    margin-right: 8px;
    text-align: right;
}

.timeframe-label {
    display: flex;
    align-items: center;
    gap: 8px;
}

.btn-orange {
    background: #f59e42;
    color: #23232a;
}

.btn-orange:hover {
    background: #ea580c;
    color: #fff;
}

.btn-red {
    background: #ef4444;
}

.btn-red:hover {
    background: #b91c1c;
}

.btn-gray {
    background: #64748b;
}

.btn-gray:hover {
    background: #334155;
}

.stacktrace-links {
    display: flex;
    flex-direction: column;
    gap: 0.35rem;
}

.stacktrace-links--detail {
    max-height: 320px;
    overflow-y: auto;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.25);
}

.stacktrace-list a {
    padding: 0.4rem;
    border-radius: 0.25rem;
    border: 1px solid var(--accent);
    background: rgba(76, 201, 240, 0.1);
    color: var(--accent);
    text-decoration: none;
    font-weight: 500;
    overflow-wrap: break-word;
}

.stacktrace-entry {
    display: flex;
    align-items: center;
    gap: 0.35rem;
}

.stacktrace-ide-status {
    margin-bottom: 0.5rem;
    padding: 0.4rem 0.6rem;
    border: 1px solid var(--border-color);
    border-radius: 0.35rem;
    background: rgba(255, 193, 7, 0.1);
    color: #facc15;
    font-size: 0.85rem;
}

.stacktrace-github-btn {
    padding: 0.3rem 0.6rem;
    border-radius: 0.4rem;
    border: 1px solid var(--border-color);
    background: transparent;
    color: var(--text-color);
    cursor: pointer;
}

.stacktrace-github-btn:hover {
    background: rgba(255, 255, 255, 0.05);
}

.stacktrace-controls {
    margin-top: 1rem;
    display: flex;
    flex-direction: column;
    gap: 0.65rem;
    padding: 0.75rem;
    border: 1px solid var(--border-color);
    border-radius: 0.5rem;
    background: rgba(0, 0, 0, 0.1);
}

.stacktrace-controls textarea,
.stacktrace-controls input {
    background: var(--input-bg);
    color: var(--input-text);
    border: 1px solid var(--input-border);
}

.stacktrace-explainer {
    margin: 0;
    font-size: 0.85rem;
    color: var(--muted, #b0b0b0);
}

.stacktrace-filter-field {
    position: relative;
    display: flex;
    align-items: center;
    gap: 0.4rem;
}

.stacktrace-help {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 18px;
    height: 18px;
    border-radius: 50%;
    background: var(--accent, var(--link-color));
    color: #010101;
    font-size: 0.75rem;
    cursor: help;
}

.stacktrace-help[data-tooltip] {
    position: relative;
}

.stacktrace-help[data-tooltip]::after {
    content: attr(data-tooltip);
    position: absolute;
    bottom: 125%;
    left: 50%;
    transform: translateX(-50%);
    white-space: pre-line;
    background: #000;
    color: #fff;
    padding: 0.4rem 0.6rem;
    border-radius: 0.35rem;
    font-size: 0.75rem;
    opacity: 0;
    pointer-events: none;
    transition: opacity 0.1s ease;
    min-width: 180px;
    max-width: 260px;
    z-index: 5;
}

.stacktrace-help[data-tooltip]:hover::after {
    opacity: 1;
}

.stacktrace-controls h3 {
    display: flex;
    align-items: center;
    gap: 0.35rem;
    margin: 0;
}