/* ============================================================
   ADS - Edit Ticket screen redesign (loaded after the Bento layer)

   Pure layout / skin. Every rule is scoped to #page-edit, so the Create screen
   (which shares the same #issueForm) and every other screen are untouched, and
   no element id, field or script behaviour changes.

   Layout (desktop):
     [ Edit Ticket - subtitle                                   ]
     [ 1 Repository ▾      2 Ticket ▾                           ]   picker card
     [ #123  Ticket title            • Open                      ]   summary banner
     [ Effort & Due: planned / logged / remaining / due + timer  ]   effort panel
     [ Ticket details (title, description) | Properties         ]   two panels
     [ Comments ]  [ Issue relationships ]
     [ hint ........................................ SAVE ]       sticky action bar
   ============================================================ */

#page-edit .page-body { max-width: 1180px; }

/* ---------- header ---------- */
#page-edit .edit-page-head { margin-bottom: 16px; }
#page-edit .edit-page-head .page-screen-title { margin-bottom: 4px; }
#page-edit .edit-page-sub { margin: 0; color: var(--gray-600, #475569); font-size: 13.5px; }

/* ---------- picker card ---------- */
#page-edit .form-wrapper-screen { margin-bottom: 16px; }
#page-edit .edit-picker-card { padding: 18px 22px 20px; }
#page-edit .edit-form-notice {
    display: flex; align-items: center; gap: 8px;
    margin: 0 0 16px; padding: 9px 14px; font-size: 13px;
    border-radius: var(--bento-r-sm, 10px);
}
#page-edit .edit-form-notice i { opacity: 0.8; }
#page-edit .edit-picker {
    display: grid; grid-template-columns: repeat(2, minmax(0, 1fr)); gap: 16px 28px;
}
#page-edit .edit-picker-step { display: flex; align-items: flex-start; gap: 12px; min-width: 0; }
#page-edit .edit-picker-step .field-group { flex: 1; min-width: 0; margin: 0; }
#page-edit .edit-step-num {
    flex: 0 0 auto; width: 26px; height: 26px; margin-top: 1px; border-radius: 50%;
    display: grid; place-items: center; font-size: 12.5px; font-weight: 700;
    color: var(--green-dark, #0b7a55); background: var(--green-lite, #e6f7f0);
    border: 1px solid var(--green-mid, #a7e3c9);
}

/* ---------- ticket summary banner ---------- */
#page-edit .edit-ticket-banner {
    display: flex; flex-wrap: wrap; align-items: center; gap: 8px 12px;
    margin: 0 0 16px; padding: 12px 18px;
    background: var(--bento-tint, rgba(14,161,111,.07));
    border: 1px solid var(--green-mid, #a7e3c9);
    border-radius: var(--bento-r-md, 14px);
}
#page-edit .etb-num { font-weight: 800; color: var(--green-dark, #0b7a55); font-size: 15px; }
#page-edit .etb-title { font-weight: 600; color: var(--gray-900, #0f172a); flex: 1 1 260px; min-width: 0; overflow-wrap: anywhere; }
#page-edit .etb-chip {
    display: inline-flex; align-items: center; gap: 5px; padding: 2px 10px; border-radius: 999px;
    font-size: 12px; font-weight: 600; background: #fff; border: 1px solid var(--bento-line, rgba(15,23,42,.1)); color: #334155;
}
#page-edit .etb-chip.is-open   { color: #15803d; border-color: #bbf7d0; background: #f0fdf4; }
#page-edit .etb-chip.is-closed { color: #6b21a8; border-color: #e9d5ff; background: #faf5ff; }

/* ---------- fields: two panels (details | properties) ---------- */
#page-edit .edit-fields-wrap { padding: 0; background: none; border: 0; box-shadow: none; }
#page-edit #edit-fields-grid { position: relative; }
/* empty state while no ticket is chosen (the script dims + locks the grid) */
#page-edit #edit-fields-grid[style*="pointer-events"][style*="none"]::before {
    content: "Select a repository and a ticket above to start editing";
    position: absolute; top: 42%; left: 50%; transform: translate(-50%, -50%); z-index: 3;
    padding: 6px 16px; border-radius: 999px; white-space: nowrap; font-size: 12.5px; font-weight: 600;
    color: #475569; background: #fff; border: 1px solid var(--bento-line, rgba(15,23,42,.1));
    box-shadow: var(--bento-shadow, 0 6px 18px -8px rgba(15,23,42,.25));
}
/* the shared form carries its own card styling on Create; here the two panels are the cards */
#page-edit #edit-fields-grid > #issueForm {
    margin: 0; padding: 0; background: none; border: 0; box-shadow: none; border-radius: 0; max-width: none;
}

