/* 사용자 목록 / 삭제 사용자 관리 공통 스타일 */

.users-management-page,
.deleted-users-page {
    display: grid;
    grid-template-columns: minmax(0, 1fr);
    gap: 24px;
    --user-management-button-height: 42px;
    --user-management-button-padding-inline: 18px;
    --user-management-button-min-width: 124px;
    --user-management-button-wide-min-width: 168px;
    --user-management-button-radius: 10px;
    --user-management-inline-action-height: 36px;
}

.users-management-page > *,
.deleted-users-page > * {
    width: 100%;
}

.users-page-header {
    margin-bottom: 0;
}

.users-page-header h2 {
    margin-bottom: 8px;
}

.users-page-header .page-subtitle {
    margin: 0;
    max-width: 780px;
    color: #475569;
    line-height: 1.7;
}

.users-page-header .header-actions {
    display: flex;
    align-items: center;
    gap: 12px;
    flex-wrap: wrap;
}

.users-management-page .btn,
.deleted-users-page .btn,
.modal-content .btn {
    min-height: var(--user-management-button-height);
    padding: 0 var(--user-management-button-padding-inline);
    border-radius: var(--user-management-button-radius);
    font-size: 14px;
    font-weight: 700;
    line-height: 1;
    white-space: nowrap;
}

.users-page-header .header-actions .btn,
.user-filter-actions .btn,
.username-input-group .btn,
.temp-password-inline .btn,
.modal-footer .btn {
    min-width: var(--user-management-button-min-width);
}

.users-overview-grid {
    margin-bottom: 0;
}

.users-overview-panel {
    display: grid;
    gap: 12px;
}

.users-overview-panel h3 {
    margin: 0;
    font-size: 20px;
    color: #0f172a;
}

.users-overview-panel p {
    margin: 0;
    color: #475569;
    line-height: 1.7;
}

.users-overview-panel-primary {
    background: linear-gradient(135deg, #f8fbff 0%, #eef5ff 100%);
    border-color: #dbeafe;
}

.admin-surface-page .users-summary-cards {
    display: grid;
    grid-template-columns: repeat(5, minmax(0, 1fr));
    gap: 18px;
    margin-bottom: 0;
}

.users-summary-cards .summary-card {
    min-width: 0;
}

.users-summary-cards .card-copy {
    margin-top: 10px;
    color: #475569;
    font-size: 12px;
    line-height: 1.6;
}

.user-filter-panel {
    margin-bottom: 0;
}

.user-filter-grid {
    display: grid;
    grid-template-columns: minmax(260px, 1.45fr) repeat(4, minmax(160px, 0.92fr)) minmax(150px, 0.82fr) auto;
    gap: 14px;
    align-items: end;
}

.deleted-user-filter-grid {
    grid-template-columns: minmax(260px, 1.5fr) repeat(4, minmax(160px, 0.9fr)) auto;
}

.user-field {
    min-width: 0;
}

.user-field-keyword {
    min-width: 260px;
}

.user-filter-actions {
    display: flex;
    align-items: end;
    gap: 10px;
}

.user-filter-actions .btn {
    min-width: var(--user-management-button-min-width);
}

.users-work-grid {
    display: grid;
    grid-template-columns: minmax(0, 1.45fr) minmax(360px, 0.95fr);
    gap: 18px;
    align-items: start;
}

.users-table-card,
.users-detail-card {
    display: grid;
    gap: 18px;
    padding: 22px 24px;
}

.users-detail-card {
    position: sticky;
    top: 84px;
}

.users-table-header {
    display: flex;
    align-items: flex-start;
    justify-content: space-between;
    gap: 16px;
}

.users-table-header h3 {
    margin: 0 0 6px;
    font-size: 20px;
    color: #0f172a;
}

.users-table-header p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
}

.users-inline-summary {
    color: #2563eb;
    font-size: 13px;
    font-weight: 700;
    text-align: right;
}

.users-table {
    min-width: 980px;
}

