/* static/css/schedule_modal.css */
.schedule-modal,
.project-modal,
.preview-modal,
.project-list-modal {
    display: none;
    position: fixed;
    inset: 0;
    z-index: 10030;
}

.schedule-modal.is-open,
.project-modal.is-open,
.preview-modal.is-open,
.project-list-modal.is-open {
    display: block;
}

.schedule-modal__backdrop,
.project-modal__backdrop,
.preview-modal__backdrop,
.project-list-modal__backdrop {
    position: absolute;
    inset: 0;
    background: rgba(0, 0, 0, 0.45);
}

.schedule-modal__dialog,
.project-modal__dialog,
.preview-modal__dialog,
.project-list-modal__dialog {
    position: absolute;
    width: min(42rem, calc(100% - 2rem));
    min-width: 30rem;
    min-height: 20rem;
    background: #ffffff;
    border-radius: 0.75rem;
    box-shadow: 0 1rem 2.5rem rgba(0, 0, 0, 0.25);
    overflow: hidden;
    box-sizing: border-box;
}

.schedule-modal__dialog--wide,
.project-modal__dialog--wide,
.preview-modal__dialog--wide,
.project-list-modal__dialog--wide {
    width: min(72rem, calc(100% - 2rem));
}

.schedule-modal__header,
.project-modal__header,
.preview-modal__header,
.project-list-modal__header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 1rem;
    padding: 1rem 1.25rem;
    border-bottom: 0.0625rem solid #dddddd;
    background: #ffffff;
    cursor: move;
    user-select: none;
}

.schedule-modal__header-title,
.project-modal__header-title,
.preview-modal__header-title,
.project-list-modal__header-title {
    min-width: 0;
}

.schedule-modal__header h2,
.project-modal__header h2,
.preview-modal__header h2,
.project-list-modal__header h2 {
    margin: 0;
    font-size: 1.25rem;
    line-height: 1.4;
}

.schedule-modal__project-name,
.project-modal__project-name,
.preview-modal__project-name,
.project-list-modal__project-name {
    margin: 0.25rem 0 0;
    color: #555555;
    font-size: 0.875rem;
}

.schedule-modal__close,
.project-modal__close,
.preview-modal__close,
.project-list-modal__close {
    flex: 0 0 auto;
    width: 2.25rem;
    height: 2.25rem;
    border: none;
    border-radius: 50%;
    background: #f1f1f1;
    color: #333333;
    font-size: 1.5rem;
    line-height: 1;
    cursor: pointer;
}

.schedule-modal__close:hover,
.project-modal__close:hover,
.preview-modal__close:hover,
.project-list-modal__close:hover {
    background: #e5e5e5;
}

.schedule-modal__body,
.project-modal__body,
.preview-modal__body,
.project-list-modal__body {
    padding: 1rem 1.25rem;
    max-height: calc(100% - 8.5rem);
    overflow: auto;
}

.project-modal__dialog,
.project-list-modal__dialog {
    display: flex;
    flex-direction: column;
    overflow: hidden;
}

.project-modal__body,
.project-list-modal__body {
    flex: 1 1 auto;
    min-height: 0;
    max-height: none;
    overflow: auto;
}

.project-modal__footer,
.project-list-modal__footer {
    flex: 0 0 auto;
}

.project-modal__dialog.is-resized .project-modal__body,
.project-list-modal__dialog.is-resized .project-list-modal__body {
    max-height: none;
}

.schedule-modal__notice {
    margin-bottom: 1rem;
    padding: 0.625rem 0.75rem;
    border: 0.0625rem solid #f0d8a8;
    border-radius: 0.5rem;
    background: #fffaf0;
    color: #4a3a12;
    font-size: 0.875rem;
    line-height: 1.6;
}

.schedule-modal__notice p {
    margin: 0;
}

.schedule-modal__table-wrap {
    width: 100%;
    max-height: calc(100vh - 16rem);
    overflow: auto;
}

.schedule-modal__dialog.is-resized .schedule-modal__table-wrap {
    max-height: calc(100% - 4rem);
}

.schedule-modal__table {
    width: 100%;
    min-width: 52rem;
    border-collapse: collapse;
    background: #ffffff;
}

