* {
    box-sizing: border-box;
}

:root {
    --bg: #e9eef2;
    --surface: #ffffff;
    --surface-muted: #f6f8fa;
    --line: #d2d8de;
    --text: #18222d;
    --text-soft: #566778;
    --brand: #1f4f7d;
    --brand-soft: #2f6aa1;
    --danger: #c43030;
    --ok: #1c7d4f;
    --radius: 10px;
    --shadow: 0 8px 24px rgba(7, 23, 38, 0.11);
}

html,
body {
    margin: 0;
    min-height: 100%;
    font-family: "Segoe UI", Tahoma, Arial, sans-serif;
    color: var(--text);
    background: radial-gradient(circle at 12% 12%, #f8fbff, #eef3f8 40%, #e4ebf3);
}

body[class*="page-"]:not(.page-login) {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

body[class*="page-"]:not(.page-login) > .page-content,
body.page-pdf-preview > .pdf-container,
body.page-instructor-workspace > .workspace {
    flex: 1 1 auto;
}

body[class*="page-"]:not(.page-login) > .app-footer {
    margin-top: auto;
}

a {
    color: inherit;
}

header.app-header,
footer.app-footer {
    background: linear-gradient(95deg, #1b3f63, #274e74 55%, #2d638f);
    color: #fff;
    padding: 12px 18px;
    box-shadow: 0 6px 12px rgba(20, 33, 45, 0.2);
}

header.app-header h1,
header.app-header h4,
footer.app-footer p {
    margin: 0;
}

header.app-header h4 {
    margin-top: 6px;
    color: rgba(255, 255, 255, 0.88);
    font-weight: 500;
}

.page-instructor-workspace .app-header {
    position: relative;
}

.window-bookmarks {
    position: absolute;
    right: 18px;
    top: 12px;
    display: flex;
    flex-wrap: wrap;
    justify-content: flex-end;
    gap: 6px;
    max-width: min(65vw, 980px);
    z-index: 5;
}

.window-bookmark {
    padding: 5px 10px;
    border-radius: 999px;
    border: 1px solid rgba(255, 255, 255, 0.45);
    background: rgba(255, 255, 255, 0.16);
    color: #fff;
    font-size: 12px;
    font-weight: 600;
    line-height: 1.2;
}

.window-bookmark:hover {
    background: rgba(255, 255, 255, 0.28);
}

.app-footer .footer-actions {
    float: right;
    display: inline-flex;
    gap: 8px;
    flex-wrap: wrap;
}

main.page-content {
    padding: 20px;
}

button,
.button {
    border: 0;
    border-radius: 8px;
    cursor: pointer;
    font-size: 14px;
    padding: 9px 14px;
    background: var(--brand);
    text-decoration: none;
    color: #fff;
    transition: background 0.2s ease, transform 0.15s ease;
}

button:hover,
.button:hover {
    background: var(--brand-soft);
}

button:active,
.button:active {
    transform: translateY(1px);
}

button:disabled {
    opacity: 0.6;
    cursor: not-allowed;
}

.card {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.dialogmodal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 2100;
    background: rgba(10, 18, 24, 0.55);
    justify-content: center;
    align-items: center;
    padding: 16px;
}

.dialogmodal > div {
    width: 100%;
    max-width: 400px;
    background: var(--surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
}

.dialogsection {
    margin-bottom: 12px;
}

.dialogsection input,
.dialogsection select,
.dialogsection textarea,
.login-box input,
input[type="text"],
input[type="password"],
input[type="number"],
select,
textarea {
    width: 100%;
    border: 1px solid var(--line);
    border-radius: 8px;
    background: #fff;
    padding: 8px 10px;
    margin-bottom: 8px;
}

.table-wrap {
    overflow-x: auto;
    padding-bottom: 8px;
}

.mobile-row-hint {
    color: var(--text-soft);
}

.desktop-only {
    display: table-cell;
}

table {
    width: 100%;
    border-collapse: collapse;
    background: #fff;
}

th,
td {
    border: 1px solid var(--line);
    padding: 4px;
    vertical-align: top;
}

th {
    background: var(--surface-muted);
}

.container-grid {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(320px, 1fr));
    gap: 16px;
}

.column {
    padding: 12px;
    position: relative;
}

.column h2 {
    margin: 0 0 8px;
    font-size: 18px;
    color: #f5f8fb;
    background: linear-gradient(100deg, #2a5f8e, #2f79a1);
    border-radius: 8px;
    padding: 8px 10px;
}

.column h3 {
    margin: 0 0 10px;
    background: #eef3f8;
    border: 1px solid #d4dde6;
    border-radius: 8px;
    padding: 8px;
    font-size: 14px;
}

.column h4 {
    margin: 8px 0;
    background: #f4f7fb;
    border: 1px solid #d2dbe4;
    border-radius: 6px;
    padding: 6px;
}

.page-login {
    display: flex;
    justify-content: center;
    align-items: center;
    min-height: 100vh;
    padding: 16px;
}

.login-box {
    width: 100%;
    max-width: 370px;
    background: #fff;
    border: 1px solid var(--line);
    border-radius: 12px;
    box-shadow: var(--shadow);
    padding: 22px;
}

.login-box h2 {
    margin-top: 0;
}

.error {
    color: var(--danger);
    margin-bottom: 10px;
}

.page-dashboard .page-content,
.page-student-list .page-content,
.page-trainer .page-content {
    padding-top: 20px;
    padding-bottom: 20px;
}

.page-dashboard .container-grid {
    display: grid;
    grid-template-columns: repeat(auto-fill, 320px);
    justify-content: start;
    gap: 16px;
}

.page-trainer .atis-btn {
    margin-top: 6px;
    display: inline-block;
}

.page-trainer .trainer-flightplan-summary-row td {
    text-align: center;
    vertical-align: middle;
}

.page-trainer .trainer-flightplan-summary-row .atis-btn {
    margin-top: 0;
    margin-left: 8px;
    vertical-align: middle;
}

.page-trainer .button-row {
    justify-content: center;
}

.page-dashboard .container-grid .column,
.page-student-list .column,
.page-trainer .column {
    background: var(--surface);
    border: 1px solid var(--line);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
}

.page-dashboard .container-grid .column {
    width: 320px;
    min-width: 320px;
}

.button-row {
    display: flex;
    gap: 8px;
    margin: 8px 0;
    flex-wrap: wrap;
}

.button-row-right {
    justify-content: flex-end;
}

.progressstatus {
    color: var(--ok);
}

.new-student-ui {
    display: none;
}

.delete-courseprogress-btn {
    background: var(--danger);
}

.message {
    color: #169b2a;
    margin-bottom: 10px;
}

.section-title {
    margin-top: 0;
}

.admin-table {
    width: 100%;
    border-collapse: collapse;
}

.admin-table th,
.admin-table td {
    border: 1px solid #ddd;
    padding: 8px;
    text-align: left;
    vertical-align: middle;
}

.admin-table th {
    background: #4a5c6f;
    color: #fff;
}

.save-row {
    text-align: center;
    padding: 12px;
}

.delete-row-btn {
    background: #c63d3d;
}

.delete-row-btn:hover {
    background: #a62f2f;
}

.page-admin-freqs .page-content,
.page-admin-users .page-content,
.page-admin-tts .page-content {
    width: min(1200px, calc(100vw - 24px));
    margin: 20px auto;
}

.freqs-card,
.admin-users-card,
.tts-card {
    padding: 14px;
}

.top-actions {
    margin: 10px 0;
}

.status-active {
    color: #169b2a;
    font-weight: bold;
}

.status-inactive {
    color: #b30000;
    font-weight: bold;
}

.level-admin {
    color: #d9534f;
    font-weight: bold;
}

.level-editor {
    color: #f0ad4e;
    font-weight: bold;
}

.level-user {
    color: #5cb85c;
    font-weight: bold;
}

.level-student {
    color: #1c3390;
    font-weight: bold;
}

.btn-secondary {
    padding: 6px 10px;
    font-size: 0.9em;
    margin-right: 6px;
}

.page-admin-tts .meta {
    display: grid;
    grid-template-columns: repeat(4, minmax(120px, 1fr));
    gap: 10px;
    margin-bottom: 10px;
    font-size: 0.95em;
}

.page-admin-tts .meta div {
    background: #fafafa;
    border: 1px solid #e3e3e3;
    border-radius: 4px;
    padding: 8px;
}

textarea.code-editor {
    width: 100%;
    min-height: 460px;
    border: 1px solid #cfcfcf;
    border-radius: 4px;
    padding: 10px;
    box-sizing: border-box;
    font-family: Consolas, 'Courier New', monospace;
    font-size: 14px;
    line-height: 1.45;
    resize: vertical;
    background: #fcfcfc;
}

.save-btn {
    background: #2e8b57;
}

.save-btn:hover,
.save-btn:focus {
    background: #246e45;
}

.restore-btn {
    background: #c1781a;
}

.restore-btn:hover,
.restore-btn:focus {
    background: #a5630f;
}

.hint {
    margin: 8px 0 0;
    font-size: 0.9em;
    color: #555;
}

.page-manuscript-editor .page-content {
    width: min(1400px, calc(100vw - 24px));
    margin: 20px auto;
}

.manuscript-card {
    padding: 14px;
}

.fp-fieldset {
    background: #fff;
    border: 1px solid #ccc;
    border-radius: 8px;
    margin-bottom: 16px;
    padding: 14px;
}

.fp-grid-4,
.fp-grid-3,
.fp-grid-2 {
    display: grid;
    gap: 12px;
    margin-bottom: 10px;
}

.fp-grid-4 {
    grid-template-columns: repeat(4, minmax(120px, 1fr));
}

.fp-grid-3 {
    grid-template-columns: repeat(3, minmax(160px, 1fr));
}

.fp-grid-2 {
    grid-template-columns: repeat(2, minmax(240px, 1fr));
}

.page-manuscript-editor textarea {
    width: 100%;
    min-height: 3em;
    resize: vertical;
    border: 1px solid #ccc;
    border-radius: 6px;
    padding: 6px;
}

.drag-handle {
    cursor: grab;
    width: 32px;
    text-align: center;
    color: #6f7c89;
    font-size: 1.15em;
}

.copy-freq-btn,
.add-row-btn,
.play-atis-btn,
.play-tts-btn {
    padding: 4px 8px;
    font-size: 0.9em;
}

.add-row-btn {
    background: #2e8b57;
}

.copy-freq-btn {
    background: #66788a;
}

.play-atis-btn,
.play-tts-btn {
    background: #2c52b4;
}

.success-msg-overlay,
.error-msg-overlay {
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    color: #000;
    padding: 32px 48px;
    border-radius: 12px;
    font-size: 1.2em;
    text-align: center;
    z-index: 9999;
    opacity: 1;
    transition: opacity 0.8s;
    pointer-events: none;
}

.success-msg-overlay {
    background: rgba(80, 200, 120, 0.5);
}

.error-msg-overlay {
    background: rgba(255, 80, 80, 0.5);
}

.success-msg-overlay.hide,
.error-msg-overlay.hide {
    opacity: 0;
}

.page-instructor-workspace .app-header,
.page-instructor-workspace .app-footer {
    position: relative;
    z-index: 10;
}

.page-instructor-workspace .app-header {
    top: auto;
}

.page-instructor-workspace .app-footer {
    bottom: auto;
}

.page-instructor-workspace {
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

.workspace {
    position: relative;
    flex: 1 1 auto;
    min-height: 0;
    overflow: hidden;
    background: linear-gradient(130deg, #eef3f7, #dde6ef);
    border-top: 1px solid #cad5e0;
    border-bottom: 1px solid #cad5e0;
    padding: 12px;
}

.workspace-window {
    position: absolute;
    width: 520px;
    min-width: 360px;
    min-height: 320px;
    max-height: calc(100vh - 170px);
    background: var(--surface);
    border: 1px solid #b9c7d5;
    border-radius: 12px;
    box-shadow: var(--shadow);
    overflow: hidden;
}

.workspace-window.is-active {
    border-color: #346f9f;
}

.window-header {
    background: linear-gradient(100deg, #21486f, #2c618a);
    color: #fff;
    padding: 10px;
    cursor: move;
}

.aircraft-reg {
    font-size: 24px;
    font-weight: bold;
}

.window-header .meta {
    font-size: 12px;
    opacity: 0.92;
}

.window-body {
    display: flex;
    flex-direction: column;
    gap: 8px;
    height: calc(100% - 56px);
    padding: 8px;
}

.window-panel {
    border: 1px solid var(--line);
    border-radius: 8px;
    overflow: hidden;
    display: flex;
    flex-direction: column;
    min-height: 0;
}

.window-panel-header {
    background: #f1f5f9;
    border-bottom: 1px solid var(--line);
    padding: 6px 8px;
    font-size: 13px;
    font-weight: 600;
}

.window-panel-scroll {
    overflow-x: hidden;
    overflow-y: auto;
    padding: 8px;
    min-height: 0;
}

.window-panel-routes {
    flex: 0 0 auto;
}

.window-panel-routes .window-panel-scroll {
    overflow-y: visible;
    overflow-x: auto;
    max-height: none;
}

.window-panel-transmissions {
    flex: 1 1 auto;
    min-height: 0;
}

.transmission-list {
    list-style: none;
    padding: 0;
    margin: 0;
}

.transmission-list li {
    border-bottom: 1px solid #ecf0f4;
    padding: 7px 0;
}

.transmission-list li.active-green {
    background: #d7f7d7;
}

.transmission-list li.active-yellow {
    background: #f7f6cf;
}

.freq-header {
    cursor: context-menu;
}

.freq-value {
    float: right;
}

.freq-error {
    color: #ab2424;
    font-size: 12px;
    font-style: italic;
    margin-top: 3px;
    cursor: context-menu;
}

.word.error {
    color: #cf1616;
    font-weight: 700;
}

.antal-fejl {
    margin-top: 6px;
    font-size: 13px;
    font-weight: 700;
    color: #9d1f1f;
}

.flightplan-table {
    font-size: 12px;

}

.flightplan-table th,
.flightplan-table td {
  padding: 1px;
}

.window-resizer {
    position: absolute;
    width: 14px;
    height: 14px;
    right: 3px;
    bottom: 3px;
    border-radius: 4px;
    background: #8aa0b5;
    cursor: nwse-resize;
}

.error-popup {
    display: none;
    position: fixed;
    top: 50%;
    left: 50%;
    transform: translate(-50%, -50%);
    z-index: 2200;
    background: #fff;
    border: 1px solid var(--line);
    box-shadow: var(--shadow);
    border-radius: 10px;
    padding: 16px;
    min-width: 300px;
}

.report-popup {
    display: none;
    position: fixed;
    inset: 0;
    background: rgba(0, 0, 0, 0.7);
    z-index: 2300;
}

.report-content {
    width: 84%;
    max-width: 860px;
    height: 82%;
    margin: 4vh auto;
    background: #fff;
    border-radius: 10px;
    padding: 16px;
    overflow: auto;
    position: relative;
}

.report-text {
    white-space: pre-line;
    font-family: Consolas, "Courier New", monospace;
    font-size: 13px;
}

.pdf-container {
    width: 100%;
    min-height: calc(100vh - 150px);
    display: flex;
    justify-content: center;
    align-items: center;
    padding: 20px;
}

.pdf-frame {
    width: 92vw;
    height: 74vh;
    border: 1px solid var(--line);
    border-radius: 10px;
    background: #fff;
}

@media (max-width: 960px) {
    .app-footer .footer-actions {
        float: none;
        margin-top: 8px;
        justify-content: center;
    }

    .page-instructor-workspace .workspace-window {
        width: calc(100% - 20px);
        min-width: 0;
        left: 10px !important;
    }

    .window-body {
        grid-template-columns: 1fr;
    }
}

@media (max-width: 700px) {
    .desktop-only {
        display: none;
    }
}
