/* Milestone 218 (TD-114/ADR-0014) — Generation Workspace.
   Extends style.css's existing dark-engineering-tool visual language
   additively, same convention brand.css itself already established
   (Milestone 214/216) -- no second visual identity. */

.gen-banner {
    background: #2a5d34;
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.gen-back-link {
    margin-left: auto;
    color: #fff;
    font-size: 12px;
    text-decoration: underline;
}

.gen-main {
    max-width: 1200px;
    margin: 0 auto;
    padding: 20px;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.gen-panel {
    background: #fff;
    border: 1px solid #ddd;
    border-radius: 6px;
    padding: 16px;
}

.gen-panel-wide {
    grid-column: 1 / -1;
}

.gen-actor {
    grid-column: 1 / -1;
}

.gen-panel h2 {
    margin-top: 0;
    font-size: 15px;
}

.gen-hint {
    font-size: 12px;
    color: #666;
    line-height: 1.5;
}

.gen-form {
    display: flex;
    flex-wrap: wrap;
    gap: 8px;
    align-items: center;
    margin-bottom: 10px;
}

.gen-form label {
    font-size: 12px;
    color: #444;
}

.gen-form input,
.gen-form select {
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    flex: 1 1 auto;
    min-width: 120px;
}

.gen-form button {
    padding: 7px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    background: #0B3D2E;
    color: #fff;
}

/* Milestone 219L (ADR-0022): real per-user session bar, replacing the
   removed #actor-role <select>'s styling above. */
.gen-auth-bar {
    font-size: 13px;
    display: flex;
    align-items: center;
    gap: 8px;
}

.gen-auth-bar button {
    padding: 6px 12px;
    border: none;
    border-radius: 4px;
    font-size: 12px;
    cursor: pointer;
    background: #0B3D2E;
    color: #fff;
}

.gen-auth-form {
    margin-bottom: 0;
}

.gen-login-error {
    font-size: 12px;
    color: #b02020;
}

.gen-form button:disabled {
    background: #9aa; /* stylelint-disable-line */
    background-color: #b7c2bb;
    cursor: not-allowed;
}

.gen-preview {
    font-size: 12px;
    background: #f7f7f7;
    border: 1px solid #e5e5e5;
    border-radius: 4px;
    padding: 8px;
    margin-bottom: 8px;
    max-height: 180px;
    overflow-y: auto;
}

.gen-preview-conflict {
    color: #b02020;
    font-weight: 600;
}

.gen-preview-ok {
    color: #1a6b1a;
}

.gen-result {
    font-size: 12px;
    margin-bottom: 8px;
}

.gen-result-success {
    color: #1a6b1a;
}

.gen-result-error {
    color: #b02020;
    font-weight: 600;
}

.gen-search-label {
    display: block;
    font-size: 11px;
    color: #888;
    margin-top: 4px;
}

.gen-search {
    width: 100%;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    box-sizing: border-box;
    margin-bottom: 6px;
}

.gen-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
}

.gen-list-item {
    padding: 5px 8px;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    font-size: 12px;
    background: #fafafa;
}

.gen-history table {
    width: 100%;
    border-collapse: collapse;
    font-size: 12px;
}

.gen-history th,
.gen-history td {
    text-align: left;
    padding: 6px 8px;
    border-bottom: 1px solid #eee;
}

.gen-history .status-success { color: #1a6b1a; font-weight: 600; }
.gen-history .status-rejected { color: #b02020; font-weight: 600; }

/* Milestone 218C (TD-117/ADR-0016): LAND and PROJECTS rendered as visually
   distinct sibling groups under Estate -- a Project must never appear to
   "contain" Block/Plot the way it would if these panels were just more
   items in the same flat grid. Each group is its own full-width region
   with its own heading, and re-establishes the same 2-column panel grid
   .gen-main already uses, rather than a new layout system. */
.gen-domain-group {
    grid-column: 1 / -1;
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 16px;
}

.gen-domain-heading {
    grid-column: 1 / -1;
    font-size: 13px;
    text-transform: uppercase;
    letter-spacing: 0.06em;
    color: #0B3D2E;
    border-bottom: 2px solid #0B3D2E;
    padding-bottom: 6px;
    margin: 6px 0 0 0;
}

.gen-panel h3 {
    font-size: 13px;
    margin: 14px 0 8px 0;
    border-top: 1px solid #eee;
    padding-top: 12px;
}

.gen-checkbox-columns {
    display: flex;
    gap: 16px;
    flex: 1 1 100%;
    margin-bottom: 8px;
}

.gen-checkbox-columns > div {
    flex: 1 1 50%;
    min-width: 0;
}

.gen-checkbox-list {
    display: flex;
    flex-direction: column;
    gap: 4px;
    max-height: 160px;
    overflow-y: auto;
    border: 1px solid #e0e0e0;
    border-radius: 4px;
    padding: 6px;
}

.gen-checkbox-list label {
    display: flex;
    align-items: center;
    gap: 6px;
    font-size: 12px;
    color: #333;
}

.gen-checkbox-list .gen-checkbox-disabled {
    color: #aaa;
}

/* Milestone 219 (ADR-0019) — Generation History rollback lifecycle. */

.gen-history .status-active { color: #1a6b1a; font-weight: 600; }
.gen-history .status-rolled-back { color: #b02020; font-weight: 600; }

.gen-history-actions {
    display: flex;
    gap: 6px;
    flex-wrap: wrap;
}

/* Milestone 219C — a legacy batch (no recorded OperationType, predates
   Milestone 219) is inspectable but explicitly not rollback-capable; this
   is a distinct, muted label, never the danger-red rollback button. */
.gen-legacy-note {
    color: #777;
    font-style: italic;
    font-size: 11px;
}

.gen-history-actions button {
    padding: 4px 8px;
    border: 1px solid #0B3D2E;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    background: #fff;
    color: #0B3D2E;
}

.gen-history-actions button.gen-btn-danger {
    border-color: #b02020;
    color: #b02020;
}

.gen-history-actions button:disabled,
.gen-undo-btn:disabled {
    border-color: #ccc;
    color: #999;
    cursor: not-allowed;
}

.gen-undo-btn {
    margin-left: 8px;
    padding: 4px 10px;
    border: 1px solid #b02020;
    border-radius: 4px;
    font-size: 11px;
    cursor: pointer;
    background: #fff;
    color: #b02020;
}

/* Milestone 219A (ADR-0019 UI integration) — real modal dialogs, replacing
   window.alert()/confirm()/prompt() as the primary rollback UX. Reuses the
   existing panel/button visual language (.gen-panel's white/border/radius,
   .gen-form button's dark-green primary) rather than introducing a second
   visual identity. */

.gen-modal-root:not([hidden]) {
    position: fixed;
    inset: 0;
    z-index: 1000;
    display: flex;
    align-items: flex-start;
    justify-content: center;
    padding: 40px 16px;
    background: rgba(10, 20, 15, 0.55);
    overflow-y: auto;
}

.gen-modal {
    background: #fff;
    border-radius: 8px;
    max-width: 560px;
    width: 100%;
    box-shadow: 0 12px 40px rgba(0, 0, 0, 0.3);
    font-size: 13px;
    color: #222;
}

.gen-modal-header {
    padding: 16px 20px;
    border-bottom: 1px solid #eee;
    font-size: 15px;
    font-weight: 700;
    color: #0B3D2E;
}

.gen-modal-header.gen-modal-header-danger {
    color: #b02020;
}

.gen-modal-body {
    padding: 16px 20px;
    max-height: 55vh;
    overflow-y: auto;
}

.gen-modal-fields {
    display: grid;
    grid-template-columns: auto 1fr;
    gap: 4px 12px;
    font-size: 12.5px;
    margin-bottom: 12px;
}

.gen-modal-fields dt {
    color: #666;
}

.gen-modal-fields dd {
    margin: 0;
    font-weight: 600;
}

.gen-modal-warning {
    background: #fff7e6;
    border: 1px solid #f0c36d;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: #6b4d00;
    line-height: 1.5;
    margin-bottom: 12px;
}

.gen-modal-blocked {
    background: #fdeeee;
    border: 1px solid #e5a0a0;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: #7a1414;
    line-height: 1.5;
}

.gen-modal-success {
    background: #eaf6ea;
    border: 1px solid #9fd39f;
    border-radius: 6px;
    padding: 10px 12px;
    font-size: 12px;
    color: #1a4d1a;
    line-height: 1.5;
}

.gen-dependency-list,
.gen-record-list {
    list-style: none;
    margin: 8px 0 0 0;
    padding: 0;
    max-height: 200px;
    overflow-y: auto;
}

.gen-dependency-list li,
.gen-record-list li {
    padding: 4px 0;
    border-bottom: 1px solid #f0e0e0;
    font-family: monospace;
    font-size: 12px;
}

.gen-record-list li {
    border-bottom: 1px solid #eee;
}

.gen-record-list li.gen-record-deleted {
    color: #999;
    text-decoration: line-through;
}

.gen-modal-reason {
    width: 100%;
    box-sizing: border-box;
    padding: 6px 8px;
    border: 1px solid #ccc;
    border-radius: 4px;
    font-size: 12px;
    margin-top: 4px;
    resize: vertical;
    min-height: 44px;
}

.gen-modal-actions {
    padding: 14px 20px;
    border-top: 1px solid #eee;
    display: flex;
    justify-content: flex-end;
    gap: 8px;
}

.gen-modal-actions button {
    padding: 8px 14px;
    border: none;
    border-radius: 4px;
    font-size: 12.5px;
    cursor: pointer;
}

.gen-modal-btn-cancel {
    background: #eee;
    color: #333;
}

.gen-modal-btn-confirm {
    background: #0B3D2E;
    color: #fff;
}

.gen-modal-btn-danger {
    background: #b02020;
    color: #fff;
}

.gen-modal-btn-confirm:disabled,
.gen-modal-btn-danger:disabled {
    background: #b7c2bb;
    cursor: not-allowed;
}

.gen-batch-id {
    font-family: monospace;
    background: #f3f3f3;
    border-radius: 3px;
    padding: 1px 5px;
}

/* Mobile-responsive pass: additive-only, matches the breakpoint/approach
   used in terracore.css/style.css. Collapses the Generation Workspace's
   2-column panel grid to one column, makes the history table scroll
   inside its own contained box instead of the whole page, and gives
   modals/forms comfortable touch targets. Nothing above 900px changes. */
@media (max-width: 900px) {
    .gen-main, .gen-domain-group { grid-template-columns: 1fr; padding: 12px; gap: 12px; }
    .gen-panel-wide, .gen-actor, .gen-domain-heading { grid-column: 1; }
    .gen-form input, .gen-form select { padding: 9px 10px; font-size: 16px; min-width: 0; flex: 1 1 100%; }
    .gen-form button { padding: 10px 14px; font-size: 13px; }
    .gen-checkbox-columns { flex-direction: column; gap: 10px; }
    .gen-history { overflow-x: auto; -webkit-overflow-scrolling: touch; }
    .gen-history table { min-width: 560px; }
    .gen-modal-root:not([hidden]) { padding: 0; align-items: stretch; }
    .gen-modal { max-width: none; width: 100%; min-height: 100%; border-radius: 0; }
    .gen-modal-actions { flex-wrap: wrap; }
    .gen-modal-actions button { flex: 1 1 auto; padding: 11px 14px; }
}