.schedule-modal__table th,
.schedule-modal__table td {
    padding: 0.5rem;
    border: 0.0625rem solid #dddddd;
    text-align: left;
    vertical-align: middle;
    white-space: nowrap;
}

.schedule-modal__table th {
    background: #f3f3f3;
    font-weight: 700;
}

.schedule-modal__table tbody tr {
    background: #f4fff0;
}

.schedule-modal__table tbody tr.is-highlight {
    outline: 0.1875rem solid #f0a202;
    outline-offset: -0.1875rem;
}

.schedule-modal__table input[type="date"],
.schedule-modal__table input[type="time"] {
    box-sizing: border-box;
    width: 8.25rem;
    padding: 0.375rem 0.5rem;
    border: 0.0625rem solid #aaaaaa;
    border-radius: 0.25rem;
    background: #ffffff;
    font-size: 0.9375rem;
}

.schedule-modal__table input[type="time"] {
    width: 6.75rem;
}

.schedule-modal__row-actions {
    display: flex;
    gap: 0.375rem;
    align-items: center;
}

.schedule-modal__row-actions button {
    padding: 0.375rem 0.625rem;
    border: 0.0625rem solid #999999;
    border-radius: 0.25rem;
    background: #ffffff;
    color: #222222;
    cursor: pointer;
    font-size: 0.9375rem;
}

.schedule-modal__row-actions button:hover {
    opacity: 0.85;
}

.schedule-modal__row-actions button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.schedule-modal__row-actions .modal-row-delete {
    border-color: #b00020;
    color: #b00020;
}

.project-list-modal__grid {
    display: grid;
    grid-template-columns: 1fr 1fr;
    gap: 1rem;
}

.project-list-modal__section {
    min-width: 0;
    padding: 0.75rem;
    border: 0.0625rem solid #dddddd;
    border-radius: 0.625rem;
    background: #fafafa;
}

.project-list-modal__section-title {
    margin: 0 0 0.625rem;
    font-size: 1rem;
    line-height: 1.4;
}

.project-list-modal__search {
    box-sizing: border-box;
    width: 100%;
    margin-bottom: 0.625rem;
    padding: 0.5rem 0.625rem;
    border: 0.0625rem solid #aaaaaa;
    border-radius: 0.25rem;
    font-size: 0.9375rem;
}

.project-list-modal__list {
    min-height: 14rem;
    max-height: 22rem;
    margin: 0;
    padding: 0;
    overflow: auto;
}

.project-list-modal__dialog.is-resized .project-list-modal__list {
    max-height: none;
}

.project-list-modal__actions {
    display: flex;
    flex-wrap: wrap;
    gap: 0.5rem;
    margin-top: 0.75rem;
}

.project-list-modal__actions button {
    min-width: 6rem;
    padding: 0.5rem 0.75rem;
    border: 0.0625rem solid #999999;
    border-radius: 0.25rem;
    background: #ffffff;
    color: #222222;
    cursor: pointer;
    font-size: 0.9375rem;
}

.project-list-modal__actions button:hover {
    opacity: 0.85;
}

.project-list-modal__current {
    margin-top: 1rem;
    padding: 0.75rem;
    border-radius: 0.5rem;
    background: #f2f6ff;
    color: #003399;
    font-weight: 700;
    text-align: center;
}

.project-list-modal-open-button {
    padding: 0.5rem 1rem;
    border: 0.0625rem solid #222222;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #222222;
    cursor: pointer;
    font-size: 1rem;
}

.project-list-modal-open-button:hover {
    opacity: 0.86;
}

.schedule-modal__footer,
.project-modal__footer,
.preview-modal__footer,
.project-list-modal__footer {
    display: flex;
    justify-content: flex-end;
    gap: 0.625rem;
    padding: 1rem 1.25rem;
    border-top: 0.0625rem solid #dddddd;
    background: #f8f8f8;
}

.schedule-modal__button,
.project-modal__button,
.preview-modal__button,
.project-list-modal__button {
    min-width: 5rem;
    padding: 0.5rem 1rem;
    border: 0.0625rem solid #aaaaaa;
    border-radius: 0.375rem;
    background: #ffffff;
    color: #222222;
    cursor: pointer;
    font-size: 1rem;
    line-height: 1.4;
}