.deleted-users-table {
    min-width: 920px;
}

.user-col-account {
    width: 290px;
}

.user-col-role {
    width: 170px;
}

.user-col-status {
    width: 190px;
}

.user-col-login {
    width: 160px;
}

.user-col-created {
    width: 150px;
}

.user-col-action {
    width: 120px;
}

.users-table tbody tr {
    cursor: pointer;
    transition: background-color 0.16s ease, box-shadow 0.16s ease;
}

.users-table tbody tr:hover {
    background: #f8fbff;
}

.users-table tbody tr.is-selected {
    background: #eef4ff;
    box-shadow: inset 3px 0 0 #2563eb;
}

.user-cell-stack {
    display: grid;
    gap: 4px;
    min-width: 0;
}

.user-primary-text {
    color: #0f172a;
    font-size: 13px;
    font-weight: 700;
    word-break: break-word;
}

.user-secondary-text {
    color: #475569;
    font-size: 12px;
    line-height: 1.55;
    word-break: break-word;
}

.user-muted-text {
    color: #64748b;
    font-size: 12px;
}

.user-inline-badges {
    display: flex;
    flex-wrap: wrap;
    gap: 6px;
}

.user-inline-badges .status-badge,
.user-inline-badges .role-badge,
.user-inline-badges .user-soft-badge {
    min-height: 24px;
    padding: 0 10px;
    border-radius: 999px;
    font-size: 11px;
    font-weight: 700;
}

.user-soft-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    background: #eff6ff;
    color: #1d4ed8;
}

.user-soft-badge.warning {
    background: #fef3c7;
    color: #b45309;
}

.user-soft-badge.danger {
    background: #fee2e2;
    color: #b91c1c;
}

.user-inline-date {
    color: #334155;
    font-size: 12px;
    font-weight: 600;
}

.user-inline-date-caption {
    color: #94a3b8;
    font-size: 11px;
}

.users-table .btn-action {
    min-width: 96px;
    min-height: var(--user-management-inline-action-height);
    padding: 0 14px;
}

.user-stage-badge {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    min-height: 32px;
    padding: 0 12px;
    border-radius: 999px;
    background: #eff6ff;
    color: #1d4ed8;
    font-size: 12px;
    font-weight: 800;
    white-space: nowrap;
}

.user-stage-badge.is-warning {
    background: #fef3c7;
    color: #b45309;
}

.user-stage-badge.is-danger {
    background: #fee2e2;
    color: #b91c1c;
}

.user-stage-badge.is-success {
    background: #dcfce7;
    color: #15803d;
}

.user-detail-empty {
    padding: 26px 22px;
    border-radius: 16px;
    background: #f8fafc;
    color: #64748b;
    font-size: 13px;
    line-height: 1.7;
    text-align: center;
}

.user-detail-workspace {
    display: grid;
    gap: 16px;
}

.user-selected-summary {
    padding: 14px 16px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
    color: #1e3a8a;
    font-size: 13px;
    font-weight: 700;
    line-height: 1.6;
}

.user-detail-alert {
    padding: 14px 16px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #f8fbff;
    color: #1e3a8a;
    font-size: 13px;
    line-height: 1.65;
}

.user-detail-alert.is-danger {
    border-color: #fecaca;
    background: #fff7f7;
    color: #991b1b;
}

.user-detail-section {
    display: grid;
    gap: 12px;
    padding: 16px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fbfdff;
}

.user-detail-section h4 {
    margin: 0;
    color: #0f172a;
    font-size: 15px;
}

.user-detail-copy {
    margin: 0;
    color: #64748b;
    font-size: 12px;
    line-height: 1.6;
}

.user-detail-list {
    margin: 0;
    display: grid;
    gap: 10px;
}

.user-detail-list .detail-row {
    display: grid;
    grid-template-columns: minmax(96px, 120px) minmax(0, 1fr);
    gap: 14px;
    align-items: start;
}

