/* ==========================================================================
   IHK-Prüfungsrechner – Responsive Basis-Styling
   Keine externen Abhängigkeiten (kein Bootstrap, keine CDN-Schriftarten)
   ========================================================================== */

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

html {
    font-size: 16px;
    line-height: 1.5;
}

body {
    font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif;
    color: #1a1a1a;
    background-color: #f5f7fa;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

/* --- Typography --- */
h1, h2, h3, h4 {
    font-weight: 600;
    line-height: 1.3;
    margin-bottom: 0.5rem;
}

h1 { font-size: 1.75rem; }
h2 { font-size: 1.35rem; }
h3 { font-size: 1.15rem; }

p { margin-bottom: 0.75rem; }

a {
    color: #2563eb;
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

/* --- Container --- */
.container {
    width: 100%;
    max-width: 1200px;
    margin: 0 auto;
    padding: 1.5rem 1rem;
}

/* --- Navigation --- */
.main-nav {
    background-color: #1e293b;
    color: #fff;
    padding: 0.75rem 1rem;
    position: sticky;
    top: 0;
    z-index: 100;
}

.nav-container {
    max-width: 1200px;
    margin: 0 auto;
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 0.5rem;
}

.nav-brand {
    color: #fff;
    font-weight: 700;
    font-size: 1.1rem;
    text-decoration: none;
}

.nav-brand:hover {
    text-decoration: none;
    opacity: 0.9;
}

.nav-links {
    display: flex;
    align-items: center;
    gap: 1rem;
    flex-wrap: wrap;
}

.nav-links a {
    color: #cbd5e1;
    text-decoration: none;
    padding: 0.25rem 0.5rem;
    border-radius: 4px;
    transition: color 0.2s, background-color 0.2s;
}

.nav-links a:hover,
.nav-links a.active {
    color: #fff;
    background-color: rgba(255, 255, 255, 0.1);
    text-decoration: none;
}

.nav-user {
    color: #94a3b8;
    font-size: 0.875rem;
}

.nav-form {
    display: inline;
}

/* --- Buttons --- */
.btn {
    display: inline-block;
    padding: 0.5rem 1rem;
    font-size: 0.875rem;
    font-weight: 500;
    border: 1px solid transparent;
    border-radius: 6px;
    cursor: pointer;
    text-align: center;
    text-decoration: none;
    transition: background-color 0.2s, border-color 0.2s, opacity 0.2s;
    line-height: 1.4;
}

.btn:hover {
    text-decoration: none;
    opacity: 0.9;
}

.btn-primary {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.btn-primary:hover {
    background-color: #1d4ed8;
    border-color: #1d4ed8;
}

.btn-danger {
    background-color: #dc2626;
    color: #fff;
    border-color: #dc2626;
}

.btn-danger:hover {
    background-color: #b91c1c;
}

.btn-outline {
    background-color: transparent;
    color: #fff;
    border-color: #64748b;
}

.btn-outline:hover {
    background-color: rgba(255, 255, 255, 0.1);
    border-color: #94a3b8;
}

.btn-sm {
    padding: 0.25rem 0.75rem;
    font-size: 0.8rem;
}

.btn-block {
    display: block;
    width: 100%;
}

/* --- Forms --- */
.form-group {
    margin-bottom: 1rem;
}

.form-group label {
    display: block;
    font-weight: 500;
    margin-bottom: 0.25rem;
    font-size: 0.875rem;
    color: #374151;
}

.form-row {
    display: flex;
    gap: 1rem;
    flex-wrap: wrap;
}

.form-row .form-group {
    flex: 1;
    min-width: 150px;
}

input[type="text"],
input[type="email"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    padding: 0.5rem 0.75rem;
    font-size: 0.875rem;
    border: 1px solid #d1d5db;
    border-radius: 6px;
    background-color: #fff;
    transition: border-color 0.2s, box-shadow 0.2s;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: #2563eb;
    box-shadow: 0 0 0 3px rgba(37, 99, 235, 0.1);
}

input.is-invalid {
    border-color: #dc2626;
    box-shadow: 0 0 0 3px rgba(220, 38, 38, 0.1);
}

input[type="number"] {
    width: 80px;
    text-align: center;
}

/* --- Alerts --- */
.alert {
    padding: 0.75rem 1rem;
    border-radius: 6px;
    margin-bottom: 1rem;
    font-size: 0.875rem;
    border: 1px solid transparent;
}

.alert-success {
    background-color: #ecfdf5;
    color: #065f46;
    border-color: #a7f3d0;
}

.alert-error {
    background-color: #fef2f2;
    color: #991b1b;
    border-color: #fecaca;
}

.alert-info {
    background-color: #eff6ff;
    color: #1e40af;
    border-color: #bfdbfe;
}

/* --- Tables --- */
table {
    width: 100%;
    border-collapse: collapse;
    background-color: #fff;
    border-radius: 8px;
    overflow: hidden;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

thead {
    background-color: #f8fafc;
}

th, td {
    padding: 0.75rem 1rem;
    text-align: left;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.875rem;
}

th {
    font-weight: 600;
    color: #374151;
    white-space: nowrap;
}

th a {
    color: #374151;
    text-decoration: none;
}

th a:hover {
    color: #2563eb;
}

tbody tr:hover {
    background-color: #f9fafb;
}

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

/* --- Cards --- */
.card {
    background-color: #fff;
    border-radius: 8px;
    padding: 1.5rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
    margin-bottom: 1.5rem;
}

.card h2, .card h3 {
    margin-bottom: 1rem;
}

/* --- Login Page --- */
.login-page {
    background-color: #1e293b;
    display: flex;
    align-items: center;
    justify-content: center;
    min-height: 100vh;
}

.login-container {
    width: 100%;
    max-width: 400px;
    padding: 1rem;
}

.login-card {
    background-color: #fff;
    border-radius: 12px;
    padding: 2rem;
    box-shadow: 0 4px 24px rgba(0, 0, 0, 0.15);
    text-align: center;
}

.login-card h1 {
    font-size: 1.5rem;
    margin-bottom: 0.25rem;
}

.login-subtitle {
    color: #6b7280;
    font-size: 0.875rem;
    margin-bottom: 1.5rem;
}

.login-form {
    text-align: left;
}

.login-form .form-group {
    margin-bottom: 1.25rem;
}

.login-form .btn {
    margin-top: 0.5rem;
}

/* --- Badges --- */
.badge {
    display: inline-block;
    padding: 0.2rem 0.6rem;
    font-size: 0.75rem;
    font-weight: 600;
    border-radius: 12px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.badge-success {
    background-color: #ecfdf5;
    color: #065f46;
}

.badge-danger {
    background-color: #fef2f2;
    color: #991b1b;
}

.badge-warning {
    background-color: #fffbeb;
    color: #92400e;
}

.badge-info {
    background-color: #eff6ff;
    color: #1e40af;
}

/* --- Score Entry Sections --- */
.score-section {
    background-color: #fff;
    border-radius: 8px;
    padding: 1rem 1.25rem;
    margin-bottom: 0.75rem;
    box-shadow: 0 1px 3px rgba(0, 0, 0, 0.08);
}

.score-section h3 {
    margin-bottom: 0.5rem;
    padding-bottom: 0.4rem;
    border-bottom: 2px solid #e5e7eb;
    font-size: 1rem;
}

.score-fields {
    display: grid;
    grid-template-columns: repeat(auto-fill, minmax(160px, 1fr));
    gap: 0.4rem;
}

.score-field {
    display: flex;
    flex-direction: column;
}

.score-field label {
    font-size: 0.72rem;
    color: #6b7280;
    margin-bottom: 0.1rem;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
}

.score-field input {
    width: 100%;
    text-align: center;
    padding: 0.3rem 0.4rem;
    font-size: 0.85rem;
}

.score-result {
    margin-top: 0.5rem;
    padding-top: 0.4rem;
    border-top: 1px solid #e5e7eb;
    display: flex;
    align-items: center;
    gap: 0.75rem;
    flex-wrap: wrap;
    font-size: 0.85rem;
}

.score-result .result-value {
    font-size: 1.05rem;
    font-weight: 700;
    color: #1e293b;
}

.score-result .result-grade {
    font-size: 0.8rem;
    color: #6b7280;
}

/* --- Mode Toggle --- */
.mode-toggle {
    display: flex;
    gap: 0.3rem;
    margin-bottom: 0.5rem;
}

.mode-toggle button {
    padding: 0.25rem 0.6rem;
    font-size: 0.75rem;
    border: 1px solid #d1d5db;
    border-radius: 4px;
    background-color: #fff;
    cursor: pointer;
    transition: background-color 0.2s, border-color 0.2s;
}

.mode-toggle button.active {
    background-color: #2563eb;
    color: #fff;
    border-color: #2563eb;
}

.mode-toggle button:hover:not(.active) {
    background-color: #f3f4f6;
}

/* --- MEPR Toggle --- */
.mepr-toggle {
    margin-top: 0.75rem;
}

.mepr-toggle summary {
    cursor: pointer;
    font-size: 0.85rem;
    color: #6b7280;
    user-select: none;
}

.mepr-toggle summary:hover {
    color: #374151;
}

.mepr-fields {
    margin-top: 0.5rem;
    padding: 0.75rem;
    background-color: #f9fafb;
    border-radius: 6px;
}

/* --- Pass Rules --- */
.pass-rules {
    list-style: none;
    padding: 0;
}

.pass-rules li {
    padding: 0.5rem 0;
    font-size: 0.875rem;
    display: flex;
    align-items: center;
    gap: 0.5rem;
}

.pass-rules .rule-icon {
    width: 20px;
    height: 20px;
    border-radius: 50%;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    font-size: 0.7rem;
    font-weight: 700;
    flex-shrink: 0;
}

.pass-rules .rule-pass {
    background-color: #ecfdf5;
    color: #065f46;
}

.pass-rules .rule-fail {
    background-color: #fef2f2;
    color: #991b1b;
}

.pass-rules .rule-pending {
    background-color: #f3f4f6;
    color: #6b7280;
}

/* --- Footer --- */
.main-footer {
    margin-top: auto;
    padding: 1rem;
    text-align: center;
    font-size: 0.8rem;
    color: #6b7280;
    border-top: 1px solid #e5e7eb;
}

/* --- Utility --- */
.text-center { text-align: center; }
.text-right { text-align: right; }
.mt-1 { margin-top: 0.5rem; }
.mt-2 { margin-top: 1rem; }
.mb-1 { margin-bottom: 0.5rem; }
.mb-2 { margin-bottom: 1rem; }
.hidden { display: none; }

/* --- Sortable Table Headers --- */
th.sortable {
    cursor: pointer;
    user-select: none;
}

th.sortable:hover {
    background-color: #f1f5f9;
}

th.sortable::after {
    content: ' \2195';
    font-size: 0.7rem;
    color: #9ca3af;
}

/* --- Toast Notifications --- */
.toast {
    position: fixed;
    bottom: 1.5rem;
    right: 1.5rem;
    padding: 0.75rem 1.25rem;
    border-radius: 8px;
    font-size: 0.875rem;
    color: #fff;
    background-color: #1e293b;
    box-shadow: 0 4px 12px rgba(0, 0, 0, 0.15);
    z-index: 1000;
    opacity: 0;
    transform: translateY(10px);
    transition: opacity 0.3s, transform 0.3s;
}

.toast.show {
    opacity: 1;
    transform: translateY(0);
}

.toast-error {
    background-color: #dc2626;
}

.toast-success {
    background-color: #059669;
}

/* --- Responsive --- */
@media (max-width: 768px) {
    .nav-container {
        flex-direction: column;
        align-items: flex-start;
    }

    .nav-links {
        width: 100%;
        justify-content: flex-start;
    }

    .score-fields {
        grid-template-columns: repeat(auto-fill, minmax(140px, 1fr));
    }

    table {
        display: block;
        overflow-x: auto;
        white-space: nowrap;
    }

    .form-row {
        flex-direction: column;
    }

    h1 { font-size: 1.4rem; }
    h2 { font-size: 1.15rem; }
}

@media (max-width: 480px) {
    .container {
        padding: 1rem 0.75rem;
    }

    .score-section {
        padding: 1rem;
    }

    .login-card {
        padding: 1.5rem;
    }

    .score-fields {
        grid-template-columns: 1fr 1fr;
    }
}

/* --- Weighted Results Table --- */
.weighted-table {
    margin: 1rem 0;
    font-size: 0.875rem;
}

.weighted-table th {
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

.weighted-table td:nth-child(2),
.weighted-table td:nth-child(3),
.weighted-table td:nth-child(4),
.weighted-table td:nth-child(5),
.weighted-table th:nth-child(2),
.weighted-table th:nth-child(3),
.weighted-table th:nth-child(4),
.weighted-table th:nth-child(5) {
    text-align: center;
}

/* --- MEPR Hints --- */
.mepr-hint {
    margin-top: 0.5rem;
    padding: 0.4rem 0.75rem;
    border-radius: 4px;
    font-size: 0.8rem;
    font-weight: 500;
}

.mepr-hint-possible {
    background-color: #fffbeb;
    color: #92400e;
    border: 1px solid #fde68a;
}

.mepr-hint-impossible {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

/* --- MEPR Overview in Gesamtergebnis --- */
.mepr-overview {
    padding: 1rem;
    background-color: #fffbeb;
    border: 1px solid #fde68a;
    border-radius: 6px;
}

.mepr-overview h4 {
    margin-bottom: 0.5rem;
    color: #92400e;
}

.mepr-overview-list {
    list-style: none;
    padding: 0;
}

.mepr-overview-list li {
    padding: 0.4rem 0;
    font-size: 0.875rem;
    border-bottom: 1px solid #fde68a;
}

.mepr-overview-list li:last-child {
    border-bottom: none;
}

.mepr-overview-impossible {
    color: #991b1b;
}

.mepr-overview-possible {
    color: #92400e;
}

.mepr-overview-passed {
    color: #065f46;
    font-weight: 500;
    margin: 0;
}

/* --- MEPR Status Messages --- */
.mepr-status {
    padding: 0.6rem 0.75rem;
    border-radius: 4px;
    font-size: 0.875rem;
    font-weight: 500;
    margin-bottom: 0.5rem;
}

.mepr-status-passed {
    background-color: #ecfdf5;
    color: #065f46;
    border: 1px solid #a7f3d0;
}

.mepr-status-possible {
    background-color: #eff6ff;
    color: #1e40af;
    border: 1px solid #93c5fd;
}

.mepr-status-impossible {
    background-color: #fef2f2;
    color: #991b1b;
    border: 1px solid #fecaca;
}

.mepr-status-info {
    background-color: #f3f4f6;
    color: #374151;
    border: 1px solid #d1d5db;
}

/* --- Examiner Table (Einzelbewertung 3 Prüfer) --- */
.examiner-table {
    width: 100%;
    border-collapse: collapse;
    margin: 0;
    box-shadow: none;
}

.examiner-table th,
.examiner-table td {
    padding: 0.5rem 0.75rem;
    text-align: center;
    border-bottom: 1px solid #e5e7eb;
    font-size: 0.85rem;
    white-space: nowrap;
}

.examiner-table th:first-child,
.examiner-table td:first-child {
    text-align: left;
    font-weight: 500;
    white-space: nowrap;
}

.examiner-table thead th {
    background-color: #f8fafc;
    font-size: 0.8rem;
    font-weight: 600;
    color: #374151;
}

.examiner-table input[type="number"] {
    width: 100%;
    min-width: 80px;
    text-align: center;
    padding: 0.4rem 0.5rem;
    font-size: 0.9rem;
}

.examiner-table .avg-cell {
    font-weight: 700;
    color: #1e293b;
    background-color: #f0f9ff;
}

.avg-input {
    width: 100%;
    min-width: 80px;
    text-align: center;
    font-weight: 700;
    border: 1px solid #93c5fd;
    background: #f0f9ff;
    padding: 0.4rem 0.5rem;
    border-radius: 4px;
    font-size: 0.9rem;
}

.avg-input.avg-overridden {
    background-color: #fef3c7;
    border-color: #f59e0b;
}

.avg-input::placeholder {
    color: #9ca3af;
    font-weight: 400;
}

.examiner-table tbody tr:last-child td {
    border-bottom: none;
}

.examiner-table tbody tr:hover {
    background-color: #f9fafb;
}

/* Responsive: stack examiner table on small screens */
@media (max-width: 600px) {
    .examiner-table th:not(:first-child),
    .examiner-table td:not(:first-child) {
        padding: 0.4rem;
    }

    .examiner-table input[type="number"] {
        width: 55px;
        font-size: 0.8rem;
    }
}

/* --- Tabs --- */
.tab-nav {
    display: flex;
    align-items: stretch;
    flex-wrap: wrap;
    gap: 0;
    border-bottom: 2px solid #e5e7eb;
    margin-bottom: 0.75rem;
    padding-bottom: 0;
}

.tab-btn {
    padding: 0.6rem 0.75rem 0.5rem;
    font-size: 0.8rem;
    font-weight: 500;
    border: none;
    border-bottom: 3px solid transparent;
    background: none;
    color: #6b7280;
    cursor: pointer;
    white-space: nowrap;
    margin-bottom: -2px;
    transition: color 0.2s, border-color 0.2s;
}

.tab-btn:hover {
    color: #1e293b;
}

.tab-btn.active {
    color: #2563eb;
    border-bottom-color: #2563eb;
}

.tab-content {
    display: none;
}

.tab-content.active {
    display: block;
}

@media (max-width: 600px) {
    .tab-btn {
        padding: 0.4rem 0.5rem;
        font-size: 0.72rem;
    }
}

/* --- Tab Group Labels & Separators --- */
.tab-group-label {
    font-size: 0.7rem;
    font-weight: 600;
    color: #9ca3af;
    text-transform: uppercase;
    letter-spacing: 0.03em;
    padding: 0.5rem 0.4rem 0.5rem 0;
    align-self: center;
}

.tab-separator {
    width: 1px;
    background-color: #d1d5db;
    margin: 0.3rem 0.5rem;
    align-self: stretch;
}