#page-edit #form-grid-inner {
    display: grid; align-items: start; gap: 16px 22px;
    grid-template-columns: minmax(0, 1.8fr) minmax(260px, 1fr);
    /* spare height (from the tall description) goes to the last row, so the property
       fields stay compact at the top of their panel */
    grid-template-rows: repeat(3, auto) 1fr;
}
#page-edit #form-grid-inner > .field-group .field-label { font-size: 12px; }
/* the two panels are painted by pseudo-elements, so no markup is needed */
#page-edit #form-grid-inner::before,
#page-edit #form-grid-inner::after {
    content: ""; z-index: 0; align-self: stretch;
    background: var(--bento-surface, rgba(255,255,255,.85));
    border: 1px solid var(--bento-line, rgba(15,23,42,.07));
    border-radius: var(--bento-r-lg, 20px);
    box-shadow: var(--bento-shadow, 0 1px 2px rgba(15,23,42,.04), 0 12px 30px -14px rgba(15,23,42,.16));
}
#page-edit #form-grid-inner::before { grid-column: 2; grid-row: 1 / span 4; background: var(--gray-50, #f8fafc); }
#page-edit #form-grid-inner::after  { grid-column: 1; grid-row: 1 / span 4; }

/* fields sit directly on the panel (no tile-within-a-tile) */
#page-edit #form-grid-inner > .field-group {
    position: relative; z-index: 1; margin: 0; margin-inline: 22px; min-width: 0;
    padding: 0; background: none; border: 0; border-radius: 0; box-shadow: none;
}
/* left panel */
#page-edit #form-grid-inner > #fg-title { grid-column: 1; grid-row: 1; margin-top: 20px; }
#page-edit #form-grid-inner > #description-container { grid-column: 1; grid-row: 2 / span 3; margin-bottom: 20px; }
/* right panel */
#page-edit #form-grid-inner > #fg-milestone { grid-column: 2; grid-row: 1; margin-top: 20px; }
#page-edit #form-grid-inner > #fg-module    { grid-column: 2; grid-row: 2; }
#page-edit #form-grid-inner > #fg-assignee  { grid-column: 2; grid-row: 3; }
#page-edit #form-grid-inner > #fg-label     { grid-column: 2; grid-row: 4; margin-bottom: 20px; }
/* Dropdown stacking fix: every .field-group above is position:relative + z-index:1, so each one
   is its own stacking context and a later sibling (LABEL) painted over the open Assignee list
   (whose z-index:40 is trapped inside #fg-assignee). Earlier rows now stack above later ones,
   so any open dropdown overlays the fields below it instead of being covered by them. */
#page-edit #form-grid-inner > #fg-milestone { z-index: 4; }
#page-edit #form-grid-inner > #fg-module    { z-index: 3; }
#page-edit #form-grid-inner > #fg-assignee  { z-index: 2; }
/* Create-only fields never belong on this screen (the app already hides them here);
   hiding them in CSS too keeps the two-panel grid intact whatever state they are in. */
#page-edit #fg-repo, #page-edit #fg-gtnum, #page-edit #issue-attachment-field,
#page-edit #fg-planned-effort-days, #page-edit #fg-planned-effort-hrs,
#page-edit .create { display: none !important; }
/* panel captions */
#page-edit #fg-title::before,
#page-edit #fg-milestone::before {
    display: block; margin-bottom: 12px; padding-bottom: 8px;
    font-size: 11.5px; font-weight: 800; letter-spacing: .08em; text-transform: uppercase;
    color: var(--gray-500, #64748b); border-bottom: 1px solid var(--bento-line, rgba(15,23,42,.08));
}
#page-edit #fg-title::before     { content: "Ticket details"; }
#page-edit #fg-milestone::before { content: "Properties"; }

#page-edit #fg-title input { font-weight: 600; }
#page-edit #description { min-height: 260px; resize: vertical; }
/* the form's own action row is empty on this screen (the save button lives in the bar below) */
#page-edit #form-grid-inner > #fg-actions { grid-column: 1 / -1; grid-row: auto; margin: 0; } /* base rule spans 3 columns -> phantom 3rd column here */
#page-edit #fg-actions:not(:has(button)) { display: none; }

