/* PhosMega core – shared house style of all PhosMega apps.
 * Dark header, cards, footer with the PhosMega logo, the rising sun and an accent line.
 * Colors come from the app (AppInfo.dark_color / accent_color), set on :root by the layout.
 * Mobile first. Apps add their own stylesheet after this one.
 */

:root {
  --brand-dark: #1e2d32;
  --brand-accent: #f4a21c;
  --brand-accent-dark: color-mix(in srgb, var(--brand-accent) 85%, black);
  --brand-accent-soft: color-mix(in srgb, var(--brand-accent) 14%, white);
  --brand-dark-light: color-mix(in srgb, var(--brand-dark) 85%, white);
  --background: #f3f4f3;
  --surface: #ffffff;
  --border: #dfe3e2;
  --line: #edf0ef;
  --text: var(--brand-dark);
  --muted: #66767a;
  --danger: #c0392b;
  --success: #2e8b57;
  --info: #2f5d87;
  --radius: 10px;
  --font: "Poppins", system-ui, sans-serif;
}

* { box-sizing: border-box; }
html, body { margin: 0; }

body {
  min-height: 100vh;
  display: flex;
  flex-direction: column;
  background: var(--background);
  color: var(--text);
  font-family: var(--font);
  font-size: 15px;
  line-height: 1.5;
}

a { color: var(--brand-dark); text-decoration-color: var(--brand-accent); text-underline-offset: 3px; }
a:hover { color: var(--brand-accent-dark); }

