/* Shared skin for every FamGuiGau module: reset, app shell and the components
   that both maquettes build their screens out of. Module-specific compositions
   live in the per-module stylesheet. */

*,
*::before,
*::after {
    box-sizing: border-box;
}

body {
    margin: 0;
    min-height: 100vh;
    background: var(--fgg-app-bg);
    color: var(--fgg-ink);
    font-family: var(--fgg-font-family);
    font-size: var(--fgg-font-size);
    line-height: var(--fgg-line-height);
}

a {
    color: var(--fgg-link);
    text-decoration: none;
}

a:hover {
    text-decoration: underline;
}

h1,
h2,
h3,
p {
    margin: 0;
    font-family: inherit;
}

input,
select,
textarea,
button {
    font-family: inherit;
}

input:focus,
select:focus,
textarea:focus {
    outline: none;
    border-color: var(--fgg-primary);
    box-shadow: var(--fgg-shadow-focus);
}

table {
    border-collapse: collapse;
}

.visually-hidden {
    position: absolute;
    width: 1px;
    height: 1px;
    margin: -1px;
    padding: 0;
    overflow: hidden;
    clip-path: inset(50%);
    white-space: nowrap;
    border: 0;
}

/* ---------- Icons ---------- */

.icon-sprite {
    display: none;
}

.icon {
    flex: none;
    width: 14px;
    height: 14px;
    fill: none;
    stroke: currentcolor;
    stroke-width: 2;
    stroke-linecap: round;
    stroke-linejoin: round;
}

.icon--sm {
    width: 13px;
    height: 13px;
}

.icon--xs {
    width: 12px;
    height: 12px;
}

.icon--md {
    width: 15px;
    height: 15px;
}

.icon--lg {
    width: 17px;
    height: 17px;
}

.icon--xl {
    width: 26px;
    height: 26px;
}

.icon--accent {
    color: var(--fgg-primary);
}

/* ---------- App shell ---------- */

.app {
    display: flex;
    flex-direction: column;
    min-height: 100vh;
}

.app__body {
    flex: 1;
    display: flex;
    flex-direction: column;
    padding: var(--fgg-space-7) var(--fgg-space-6) var(--fgg-space-9);
}

.app__content {
    display: flex;
    flex-direction: column;
    gap: var(--fgg-space-7);
    width: 100%;
    max-width: var(--fgg-content-width);
    margin: 0 auto;
}

.app-nav {
    background: var(--fgg-primary);
    padding: var(--fgg-space-6) var(--fgg-space-6) var(--fgg-space-5);
}

.app-nav__inner {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-4);
    max-width: var(--fgg-content-width);
    margin: 0 auto;
}

.app-nav__burger {
    flex: none;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    padding: 9px 11px;
    color: #000;
    background: var(--fgg-neutral);
    border: 1px solid var(--fgg-control-border);
    border-radius: var(--fgg-radius);
    cursor: pointer;
}

.app-nav__burger:hover {
    background: var(--fgg-neutral-hover);
}

.app-tabs {
    display: flex;
    flex: 1;
    min-width: 0;
}

.app-tab {
    flex: 1;
    max-width: 220px;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 9px var(--fgg-space-4);
    color: #000;
    font-size: var(--fgg-font-size-xs);
    font-weight: bold;
    text-transform: uppercase;
    white-space: nowrap;
    background: var(--fgg-neutral);
    border: 1px solid var(--fgg-control-border);
    cursor: pointer;
}

.app-tab:hover {
    text-decoration: none;
}

.app-tab:first-child {
    border-radius: var(--fgg-radius) 0 0 var(--fgg-radius);
}

.app-tab:last-child {
    border-left: 0;
    border-radius: 0 var(--fgg-radius) var(--fgg-radius) 0;
}

.app-tab--active {
    background: var(--fgg-selected);
}

/* ---------- Cards ---------- */

.card {
    background: var(--fgg-surface);
    border-radius: var(--fgg-radius);
    padding: var(--fgg-space-7) var(--fgg-space-8);
}

