/* lnbrt Backup Manager - CI angelehnt an linetz.de
   Primaerfarbe Blau #1a9aff, dunkles Navy #1a3a5c, Schrift Fira Sans/Fira Mono. */

:root {
    --color-primary: #1a9aff;
    --color-primary-dark: #1483d6;
    --color-navy: #1a3a5c;
    --color-navy-dark: #0d1b2e;
    --color-bg: #f8f6f5;
    --color-surface: #ffffff;
    --color-text: #2b2b2b;
    --color-muted: #848484;
    --color-border: #e5e5e5;
    --color-danger: #ac3711;
    --color-success: #2e9e4d;
    --radius: 8px;
    --shadow: 0 1px 3px rgba(13, 27, 46, 0.08), 0 1px 2px rgba(13, 27, 46, 0.06);
}

* { box-sizing: border-box; }

body {
    font-family: "Fira Sans", "Helvetica Neue", Helvetica, Arial, sans-serif;
    background: var(--color-bg);
    color: var(--color-text);
    margin: 0;
    padding: 0;
    line-height: 1.5;
    min-height: 100vh;
    display: flex;
    flex-direction: column;
}

code, .mono {
    font-family: "Fira Mono", Consolas, "Liberation Mono", monospace;
    background: #eef2f6;
    padding: 0.1em 0.4em;
    border-radius: 4px;
    font-size: 0.9em;
}

h1, h2, h3 {
    font-weight: 600;
    color: var(--color-navy-dark);
}

/* .page ist der Hauptinhalt zwischen Menue und Footer - flex:1 0 auto sorgt
   dafuer, dass er den gesamten verbleibenden Platz einnimmt, damit der Footer
   immer am unteren Bildschirmrand klebt, auch wenn eine Seite wenig Inhalt hat. */
.page {
    width: 100%;
    padding: 24px;
    flex: 1 0 auto;
}

.site-footer {
    padding: 16px 24px;
    text-align: center;
    font-size: 0.8rem;
    color: var(--color-muted);
    border-top: 1px solid #e3e8ee;
}

/* Formulare bleiben bewusst schmal (bessere Lesbarkeit von Eingabefeldern),
   Tabellen sollen dagegen die volle verfuegbare Breite nutzen. */
table { max-width: none; }

/* --- Topbar --- */
.topbar {
    display: flex;
    align-items: center;
    flex-wrap: wrap;
    gap: 12px 24px;
    background: var(--color-navy-dark);
    color: #fff;
    padding: 14px 24px;
    box-shadow: var(--shadow);
}

.topbar-brand {
    display: flex;
    align-items: baseline;
    gap: 8px;
    white-space: nowrap;
}

.topbar-logo {
    font-family: "Fira Mono", monospace;
    font-weight: 700;
    font-size: 1.3rem;
    color: var(--color-primary);
    letter-spacing: 0.02em;
}

.topbar-title {
    font-weight: 300;
    font-size: 1rem;
    color: #cdd8e4;
}

.topbar-nav {
    display: flex;
    flex-wrap: wrap;
    gap: 4px;
    flex: 1;
}

.topbar-nav a {
    color: #dbe6f2;
    text-decoration: none;
    padding: 6px 12px;
    border-radius: var(--radius);
    font-size: 0.9rem;
    transition: background 0.15s ease, color 0.15s ease;
    white-space: nowrap;
}

.topbar-nav a:hover {
    background: rgba(26, 154, 255, 0.18);
    color: #fff;
}

.topbar-actions { display: flex; align-items: center; gap: 10px; }

/* --- Buttons (auch fuer Links, die wie Aktionen aussehen sollen) --- */
.btn {
    display: inline-block;
    font-family: inherit;
    font-size: 0.85rem;
    font-weight: 500;
    line-height: 1.4;
    text-decoration: none;
    padding: 7px 14px;
    margin: 0;
    border-radius: 999px;
    border: 1px solid transparent;
    cursor: pointer;
    vertical-align: middle;
    transition: filter 0.15s ease;
}

.btn:hover { filter: brightness(0.95); }