.schedule-modal__button:hover,
.project-modal__button:hover,
.preview-modal__button:hover,
.project-list-modal__button:hover {
    opacity: 0.86;
}

.schedule-modal__button--sub,
.project-modal__button--sub,
.preview-modal__button--sub,
.project-list-modal__button--sub {
    background: #eeeeee;
    color: #333333;
}

.schedule-modal__resize-handle,
.project-modal__resize-handle,
.preview-modal__resize-handle,
.project-list-modal__resize-handle {
    position: absolute;
    right: 0;
    bottom: 0;
    width: 1.75rem;
    height: 1.75rem;
    cursor: nwse-resize;
    z-index: 10;
}

.schedule-modal__resize-handle::before,
.project-modal__resize-handle::before,
.preview-modal__resize-handle::before,
.project-list-modal__resize-handle::before {
    content: "";
    position: absolute;
    right: 0.375rem;
    bottom: 0.375rem;
    width: 1rem;
    height: 1rem;
    border-right: 0.1875rem solid #555555;
    border-bottom: 0.1875rem solid #555555;
}

.schedule-modal__resize-handle::after,
.project-modal__resize-handle::after,
.preview-modal__resize-handle::after,
.project-list-modal__resize-handle::after {
    content: "";
    position: absolute;
    right: 0.75rem;
    bottom: 0.75rem;
    width: 0.5rem;
    height: 0.5rem;
    border-right: 0.125rem solid #888888;
    border-bottom: 0.125rem solid #888888;
}

/* 案件登録・修正モーダル（案件一覧モーダルより前面） */
#project-modal {
    z-index: 10050;
}

/* 関係者一覧モーダル・メモモーダル：バックドロップなし、背景操作可 */
.user-list-modal {
    pointer-events: none;
}

.user-list-modal .user-list-modal__backdrop {
    display: none;
}

.user-list-modal__dialog {
    pointer-events: auto;
}

/* メモモーダル */
.memo-modal {
    z-index: 10060;
    pointer-events: none;
}

.memo-modal .schedule-modal__backdrop {
    display: none;
}

.memo-modal__dialog {
    width: min(32rem, calc(100% - 2rem));
    min-height: auto;
    pointer-events: auto;
}

.user-list-modal [data-user-list-modal-drag],
.memo-modal [data-user-list-memo-modal-drag],
.project-list-modal [data-project-list-modal-drag],
#project-modal [data-project-modal-drag],
#schedule-modal [data-schedule-modal-drag] {
    cursor: move;
    user-select: none;
}

.user-list-modal [data-user-list-modal-drag] button,
.memo-modal [data-user-list-memo-modal-drag] button,
.project-list-modal [data-project-list-modal-drag] button,
#project-modal [data-project-modal-drag] button,
#schedule-modal [data-schedule-modal-drag] button {
    cursor: pointer;
}

.memo-modal__body {
    display: flex;
    flex-direction: column;
    gap: 0.5rem;
}

.memo-modal__body textarea {
    box-sizing: border-box;
    width: 100%;
    padding: 0.5rem 0.625rem;
    border: 0.0625rem solid #aaaaaa;
    border-radius: 0.375rem;
    font-size: 0.9375rem;
    line-height: 1.6;
    resize: vertical;
}

.memo-char-counter {
    text-align: right;
    font-size: 0.8125rem;
    color: #888888;
}

.btn-memo {
    margin-top: 0.375rem;
    padding: 0.25rem 0.625rem;
    border: 0.0625rem solid #999999;
    border-radius: 0.25rem;
    background: #f5f5f5;
    color: #333333;
    cursor: pointer;
    font-size: 0.875rem;
}

.btn-memo:hover {
    background: #ebebeb;
}

.btn-memo--has-content {
    border-color: #4a7fc1;
    color: #1a4a8a;
    background: #eef4ff;
}

.schedule-modal__button--main {
    background: #2c5aa0;
    border-color: #2c5aa0;
    color: #ffffff;
}

.schedule-modal__button--main:hover {
    opacity: 0.86;
}