.card--flush {
    padding: 0;
    overflow: hidden;
}

.card--tight {
    padding: var(--fgg-space-6) var(--fgg-space-8);
}

.card__head {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--fgg-space-4);
    flex-wrap: wrap;
}

.card__title {
    margin: 0;
    display: flex;
    align-items: center;
    gap: var(--fgg-space-3);
    font-size: var(--fgg-heading-size);
    color: var(--fgg-ink-strong);
    white-space: nowrap;
}

.card__title--screen {
    color: var(--fgg-ink);
    text-transform: uppercase;
}

.card__note {
    margin-top: var(--fgg-space-3);
    font-size: var(--fgg-font-size-sm);
    color: var(--fgg-ink-muted);
}

.card__note--tight {
    margin-top: var(--fgg-space-1);
}

/* ---------- Buttons ---------- */

.btn {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: 7px;
    padding: 7px var(--fgg-space-6);
    font-size: inherit;
    white-space: nowrap;
    border-radius: var(--fgg-radius);
    cursor: pointer;
}

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

.btn--neutral {
    color: #000;
    background: var(--fgg-neutral);
    border: 1px solid var(--fgg-control-border);
}

.btn--neutral:hover {
    background: var(--fgg-neutral-hover);
}

.btn--primary {
    color: #fff;
    background: var(--fgg-primary);
    border: 1px solid var(--fgg-primary-border);
}

.btn--primary:hover {
    background: var(--fgg-primary-hover);
}

.btn--danger {
    color: #fff;
    background: var(--fgg-danger-raised);
    border: 1px solid var(--fgg-danger-raised-border);
}

.btn--danger:hover {
    background: var(--fgg-danger-raised-hover);
}

.btn--add {
    padding: var(--fgg-space-3) var(--fgg-space-6);
}

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

.btn--lg {
    padding: 11px var(--fgg-space-6);
    font-size: var(--fgg-subheading-size);
}

/* ---------- Segmented controls & toggle chips ---------- */

.segmented {
    display: flex;
}

.segmented--grow {
    flex: 1;
    min-width: 200px;
}

.segmented__item {
    flex: 1;
    display: inline-flex;
    align-items: center;
    justify-content: center;
    gap: var(--fgg-space-2);
    padding: 7px var(--fgg-space-4);
    color: #000;
    font-size: var(--fgg-font-size-sm);
    white-space: nowrap;
    background: var(--fgg-neutral);
    border: 1px solid var(--fgg-control-border);
    border-left: 0;
    cursor: pointer;
}

.segmented__item:hover {
    text-decoration: none;
}

/* Radio-backed segments interleave a hidden input before each label, so the
   ends are matched on the item's own type rather than on child position. */
.segmented__item:first-of-type {
    border-left: 1px solid var(--fgg-control-border);
    border-radius: var(--fgg-radius) 0 0 var(--fgg-radius);
}

.segmented__item:last-of-type {
    border-radius: 0 var(--fgg-radius) var(--fgg-radius) 0;
}

.segmented__item--active {
    color: var(--fgg-ink-darkest);
    font-weight: bold;
    background: var(--fgg-selected);
}

.segmented--sm .segmented__item {
    padding: 7px var(--fgg-space-3);
}

/* The list filters only swap the background; the dialog segments also go bold. */
.segmented--quiet .segmented__item {
    font-size: var(--fgg-font-size-xs);
}

.segmented--quiet .segmented__item--active {
    color: #000;
    font-weight: normal;
}

.chips {
    display: flex;
    gap: var(--fgg-space-2);
    flex-wrap: wrap;
}

.chip {
    padding: 7px var(--fgg-space-4);
    color: #000;
    font-size: var(--fgg-font-size-xs);
    white-space: nowrap;
    background: var(--fgg-neutral);
    border: 1px solid var(--fgg-control-border);
    border-radius: var(--fgg-radius);
    cursor: pointer;
}

.chip--active {
    color: var(--fgg-ink-darkest);
    font-weight: bold;
    background: var(--fgg-selected);
}

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