.btn-scheduler.is-active { background: var(--color-primary); color: #fff; }
.btn-scheduler.is-paused { background: #fff; color: var(--color-navy-dark); border-color: #fff; }

.btn-ghost {
    background: transparent;
    color: var(--color-primary);
    border-color: var(--color-primary);
}
.btn-ghost:hover { background: rgba(26, 154, 255, 0.1); filter: none; }

.btn-danger {
    background: var(--color-danger);
    color: #fff;
}
.btn-danger:hover { filter: brightness(0.9); }

/* Ueberschrift + Aktion (z.B. "Show archived tasks") nebeneinander statt
   dass der Link unschoen direkt an der Unterstreichung der Ueberschrift klebt. */
.section-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    flex-wrap: wrap;
    gap: 8px 16px;
}
.section-header h2 { margin-top: 0; }

/* Dashboard-Kacheln auf der Startseite (index.php) - Uebersicht ueber Backups,
   Templates, Agents, Connections und den Monitoring-Status. */
.dashboard {
    display: grid;
    grid-template-columns: repeat(auto-fit, minmax(160px, 1fr));
    gap: 18px;
    margin-bottom: 28px;
}
.dashboard-card {
    position: relative;
    overflow: hidden;
    background: var(--color-surface);
    border: 1px solid var(--color-border);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 22px 16px 18px;
    display: flex;
    flex-direction: column;
    align-items: center;
    justify-content: center;
    text-decoration: none;
    transition: transform 0.15s ease, box-shadow 0.15s ease;
}
.dashboard-card::before {
    content: "";
    position: absolute;
    top: 0; left: 0; right: 0;
    height: 4px;
    background: var(--accent, var(--color-primary));
}
.dashboard-card:hover {
    transform: translateY(-2px);
    box-shadow: 0 4px 10px rgba(13, 27, 46, 0.12), 0 1px 2px rgba(13, 27, 46, 0.08);
}
.dashboard-card-icon {
    width: 44px;
    height: 44px;
    border-radius: 50%;
    background: var(--accent, var(--color-primary));
    display: flex;
    align-items: center;
    justify-content: center;
    font-size: 1.4rem;
    margin-bottom: 10px;
}
.dashboard-card-blue { --accent: var(--color-primary); }
.dashboard-card-navy { --accent: var(--color-navy); }
.dashboard-card-green { --accent: var(--color-success); }
.dashboard-card-amber { --accent: #e0a800; }
.dashboard-card-red { --accent: var(--color-danger); }
.dashboard-card-value {
    font-size: 2rem;
    font-weight: 600;
    color: var(--color-navy-dark);
}
.dashboard-card-label {
    font-size: 0.85rem;
    color: var(--color-muted);
    margin-top: 4px;
    font-weight: 500;
}
.dashboard-card-monitoring {
    display: flex;
    gap: 14px;
    font-size: 1.1rem;
    font-weight: 600;
    color: var(--color-navy-dark);
}
.dashboard-card-monitoring .dot { margin-right: 4px; }

.dot {
    display: inline-block;
    width: 12px;
    height: 12px;
    border-radius: 50%;
    vertical-align: middle;
}
.dot-green { background: var(--color-success); }
.dot-yellow { background: #e0a800; }
.dot-red { background: var(--color-danger); }

/* Einheitlicher Abstand zwischen Topbar und erstem Seiteninhalt: unabhaengig
   davon, ob eine Seite direkt mit <h2> beginnt oder mit einem Wrapper-Element
   (z.B. .section-header, #jobs-list/#backups-list/...) - nur .page's eigenes
   Padding zaehlt. Die AJAX-List-Container haengen ihren Inhalt eine Ebene
   tiefer ein, daher zusaetzlich zum direkten .page-Kind auch deren erstes Kind. */
.page > :first-child,
.page > :first-child > :first-child {
    margin-top: 0;
}

/* --- Typografie / Inhalte --- */
h2 {
    margin-top: 32px;
    margin-bottom: 12px;
    font-size: 1.4rem;
    border-bottom: 2px solid var(--color-primary);
    display: inline-block;
    padding-bottom: 4px;
}

a { color: var(--color-primary); }
a:hover { color: var(--color-primary-dark); }

p { color: var(--color-muted); }

/* --- Tabellen --- */
table {
    border-collapse: separate;
    border-spacing: 0;
    width: 100%;
    margin-top: 12px;
    margin-bottom: 24px;
    background: var(--color-surface);
    border-radius: var(--radius);
    overflow: hidden;
    box-shadow: var(--shadow);
}

th, td {
    text-align: left;
    padding: 10px 14px;
    border-bottom: 1px solid var(--color-border);
    font-size: 0.9rem;
    vertical-align: top;
}

th {
    background: var(--color-navy);
    color: #fff;
    font-weight: 600;
    font-size: 0.8rem;
    text-transform: uppercase;
    letter-spacing: 0.03em;
}

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

tbody tr:hover { background: #f2f8ff; }

/* --- Formulare --- */
form {
    margin-top: 16px;
    margin-bottom: 24px;
    background: var(--color-surface);
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 20px;
    max-width: 640px;
}

label {
    display: block;
    font-size: 0.8rem;
    font-weight: 600;
    color: var(--color-navy);
    margin-top: 14px;
    margin-bottom: 4px;
    text-transform: uppercase;
    letter-spacing: 0.02em;
}

label:first-child { margin-top: 0; }

input, select, textarea {
    font-family: inherit;
    font-size: 0.95rem;
    padding: 8px 10px;
    width: 100%;
    border: 1px solid var(--color-border);
    border-radius: 5px;
    background: #fff;
    color: var(--color-text);
}

input:focus, select:focus, textarea:focus {
    outline: none;
    border-color: var(--color-primary);
    box-shadow: 0 0 0 3px rgba(26, 154, 255, 0.18);
}

button, input[type="submit"] {
    font-family: inherit;
    font-weight: 600;
    font-size: 0.9rem;
    background: var(--color-primary);
    color: #fff;
    border: none;
    border-radius: 999px;
    padding: 9px 22px;
    margin-top: 18px;
    cursor: pointer;
    transition: filter 0.15s ease;
    width: auto;
}

button:hover, input[type="submit"]:hover { filter: brightness(0.92); }

/* forms that only wrap small inline actions (z.B. Connections/Agents-Zeilenformulare) */
table form {
    box-shadow: none;
    padding: 0;
    margin: 0;
    max-width: none;
    background: transparent;
}
table form button { margin-top: 0; padding: 6px 14px; font-size: 0.8rem; align-self: flex-end; }

/* kompaktes Label+Feld-Paar fuer Zeilenformulare (Connections/Agents) - Label
   bleibt sichtbar statt sich allein auf Platzhaltertext zu verlassen */
.field {
    display: inline-flex;
    flex-direction: column;
    gap: 2px;
}
.field label {
    margin: 0;
    font-size: 0.65rem;
    font-weight: 600;
    color: var(--color-muted);
    text-transform: uppercase;
    letter-spacing: 0.02em;
    white-space: nowrap;
}
.field input, .field select { width: auto; }

#tables-list, #tables-checkboxes, #tablesCheckboxes, #restoreTablesCheckboxes { margin-top: 10px; }
#tables-list label, #tables-checkboxes label, #tablesCheckboxes label, #restoreTablesCheckboxes label {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-transform: none;
    font-weight: 400;
    color: var(--color-text);
    font-size: 0.9rem;
    margin: 2px 10px 2px 0;
}
#tables-list input[type="checkbox"], #tablesCheckboxes input[type="checkbox"], #restoreTablesCheckboxes input[type="checkbox"] { width: auto; }

/* --- Popups (native <dialog>: Restore aus backups.php, Add-Template aus templates.php) --- */
dialog {
    border: none;
    border-radius: var(--radius);
    box-shadow: var(--shadow);
    padding: 24px;
    width: 100%;
    max-width: 480px;
}
dialog::backdrop { background: rgba(13, 27, 46, 0.55); }
dialog form {
    box-shadow: none;
    padding: 0;
    margin: 0;
    max-width: none;
}
dialog h2 { margin-top: 0; border-bottom: none; padding-bottom: 0; }

/* --- Secret-Key-Felder mit Augen-Icon zum Ein-/Ausblenden --- */
.input-with-toggle {
    display: inline-flex;
    align-items: center;
    position: relative;
    width: 100%;
}
.input-with-toggle input { padding-right: 34px; width: 100%; }
.input-with-toggle .toggle-visibility {
    position: absolute;
    right: 4px;
    background: none;
    border: none;
    box-shadow: none;
    padding: 2px 6px;
    margin: 0;
    font-size: 0.95rem;
    line-height: 1;
    cursor: pointer;
    color: var(--color-muted);
}
.input-with-toggle .toggle-visibility:hover { filter: none; color: var(--color-primary); }

/* --- Icon-Links in Aktions-Spalten (z.B. agents.php) ---
   WICHTIG: display:flex gehoert auf die innere .actions-inner, NICHT auf die <td>
   selbst - eine <td> mit display:flex verliert ihr display:table-cell und dadurch
   die normale Zeilenhoehen-Ausrichtung mit den Nachbarzellen (Zeilen mit mehr/weniger
   Actions wurden dadurch unterschiedlich hoch als der Rest der Tabellenzeile). */
td.actions {
    white-space: nowrap;
    vertical-align: top;
}
.actions-inner {
    display: flex;
    flex-direction: column;
    gap: 6px;
    align-items: flex-start;
}
.icon-link {
    display: inline-flex;
    align-items: center;
    gap: 4px;
    text-decoration: none;
    font-size: 0.85rem;
    color: var(--color-navy);
    background: #eef2f6;
    padding: 4px 10px;
    border-radius: 999px;
    transition: background 0.15s ease, color 0.15s ease;
}
.icon-link:hover { background: rgba(26, 154, 255, 0.15); color: var(--color-primary-dark); }
.icon-link-danger { color: var(--color-danger); }
.icon-link-danger:hover { background: rgba(172, 55, 17, 0.12); color: var(--color-danger); }

/* Dump-Optionen (mysqldump/pg_dump-Flags) als kleine Toggle-Buttons statt nackter
   Checkboxen oder grosser Karten - siehe renderDumpOptionCheckboxes() in
   src/Functions.php. Nur der kurze, selbsterklaerende Name ist sichtbar; Flag +
   Langbeschreibung stehen im title-Tooltip. */
.dump-options-grid {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
    margin: 4px 0 12px;
}
.dump-option-chip {
    display: inline-flex;
    align-items: center;
    gap: 5px;
    margin: 0;
    padding: 4px 10px;
    border: 1px solid var(--color-border);
    border-radius: 999px;
    background: var(--color-surface);
    cursor: pointer;
    font-weight: 400;
    font-size: 0.8rem;
    line-height: 1.4;
    text-transform: none;
    letter-spacing: normal;
    white-space: nowrap;
    transition: border-color 0.15s ease, background 0.15s ease, color 0.15s ease;
}
.dump-option-chip:hover { border-color: var(--color-primary); }
.dump-option-chip:has(input:checked) {
    border-color: var(--color-primary);
    background: var(--color-primary);
    color: #fff;
}
.dump-option-chip input {
    flex-shrink: 0;
    width: 12px;
    height: 12px;
    margin: 0;
    accent-color: var(--color-primary);
}

/* Read-only Anzeige (z.B. Job-/Backup-Listen) der tatsaechlich verwendeten Flags -
   siehe renderDumpOptionBadges(). */
.dump-option-badges { display: inline-flex; flex-wrap: wrap; gap: 4px; }
.dump-option-badge {
    font-family: "Fira Mono", Consolas, "Liberation Mono", monospace;
    font-size: 0.75rem;
    color: var(--color-navy);
    background: #eef2f6;
    padding: 2px 8px;
    border-radius: 999px;
}

/* Kompakter Aufklapper fuer die Chips innerhalb einer Tabellenzelle (Templates-Liste). */
.dump-options-details summary {
    cursor: pointer;
    color: var(--color-primary);
    font-size: 0.85rem;
    list-style: none;
}
.dump-options-details summary::-webkit-details-marker { display: none; }
.dump-options-details summary::before { content: "⚙️ "; }
.dump-options-details[open] summary::before { content: "⚙️ "; }
.dump-options-details .dump-options-grid {
    margin-top: 8px;
    padding: 10px;
    background: var(--color-bg);
    border-radius: var(--radius);
    max-width: 280px;
}

/* --- Pagination (index.php, cleanup.php, backups.php) --- */
.pager {
    display: flex;
    justify-content: space-between;
    align-items: center;
    flex-wrap: wrap;
    gap: 10px;
    margin-top: 8px;
    margin-bottom: 24px;
}
.pager-per-page {
    display: flex;
    align-items: center;
    gap: 6px;
    margin: 0;
    padding: 0;
    background: none;
    box-shadow: none;
    max-width: none;
}
.pager-per-page label { margin: 0; font-size: 0.75rem; }
.pager-per-page select { width: auto; padding: 4px 8px; }
.pager-nav { display: flex; align-items: center; gap: 10px; }
.pager-info { font-size: 0.85rem; color: var(--color-muted); }
