/* ============================================
   TECHNIKER BERECHNUNGSTOOLS — GitHub Style
   ============================================ */
@import url('https://fonts.googleapis.com/css2?family=IBM+Plex+Sans:wght@400;500;600&family=IBM+Plex+Mono:wght@400;500&display=swap');

/* ---- LIGHT MODE (default) ---- */
:root {
    --bg-canvas: #f6f8fa;
    --bg-default: #ffffff;
    --bg-subtle: #f6f8fa;
    --bg-inset: #eff2f5;
    --bg-emphasis: #24292f;
    --bg-accent: #ddf4ff;
    --bg-accent-emphasis: #0969da;
    --bg-success: #dafbe1;
    --bg-success-emphasis: #1a7f37;
    --bg-attention: #fff8c5;
    --bg-danger: #ffebe9;
    --border-default: #d0d7de;
    --border-muted: #d8dee4;
    --border-subtle: rgba(27,31,36,0.08);
    --text-primary: #24292f;
    --text-secondary: #57606a;
    --text-tertiary: #6e7781;
    --text-link: #0969da;
    --text-success: #1a7f37;
    --text-attention: #9a6700;
    --text-danger: #cf222e;
    --text-on-emphasis: #ffffff;
    --accent-fg: #0969da;
    --accent-emphasis: #0969da;
    --success-fg: #1a7f37;
    --star-color: #d4a72c;
    --shadow-sm: 0 1px 0 rgba(27,31,36,0.04);
    --shadow-md: 0 3px 6px rgba(140,149,159,0.15);
    --shadow-lg: 0 8px 24px rgba(140,149,159,0.2);
    --shadow-drag: 0 12px 28px rgba(140,149,159,0.3);
    --overlay-bg: rgba(27,31,36,0.5);
    --header-bg: #24292f;
    --header-border: #57606a;
    --font-sans: 'IBM Plex Sans', -apple-system, BlinkMacSystemFont, "Segoe UI", Helvetica, sans-serif;
    --font-mono: 'IBM Plex Mono', SFMono-Regular, Consolas, monospace;
    --radius-sm: 6px;
    --radius-md: 8px;
    --radius-lg: 12px;
    --transition: 0.2s ease;
}

/* ---- DARK MODE ---- */
[data-theme="dark"] {
    --bg-canvas: #0d1117;
    --bg-default: #161b22;
    --bg-subtle: #161b22;
    --bg-inset: #010409;
    --bg-emphasis: #6e7681;
    --bg-accent: #121d2f;
    --bg-accent-emphasis: #1f6feb;
    --bg-success: #12261e;
    --bg-success-emphasis: #238636;
    --bg-attention: #272115;
    --bg-danger: #2d1619;
    --border-default: #30363d;
    --border-muted: #21262d;
    --border-subtle: rgba(240,246,252,0.1);
    --text-primary: #c9d1d9;
    --text-secondary: #8b949e;
    --text-tertiary: #6e7681;
    --text-link: #58a6ff;
    --text-success: #3fb950;
    --text-attention: #d29922;
    --text-danger: #f85149;
    --text-on-emphasis: #ffffff;
    --accent-fg: #58a6ff;
    --accent-emphasis: #1f6feb;
    --success-fg: #3fb950;
    --star-color: #e3b341;
    --shadow-sm: 0 0 transparent;
    --shadow-md: 0 3px 6px #010409;
    --shadow-lg: 0 8px 24px #010409;
    --shadow-drag: 0 12px 28px rgba(1,4,9,0.6);
    --overlay-bg: rgba(1,4,9,0.7);
    --header-bg: #161b22;
    --header-border: #30363d;
}

/* ---- RESET ---- */
*, *::before, *::after {
    margin: 0;
    padding: 0;
    box-sizing: border-box;
}

html { scroll-behavior: smooth; }

body {
    font-family: var(--font-sans);
    background: var(--bg-canvas);
    color: var(--text-primary);
    line-height: 1.6;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
    -webkit-font-smoothing: antialiased;
}

/* ---- HEADER ---- */
header {
    background: var(--header-bg);
    border-bottom: 1px solid var(--header-border);
    padding: 16px 24px;
    display: flex;
    align-items: center;
    justify-content: space-between;
    position: sticky;
    top: 0;
    z-index: 100;
}

.header-left {
    display: flex;
    align-items: center;
    gap: 12px;
}

.header-logo {
    width: 32px;
    height: 32px;
    fill: #ffffff;
    flex-shrink: 0;
}

.header-title {
    color: #ffffff;
    font-size: 17px;
    font-weight: 600;
    letter-spacing: -0.01em;
}

.header-right {
    display: flex;
    align-items: center;
    gap: 8px;
}

/* Theme Toggle */
.theme-toggle {
    background: transparent;
    border: 1px solid rgba(255,255,255,0.2);
    color: rgba(255,255,255,0.7);
    width: 36px;
    height: 36px;
    border-radius: var(--radius-md);
    cursor: pointer;
    display: flex;
    align-items: center;
    justify-content: center;
    transition: all var(--transition);
    font-size: 18px;
    padding: 0;
    box-shadow: none;
}