.badge {
    display: inline-flex;
    align-items: center;
    gap: var(--fgg-space-2);
    padding: var(--fgg-space-1) 9px;
    font-size: var(--fgg-font-size-xs);
    white-space: nowrap;
    border-radius: var(--fgg-radius);
}

.badge--lg {
    padding: 5px var(--fgg-space-4);
    font-weight: bold;
}

.badge--todo {
    color: #000;
    background: var(--fgg-neutral);
    border: 1px solid var(--fgg-control-border);
}

.badge--doing {
    color: #fff;
    background: var(--fgg-pending-raised);
    border: 1px solid var(--fgg-pending-raised-border);
}

.badge--done {
    color: #fff;
    background: var(--fgg-done-raised);
    border: 1px solid var(--fgg-done-raised-border);
}

.badge--warning {
    color: var(--fgg-danger);
    background: var(--fgg-warn-bg);
    border: 1px solid var(--fgg-warn-border);
}

.badge--info {
    color: var(--fgg-ink);
    background: var(--fgg-chip-bg);
    border: 1px solid var(--fgg-info-border);
}

.badge--open {
    color: var(--fgg-success-ink);
    background: var(--fgg-success-bg);
    border: 1px solid var(--fgg-success-border);
}

.badge--off {
    color: var(--fgg-off-ink);
    background: var(--fgg-off-bg);
    border: 1px solid var(--fgg-off-border);
}

.badge--plain {
    padding: var(--fgg-space-1) 9px;
    font-weight: bold;
    color: var(--fgg-ink);
    background: var(--fgg-chip-bg);
}

/* ---------- Tables ---------- */

.table {
    width: 100%;
    font-size: var(--fgg-font-size-sm);
}

.table th {
    padding: 9px var(--fgg-space-5);
    color: #fff;
    font-size: var(--fgg-font-size-xs);
    font-weight: bold;
    letter-spacing: 0.04em;
    text-align: left;
    text-transform: uppercase;
    background: var(--fgg-table-head);
}

.table td {
    padding: 11px var(--fgg-space-5);
    border-bottom: 1px solid var(--fgg-cell-border);
}

.table tbody tr {
    background: var(--fgg-surface);
}

.table tbody tr:nth-child(even) {
    background: var(--fgg-zebra);
}

/* Rows that a Stimulus controller shows and hides cannot rely on :nth-child,
   so the controller re-applies the stripe itself. */
.table--js-stripes tbody tr:nth-child(even) {
    background: var(--fgg-surface);
}

.table--js-stripes tbody tr.is-alt {
    background: var(--fgg-zebra);
}

.table tbody tr:hover {
    background: var(--fgg-row-hover);
}

.table td a {
    display: block;
    color: inherit;
}

.table td a:hover {
    text-decoration: none;
}

.table__cell--strong {
    font-weight: bold;
}

.table__cell--muted {
    color: var(--fgg-ink-muted);
}

.table__cell--nowrap {
    white-space: nowrap;
}

.table .table__cell--amount {
    font-variant-numeric: tabular-nums;
    text-align: right;
    white-space: nowrap;
}

/* ---------- Fields ---------- */

.field__label {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-2);
    margin-bottom: var(--fgg-space-2);
    color: var(--fgg-ink-strong);
    font-weight: bold;
}

.field__control {
    width: 100%;
    padding: var(--fgg-space-3);
    color: var(--fgg-ink);
    font-size: var(--fgg-font-size);
    background: var(--fgg-field-bg);
    border: 1px solid var(--fgg-field-border);
    border-radius: var(--fgg-radius);
}

.field__control--color {
    height: 42px;
    padding: var(--fgg-space-1);
    cursor: pointer;
}

textarea.field__control {
    resize: vertical;
}

.field__control:disabled {
    color: var(--fgg-ink-faint);
    background: var(--fgg-off-bg);
    border-color: var(--fgg-off-border);
}