/* 四隅リサイズハンドル */
.schedule-modal__resize-handle--se {
    right: 0; bottom: 0; left: auto; top: auto;
    cursor: nwse-resize;
}
.schedule-modal__resize-handle--sw {
    left: 0; bottom: 0; right: auto; top: auto;
    cursor: nesw-resize;
}
.schedule-modal__resize-handle--ne {
    right: 0; top: 0; left: auto; bottom: auto;
    cursor: nesw-resize;
}
.schedule-modal__resize-handle--nw {
    left: 0; top: 0; right: auto; bottom: auto;
    cursor: nwse-resize;
}

/* SW: ::before / ::after を左下に */
.schedule-modal__resize-handle--sw::before {
    right: auto; left: 0.375rem; bottom: 0.375rem; top: auto;
    border-right: none; border-left: 0.1875rem solid #555555;
    border-bottom: 0.1875rem solid #555555; border-top: none;
}
.schedule-modal__resize-handle--sw::after {
    right: auto; left: 0.75rem; bottom: 0.75rem; top: auto;
    border-right: none; border-left: 0.125rem solid #888888;
    border-bottom: 0.125rem solid #888888; border-top: none;
}

/* NE: ::before / ::after を右上に */
.schedule-modal__resize-handle--ne::before {
    right: 0.375rem; bottom: auto; top: 0.375rem; left: auto;
    border-right: 0.1875rem solid #555555; border-bottom: none;
    border-top: 0.1875rem solid #555555; border-left: none;
}
.schedule-modal__resize-handle--ne::after {
    right: 0.75rem; bottom: auto; top: 0.75rem; left: auto;
    border-right: 0.125rem solid #888888; border-bottom: none;
    border-top: 0.125rem solid #888888; border-left: none;
}

/* NW: ::before / ::after を左上に */
.schedule-modal__resize-handle--nw::before {
    right: auto; left: 0.375rem; bottom: auto; top: 0.375rem;
    border-right: none; border-left: 0.1875rem solid #555555;
    border-bottom: none; border-top: 0.1875rem solid #555555;
}
.schedule-modal__resize-handle--nw::after {
    right: auto; left: 0.75rem; bottom: auto; top: 0.75rem;
    border-right: none; border-left: 0.125rem solid #888888;
    border-bottom: none; border-top: 0.125rem solid #888888;
}

.preview-modal__dialog {
    width: min(92rem, calc(100% - 4rem));
    min-width: 40rem;
    min-height: 28rem;
}

.preview-modal__body {
    overflow: auto;
}

@media (max-width: 48rem) {
    .schedule-modal__dialog,
    .schedule-modal__dialog--wide,
    .project-modal__dialog,
    .project-modal__dialog--wide,
    .preview-modal__dialog,
    .preview-modal__dialog--wide,
    .project-list-modal__dialog,
    .project-list-modal__dialog--wide {
        position: relative;
        width: calc(100% - 1rem);
        min-width: 0;
        min-height: 0;
        margin: 2rem auto;
        border-radius: 0.625rem;
    }

    .schedule-modal__header,
    .project-modal__header,
    .preview-modal__header,
    .project-list-modal__header {
        padding: 0.875rem 1rem;
        cursor: default;
    }

    .schedule-modal__header h2,
    .project-modal__header h2,
    .preview-modal__header h2,
    .project-list-modal__header h2 {
        font-size: 1.125rem;
    }

    .schedule-modal__body,
    .project-modal__body,
    .preview-modal__body,
    .project-list-modal__body {
        padding: 0.875rem 1rem;
        max-height: none;
        overflow: visible;
    }

    .schedule-modal__table-wrap {
        max-height: calc(100vh - 14rem);
    }

    .project-list-modal__grid {
        grid-template-columns: 1fr;
    }

    .project-list-modal__list {
        max-height: 16rem;
    }

    .schedule-modal__footer,
    .project-modal__footer,
    .preview-modal__footer,
    .project-list-modal__footer {
        padding: 0.875rem 1rem;
    }

    .schedule-modal__button,
    .project-modal__button,
    .preview-modal__button,
    .project-list-modal__button {
        width: 100%;
    }

    .schedule-modal__resize-handle,
    .project-modal__resize-handle,
    .preview-modal__resize-handle,
    .project-list-modal__resize-handle {
        display: none;
    }
}