/*
 * Goal-owned styling, independent of Bootstrap classes/variables.
 * Values mirror the existing cards, forms, buttons and responsive column widths.
 * The application shell and shared confirmation/wait overlays remain separately owned.
 */
.goal-ui {
    box-sizing: border-box;
    font-family: system-ui, -apple-system, "Segoe UI", Roboto, "Helvetica Neue", Arial, sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol";
    font-size: 16px;
    font-weight: 400;
    line-height: 1.5;
    color: #212529;
    text-align: left;
}
.goal-ui *, .goal-ui *::before, .goal-ui *::after { box-sizing: border-box; }
.goal-ui [hidden], .goal-dialog-backdrop[hidden] { display: none !important; }
#goalViewId { background: rgb(225,235,247); border-radius: .5rem; }
.goal-ui p { margin: 0 0 1rem; }
.goal-ui label { display: inline-block; }
.goal-ui strong, .goal-strong { font-weight: 700; }
.goal-ui a { color: #0d6efd; text-decoration: underline; }
.goal-ui a:hover { color: #0a58ca; }
.goal-ui fieldset { min-width: 0; padding: 0; margin: 0; border: 0; }
.goal-ui form { margin: 0; }
/* Goal sentences are also displayed by StartView; keep their presentation self-contained. */
.goal-condition-summary { font-size: 1rem; font-weight: 300; }
.goal-ui .goal-empty-explanation { margin: .5rem; padding: .5rem; font-size: 1.25rem; font-weight: 300; }
.goal-layout { display: flex; flex-wrap: wrap; margin-right: -12px; margin-left: -12px; }
.goal-info, .goal-subgoals { flex: 0 0 auto; width: 100%; padding-right: 12px; padding-left: 12px; }
.goal-card {
    position: relative;
    display: flex;
    flex-direction: column;
    min-width: 0;
    margin: .5rem;
    padding: .5rem;
    overflow-wrap: break-word;
    background: #fff;
    border: 1px solid rgba(0,0,0,.175);
    border-radius: .375rem;
}
.goal-card-header {
    padding: .5rem 1rem;
    text-align: center;
    background: rgba(123,145,187,1);
    border-bottom: 1px solid rgba(0,0,0,.175);
    border-radius: calc(.375rem - 1px) calc(.375rem - 1px) 0 0;
}
.goal-heading { font-size: calc(1.3rem + .6vw); font-weight: 700; word-break: break-word; }
.goal-card-body { flex: 1 1 auto; padding: 1rem; }
.goal-form-container { margin-top: 10px; margin-bottom: 10px; background: #fff; border-radius: .5rem; }
.goal-detail { margin: .25rem; }
.goal-condition { min-width: 400px; max-width: 500px; }
.goal-label, .goal-field-label, .goal-error { margin-bottom: .5rem; }
.goal-label { font-weight: 700; }
.goal-ui .goal-label-block { display: block; }
.goal-error, .goal-danger-text { color: #dc3545; }
.goal-success-text { color: #198754; }
.goal-muted-text { color: rgba(33,37,41,.75); }
.goal-body-text { color: #212529; }
.goal-status { display: inline-block; margin-bottom: .5rem; }
.goal-input {
    display: block;
    width: 100%;
    padding: .375rem .75rem;
    margin: 0;
    font: inherit;
    color: #212529;
    line-height: 1.5;
    background-color: #fff;
    background-clip: padding-box;
    border: 1px solid #dee2e6;
    border-radius: .375rem;
    appearance: none;
    transition: border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.goal-input:focus { color: #212529; background-color: #fff; border-color: #86b7fe; outline: 0; box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); }
.goal-input:disabled { background-color: #e9ecef; opacity: 1; }
.goal-input::placeholder { color: rgba(33,37,41,.75); opacity: 1; }
.goal-ui textarea.goal-input { min-height: calc(1.5em + .75rem + 2px); resize: vertical; }
.goal-ui input[type="date"] { min-height: calc(1.5em + .75rem + 2px); }
.goal-ui input[type="date"]::-webkit-datetime-edit { padding: 0; }
.goal-select {
    padding-right: 2.25rem;
    background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath fill='none' stroke='%23343a40' stroke-linecap='round' stroke-linejoin='round' stroke-width='2' d='m2 5 6 6 6-6'/%3e%3c/svg%3e");
    background-repeat: no-repeat;
    background-position: right .75rem center;
    background-size: 16px 12px;
}
.goal-button {
    display: inline-block;
    margin: 0;
    padding: .375rem .75rem;
    font: inherit;
    font-weight: 400;
    line-height: 1.5;
    color: #fff;
    text-align: center;
    text-decoration: none;
    vertical-align: middle;
    cursor: pointer;
    user-select: none;
    background: #0d6efd;
    border: 1px solid transparent;
    border-radius: .375rem;
    transition: color .15s ease-in-out, background-color .15s ease-in-out, border-color .15s ease-in-out, box-shadow .15s ease-in-out;
}
.goal-button:focus { outline: 0; }
.goal-button:disabled { pointer-events: none; opacity: .65; }
.goal-button-small { padding: .25rem .5rem; font-size: .875rem; border-radius: .25rem; }
.goal-primary { background-color: #0d6efd; border-color: #0d6efd; }
.goal-primary:hover { background-color: #0b5ed7; border-color: #0a58ca; }
.goal-primary:focus-visible { background-color: #0b5ed7; border-color: #0a58ca; box-shadow: 0 0 0 .25rem rgba(49,132,253,.5); }
.goal-primary:active { background-color: #0a58ca; border-color: #0a53be; }
.goal-secondary { background-color: #6c757d; border-color: #6c757d; }
.goal-secondary:hover { background-color: #5c636a; border-color: #565e64; }
.goal-secondary:focus-visible { background-color: #5c636a; border-color: #565e64; box-shadow: 0 0 0 .25rem rgba(130,138,145,.5); }
.goal-secondary:active { background-color: #565e64; border-color: #51585e; }
.goal-success { background-color: #198754; border-color: #198754; }
.goal-success:hover { background-color: #157347; border-color: #146c43; }
.goal-success:focus-visible { background-color: #157347; border-color: #146c43; box-shadow: 0 0 0 .25rem rgba(60,153,110,.5); }
.goal-success:active { background-color: #146c43; border-color: #13653f; }
.goal-danger { background-color: #dc3545; border-color: #dc3545; }
.goal-danger:hover { background-color: #bb2d3b; border-color: #b02a37; }
.goal-danger:focus-visible { background-color: #bb2d3b; border-color: #b02a37; box-shadow: 0 0 0 .25rem rgba(225,83,97,.5); }
.goal-danger:active { background-color: #b02a37; border-color: #a52834; }
.goal-form-actions { display: grid; gap: .5rem; }
.goal-condition-create { margin-right: .5rem; }
.goal-manual-reach { margin-top: .5rem !important; margin-bottom: .5rem !important; }
.goal-term-list { margin-top: 0; margin-bottom: 1rem; padding-left: 2rem; }
.goal-term-action { margin-left: .5rem; }
/* Local SVG symbols inherit link/hover colors without an icon font. */
.goal-term-icon { width: 1em; height: 1em; fill: currentColor; vertical-align: -.125em; }
.goal-subgoal-list { display: flex; flex-direction: column; padding-left: 0; margin: 0; border-radius: .375rem; counter-reset: goal-subgoals; list-style: none; }
.goal-subgoal {
    position: relative;
    display: flex;
    justify-content: space-between;
    align-items: flex-start;
    padding: .5rem 1rem;
    color: #212529;
    cursor: pointer;
    text-decoration: none;
    background-color: #fff;
    border: 1px solid #dee2e6;
}
.goal-subgoal::before { content: counter(goal-subgoals) ". "; counter-increment: goal-subgoals; }
.goal-subgoal + .goal-subgoal { border-top-width: 0; }
.goal-subgoal:first-child { border-top-left-radius: inherit; border-top-right-radius: inherit; }
.goal-subgoal:last-child { border-bottom-left-radius: inherit; border-bottom-right-radius: inherit; }
.goal-subgoal-reached { background-color: rgba(25,135,84,.5); background-image: linear-gradient(180deg,rgba(255,255,255,.15),rgba(255,255,255,0)); }
.goal-subgoal-failed { background-color: rgba(220,53,69,.25); background-image: linear-gradient(180deg,rgba(255,255,255,.15),rgba(255,255,255,0)); }
.goal-subgoal-text { margin-left: .5rem; margin-right: auto; }
.goal-strike { text-decoration: line-through !important; }
.goal-description, .goal-description p { font-size: 1rem; font-weight: 300; }
.goal-description p { margin-top: 0; margin-bottom: 1rem; }
.goal-trophy { margin-left: .5rem; vertical-align: middle; }
.goal-empty p { margin: .5rem; padding: .5rem; font-size: 1.25rem; font-weight: 300; }
.goal-create-subgoal { display: flex; justify-content: center; padding: 1rem; }

/*
 * These dialogs are intentionally below the unchanged shared modal/backdrop and
 * screen cover. Native show() keeps them out of the browser top layer; GoalRenderer
 * supplies the local backdrop/focus/scroll lifecycle rather than Bootstrap.
 */
.goal-dialog-backdrop { position: fixed; inset: 0; z-index: 1039; background: rgba(0,0,0,.5); }
dialog.goal-dialog {
    position: fixed;
    z-index: 1040;
    top: .5rem;
    left: 50%;
    transform: translateX(-50%);
    width: calc(100% - 1rem);
    max-width: 500px;
    max-height: calc(100vh - 1rem);
    margin: 0;
    padding: 0;
    background: #fff;
    border: 1px solid rgba(0,0,0,.175);
    border-radius: .5rem;
    outline: 0;
    overflow: hidden;
}
dialog.goal-dialog:not([open]) { display: none; }
dialog.goal-dialog[open], .goal-dialog-content { display: flex; flex-direction: column; }
.goal-dialog-content { min-height: 0; max-height: inherit; width: 100%; }
.goal-dialog-header { display: flex; flex-shrink: 0; align-items: center; justify-content: space-between; padding: 1rem; border-bottom: 1px solid #dee2e6; }
.goal-dialog-header h5 { margin: 0; font: inherit; font-size: 1.25rem; font-weight: 500; line-height: 1.5; }
.goal-close {
    box-sizing: content-box;
    flex: 0 0 auto;
    width: 1em;
    height: 1em;
    padding: .5rem;
    margin: -.5rem -.5rem -.5rem auto;
    font: inherit;
    line-height: 1;
    color: #000;
    background: transparent url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 16 16'%3e%3cpath d='M.293.293a1 1 0 0 1 1.414 0L8 6.586l6.293-6.293a1 1 0 1 1 1.414 1.414L9.414 8l6.293 6.293a1 1 0 0 1-1.414 1.414L8 9.414l-6.293 6.293a1 1 0 0 1-1.414-1.414L6.586 8 .293 1.707a1 1 0 0 1 0-1.414z'/%3e%3c/svg%3e") center/1em auto no-repeat;
    border: 0;
    border-radius: .375rem;
    opacity: .5;
    cursor: pointer;
}
.goal-close:hover { opacity: .75; }
.goal-close:focus { outline: 0; box-shadow: 0 0 0 .25rem rgba(13,110,253,.25); opacity: 1; }
.goal-dialog-body { position: relative; flex: 1 1 auto; min-height: 0; padding: 1rem; overflow-y: auto; }
.goal-dialog-footer { display: flex; flex-wrap: wrap; flex-shrink: 0; align-items: center; justify-content: flex-end; padding: .75rem; border-top: 1px solid #dee2e6; }
.goal-dialog-footer > * { margin: .25rem; }
.goal-dialog-footer > .goal-dialog-spinner { margin-right: 3rem; }
.goal-dialog-spinner img { vertical-align: middle; }
.goal-delete-section { margin-bottom: 1rem; }
.goal-condition-grid { display: grid; grid-template-columns: 1fr; gap: 1rem 1.5rem; }
@media (min-width: 576px) {
    dialog.goal-dialog { top: 1.75rem; width: calc(100% - 3.5rem); max-height: calc(100vh - 3.5rem); }
}
@media (min-width: 768px) {
    .goal-info { width: 41.66666667%; }
    .goal-info-new { width: 83.33333333%; }
    .goal-subgoals { width: 58.33333333%; }
    .goal-form-actions { display: flex; justify-content: flex-end; }
    .goal-form-actions #cancelCreateGoalBtn { margin-right: .5rem; }
    .goal-condition-grid { grid-template-columns: repeat(4, minmax(0, 1fr)); }
}
@media (min-width: 992px) { dialog.goal-dialog-wide { max-width: 800px; } }
@media (min-width: 1200px) { .goal-heading { font-size: 1.75rem; } }
@media (prefers-reduced-motion: reduce) { .goal-input, .goal-button { transition: none; } }