.theme-toggle:hover {
    background: rgba(255,255,255,0.08);
    border-color: rgba(255,255,255,0.35);
    color: #ffffff;
    transform: none;
    box-shadow: none;
}

/* ---- BACK BUTTON (for sub-pages) ---- */
.back-bar {
    background: var(--bg-default);
    border-bottom: 1px solid var(--border-default);
    padding: 12px 24px;
}

.back-link {
    display: inline-flex;
    align-items: center;
    gap: 6px;
    color: var(--text-link);
    text-decoration: none;
    font-size: 14px;
    font-weight: 500;
    padding: 6px 12px;
    border-radius: var(--radius-md);
    transition: all var(--transition);
}

.back-link:hover {
    background: var(--bg-accent);
    text-decoration: none;
}

.back-link svg {
    width: 16px;
    height: 16px;
    fill: currentColor;
}

/* ---- MAIN CONTAINER ---- */
.page-container {
    flex: 1;
    max-width: 1200px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

.container {
    flex: 1;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
    background: var(--bg-default);
    border: 1px solid var(--border-default);
    border-radius: var(--radius-lg);
    animation: fadeIn 0.3s ease;
}

.container2 {
    flex: 1;
    max-width: 860px;
    width: 100%;
    margin: 0 auto;
    padding: 24px;
}

@keyframes fadeIn {
    from { opacity: 0; transform: translateY(8px); }
    to { opacity: 1; transform: translateY(0); }
}

/* ---- TYPOGRAPHY ---- */
h2, h3, h4 {
    font-family: var(--font-sans);
    color: var(--text-primary);
    font-weight: 600;
}

h2 {
    font-size: 22px;
    margin-bottom: 8px;
    padding-bottom: 10px;
    border-bottom: 1px solid var(--border-default);
}

h3 {
    font-size: 16px;
    margin-top: 20px;
    margin-bottom: 8px;
}

p {
    color: var(--text-secondary);
    font-size: 14px;
    margin-bottom: 12px;
    line-height: 1.7;
}

/* ---- DESCRIPTION BOX ---- */
.description {
    background: var(--bg-accent);
    border: 1px solid var(--border-default);
    border-left: 3px solid var(--accent-fg);
    border-radius: var(--radius-md);
    padding: 16px 20px;
    margin-bottom: 24px;
    font-size: 14px;
    line-height: 1.7;
    color: var(--text-secondary);
}

/* ---- TABLES ---- */
table {
    width: 100%;
    border-collapse: separate;
    border-spacing: 0;
    margin-bottom: 20px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}

th, td {
    padding: 12px 16px;
    text-align: center;
    font-size: 14px;
    border-bottom: 1px solid var(--border-default);
}

th {
    background: var(--bg-subtle);
    font-weight: 600;
    font-size: 13px;
    color: var(--text-primary);
    text-transform: uppercase;
    letter-spacing: 0.04em;
}

th[colspan] {
    background: var(--header-bg);
    color: var(--text-on-emphasis);
    font-size: 14px;
    text-transform: none;
    letter-spacing: normal;
    padding: 14px 16px;
}

td {
    background: var(--bg-default);
    color: var(--text-primary);
}

tr:last-child td {
    border-bottom: none;
}

tr:hover td {
    background: var(--bg-subtle);
}

/* ---- FORM ELEMENTS ---- */
.input-field,
input[type="number"],
input[type="text"],
select {
    max-width: 260px;
    padding: 8px 12px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    font-family: var(--font-sans);
    font-size: 14px;
    color: var(--text-primary);
    background: var(--bg-default);
    transition: all var(--transition);
    outline: none;
}

.input-field:focus,
input[type="number"]:focus,
input[type="text"]:focus,
select:focus {
    border-color: var(--accent-fg);
    box-shadow: 0 0 0 3px rgba(9,105,218,0.15);
    outline: none;
}

[data-theme="dark"] .input-field:focus,
[data-theme="dark"] input[type="number"]:focus,
[data-theme="dark"] input[type="text"]:focus,
[data-theme="dark"] select:focus {
    box-shadow: 0 0 0 3px rgba(31,111,235,0.3);
}

select {
    cursor: pointer;
    appearance: none;
    -webkit-appearance: none;
    background-image: url("data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' width='12' height='12' viewBox='0 0 12 12'%3E%3Cpath fill='%2357606a' d='M6 8.825L1.175 4 2.238 2.938 6 6.7 9.763 2.938 10.825 4z'/%3E%3C/svg%3E");
    background-repeat: no-repeat;
    background-position: right 10px center;
    padding-right: 32px;
}

/* ---- RESULT FIELDS ---- */
.result-field {
    background: var(--bg-success) !important;
    color: var(--text-success) !important;
    padding: 10px 14px;
    border-radius: var(--radius-md);
    font-weight: 600;
    font-family: var(--font-mono);
    font-size: 14px;
}

.good {
    background: var(--bg-success) !important;
    color: var(--text-success) !important;
}

.bad {
    background: var(--bg-danger) !important;
    color: var(--text-danger) !important;
}

/* ---- BUTTONS ---- */
button {
    background: var(--bg-success-emphasis);
    color: var(--text-on-emphasis);
    padding: 10px 20px;
    border: 1px solid rgba(27,31,36,0.15);
    border-radius: var(--radius-md);
    cursor: pointer;
    font-family: var(--font-sans);
    font-size: 14px;
    font-weight: 500;
    transition: all var(--transition);
    box-shadow: var(--shadow-sm);
}

button:hover {
    filter: brightness(1.1);
    transform: none;
    box-shadow: var(--shadow-sm);
}

button:active {
    transform: scale(0.98);
}

/* ---- FOOTER ---- */
.bottom-header,
footer.bottom-header {
    background: var(--bg-default);
    border-top: 1px solid var(--border-default);
    color: var(--text-tertiary);
    text-align: center;
    padding: 20px 24px;
    font-size: 12px;
    margin-top: auto;
}

.bottom-header p {
    margin: 0;
    color: var(--text-tertiary);
    font-size: 12px;
}

.bottom-header a {
    color: var(--text-link);
    text-decoration: none;
}

.bottom-header a:hover {
    text-decoration: underline;
}

/* ---- RESPONSIVE ---- */
@media (max-width: 768px) {
    header {
        padding: 12px 16px;
    }

    .header-title {
        font-size: 15px;
    }

    .page-container {
        padding: 16px;
    }

    .container {
        padding: 16px;
        border-radius: var(--radius-md);
    }

    table { font-size: 13px; }
    th, td { padding: 10px 10px; }

    .input-field,
    input[type="number"],
    input[type="text"],
    select {
        max-width: 100%;
    }
}

@media (max-width: 480px) {
    header { padding: 10px 12px; }
    .header-title { font-size: 14px; }
    .page-container { padding: 12px; }
    .container { padding: 14px; }
    button { width: 100%; padding: 12px; }
}

/* ---- VALIDATION ---- */
.input-error {
    border-color: var(--text-danger) !important;
    box-shadow: 0 0 0 2px rgba(207,34,46,0.15) !important;
}

.validation-msg {
    display: inline-block;
    font-size: 12px;
    color: var(--text-danger);
    margin-left: 6px;
    font-weight: 500;
}

/* ---- HISTORY PANEL ---- */
.history-panel {
    margin-top: 20px;
    border: 1px solid var(--border-default);
    border-radius: var(--radius-md);
    overflow: hidden;
}

.history-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    padding: 10px 14px;
    background: var(--bg-subtle);
    border-bottom: 1px solid var(--border-default);
    font-size: 13px;
    font-weight: 600;
    color: var(--text-primary);
}