/* ---------- comments + relationships ---------- */
#page-edit #comments-section,
#page-edit .issue-relationships-section {
    max-width: none; margin: 0 0 16px; padding: 20px 24px;
    background: var(--bento-surface, rgba(255,255,255,.85));
    border: 1px solid var(--bento-line, rgba(15,23,42,.07));
    border-radius: var(--bento-r-lg, 20px);
    box-shadow: var(--bento-shadow, 0 1px 2px rgba(15,23,42,.04), 0 12px 30px -14px rgba(15,23,42,.16));
}
#page-edit .comments-header,
#page-edit .issue-relationships-header { padding-bottom: 12px; margin-bottom: 16px; }
#page-edit .comments-title-wrap h3,
#page-edit .issue-relationships-header h3 { font-size: 15.5px; font-weight: 700; }

/* ---------- sticky save bar ---------- */
#page-edit .edit-bottom-actions {
    position: sticky; bottom: 14px; z-index: 6;
    align-items: center; justify-content: space-between; gap: 16px;
    margin: 4px 0 8px; padding: 12px 16px; border-top: 0;
    background: rgba(255,255,255,.92); -webkit-backdrop-filter: blur(10px); backdrop-filter: blur(10px);
    border: 1px solid var(--bento-line, rgba(15,23,42,.08));
    border-radius: var(--bento-r-lg, 20px);
    box-shadow: 0 -4px 24px -10px rgba(15,23,42,.22), var(--bento-shadow, 0 12px 30px -14px rgba(15,23,42,.16));
}
#page-edit .edit-bottom-actions::before {
    content: "Review comments and relationships above, then save your changes.";
    font-size: 13px; color: var(--gray-600, #475569);
}
#page-edit .edit-bottom-actions .edituh { min-width: 200px; padding: 12px 26px; border-radius: var(--bento-r-md, 14px); }

/* ---------- tablet / mobile: single column ---------- */
@media (max-width: 900px) {
    #page-edit .edit-picker { grid-template-columns: 1fr; }
    #page-edit #form-grid-inner { grid-template-columns: minmax(0, 1fr); gap: 14px; }
    #page-edit #form-grid-inner::before,
    #page-edit #form-grid-inner::after { display: none; }
    #page-edit #form-grid-inner > .field-group {
        grid-column: 1 !important; grid-row: auto !important; margin: 0;
        padding: 14px 16px; background: var(--bento-surface, #fff);
        border: 1px solid var(--bento-line, rgba(15,23,42,.07)); border-radius: var(--bento-r-md, 14px);
    }
    #page-edit #fg-milestone::before, #page-edit #fg-title::before { margin-bottom: 8px; }
    /* details first, then properties (the DOM lists the properties first) */
    #page-edit #form-grid-inner > #fg-title { order: 1; }
    #page-edit #form-grid-inner > #description-container { order: 2; }
    #page-edit #form-grid-inner > #fg-milestone { order: 3; }
    #page-edit #form-grid-inner > #fg-module { order: 4; }
    #page-edit #form-grid-inner > #fg-assignee { order: 5; }
    #page-edit #form-grid-inner > #fg-label { order: 6; }
    #page-edit #form-grid-inner > #fg-actions { order: 7; }
    #page-edit #edit-fields-grid[style*="pointer-events"][style*="none"]::before { white-space: normal; width: 86%; text-align: center; }
    #page-edit #comments-section, #page-edit .issue-relationships-section { padding: 16px; }
    #page-edit .edit-bottom-actions { flex-direction: column; align-items: stretch; bottom: 70px; }
    #page-edit .edit-bottom-actions::before { text-align: center; }
    #page-edit .edit-bottom-actions .edituh { width: 100%; min-width: 0; }
}


/* ============================================================
   Effort & Due panel (planned effort, due warnings, ticket timer)
   ============================================================ */