.user-detail-list dt {
    margin: 0;
    color: #64748b;
    font-size: 12px;
    font-weight: 700;
}

.user-detail-list dd {
    margin: 0;
    color: #0f172a;
    font-size: 13px;
    line-height: 1.6;
    word-break: break-word;
}

.user-detail-actions {
    display: flex;
    flex-wrap: wrap;
    gap: 10px;
}

.user-detail-actions .btn {
    flex: 1 1 200px;
    min-width: var(--user-management-button-wide-min-width);
}

.modal {
    position: fixed;
    inset: 0;
    display: flex;
    align-items: center;
    justify-content: center;
    padding: 20px;
    background: rgba(15, 23, 42, 0.56);
    z-index: 1000;
}

.modal-content {
    width: min(100%, 880px);
    max-height: min(90vh, 960px);
    overflow-y: auto;
    background: #ffffff;
    border-radius: 18px;
    box-shadow: 0 24px 60px rgba(15, 23, 42, 0.25);
}

.modal-confirm {
    width: min(100%, 560px);
}

.modal-header {
    display: flex;
    align-items: center;
    justify-content: space-between;
    gap: 16px;
    padding: 20px 24px;
    border-bottom: 1px solid #e2e8f0;
}

.modal-header h3 {
    margin: 0;
    color: #0f172a;
    font-size: 22px;
}

.modal-close {
    display: inline-flex;
    align-items: center;
    justify-content: center;
    width: 36px;
    height: 36px;
    border: 0;
    border-radius: 999px;
    background: #f8fafc;
    color: #64748b;
    font-size: 24px;
    cursor: pointer;
    transition: background-color 0.18s ease, color 0.18s ease;
}

.modal-close:hover {
    background: #e2e8f0;
    color: #0f172a;
}

.modal-body {
    padding: 24px;
}

.modal-footer {
    display: flex;
    justify-content: flex-end;
    gap: 12px;
    padding: 20px 24px;
    border-top: 1px solid #e2e8f0;
}

.modal-footer .btn {
    min-width: var(--user-management-button-min-width);
}

.user-editor-form {
    display: grid;
    gap: 18px;
}

.form-section {
    display: grid;
    gap: 16px;
    padding: 18px;
    border: 1px solid #e2e8f0;
    border-radius: 16px;
    background: #fbfdff;
}

.form-section-header {
    display: grid;
    gap: 6px;
}

.form-section-header h4 {
    margin: 0;
    color: #0f172a;
    font-size: 16px;
}

.form-section-header p {
    margin: 0;
    color: #64748b;
    font-size: 13px;
    line-height: 1.6;
}

.form-group {
    margin: 0;
}

.form-row {
    display: grid;
    grid-template-columns: repeat(2, minmax(0, 1fr));
    gap: 16px;
}

.form-group label {
    display: block;
    margin-bottom: 6px;
    color: #334155;
    font-size: 14px;
    font-weight: 600;
}

.form-group .required,
.patient-required-mark {
    color: #dc2626;
}

.form-group input,
.form-group select {
    width: 100%;
    min-height: 42px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    font-size: 14px;
}

.form-group input:focus,
.form-group select:focus {
    outline: 2px solid rgba(59, 130, 246, 0.18);
    border-color: #60a5fa;
}

.form-group input:disabled,
.form-group select:disabled {
    background: #f8fafc;
    color: #64748b;
    cursor: not-allowed;
}

.username-input-group {
    display: flex;
    gap: 8px;
    align-items: stretch;
}

.username-input-group input {
    flex: 1 1 auto;
}

.username-input-group .btn {
    flex: 0 0 auto;
    min-width: var(--user-management-button-min-width);
}

.pagination-container {
    display: flex;
    justify-content: space-between;
    align-items: center;
    gap: 16px;
    flex-wrap: wrap;
}

.pagination-info {
    display: flex;
    align-items: center;
    gap: 10px;
    color: #475569;
    font-size: 13px;
    font-weight: 600;
}