h1, h2, h3 { font-weight: 600; margin: 0 0 12px; line-height: 1.25; }
h1 { font-size: 1.45rem; }
h2 { font-size: 1.12rem; }
h3 { font-size: 1rem; margin-top: 18px; }
code { font-size: 0.9em; background: #eef1f1; padding: 1px 5px; border-radius: 4px; }

.muted { color: var(--muted); }
.small { font-size: 0.85em; }
.nowrap { white-space: nowrap; }
.num { text-align: right; font-variant-numeric: tabular-nums; }
.hidden { display: none !important; }

/* --- Header ---------------------------------------------------------------- */

.site-header {
  display: flex; align-items: center; justify-content: space-between; flex-wrap: wrap;
  gap: 8px 16px; padding: 10px 20px; background: var(--brand-dark); color: #fff;
}
.brand { display: flex; align-items: center; gap: 12px; color: #fff; text-decoration: none; min-width: 0; }
.brand:hover { color: #fff; }
.brand-mark { height: 30px; width: auto; display: block; }
.brand-name { font-size: 1.15rem; font-weight: 600; letter-spacing: 0.01em; }
.brand-sub {
  font-size: 0.9rem; font-weight: 500; color: #cfd8da;
  border-left: 1px solid rgba(255, 255, 255, 0.25); padding-left: 12px;
  white-space: nowrap; overflow: hidden; text-overflow: ellipsis;
}

.site-nav { display: flex; align-items: center; gap: 6px 16px; flex-wrap: wrap; }
.site-nav a, .site-nav .link-button { color: #fff; text-decoration: none; font-weight: 500; font-size: 0.95rem; }
.site-nav a:hover, .site-nav .link-button:hover, .site-nav a.active { color: var(--brand-accent); }
.lang-switch { font-size: 0.8rem; color: #9fb0b4; }
.lang-switch a { font-weight: 400; font-size: 0.8rem; }
.lang-switch .current { color: var(--brand-accent); font-weight: 600; }

.link-button { background: none; border: 0; padding: 0; font: inherit; cursor: pointer; color: inherit; }
.inline-form { display: inline; margin: 0; }

.notice-bar {
  display: flex; align-items: center; justify-content: center; flex-wrap: wrap; gap: 8px 14px;
  padding: 8px 16px; background: var(--brand-accent-soft); border-bottom: 1px solid var(--brand-accent); font-size: 0.9rem;
}
.notice-bar.warning { background: #fdf0ee; border-color: var(--danger); }

/* --- Main ------------------------------------------------------------------ */

main.page { flex: 1; width: 100%; max-width: 980px; margin: 0 auto; padding: 22px 14px 40px; }
main.page.wide { max-width: 1240px; }

.card { background: var(--surface); border: 1px solid var(--border); border-radius: var(--radius); padding: 18px; margin-bottom: 16px; }
.card.narrow { max-width: 520px; margin-left: auto; margin-right: auto; }
.card.accent { border-left: 5px solid var(--brand-accent); }
.card-header { display: flex; justify-content: space-between; align-items: baseline; flex-wrap: wrap; gap: 8px 12px; margin-bottom: 8px; }
.card-header h1, .card-header h2 { margin: 0; }

.flash { padding: 10px 14px; border-radius: var(--radius); margin-bottom: 14px; border-left: 4px solid var(--brand-dark); background: #fff; }
.flash-error { border-color: var(--danger); background: #fdf0ee; }
.flash-success { border-color: var(--success); background: #eef8f2; }
.flash-info { border-color: var(--brand-accent); background: var(--brand-accent-soft); }

.tabs { display: flex; flex-wrap: wrap; gap: 4px; margin-bottom: 16px; border-bottom: 2px solid var(--border); }
.tabs a { padding: 8px 14px; text-decoration: none; font-weight: 500; color: var(--muted); border-bottom: 3px solid transparent; margin-bottom: -2px; }
.tabs a:hover { color: var(--brand-dark); }
.tabs a.active { color: var(--brand-dark); border-bottom-color: var(--brand-accent); }

/* --- Forms and buttons ----------------------------------------------------- */

.stacked-form { display: flex; flex-direction: column; gap: 14px; margin-bottom: 12px; }
.narrow-form { max-width: 420px; }
.stacked-form label, .field { display: flex; flex-direction: column; gap: 4px; font-weight: 500; }
.stacked-form label.checkbox, label.checkbox { flex-direction: row; align-items: flex-start; gap: 8px; font-weight: 400; display: flex; }
.form-grid { display: grid; grid-template-columns: repeat(auto-fill, minmax(220px, 1fr)); gap: 12px 16px; margin-bottom: 8px; }
.form-grid label { display: flex; flex-direction: column; gap: 4px; font-weight: 500; font-size: 0.92em; }
.form-grid label.checkbox { flex-direction: row; align-items: center; font-weight: 400; }
.full-row { grid-column: 1 / -1; }
.hint { font-weight: 400; color: var(--muted); font-size: 0.85em; }
fieldset { border: 1px solid var(--border); border-radius: var(--radius); padding: 12px 14px; margin: 0; }
legend { font-weight: 600; padding: 0 6px; }

input[type="text"], input[type="email"], input[type="password"], input[type="number"], input[type="tel"],
input[type="date"], input[type="time"], input[type="datetime-local"], input[type="url"], input[type="search"],
select, textarea {
  font: inherit; color: inherit; padding: 8px 10px; border: 1px solid var(--border); border-radius: 8px;
  background: #fff; width: 100%; min-width: 0;
}
.inline-input { width: auto; max-width: 320px; }
.inline-label { display: inline-flex; align-items: center; gap: 6px; font-size: 0.9em; }
input:focus, select:focus, textarea:focus { outline: 2px solid var(--brand-accent); outline-offset: -1px; border-color: var(--brand-accent); }
input[type="checkbox"], input[type="radio"] { accent-color: var(--brand-accent-dark); width: 18px; height: 18px; margin: 2px 0 0; flex: none; }

.button {
  display: inline-flex; align-items: center; justify-content: center; gap: 6px;
  font: inherit; font-weight: 500; padding: 8px 16px; border-radius: 8px;
  border: 1px solid var(--brand-dark); background: #fff; color: var(--brand-dark);
  cursor: pointer; text-decoration: none; white-space: nowrap;
}
.button:hover { background: #eef1f1; color: var(--brand-dark); }
.button.primary { background: var(--brand-accent); border-color: var(--brand-accent); color: var(--brand-dark); }
.button.primary:hover { background: var(--brand-accent-dark); border-color: var(--brand-accent-dark); }
.button.dark { background: var(--brand-dark); color: #fff; }
.button.dark:hover { background: var(--brand-dark-light); color: #fff; }
.button.danger { border-color: var(--danger); color: var(--danger); }
.button.danger:hover { background: #fdf0ee; }
.button.small { padding: 3px 10px; font-size: 0.85em; }
.button.big { padding: 12px 26px; font-size: 1.05rem; }
.button[disabled] { opacity: 0.5; cursor: default; }
.button-row { display: flex; flex-wrap: wrap; gap: 8px; align-items: center; }
.filter-row { margin-bottom: 12px; }
.pager { justify-content: center; margin-top: 12px; }

details > summary { cursor: pointer; color: var(--muted); }
.role-form { margin: 6px 0 4px; }

/* --- Lists and tables ------------------------------------------------------ */

.table-wrap { overflow-x: auto; }
.data-table { border-collapse: collapse; width: 100%; }
.data-table th, .data-table td { padding: 8px; border-bottom: 1px solid var(--line); text-align: left; vertical-align: top; }
.data-table thead th { font-weight: 500; font-size: 0.85em; border-bottom: 2px solid var(--brand-accent); white-space: nowrap; }
.data-table td.actions { white-space: nowrap; }

.item-list { list-style: none; margin: 0; padding: 0; }
.item-list > li { padding: 12px 0; border-bottom: 1px solid var(--line); }
.item-list > li:last-child { border-bottom: 0; }
.item-head { display: flex; justify-content: space-between; align-items: flex-start; gap: 10px; flex-wrap: wrap; }
.item-title { font-weight: 600; }
.item-meta { display: flex; flex-wrap: wrap; align-items: center; gap: 4px 8px; margin-top: 4px; }

.details { display: grid; grid-template-columns: max-content 1fr; gap: 4px 16px; margin: 0 0 12px; }
.details dt { color: var(--muted); }
.details dd { margin: 0; }

.log-message { white-space: pre-wrap; word-break: break-word; font-size: 0.9em; }
.log-exc { white-space: pre-wrap; font-size: 0.8em; background: #f6f7f7; padding: 8px; border-radius: 6px; max-height: 320px; overflow: auto; }
.log-error td, .log-critical td { background: #fdf6f5; }
.log-warning td { background: #fffaf0; }

/* --- Badges ---------------------------------------------------------------- */

.badge { display: inline-block; padding: 2px 10px; border-radius: 999px; font-size: 0.78em; font-weight: 500; white-space: nowrap; background: #eceff0; color: var(--muted); }
.badge.amber, .status-pending, .level-warning { background: var(--brand-accent-soft); color: #a3650a; }
.badge.green, .status-active, .level-info { background: #e6f4ec; color: var(--success); }
.badge.red, .status-rejected, .level-error, .level-critical { background: #fbe5e2; color: var(--danger); }
.status-disabled, .level-debug { background: #eceff0; color: var(--muted); }
.badge.blue { background: #e3ecf5; color: var(--info); }
.badge.dark { background: var(--brand-dark); color: #fff; }

/* --- Footer: PhosMega logo bottom-left, rising sun bottom-right, accent line -- */

.site-footer { background: var(--brand-dark); margin-top: auto; color: #cfd8da; }
.footer-inner { display: flex; justify-content: space-between; align-items: flex-end; gap: 12px; padding: 14px 20px 8px; }
.footer-logo img { height: 30px; display: block; }
.footer-text { font-size: 0.8rem; text-align: center; flex: 1; }
.footer-text a { color: #cfd8da; }
.footer-version { opacity: 0.7; }
.footer-sun { height: 24px; display: block; }
.footer-line { height: 4px; background: var(--brand-accent); }

@media (max-width: 560px) {
  body { font-size: 14px; }
  .site-header { padding: 10px 14px; }
  .site-nav { gap: 6px 14px; }
  .brand-mark { height: 26px; }
  .card { padding: 14px; }
  .card-header .button { width: 100%; }
  .footer-text { display: none; }
  .details { grid-template-columns: 1fr; gap: 0; }
  .details dd { margin-bottom: 6px; }
  .inline-input { max-width: 100%; }
}