#page-edit .edit-effort-panel {
    margin: 0 0 16px; padding: 18px 22px;
    background: var(--bento-surface, rgba(255,255,255,.85));
    border: 1px solid var(--bento-line, rgba(15,23,42,.08));
    border-left: 5px solid var(--green, #0ea16f);
    border-radius: var(--bento-r-lg, 20px);
    box-shadow: var(--bento-shadow, 0 1px 2px rgba(15,23,42,.04), 0 12px 30px -14px rgba(15,23,42,.16));
}
#page-edit .edit-effort-panel.tet-warn   { border-left-color: #f59e0b; }
#page-edit .edit-effort-panel.tet-danger { border-left-color: #dc2626; }
#page-edit .edit-effort-panel.tet-closed { border-left-color: #94a3b8; }
#page-edit .tet-loading { color: #64748b; font-size: 13px; }
#page-edit .tet-head { display: flex; flex-wrap: wrap; align-items: baseline; gap: 4px 12px; margin-bottom: 14px; }
#page-edit .tet-title { font-size: 15.5px; font-weight: 700; color: var(--gray-900, #0f172a); }
#page-edit .tet-title i { color: var(--green-dark, #0b7a55); margin-right: 4px; }
#page-edit .tet-sub { font-size: 12.5px; color: var(--gray-500, #64748b); }
#page-edit .tet-body { display: grid; grid-template-columns: minmax(0, 1fr) 270px; gap: 20px 26px; align-items: start; }
#page-edit .tet-grid { display: grid; grid-template-columns: repeat(4, minmax(0, 1fr)); gap: 12px; }
#page-edit .tet-grid.tet-grid-2 { grid-template-columns: repeat(2, minmax(0, 1fr)); }   /* Planned Effort hidden for this user */
#page-edit .tet-tile {
    padding: 10px 14px; background: var(--gray-50, #f8fafc);
    border: 1px solid var(--bento-line, rgba(15,23,42,.07)); border-radius: var(--bento-r-md, 14px);
}
#page-edit .tet-tile.tet-warn   { background: #fffbeb; border-color: #fde68a; }
#page-edit .tet-tile.tet-danger { background: #fef2f2; border-color: #fecaca; }
#page-edit .tet-k { font-size: 11px; font-weight: 700; letter-spacing: .06em; text-transform: uppercase; color: var(--gray-500, #64748b); }
#page-edit .tet-v { font-size: 20px; font-weight: 800; color: var(--gray-900, #0f172a); margin-top: 2px; font-variant-numeric: tabular-nums; }
#page-edit .tet-tile.tet-warn .tet-v   { color: #b45309; }
#page-edit .tet-tile.tet-danger .tet-v { color: #b91c1c; }
#page-edit .tet-s { font-size: 12px; color: var(--gray-500, #64748b); min-height: 16px; }
#page-edit .tet-bar { height: 9px; margin: 14px 0 4px; border-radius: 999px; background: #e2e8f0; overflow: hidden; }
#page-edit .tet-bar > span { display: block; height: 100%; border-radius: 999px; background: var(--green, #0ea16f); transition: width .4s ease; }
#page-edit .tet-bar.tet-warn > span   { background: #f59e0b; }
#page-edit .tet-bar.tet-danger > span { background: #dc2626; }
#page-edit .tet-warns { display: flex; flex-direction: column; gap: 6px; margin-top: 12px; }
#page-edit .tet-row { display: flex; gap: 8px; align-items: flex-start; padding: 8px 12px; border-radius: 10px; font-size: 13px; font-weight: 600; }
#page-edit .tet-w-ok     { background: #f0fdf4; color: #15803d; }
#page-edit .tet-w-info   { background: #f1f5f9; color: #475569; font-weight: 500; }
#page-edit .tet-w-warn   { background: #fffbeb; color: #92400e; }
#page-edit .tet-w-danger { background: #fef2f2; color: #b91c1c; }
#page-edit .tet-timer {
    padding: 14px 16px; text-align: center;
    background: var(--gray-50, #f8fafc); border: 1px solid var(--bento-line, rgba(15,23,42,.07)); border-radius: var(--bento-r-md, 14px);
}
#page-edit .tet-timer-state { font-size: 12.5px; font-weight: 700; color: var(--gray-600, #475569); }
#page-edit .tet-timer-state.is-running { color: #15803d; }
#page-edit .tet-dot { display: inline-block; width: 8px; height: 8px; margin-right: 4px; border-radius: 50%; background: #16a34a; animation: tetPulse 1.4s infinite; }
@keyframes tetPulse { 0%,100% { opacity: 1; } 50% { opacity: .3; } }
#page-edit .tet-clock { margin: 6px 0 10px; font-size: 30px; font-weight: 800; letter-spacing: .02em; font-variant-numeric: tabular-nums; color: var(--gray-900, #0f172a); }
#page-edit .tet-clock-idle { color: #94a3b8; }
#page-edit .tet-btn { width: 100%; justify-content: center; }
#page-edit .tet-timer-sub { margin-top: 10px; font-size: 12px; color: var(--gray-500, #64748b); }

@media (max-width: 900px) {
    #page-edit .tet-body { grid-template-columns: minmax(0, 1fr); }
    #page-edit .tet-grid { grid-template-columns: repeat(2, minmax(0, 1fr)); }
    #page-edit .edit-effort-panel { padding: 16px; }
}