.page-size-select {
    min-height: 40px;
    padding: 0 12px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: #0f172a;
    font-size: 14px;
}

.pagination {
    display: flex;
    justify-content: flex-end;
    flex-wrap: wrap;
    gap: 8px;
}

.pagination button {
    min-width: 44px;
    min-height: 38px;
    padding: 0 14px;
    border: 1px solid #cbd5e1;
    border-radius: 10px;
    background: #ffffff;
    color: #334155;
    font-size: 13px;
    font-weight: 700;
    cursor: pointer;
    transition: background-color 0.18s ease, border-color 0.18s ease, color 0.18s ease;
}

.pagination button:hover:not(:disabled) {
    background: #eff6ff;
    border-color: #93c5fd;
    color: #1d4ed8;
}

.pagination button.active {
    background: #2563eb;
    border-color: #2563eb;
    color: #ffffff;
}

.pagination button:disabled {
    opacity: 0.45;
    cursor: not-allowed;
}

.form-hint {
    display: block;
    margin-top: 6px;
    color: #94a3b8;
    font-size: 12px;
}

.username-check-result {
    min-height: 20px;
    margin-top: 8px;
    font-size: 13px;
    font-weight: 600;
}

.username-check-result.success {
    color: #15803d;
}

.username-check-result.error {
    color: #b91c1c;
}

.username-check-result.checking {
    color: #1d4ed8;
}

.status-row {
    display: flex;
    align-items: center;
    gap: 14px;
}

.status-label {
    margin: 0;
    min-width: 72px;
    color: #334155;
    font-size: 14px;
    font-weight: 700;
}

.status-radio-group {
    display: flex;
    flex-wrap: wrap;
    gap: 12px;
    align-items: center;
}

.status-radio-group label {
    display: inline-flex;
    align-items: center;
    gap: 8px;
    margin: 0;
    padding: 8px 12px;
    border: 1px solid #dbe4ef;
    border-radius: 999px;
    background: #ffffff;
    color: #334155;
    font-weight: 600;
    cursor: pointer;
}

.status-radio-group input[type="radio"] {
    width: 16px;
    height: 16px;
    margin: 0;
    accent-color: #2563eb;
}

.patient-profile-section {
    transition: border-color 0.2s ease, background-color 0.2s ease, box-shadow 0.2s ease;
}

