/* Вразвитии · CTPA · 2026-11-05
   Three scoped UX repairs only: task date/time native controls; compact Focus
   card; safe active task timer controls. Business logic and timers unchanged. */

/* Prevent intrinsic sizes of native date/time controls from escaping grid cells. */
.modal-form[data-form="task"] .task-datetime-fields {
  grid-template-columns:repeat(2,minmax(0,1fr));
  gap:12px;
  min-width:0;
  max-width:100%;
}
.modal-form[data-form="task"] .task-datetime-fields > .field {
  min-width:0;
  max-width:100%;
}
.modal-form[data-form="task"] .task-datetime-fields input {
  box-sizing:border-box;
  display:block;
  width:100%;
  min-width:0;
  max-width:100%;
}
.modal-form[data-form="task"] .task-datetime-fields input::-webkit-date-and-time-value {
  min-width:0;
  text-align:left;
}

/* iPhone date localization can be wider than a half-width field. Give both
   system pickers their own row and full width, avoiding overlap on iOS. */
@media screen and (max-width:980px) {
  .modal-form[data-form="task"] .task-datetime-fields {
    display:grid;
    grid-template-columns:minmax(0,1fr);
    gap:10px;
  }
  .modal-form[data-form="task"] .task-datetime-fields > .field {
    width:100%;
    min-width:0;
    max-width:100%;
  }
  .modal-form[data-form="task"] .task-datetime-fields input {
    width:100%;
    min-width:0;
    max-width:100%;
    font-size:16px;
  }

  /* Normal task: compact content, bounded title, two-dimensional layout. */
  .flow-page-compact .flow-task {
    display:grid !important;
    grid-template-columns:minmax(0,1fr) auto;
    align-items:center;
    gap:7px 9px;
    flex-wrap:nowrap !important;
    padding:10px 11px !important;
    min-width:0;
    border-radius:13px;
  }
  .flow-page-compact .flow-task-info {
    display:flex;
    flex:initial;
    align-items:center;
    gap:8px;
    min-width:0;
    width:100%;
  }
  .flow-page-compact .flow-task-info > div {
    flex:1;
    min-width:0;
    max-width:100%;
  }
  .flow-page-compact .flow-task-info > div > strong {
    font-size:14px;
    line-height:1.28;
    font-weight:720;
    display:block;
    margin:0;
    overflow-wrap:break-word;
    word-break:normal;
  }
  .flow-page-compact .flow-task-meta {
    display:flex;
    flex-wrap:wrap;
    align-items:baseline;
    column-gap:8px;
    row-gap:2px;
    margin-top:4px;
    line-height:1.2;
  }
  .flow-page-compact .flow-task-meta span {
    font-size:10.5px;
    line-height:1.25;
    white-space:normal;
  }
  .flow-page-compact .flow-task-controls {
    min-width:0;
    flex:none;
    display:flex;
    align-items:center;
    gap:6px;
    padding:0 !important;
    margin:0 !important;
    justify-self:end;
    max-width:100%;
  }
  .flow-page-compact .flow-task-controls > button {
    min-height:38px;
    padding:8px 10px;
    font-size:12px;
    line-height:1.2;
    white-space:nowrap;
  }

  /* Running or paused task: timer and actions occupy full card width;
     never compress the task text into a narrow strip. */
  .flow-page-compact .flow-task:has(.flow-timer-actions) {
    grid-template-columns:minmax(0,1fr) !important;
    align-items:stretch;
    gap:9px;
  }
  .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-task-info {
    width:100%;
    min-width:0;
    align-items:flex-start;
  }
  .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-task-controls {
    grid-column:1 / -1;
    display:grid !important;
    grid-template-columns:minmax(0,1fr);
    justify-self:stretch;
    width:100%;
    max-width:100%;
    padding:9px 0 0 !important;
    margin:0 !important;
    gap:7px;
    border-top:1px solid #e3eeea;
  }
  .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-task-controls > strong {
    font-size:19px;
    line-height:1.2;
    font-variant-numeric:tabular-nums;
    white-space:nowrap;
    padding:0;
    width:auto;
  }
  .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-timer-actions {
    display:grid !important;
    grid-template-columns:repeat(2,minmax(0,1fr));
    width:100%;
    min-width:0;
    gap:7px;
    margin:0;
  }
  .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-timer-actions > button {
    width:100%;
    min-width:0;
    min-height:39px;
    padding:9px 7px;
    margin:0;
    line-height:1.2;
    font-size:12px;
    white-space:normal;
    text-align:center;
    overflow-wrap:break-word;
  }
  .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-timer-actions > button:last-child {
    grid-column:1 / -1;
  }
}

/* Tablet has enough room for two independent native date/time fields. */
@media screen and (min-width:721px) and (max-width:980px) {
  .modal-form[data-form="task"] .task-datetime-fields {
    grid-template-columns:repeat(2,minmax(0,1fr));
  }
}

/* Very narrow phones: give the entire row to task text, then the Start button. */
@media screen and (max-width:360px) {
  .flow-page-compact .flow-task:not(:has(.flow-timer-actions)) {
    grid-template-columns:minmax(0,1fr);
  }
  .flow-page-compact .flow-task:not(:has(.flow-timer-actions)) .flow-task-controls {
    grid-column:1;
    justify-self:start;
    margin-left:36px !important;
  }
}

/* Dark-theme affordance and text remain legible after compacting. */
body.vraz-dark .flow-page-compact .flow-task:has(.flow-timer-actions) .flow-task-controls {
  border-top-color:var(--line,#435b67);
}