.field-row {
    display: flex;
    gap: var(--fgg-space-5);
    flex-wrap: wrap;
}

.field-row > .field {
    flex: 1;
    min-width: 140px;
}

.field-row > .field--time {
    flex: none;
    width: 120px;
}

/* ---------- Panels & messages ---------- */

.alert {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-3);
    padding: var(--fgg-space-4) var(--fgg-space-5);
    font-size: var(--fgg-font-size-sm);
    color: var(--fgg-danger);
    background: var(--fgg-warn-bg);
    border: 1px solid var(--fgg-warn-border);
    border-radius: var(--fgg-radius);
}

.alert--block {
    align-items: flex-start;
    padding: var(--fgg-space-5) var(--fgg-space-6);
}

.alert--block .icon {
    margin-top: 1px;
}

.notice {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-4);
    padding: var(--fgg-space-6);
    font-size: var(--fgg-font-size-sm);
    color: var(--fgg-ink-muted);
    background: var(--fgg-info-bg);
    border: 1px solid var(--fgg-info-border);
    border-radius: var(--fgg-radius);
}

.note {
    display: flex;
    gap: var(--fgg-space-4);
    padding: var(--fgg-space-5);
    font-size: var(--fgg-font-size-sm);
    color: var(--fgg-ink);
    background: #fbfaf3;
    border: 1px solid #e8e3cf;
    border-radius: var(--fgg-radius);
}

.note .icon {
    margin-top: 1px;
    color: #a89a6a;
}

.empty {
    padding: 28px var(--fgg-space-9);
    text-align: center;
    color: var(--fgg-ink-muted);
    background: var(--fgg-info-bg);
    border: 1px solid var(--fgg-info-border);
    border-radius: var(--fgg-radius);
}

.empty .icon {
    color: var(--fgg-primary);
}

.empty__text {
    margin-top: var(--fgg-space-4);
}

.toast {
    position: fixed;
    left: 0;
    right: 0;
    bottom: 0;
    display: flex;
    justify-content: center;
    padding: var(--fgg-space-4);
    z-index: var(--fgg-z-dialog);
}

.toast__inner {
    display: flex;
    align-items: center;
    justify-content: center;
    gap: var(--fgg-space-3);
    width: 100%;
    max-width: 420px;
    padding: 11px var(--fgg-space-6);
    font-size: var(--fgg-font-size-sm);
    color: var(--fgg-success-ink);
    background: var(--fgg-success-bg);
    border: 1px solid var(--fgg-success-border);
    border-radius: var(--fgg-radius);
}

/* ---------- Overlays: dialogs and drawer ---------- */

.overlay {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: var(--fgg-space-10) var(--fgg-space-5);
    overflow: auto;
    background: var(--fgg-scrim);
    backdrop-filter: blur(5px);
    z-index: var(--fgg-z-dialog);
}

.overlay[hidden] {
    display: none;
}

.overlay--top {
    align-items: flex-start;
}

.overlay--detail {
    z-index: var(--fgg-z-detail);
}

.overlay--confirm {
    z-index: var(--fgg-z-confirm);
}

.overlay__dismiss {
    position: fixed;
    inset: 0;
    cursor: default;
}

.dialog {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 100%;
    max-width: 440px;
    max-height: 100%;
    overflow: hidden;
    background: var(--fgg-surface);
    border: 1px solid var(--fgg-info-border);
    border-radius: var(--fgg-radius-lg);
    box-shadow: var(--fgg-shadow-overlay);
}

.dialog--wide {
    max-width: 460px;
}

.dialog--narrow {
    max-width: 420px;
}

.dialog--confirm {
    max-width: 400px;
}

.confirm__title {
    margin: 0 0 var(--fgg-space-5);
    font-size: var(--fgg-heading-size);
    color: var(--fgg-ink-strong);
}

.dialog__head {
    flex: none;
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: var(--fgg-space-4);
    padding: var(--fgg-space-4) var(--fgg-space-6);
    color: #fff;
    background: var(--fgg-ink-darkest);
}