.history-clear {
    background: none;
    border: none;
    color: var(--text-danger);
    font-size: 12px;
    cursor: pointer;
    padding: 2px 8px;
    border-radius: var(--radius-sm);
    font-family: var(--font-sans);
    font-weight: 500;
    box-shadow: none;
}

.history-clear:hover {
    background: var(--bg-danger);
    transform: none;
    box-shadow: none;
    filter: none;
}

.history-entry {
    padding: 10px 14px;
    border-bottom: 1px solid var(--border-default);
    cursor: pointer;
    transition: background 0.15s;
    display: flex;
    flex-direction: column;
    gap: 2px;
}

.history-entry:last-child {
    border-bottom: none;
}

.history-entry:hover {
    background: var(--bg-subtle);
}

.history-time {
    font-size: 11px;
    color: var(--text-tertiary);
    font-family: var(--font-mono);
}

.history-data {
    font-size: 13px;
    color: var(--text-secondary);
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.history-empty {
    padding: 16px;
    text-align: center;
    color: var(--text-tertiary);
    font-size: 13px;
}

/* ---- SHORTCUTS HINT ---- */
.shortcuts-hint {
    font-size: 11px;
    color: var(--text-tertiary);
    margin-top: 12px;
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
}

.shortcuts-hint kbd {
    display: inline-block;
    padding: 1px 5px;
    font-family: var(--font-mono);
    font-size: 11px;
    background: var(--bg-subtle);
    border: 1px solid var(--border-default);
    border-radius: 3px;
    color: var(--text-secondary);
}

/* ---- RECENTLY USED BADGE ---- */
.badge-recent {
    display: inline-flex;
    align-items: center;
    gap: 3px;
    font-size: 11px;
    padding: 1px 8px;
    border-radius: 20px;
    background: var(--bg-attention);
    color: var(--text-attention);
    border: 1px solid transparent;
    font-weight: 500;
    white-space: nowrap;
}

.badge-frequent {
    background: var(--bg-accent);
    color: var(--accent-fg);
}