.patient-profile-section[data-patient-active="true"] {
    border-color: #93c5fd;
    background: linear-gradient(180deg, #f8fbff 0%, #eef5ff 100%);
    box-shadow: 0 12px 24px rgba(37, 99, 235, 0.08);
}

.patient-profile-section[data-patient-active="false"] {
    border-style: dashed;
}

.temp-password-section {
    margin-top: 4px;
}

.alert {
    display: grid;
    gap: 10px;
    padding: 16px;
    border-radius: 14px;
    font-size: 14px;
}

.alert p {
    margin: 0;
    color: #0f766e;
    line-height: 1.6;
}

.alert strong {
    color: #0f172a;
}

.alert-info {
    border: 1px solid #99f6e4;
    background: #ecfeff;
}

.temp-password-inline {
    display: flex;
    align-items: center;
    gap: 10px;
    flex-wrap: wrap;
}

.temp-password-value {
    display: inline-flex;
    align-items: center;
    min-height: 40px;
    padding: 0 14px;
    border-radius: 10px;
    background: #ffffff;
    border: 1px solid #bae6fd;
    color: #0f172a;
    font-weight: 700;
    word-break: break-all;
}

.password-reset-result-card {
    display: grid;
    gap: 10px;
    margin-top: 20px;
    padding: 14px 16px;
    border: 1px solid #dbeafe;
    border-radius: 14px;
    background: #f8fbff;
}

.password-reset-result-label {
    color: #334155;
    font-size: 12px;
    font-weight: 700;
}

.confirm-icon {
    display: flex;
    justify-content: center;
    margin-bottom: 18px;
}

.confirm-message {
    text-align: center;
}

.confirm-title {
    margin: 0 0 12px;
    color: #0f172a;
    font-size: 18px;
    font-weight: 700;
    line-height: 1.6;
}

.confirm-username {
    margin: 0 0 18px;
    padding: 12px 14px;
    border: 1px solid #fecaca;
    border-radius: 12px;
    background: #fff5f5;
    color: #b91c1c;
    font-size: 18px;
    font-weight: 800;
}

.confirm-username-warning {
    border-color: #fcd34d;
    background: #fffbeb;
    color: #b45309;
}

.confirm-username-success {
    border-color: #86efac;
    background: #f0fdf4;
    color: #15803d;
}

.confirm-info {
    display: grid;
    gap: 8px;
    padding: 14px 16px;
    border: 1px solid #e2e8f0;
    border-radius: 12px;
    background: #f8fafc;
    text-align: left;
}

.confirm-info p {
    margin: 0;
    color: #475569;
    font-size: 14px;
    line-height: 1.65;
}

.confirm-info-warning {
    border-color: #fde68a;
    background: #fffbeb;
}

.confirm-info-danger {
    border-color: #fecaca;
    background: #fff7f7;
}

.toast {
    position: fixed;
    right: 24px;
    bottom: 24px;
    max-width: 360px;
    padding: 14px 18px;
    border-radius: 14px;
    background: #0f172a;
    color: #ffffff;
    box-shadow: 0 16px 34px rgba(15, 23, 42, 0.24);
    display: none;
    z-index: 2000;
    font-size: 14px;
    line-height: 1.55;
}

.toast.show {
    display: block;
    animation: userToastSlideIn 0.28s ease-out;
}

.toast.success {
    background: #15803d;
}

.toast.error {
    background: #b91c1c;
}

.toast.info {
    background: #1d4ed8;
}

@keyframes userToastSlideIn {
    from {
        transform: translateY(16px);
        opacity: 0;
    }
    to {
        transform: translateY(0);
        opacity: 1;
    }
}

@media (max-width: 1540px) {
    .admin-surface-page .users-summary-cards {
        grid-template-columns: repeat(auto-fit, minmax(220px, 1fr));
    }

    .user-filter-grid {
        grid-template-columns: repeat(3, minmax(0, 1fr));
    }

    .user-filter-actions {
        grid-column: 1 / -1;
        justify-content: flex-end;
    }
}

@media (max-width: 1360px) {
    .users-work-grid {
        grid-template-columns: 1fr;
    }

    .users-detail-card {
        position: static;
    }
}

@media (max-width: 980px) {
    .user-filter-grid,
    .deleted-user-filter-grid {
        grid-template-columns: 1fr;
    }

    .user-field-keyword,
    .user-filter-actions {
        min-width: 0;
    }

    .user-filter-actions {
        justify-content: stretch;
    }

    .user-filter-actions .btn {
        flex: 1 1 0;
    }

    .users-table-header {
        flex-direction: column;
    }

    .users-inline-summary {
        text-align: left;
    }

    .pagination-container {
        flex-direction: column;
        align-items: stretch;
    }

    .pagination {
        justify-content: flex-start;
    }
}

@media (max-width: 768px) {
    .users-page-header,
    .users-page-header .header-actions,
    .form-row,
    .status-row,
    .temp-password-inline,
    .user-detail-list .detail-row,
    .user-detail-actions,
    .modal-footer {
        grid-template-columns: 1fr;
        flex-direction: column;
        align-items: stretch;
    }

    .users-page-header .header-actions .btn,
    .user-detail-actions .btn,
    .modal-footer .btn,
    .username-input-group .btn {
        width: 100%;
    }

    .username-input-group {
        flex-direction: column;
    }

    .modal {
        padding: 12px;
    }

    .modal-body,
    .modal-header,
    .modal-footer {
        padding-left: 18px;
        padding-right: 18px;
    }

    .toast {
        right: 12px;
        left: 12px;
        bottom: 12px;
        max-width: none;
    }
}