.dialog__title {
    font-size: var(--fgg-font-size-xs);
    font-weight: bold;
    letter-spacing: var(--fgg-caps-tracking);
    text-transform: uppercase;
}

.dialog__tools {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-6);
}

.dialog__tool {
    display: inline-flex;
    color: #fff;
    line-height: 1;
}

.dialog__tool:hover {
    color: var(--fgg-info-border);
    text-decoration: none;
}

.dialog__tool--danger:hover {
    color: var(--fgg-danger-hover);
}

.dialog__body {
    position: relative;
    display: flex;
    flex-direction: column;
    gap: var(--fgg-space-7);
    min-height: 0;
    padding: var(--fgg-space-8) var(--fgg-space-9) var(--fgg-space-9);
    overflow-y: auto;
}

/*
 * Stuck to the bottom of the scrolling body: the actions take over its bottom padding to stay flush
 * with the edge, and their shadows paint its side padding so nothing scrolls past them.
 */
.dialog__actions {
    position: sticky;
    bottom: calc(-1 * var(--fgg-space-9));
    z-index: 2;
    display: flex;
    justify-content: flex-end;
    gap: var(--fgg-space-4);
    margin-bottom: calc(-1 * var(--fgg-space-9));
    padding: var(--fgg-space-7) 0 var(--fgg-space-9);
    background: var(--fgg-surface);
    border-top: 1px dotted var(--fgg-rule);
    box-shadow: calc(-1 * var(--fgg-space-9)) 0 var(--fgg-surface), var(--fgg-space-9) 0 var(--fgg-surface);
}

.dialog__actions--plain {
    padding-top: 2px;
    border-top: 0;
}

.drawer {
    position: fixed;
    inset: 0;
    display: flex;
    justify-content: flex-start;
    background: var(--fgg-scrim);
    backdrop-filter: blur(5px);
    z-index: var(--fgg-z-drawer);
}

.drawer[hidden] {
    display: none;
}

.drawer__panel {
    position: relative;
    display: flex;
    flex-direction: column;
    width: 270px;
    max-width: 85%;
    background: var(--fgg-surface);
    border-right: 1px solid var(--fgg-info-border);
    box-shadow: var(--fgg-shadow-drawer);
}

.drawer__body {
    display: flex;
    flex-direction: column;
    gap: var(--fgg-space-1);
    padding: var(--fgg-space-6);
}

.drawer__link {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-4);
    padding: 11px var(--fgg-space-3);
    color: var(--fgg-ink);
    font-size: var(--fgg-font-size);
    border-bottom: 1px dotted var(--fgg-rule);
    border-radius: var(--fgg-radius);
}

.drawer__link:hover {
    text-decoration: none;
}

.drawer__link--active {
    color: var(--fgg-ink-darkest);
    font-weight: bold;
    background: var(--fgg-selected);
}

.drawer__logout {
    margin: 0;
}

.drawer__logout button {
    display: flex;
    align-items: center;
    gap: var(--fgg-space-4);
    width: 100%;
    padding: 11px var(--fgg-space-3);
    color: var(--fgg-link);
    font-size: var(--fgg-font-size);
    text-align: left;
    background: none;
    border: 0;
    cursor: pointer;
}

.drawer__logout .icon {
    color: var(--fgg-danger);
}

/* ---------- Mobile: the tab bar moves to the bottom ---------- */

@media (max-width: 640px) {
    .app__content {
        max-width: var(--fgg-content-width-mobile);
    }

    .app-nav__inner {
        max-width: var(--fgg-content-width-mobile);
    }

    .app__body {
        padding: var(--fgg-space-7) var(--fgg-space-6) 84px;
    }

    .app-nav {
        position: fixed;
        left: 0;
        right: 0;
        bottom: 0;
        order: 2;
        padding: var(--fgg-space-4) var(--fgg-space-6);
        border-top: 2px solid #fff;
        z-index: var(--fgg-z-bottom-nav);
    }

    .table {
        font-size: var(--fgg-font-size-xs);
    }
}
